Python realizes the use of Nmap and AI stations to scan open 80 port IP and reverse domain name resolution

Source: Internet
Author: User

#!/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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.