智一面的面试题提供python的测试题
使用地址:http://www.gtalent.cn/exam/interview?token=52cf92de494f4a8b6165d817a7279966
这个确实很实用啊,可以扫描网站后台地址,不要做坏事哦
- #!/usr/bin/python
- import sys,httplib
- from optparse import OptionParser
- usageString = "Usage: %prog [options] hostname"
- parser = OptionParser(usage=usageString)
- (opts,args) = parser.parse_args()
- if len(args) < 1:
- parser.error("Hostname is required")
- print __doc__
- website = args[0]
- #login path
- dirs = ["admin","login","admin_index","admin/admin","admin/login","admin/index","admin/user"]
- for line in dirs:
- conn = httplib.HTTPConnection(website)
- conn.request('GET','/'+line)
- r1 = conn.getresponse()
- if r1.status == 200 or r1.status == 301:
- print "********************************Lucky?*************************************"
- print website+'/'+line,r1.status,r1.reason
- conn.close()
- conn = httplib.HTTPConnection(website)
- conn.request('GET','/'+line+'.asp')
- r1 = conn.getresponse()
- if r1.status == 200 or r1.status == 301:
- print "********************************Lucky?*************************************"
- print website+'/'+line+'.asp',r1.status,r1.reason
- conn.close()
- conn = httplib.HTTPConnection(website)
- conn.request('GET','/'+line+'.php')
- r1 = conn.getresponse()
- if r1.status == 200 or r1.status == 301:
- print "********************************Lucky?*************************************"
- print website+'/'+line+'.php',r1.status,r1.reason
- conn.close()
- f.close()