请叫我宁姐 2018-11-19 08:35 采纳率: 50%
浏览 1227
已采纳

map 运行报错,路径错误,乱七八糟的,问问大神该怎样修改,以下是报错代码

nmap.nmap.PortScannerError: 'nmap program was not found in path. PATH is : /Users/liangjianing/anaconda3/share/jupyter/kernels/python3/anaconda3/bin:/Users/liangjianing/anaconda3/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:.'
路径乱七八糟的,怎么跑到JAVA那里去了,请问大神怎样修改
补充错误
Traceback (most recent call last):
File "/Users/liangjianing/Desktop/Violent-Python-Examples-master/Chapter-2/2-nmapScan.py", line 31, in
main()
File "/Users/liangjianing/Desktop/Violent-Python-Examples-master/Chapter-2/2-nmapScan.py", line 27, in main
nmapScan(tgtHost, tgtPort)
File "/Users/liangjianing/Desktop/Violent-Python-Examples-master/Chapter-2/2-nmapScan.py", line 5, in nmapScan
nmScan = nmap.PortScanner()
File "/Users/liangjianing/anaconda3/share/jupyter/kernels/python3/anaconda3/lib/python3.7/site-packages/nmap/nmap.py", line 131, in init
os.getenv('PATH')
源代码
import nmap
import optparse

def nmapScan(tgtHost,tgtPort):
nmScan = nmap.PortScanner()
nmScan.scan(tgtHost,tgtPort)
state=nmScan[tgtHost]['tcp'][int(tgtPort)]['state']
print ("[*] " + tgtHost + " tcp/"+tgtPort +" "+state)

def main():
parser = optparse.OptionParser('usage %prog '+\
'-H -p ')
parser.add_option('-H', dest='tgtHost', type='string',\
help='specify target host')
parser.add_option('-p', dest='tgtPort', type='string',\
help='specify target port[s] separated by comma')

(options, args) = parser.parse_args()

tgtHost = options.tgtHost
tgtPorts = str(options.tgtPort).split(',')

if (tgtHost == None) | (tgtPorts[0] == None):
    print (parser.usage)
    exit(0)
for tgtPort in tgtPorts:
    nmapScan(tgtHost, tgtPort)

if name == '__main__':
main()

  • 写回答

2条回答 默认 最新

  • qq_24248933 2018-11-19 09:17
    关注

    在windows下,需要手动指定nmap的执行路径。在nmap.py初始化函数中加上自己机器上nmap可执行文件的路径即可。
    def init(self, nmap_search_path=('nmap','/usr/bin/nmap','/usr/local/bin/nmap','/sw/bin/nmap','/opt/local/bin/nmap',r"C:\Program Files\Nmap\nmap.exe") ):

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀