#!/usr/bin/python#-*-coding:utf-8-*-from libnmap.process import nmapprocessfrom libnmap.parser Import Nmapparserimport Requestsx=90while x < 255:print "\033[1;31mstart 118.192.%s.0/24\033[0m"% (str (x)) # Call Nmap Scan Segment Open 80 Port ipmission = nmapprocess ("118.192.%s.0/24"% (str (x)), options = "-P") mission.run () Hosts_hash = {}# Processing Nmap Output Results report = Nmapparser.parse (mission.stdout) #得到每一个开放80端口的IP, the result is stored in the hash for _host in Report.hosts:if _host.is_ Up () and _host.services[0].state = = ' Open ': hosts_hash[_host.address] = str (_host.services[0].port) + "/" +_ Host.services[0].stateprint Hosts_hash.keys () #对每一个IP反向域名解析for IPs in Hosts_hash.keys ():p rint "\033[1;32m[+" "+ips+" \ 033[0m "target_page = 1count = # loops through each page while 1:try:r = Requests.get (" Http://dns.aizhan.com/index.php?r=index/domains &ip=%s&page=%s "% (Ips,str (target_page))) #对每一个域名验证连接for domain in R.json () [u ' domains ']:try:test_domain = Requests.get ("/http" + domain) print count, ":", domain, "\ t:", Test_domain.status_codeexcept:print Count, ":", DOMAIn, "\ t:", "error" Count + = # is not the last page, continue, otherwise exit the loop if int (R.json () [u ' maxpage ']) >target_page:target_page + = 1else: Breakexcept: #没有域名解析到此IPprint "NONE" breakx + = 1
Python realizes the use of Nmap and AI stations to scan open 80 port IP and reverse domain name resolution