【问题标题】:Python nmap not showing hostsPython nmap 不显示主机
【发布时间】:2022-01-10 13:49:22
【问题描述】:

这是代码:

import nmap
# initialize the port scanner
nmScan = nmap.PortScanner()

# scan localhost for ports in range 21-443
nmScan.scan('89.43.3.92', '20-450')

# run a loop to print all the found result about the ports
print(nmScan.all_hosts())
for host in nmScan.all_hosts():
     print('Host : %s (%s)' % (host, nmScan[host].hostname()))
     print('State : %s' % nmScan[host].state())
     for proto in nmScan[host].all_protocols():
         print('----------')
         print('Protocol : %s' % proto)
 
         lport = nmScan[host][proto].keys()
        #  lport.sort()
         for port in lport:
             print ('port : %s\service : %s' % (port, nmScan[host][proto][port]['name']))

当我使用 127.0.0.1 时,代码工作正常,nmScan.all_hosts() 不为空,但是当我检查其他 ip 地址时,它总是为空。

P.S:在上面的代码中,我试图查看每个端口正在运行什么服务。

【问题讨论】:

    标签: python security ip host nmap


    【解决方案1】:

    如果您使用的是 VPN,请将其关闭。这解决了我的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-22
      • 1970-01-01
      • 2013-12-04
      • 2014-09-07
      • 2017-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多