Jan-19-2020, 06:54 PM
(This post was last modified: Jan-19-2020, 06:54 PM by PythonNmap.)
(Jan-19-2020, 04:11 PM)buran Wrote: Hm. that is strange
you have python-nmap installed for both python2 and python3
so, you shoould have also /usr/local/lib/python3.6/site-packages/nmap/nmap.py file
the __init__.py you show imports everything from it, incl PortScanner.
Yep, the above file exists.
$ ls -altri /usr/local/lib/python3.6/site-packages/nmap/nmap.py 803233 -rw-r--r--. 1 root root 687 Jan 17 09:38 /usr/local/lib/python3.6/site-packages/nmap/nmap.py
(Jan-19-2020, 04:11 PM)buran Wrote: Can you check that that file is there and also __init__.py file hasfrom .nmap import *
line?
$ cat __init__.py from .nmap import nmap
Ya, looks good:
[user@server01 nmap]$ cat __init__.py
from .nmap import nmap
[user@server01 nmap]$ pwd
/usr/local/lib/python3.6/site-packages/nmap
[user@server01 nmap]$
(Jan-19-2020, 04:11 PM)buran Wrote: you can have a look at the package structure in the source https://xael.org/pages/python-nmap-0.6.1.tar.gz or in the repo https://bitbucket.org/xael/python-nmap/src/default/
As to the error you get in python2 - python-nmap package is wrapper that makes easy to automate running nmap port scanner - https://nmap.org/
i.e. as far as I understand it - you need to install nmap port scanner utility separately
Ya, I see nmap is missing from my system. That's an easy fix I'll do now.
I thought I did install it separately. When you say 'separately', what do you consider 'separately'?
Tried to install python3-nmap, since python3 is the future:
pip search nmap python3-nmap (1.3.1) - Python3-nmap converts Nmap commands into python3 methods making it very easy to use nmap in any of your python pentesting projects pip install python3-nmap ERROR: Could not find a version that satisfies the requirement python3-nmap (from versions: none) ERROR: No matching distribution found for python3-nmapThough it comes up in search, it fails to install. When I switch the interpreter to python3, since I would like to use the latest supported version, I get the original error:
[user@server01 ipa-nmap]$ ./ip-get.py vlan2.xml /usr/local/lib/python3.6/site-packages/nmap/__init__.py /usr/local/lib/python3.6/site-packages/nmap/__init__.py [*] Network Address: 10.0.0.117 [*] Network Mask: 255.255.255.0 NMAP Scanner Traceback (most recent call last): File "./ip-get.py", line 34, in <module> main(); File "./ip-get.py", line 31, in main nmapScan(network_address, network_mask) File "./ip-get.py", line 17, in nmapScan nm = nmap.PortScanner () AttributeError: module 'nmap' has no attribute 'PortScanner' [user@server01 ipa-nmap]$ [user@server01 ipa-nmap]$ [user@server01 ipa-nmap]$ [user@server01 ipa-nmap]$ cat /usr/local/lib/python3.6/site-packages/nmap/__init__.py from .nmap import nmap [user@server01 ipa-nmap]$ [user@server01 ipa-nmap]$ [user@server01 ipa-nmap]$ ls -altri /usr/local/lib/python3.6/site-packages/nmap/ total 12 803233 -rw-r--r--. 1 root root 687 Jan 17 09:38 nmap.py 803232 -rw-r--r--. 1 root root 23 Jan 17 09:38 __init__.py 803231 drwxr-xr-x. 3 root root 56 Jan 17 09:38 . 67689421 drwxr-xr-x. 2 root root 62 Jan 17 09:38 __pycache__ 135679242 drwxr-xr-x. 45 root root 4096 Jan 17 09:38 .. [user@server01 ipa-nmap]$Thx,
TK