python后台扫描脚本 发表于 2018-04-19 | 分类于 Python | | 阅读次数: python 后台扫描脚本 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475# -*- coding:utf-8 -*-import urllibimport timeimport threadingurl = raw_input("输入你要扫描的网址:")txt = raw_input("输入字典(php.txt):")# 保存存在的后台地址open_url = []all_url = []# 建立线程列表threads = []# 从字典中读取每一行与url组合,然后添加到all_urldef search_url(url,txt): with open(txt,'r') as f: for each in f: each = each.replace('\n','') urllist = url + each all_url.append(urllist)# 处理urldef handle_url(urllist): print ("查找:"+urllist+'\n') try: req = urllib.urlopen(urllist) # 判断返回码 if req.getcode() == 200: open_url.append(urllist) if req.getcode() == 301: open_url.append(urllist) except: pass# 主函数def main(): search_url(url,txt) # 多线程处理 for each in all_url: t = threading.Thread(target= handle_url, args=(each,)) threads.append(t) t.start() # 线程等待 for t in threads: t.join() # 扫描成功和不成功的回显 if open_url: print ("扫描成功,网站后台地址为:") for each in open_url: print ("[+]"+each) else: print ("没有扫到网站后台,字典不给力啊")if __name__ =="__main__": # 判断运行时间 start = time.clock() main() end = time.clock() print ("The function spend time is %.3f seconds" %(end-start))