Python & nmap
^Bart
gabriele1NOSPAM at hotmail.com
Thu May 19 15:28:42 EDT 2022
> You forgot the second line (after 'import nmap' and before 'nm.scan()'):
>
> nm = nmap.PortScanner()
import nmap
nm = nmap.PortScanner()
nm.scan(hosts='192.168.205.0/24', arguments='-n -sP -PE -PA21,23,80,3389')
hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()]
for host, status in hosts_list:
print('{0}:{1}'.host)
And the result is:
Traceback (most recent call last):
File "/home/gabriele/Documenti/Python/nmap.py", line 1, in <module>
import nmap
File "/home/gabriele/Documenti/Python/nmap.py", line 2, in <module>
nm = nmap.PortScanner()
AttributeError: partially initialized module 'nmap' has no attribute
'PortScanner' (most likely due to a circular import)
>>>
I'm using the IDLE Shell 3.9.2 on Debian Bullseye+KDE, if I write the
script from command line it works!
^Bart
More information about the Python-list
mailing list