PYTHON自动化WEB旁注目录扫描器
程序员文章站
2022-03-15 23:28:12
#!/usr/bin/env python
#encoding = utf-8
import urllib,httplib
from urllib2...
#!/usr/bin/env python #encoding = utf-8 import urllib,httplib from urllib2 import Request, urlopen, URLError import Queue,sys,time import re import socket import sys from urlparse import urlparse class Scanner(): def __init__(self): alldomains = self.getdomains() print "There are %d website in the same server" % len(alldomains) time.sleep(2) print "Starting The Scanning[*.*]\n==============================" for aim in alldomains: if(self.verifydomain(aim)): for path in paths: url = 'https://'+aim+path headers = { 'User-Agent' : 'Mozilla/5.0 (compatible; Googlebot/2.1; +[url]https://www.google.com/bot.html[/url])' } req = Request(url, None, headers) try: response = urlopen(req) except URLError, e: #if hasattr(e, 'reason'): # print url,'[x] Not Found' #elif hasattr(e,'code'): # print url,'[x]Not Found' if hasattr(e, 'reason'): print url,'[x] Not Found' elif hasattr(e, "code") and e.code == 401: record = "<a href=\"%s\">%s</a>===>FOUND" % (url,url) print url," [OK] Found" self.writeresult(record) elif hasattr(e, "code") and e.code == 403: record = "<a href=\"%s\">%s</a>===>FOUND" % (url,url) print url," [OK] Found" self.writeresult(record) elif hasattr(e, "code") and e.code == 500: record = "<a href=\"%s\">%s</a>===>FOUND" % (url,url) print url," [OK] Found" self.writeresult(record) else: record = "<a href=\"%s\">%s</a>===>FOUND" % (url,url) print url," [OK] Found" self.writeresult(record) def getdomains(self): doreq = Request('https://domains.yougetsignal.com/domains.php?remoteAddress='+ domain) response = urlopen(doreq) html = response.read() response.close() #domains = re.findall(r'(\[\".*?\",\s+\".*?\"\])',html) domains = re.findall(r'\[\"(.*?)\"',html) #print domains #for val in domains: # print val # print self.verifydomain(domains[1]) return domains def verifydomain(self,domains): try: Originalhost = socket.getaddrinfo(domain,None)[0][4][0] #print Originalhost domainip = socket.getaddrinfo(domains,None)[0][4][0] #print domainip if(domainip==Originalhost): return True else: return False except: print domains+' connect issue!' def writeresult(self,record): fp = open(domain+'.html','a+') fp.writelines(record+'') fp.close() def usage(self): print "Usage: WebGrabs.py domain dict \n" print "\nExamples:WebGrabs.py [url]www.google.com[/url] dict.txt" #domain = raw_input('Url Path>>') #dic = raw_input("Wordlist Path>>") domain = raw_input('Url Path>>') dic = raw_input('Wordlist Path>>') paths = [line.rstrip() for line in open(dic)] def main(): print(''' ########################### # # # WebGrabs Scanner # # # ###########################\n>>> ''') Scanner() if __name__ == '__main__': main()
推荐阅读
-
python 配置web自动化测试框架 selenium
-
python 配置web自动化测试框架 selenium
-
利用python实现对web服务器的目录探测的方法
-
Python+Selenium - Web自动化测试-元素定位
-
python自动化web测试-openpyxl设置单元格字体颜色
-
python自动化测试之web运行代码报错:selenium.common.exceptions.NoSuchElementException: Message: no such element
-
python自动化测试之web运行代码报错:importError:no module named selenium
-
python基于watchdog库全自动化监控目录文件
-
PYTHON自动化WEB旁注目录扫描器
-
10行Python代码实现Web自动化管控的示例代码