PYTHON自动化WEB旁注目录扫描器
2020-02-01 04:27
701 查看
#!/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 = 'http://'+aim+path headers = { 'User-Agent' : 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' } 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('http://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 www.google.com 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()
转载于:https://my.oschina.net/chinahermit/blog/185817
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- Python安全小工具之Web目录扫描器
- 轻松自动化---selenium-webdriver(python) (四)--如何定位一组元素?
- 【Python Web自动化】02_02Selenium工作原理
- 【Python Web自动化】02_04注册页面创建测试数据
- 【脚本语言系列】关于PythonWeb服务自动化REST,你需要知道的事
- python+Selenium2+chrome 构建web自动化
- 轻松自动化---selenium-webdriver(python) (一)
- 【Python Web自动化】02_05获取验证码
- 【脚本语言系列】关于PythonWeb服务自动化Web API,你需要知道的事
- 轻松自动化---selenium-webdriver(python) (一)
- 轻松自动化---selenium-webdriver(python) (十二)
- python爬虫工具---selenium一个web自动化测试工具
- 我的第一个python web开发框架(9)——目录与配置说明
- Python爬虫工具 Selenium webdriver -自动化测试工具
- 轻松自动化---selenium-webdriver(python) (二)
- iOS自动化探索(三)WebDriverAgent Python Client
- 轻松自动化---selenium-webdriver(python) (二)
- 丢掉python -m SimpleHTTPServer,一行命令用http分享目录(单行web服务器)
- 轻松自动化---selenium-webdriver(python) (十二)
- python3 自动化部署javaweb系统到远程tomcat