锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

主机发现-python脚本以及记录在安装脚本过程中出现并解决的问题

时间:2023-01-15 10:30:00 jwn70mt显卡口电容

主机发现-python脚本和脚本安装过程中记录和解决的问题

    • 操作如下:
  • 1、下载脚本
  • 2、运行脚本
  • 3、安装scapy模块
  • 4、安装好scapy模块后
  • 5、安装nmap模块
  • 6、nmap模块解决方案
  • 7.脚本再次运行,正常运行
    • | Sl-no | Interface name | IPv4-address | IPv6-address |
    • | 1 | lo | 127.0.0.1 | ::1 |<= DO NOT USE LOCALHOST | 2 | eth0 | 192.168.3.130 | fe80::20c:29ff:fe7f:21d6 |
  • 8、关于第5步的一些提醒

注:环境是kali2022.2vmware
脚本地址:link

操作如下:

1、下载脚本

┌──(root?kali)-[~/Desktop]
└─# git clone https://github.com/Cyber-Forensic/nWatch.git
Cloning into ‘nWatch’…
remote: Enumerating objects: 80, done.
remote: Total 80 (delta 0), reused 0 (delta 0), pack-reused 80
Receiving objects: 100% (80/80), 24.48 KiB | 2.04 MiB/s, done.
Resolving deltas: 100% (30/30), done.

┌──(root?kali)-[~/Desktop]
└─# cd nwatch

┌──(root?kali)-[~/Desktop/nwatch]
└─# ls
LICENSE nwatch.py README.md

┌──(root?kali)-[~/Desktop/nwatch]
└─# chmod x nwatch.py

2、运行脚本

因为kali2022安装了python2和python32个版本,脚本是python2.操作时应使用python2
┌──(root?kali)-[~/Desktop/nwatch]
└─# python2 ./nwatch.py
Traceback (most recent call last):
File “./nwatch.py”, line 25, in
from scapy.all import *
ImportError: No module named scapy.all

3、安装scapy模块

┌──(root?kali)-[~/Desktop/nwatch]
└─# pip2 install scapy
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting scapy
Downloading scapy-2.4.5.tar.gz (1.1 MB)
|████████████████████████████████| 1.1 MB 20 kB/s
Using legacy ‘setup.py install’ for scapy, since package ‘wheel’ is not installed.
Installing collected packages: scapy
Running setup.py install for scapy … done
Successfully installed scapy-2.4.5

4、安装好scapy模块后

┌──(root?kali)-[~/Desktop/nwatch]
└─# python2 ./nwatch.py
Traceback (most recent call last):
File “./nwatch.py”, line 27, in
import nmap
ImportError: No module named nmap

5、安装nmap模块

┌──(root?kali)-[~/Desktop/nwatch]
└─# pip2 install python-nmap
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting python-nmap
Downloading python-nmap-0.7.1.tar.gz (44 kB)
|████████████████████████████████| 44 kB 80 kB/s
ERROR: Command errored out with exit status 1:
command: /usr/bin/python2 -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-k57JwN/python-nmap/setup.py file=tmp/pip-install-k57JwN/python-nmap/setup.pyf=getattr(tokenize, ‘"’“‘open’“‘, open)(file);code=f.read().replace(’”‘"’\r\n ‘"’"’\n;f.close();exec(compile(code, file, ‘"’“‘exec) egg_info --egg-base /tmp/pip-pip-egg-info-83vuvN
cwd: /tmp/pip-install-k57JwN/python-nmap/
Complete output (10 lines):
Traceback (most recent call last):
File “”, line 1, in
File “/tmp/pip-install-k57JwN/python-nmap/setup.py”, line 21, in
from nmap import *
File “nmap/init.py”, line 41, in
from .nmap import * # noqa
File “nmap/nmap.py”, line 137
f"nmap program was not found in path. PATH is : {os.getenv(‘PATH’)}”
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

6、nmap模块解决方案

测试:所选版本小于0.6不能正常调用,pip2 install python-nmap最新版本的安装nmap,但是由于python2不支持安装nmap最新版本,所以我选择了0.6.1版本的
┌──(root?kali)-[~/Desktop/nWatch]
└─# pip2 install pytho-nmap0.6.1
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting python-nmap
0.6.1
Downloading python-nmap-0.6.1.tar.gz (41 kB)
|████████████████████████████████| 41 kB 202 kB/s
Using legacy ‘setup.py install’ for python-nmap, since package ‘wheel’ is not installed.
Installing collected packages: python-nmap
Running setup.py install for python-nmap … done
Successfully installed python-nmap-0.6.1

7、再次运行脚本,正常运行

┌──(root㉿kali)-[~/Desktop/nWatch]
└─# python2 ./nwatch.py

             888       888          888            888      
             888   o   888          888            888      
             888  d8b  888          888            888      
    88888b.  888 d888b 888  8888b.  888888 .d8888b 88888b.  
    888 "88b 888d88888b888     "88b 888   d88P"    888 "88b 
    888  888 88888P Y88888 .d888888 888   888      888  888 
    888  888 8888P   Y8888 888  888 Y88b. Y88b.    888  888 
    888  888 888P     Y888 "Y888888  "Y888 "Y8888P 888  888 

                                    [&] Created by suraj (#r00t)

[+] Started at 01:06:04
[*] Choose a network interface


| Sl-no | Interface name | IPv4-address | IPv6-address |

| 1 | lo | 127.0.0.1 | ::1 |<= DO NOT USE LOCALHOST
| 2 | eth0 | 192.168.3.130 | fe80::20c:29ff:fe7f:21d6 |

choose an interface> 2
[] Interface => eth0
[
] Scanning subnet(192.168.3.130/24) on eth0 interface

8、关于第5步的一些提醒

直接使用pip2 install nmap安装nmap后,出现了[-] ‘module’ object has no attribute ‘PortScanner’
要解决这个问题就必须按照第5步的操作来

锐单商城拥有海量元器件数据手册IC替代型号,打造电子元器件IC百科大全!

相关文章