Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/wangoloj/python3-nmap
Browse files Browse the repository at this point in the history
Merge with fixes for issue #6
  • Loading branch information
Wangolo Joel committed Feb 18, 2020
2 parents 3116eaa + 5f7e8fc commit b94176a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion nmap3/nmap3.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def scan_top_ports(self, host, default=10):

def nmap_dns_brute_script(self, host, dns_brute="--script dns-brute.nse"):
"""
Perform nmap scan usign the dns-brute script
Perform nmap scan using the dns-brute script
:param: host can be IP or domain
:param: default is the default top port
Expand Down
35 changes: 18 additions & 17 deletions nmap3/nmapparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,29 +115,30 @@ def parse_nmap_pingscan(self, xml_root):
Performs parsing for nmap pingscan xml rests
@ return DICT
"""
ping_status = dict()
ping_status_list = []
try:

if not xml_root:
return host_list
self.xml_root == xml_root
host = xml_root.find("host")

if(host):
ping_status = host.find('status').attrib
address = []
hostname = []

for addr in host.findall("address"):
address.append(addr.attrib)
ping_status["addresses"]=address

if(host.find("hostnames")):
for host_n in host.find("hostnames").findall("hostname"):
hostname.append(host_n.attrib)
ping_status["hostname"]=hostname

return ping_status
for host in xml_root.findall("host"):
host_ping_status = dict()
if(host):
host_ping_status = host.find('status').attrib
address = []
hostname = []

for addr in host.findall("address"):
address.append(addr.attrib)
host_ping_status["addresses"]=address

if(host.find("hostnames")):
for host_n in host.find("hostnames").findall("hostname"):
hostname.append(host_n.attrib)
host_ping_status["hostname"]=hostname
ping_status_list.append(host_ping_status)
return ping_status_list
except Exception as e:
raise

Expand Down

0 comments on commit b94176a

Please sign in to comment.