Skip to content

Commit c3ed5cd

Browse files
committed
Another fix for ISSUE #30 and Issue #31 Closes:#31
1 parent 672bf41 commit c3ed5cd

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

nmap3/nmap3.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ def scan_top_ports(self, target, default=10, args=None):
126126
127127
This top port requires root previledges
128128
"""
129-
parser = NmapCommandParser(None)
130-
131129
if(default > self.maxport):
132130
raise ValueError("Port can not be greater than default 65389")
133131
self.target = target
@@ -149,7 +147,7 @@ def scan_top_ports(self, target, default=10, args=None):
149147

150148
# Begin parsing the xml response
151149
xml_root = self.get_xml_et(output)
152-
self.top_ports = parser.filter_top_ports(xml_root)
150+
self.top_ports = self.parser.filter_top_ports(xml_root)
153151
return self.top_ports
154152

155153
def nmap_dns_brute_script(self, target, dns_brute="--script dns-brute.nse"):
@@ -162,7 +160,6 @@ def nmap_dns_brute_script(self, target, dns_brute="--script dns-brute.nse"):
162160
nmap -oX - nmmapper.com --script dns-brute.nse
163161
"""
164162
self.target = target
165-
parser = NmapCommandParser(None)
166163

167164
dns_brute_args = "{target} {default}".format(target=target, default=dns_brute)
168165

@@ -174,7 +171,7 @@ def nmap_dns_brute_script(self, target, dns_brute="--script dns-brute.nse"):
174171

175172
# Begin parsing the xml response
176173
xml_root = self.get_xml_et(output)
177-
subdomains = parser.filter_subdomains(xml_root)
174+
subdomains = self.parser.filter_subdomains(xml_root)
178175
return subdomains
179176

180177
def nmap_version_detection(self, target, arg="-sV", args=None):
@@ -466,7 +463,6 @@ def nmap_no_portscan(self, target, args=None):
466463
"""
467464
if(args):
468465
assert(isinstance(args, str)), "Expected string got {0} instead".format(type(args))
469-
470466
xml_root = self.scan_command(self.no_port_scan, target=target, args=args)
471467

472468
tcp_results = self.parser.parse_noportscan(xml_root)

nmap3/nmapparser.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,10 @@ def parse_noportscan(self, xmlroot):
253253
address.append(key.attrib)
254254
host_record["addresses"]=address
255255

256-
for hostname in host.find("hostnames"):
257-
for hosts in hostname.findall("hostname"):
258-
hostnames.append(hosts.attrib)
256+
if(host.find("hostnames")):
257+
for hostname in host.find("hostnames"):
258+
for hosts in hostname.findall("hostname"):
259+
hostnames.append(hosts.attrib)
259260

260261
host_record["hostnames"]=hostnames
261262

requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
simplejson
2-
sphinx
3-
sphinx_rtd_theme

0 commit comments

Comments
 (0)