Jan-19-2020, 12:58 PM
Hi All,
Given this code snippet, could you please help me understand what am I missing?
High level overview:
1) I've imported python-nmap
2) Imported using import nmap
3) Receiving AttributeError: 'function' object has no attribute 'PortScanner'
Details:
[root@server01 nmap]# pip freeze|grep -Ei nmap
python-nmap==0.6.1
[root@server01 nmap]#
Since python2 is no longer supported, tried to use python3 but received the same error. My best interpretation of google search results is that python can't see the installed module. But I'm unable to get further then that.
Cheers,
TK
Given this code snippet, could you please help me understand what am I missing?
High level overview:
1) I've imported python-nmap
2) Imported using import nmap
3) Receiving AttributeError: 'function' object has no attribute 'PortScanner'
Details:
#!/bin/python import sys import getopt import nmap import xml.dom.minidom, xml.etree.ElementTree as et; def nmap(vlan, netmask): # NMAP VLAN to determine IP availability. print ("NMAP Scanner") nm = nmap.PortScanner () def main(): xmltree = et.parse(sys.argv[1]); # XML Tree Item = xti for xti in xmltree.iter('AR'): network_address = xti.find('NETWORK_ADDRESS').text; network_mask = xti.find('NETWORK_MASK').text; print ("[*] Network Address: ", network_address); print ("[*] Network Mask: ", network_mask); nmap(network_address, network_mask) if __name__ == "__main__": main();But instead, I'm getting:
Error:[user@server01 nmap]$ ./get_address vlan2.xml
('[*] Network Address: ', '10.0.0.117')
('[*] Network Mask: ', '255.255.255.0')
NMAP Scanner
Traceback (most recent call last):
File "./get_address", line 113, in <module>
main();
File "./get_address", line 107, in main
nmap(network_address, network_mask)
File "./get_address", line 64, in nmap
nm = nmap.PortScanner ()
AttributeError: 'function' object has no attribute 'PortScanner'
[user@server01 nmap]$
I do have python-nmap installed:[root@server01 nmap]# pip freeze|grep -Ei nmap
python-nmap==0.6.1
[root@server01 nmap]#
Since python2 is no longer supported, tried to use python3 but received the same error. My best interpretation of google search results is that python can't see the installed module. But I'm unable to get further then that.
Cheers,
TK