|
| 1 | +import requests |
| 2 | +import re |
| 3 | +import socket |
| 4 | +from bs4 import BeautifulSoup |
| 5 | +import optparse |
| 6 | + |
| 7 | +def main(): |
| 8 | + parser=optparse.OptionParser() |
| 9 | + parser.add_option('-p',dest='host',help='ip port scanner') |
| 10 | + parser.add_option('-w',dest='whois',help='Whois query') |
| 11 | + parser.add_option('-d',dest='dns',help='dns query') |
| 12 | + parser.add_option('-z',dest='domain',help='Domain name query') |
| 13 | + parser.add_option('-f',dest='fw',help='Bypass query') |
| 14 | + (options,args)=parser.parse_args() |
| 15 | + if options.host: |
| 16 | + ip=options.host |
| 17 | + portscanner(ip) |
| 18 | + elif options.whois: |
| 19 | + ws=options.whois |
| 20 | + whois(ws) |
| 21 | + elif options.dns: |
| 22 | + dn=options.dns |
| 23 | + dnsquery(dn) |
| 24 | + elif options.domain: |
| 25 | + domain=options.domain |
| 26 | + domains(domain) |
| 27 | + elif options.fw: |
| 28 | + pz=options.fw |
| 29 | + bypass(pz) |
| 30 | + else: |
| 31 | + parser.print_help() |
| 32 | + exit() |
| 33 | +def portscanner(ip): |
| 34 | + s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) |
| 35 | + socket.setdefaulttimeout(1) |
| 36 | + for port in range(1,65535): |
| 37 | + try: |
| 38 | + s.connect((ip,port)) |
| 39 | + print('[+]',ip,':',port,'open') |
| 40 | + except: |
| 41 | + pass |
| 42 | + |
| 43 | +def whois(ws): |
| 44 | + url = "http://whoissoft.com/{}".format(ws) |
| 45 | + rest = requests.get(url=url) |
| 46 | + csd = rest.content.decode('utf-8') |
| 47 | + fsd = BeautifulSoup(csd, 'html.parser') |
| 48 | + wsd = fsd.get_text() |
| 49 | + comp = re.compile( |
| 50 | + r'a:link, a:visited {.*? }|a:hover {.*?}|white-space: .*?;|font-family:.*?;|function\s+s|window.location.href\s+=\s+".*?"|return\s+false;| var _sedoq\s+=\s+_sedoq|_sedoq.partnerid\s+=\s+''316085'';| _sedoq.locale\s+=\s+''zh-cn'';|var\s+s\s+=\s+document.createElement|s.type\s+=\s+''text/javascript'';|s.async\s+=\s+true;|s.src\s+=\s+''.*?'';|var\s+f\s+=\s+document.getElementsByTagName|f.parentNode.insertBefore|/.*?/|pre\s+{|word-wrap:\s+break-word;|}|\s*\(str1\){|\s+\+\s+str1;|\s+\|\s+\|\|\s+{;|\s+\|\|\s+{;|_sedoq.partnerid|\s+=|''316085''|\s+'';|\s+enter\s+your\s+partner\s+id|_sedoq.locale\s+=\s+|zh-cn|language\s+locale|\(function\(\)\s+{|\[0\];|s.type|text/javascript|script|s,\s+f|document.getElementById\(.*?\)|.style.marginLeft|=window|\|\||\s+{|;|en-us,|en-uk,|de-de,|es-er-fr,|pt-br,|\s+.innerWidth2|es-|er-|fr|.innerWidth2|er|-,') |
| 51 | + tih = re.sub(comp, "", wsd) |
| 52 | + wrs = open('whois.txt', 'w') |
| 53 | + wrs.write(tih) |
| 54 | + wrs.close() |
| 55 | + wrr = open('whois.txt', 'r') |
| 56 | + rr = wrr.read() |
| 57 | + xin = rr.replace("''", '') |
| 58 | + xin2 = xin.replace("(", '') |
| 59 | + xin3 = xin2.replace(")", '') |
| 60 | + xin4 = xin3.replace("er-,", '') |
| 61 | + xin5 = xin4.replace('.innWidth2+"px"', '') |
| 62 | + xin6 = xin5.replace('window.onresize=function{', '') |
| 63 | + xin7 = xin6.replace('.innWidth2+"px"', '') |
| 64 | + print(xin7, end='') |
| 65 | +def dnsquery(dn): |
| 66 | + url = "https://jiexifenxi.51240.com/web_system/51240_com_www/system/file/jiexifenxi/get/?ajaxtimestamp=1526175925753" |
| 67 | + headers = { |
| 68 | + 'user-agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16'} |
| 69 | + params = {'q': '{}'.format(dn), 'type': 'a'} |
| 70 | + reqst = requests.post(url=url, headers=headers, params=params) |
| 71 | + content = reqst.content.decode('utf-8') |
| 72 | + bd = BeautifulSoup(content, 'html.parser') |
| 73 | + |
| 74 | + print('---[+]A record---') |
| 75 | + print(bd.get_text()) |
| 76 | + |
| 77 | + print('---[+]MX record---') |
| 78 | + params2 = {'q': '{}'.format(dn), 'type': 'mx'} |
| 79 | + rest = requests.post(url=url, headers=headers, params=params2) |
| 80 | + content2 = BeautifulSoup(rest.content.decode('utf-8'), 'html.parser') |
| 81 | + print(content2.get_text()) |
| 82 | + |
| 83 | + print('---[+]CNAME record---') |
| 84 | + params3 = {'q': '{}'.format(dn), 'type': 'cname'} |
| 85 | + rest2 = requests.post(url=url, headers=headers, params=params3) |
| 86 | + content3 = BeautifulSoup(rest2.content.decode('utf-8'), 'html.parser') |
| 87 | + print(content3.get_text()) |
| 88 | + |
| 89 | + print('---[+]NS record---') |
| 90 | + params4 = {'q': '{}'.format(dn), 'type': 'ns'} |
| 91 | + rest3 = requests.post(url=url, headers=headers, params=params4) |
| 92 | + content4 = BeautifulSoup(rest3.content.decode('utf-8'), 'html.parser') |
| 93 | + print(content4.get_text()) |
| 94 | + |
| 95 | + print('---[+]TXT record---') |
| 96 | + params5 = {'q': '{}'.format(dn), 'type': 'txt'} |
| 97 | + rest4 = requests.post(url=url, headers=headers, params=params5) |
| 98 | + content5 = BeautifulSoup(rest4.content.decode('utf-8'), 'html.parser') |
| 99 | + print(content5.get_text()) |
| 100 | + |
| 101 | +def domains(domain): |
| 102 | + print('---[+]Domain name query---') |
| 103 | + url = "http://i.links.cn/subdomain/" |
| 104 | + headers = {'user-agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16'} |
| 105 | + params = {'domain': '{}'.format(domain), 'b2': '1', 'b3': '1', 'b4': '1'} |
| 106 | + reqst = requests.post(url=url, headers=headers, params=params) |
| 107 | + vd = reqst.content.decode('gbk') |
| 108 | + rw = re.findall('<div class=domain><input type=hidden name=.*? id=.*? value=".*?">', vd) |
| 109 | + rw2 = "".join(str(rw)) |
| 110 | + bwdw = BeautifulSoup(str(rw2), 'html.parser') |
| 111 | + pw = bwdw.find_all('input') |
| 112 | + for l in pw: |
| 113 | + isd = l.get("value") |
| 114 | + print(isd) |
| 115 | + |
| 116 | +def bypass(pz): |
| 117 | + url = "http://www.webscan.cc/?action=query&ip={}".format(pz) |
| 118 | + headers = { |
| 119 | + 'user-agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16'} |
| 120 | + wd = requests.get(url=url, headers=headers) |
| 121 | + rcy = wd.content.decode('utf-8') |
| 122 | + res = re.findall('"domain":".*?"', str(rcy)) |
| 123 | + lis = "".join(res) |
| 124 | + rmm = lis.replace('"', '') |
| 125 | + rmm2 = rmm.replace(':', '') |
| 126 | + rmm3 = rmm2.replace('/', '') |
| 127 | + rmm4 = rmm3.replace('domain', '') |
| 128 | + rmm5 = rmm4.replace('http', '') |
| 129 | + print(rmm5) |
| 130 | + |
| 131 | +if __name__ == '__main__': |
| 132 | + main() |
0 commit comments