from urllib.request import urlopen import sys import http.client result = [] def scaning(a): count1=0 count2=0 b = [] f = open(a,'r') for i in f: b.append(i) f.close() result = [] print("\t [+]扫描" +site + "....\n\n") for admin in b: url = 'http://'+site+admin print ("\t [#] 扫描 " + url + "...") try: with urlopen(url,timeout=5) as req: connection = req.getcode() count2 = count2+1 if connection == 200: count1 = count1+1 print("%s %s" % ("\n\n>>>>"+url,"目录找到")) result.append(url+' :'+connection+'\n') input('输入Enter继续') elif connection == 404: count2 = count2 elif connection == 302: print("%s %s" % ("\n>>>>"+url,"目标跳转,可能跳转目录")) else: print("%s %s" % ("\n>>>>"+url,"奇怪的状态码")) except: continue print("\n\n完成\n") print('共计找到'+str(count1)+'个目录') print('共计扫描'+str(count2)+'次') print("[/]扫描结束") return result try: site = input("Web Site for Scan?: ") #site = ("http://"+site) print(site) print ("\tChecking website " + site + "...") conn = http.client.HTTPConnection(site,timeout=10) conn = conn.connect() print ("\t[$] Yes... Server is Online.") except: print('错误的ip') print('请输入网页结构') print('1 PHP') print('2 ASP') print('3 CFM') print('4 JS') print('5 CGI') print('6 BRF') print('7 自定义:将自定义字典保存为test.txt') print("\n example: 1 and '输入数字' 查询 PHP \n") code=int(input("> ")) print(code) if code == 1: result = scaning(a='php.txt') elif code == 2: result = scaning(a='asp.txt') elif code == 3: result = scaning(a='cfm.txt') elif code == 4: result = scaning(a='js.txt') elif code == 5: result = scaning(a='cgi.txt') elif code == 6: result = scaning(a='brf.txt') elif code == 7: result = scaning(a='test.txt') if result != []: f = open(result.txt,'w') f.write(result) f.close()