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()