首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >没有这样的文件或目录:“nmap”:“nmap”

没有这样的文件或目录:“nmap”:“nmap”
EN

Stack Overflow用户
提问于 2019-03-17 11:50:56
回答 2查看 1.1K关注 0票数 0

我们的计划是检查打开的端口,即使库已经安装并且我正在使用anacond,但我的nmap出错了。

代码语言:javascript
复制
import socket, subprocess, re

s = socket.socket()
host = socket.gethostname()
nmap_lst_out = []

s = socket.socket()
print ('The Name of the Local Machine:-',host)
print ('\n' * 2)
print ('*' * 60)
print('PLEASE WAIT SCANNING THE REMOTE HOST {} AT {}'.format(host,socket.gethostbyname('localhost')))
print ('*' * 60)
for port in range(1,1024):
    try:
        s.connect((host,port))
        open_port = socket.getservbyport(port)
        print ('PORT {0} OPEN'.format(open_port))
        s.close()
        s = socket.socket()

    except:
        print ("\r+",end="")


nmap_out = subprocess.check_output(['nmap','Saujan'])
nmap_out = str(nmap_out)
nmap_out = nmap_out.split('\\n')

for i in nmap_out:
    out = re.search('(open\s+)([a-zA-Z]+)',i)
    if out:
       nmap_lst_out.append(out.group(2))
       print ('NMAP OPEN PORT:-',out.group(2))`

我也已经安装了这个软件包。

已安装的软件包

Saujan:Project $ pip安装nmap要求已经满足: nmap in /anaconda3 3/lib/python3.7 3.7/site-packages (0.0.1)

EN

回答 2

Stack Overflow用户

发布于 2020-06-25 17:35:21

即使安装了nmap,也不能执行它,只要不在路径目录中运行它。因此,首先您应该导航到安装nmap的目录,然后尝试运行它。

票数 0
EN

Stack Overflow用户

发布于 2021-06-10 14:47:07

  1. 检查Nmap是否安装在计算机上,而不是安装在Python包中。这取决于您的操作系统,但请尝试:
  • apt-get install nmap -基于Debian的,如Debian,Ubuntu等.
  • yum install nmap -用于Centos/RedHat发行版。
  • brew install nmap - On MacOS
  • 通过在Windows系统上下载安装程序来安装应用程序
  1. 最好是使用subprocess.Popen而不是subprocess.check_output
代码语言:javascript
复制
import subprocess

p = subprocess.Popen(['nmap', 'Saujan'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, err = p.communicate()
for i in output.readlines():
    # Use your regular expressions...
  1. 此外,也有一些库可以为您工作。我是一个名为Nmapthon的作者。你可以随便看看
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55206719

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档