Skip to content

Commit fd6dece

Browse files
authored
Merge pull request #96 from cldhms/master
Added ip protocol scan technique and missing udp scan doc
2 parents ccf13ce + f4a49fd commit fd6dece

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

nmap3/nmap3.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ class NmapScanTechniques(Nmap):
306306
3) FIN Scan (-sF)
307307
4) Ping Scan (-sP)
308308
5) Idle Scan (-sI)
309+
6) UDP Scan (-sU)
310+
7) IP Scan (-sO)
309311
"""
310312

311313
def __init__(self, path=None):
@@ -317,6 +319,7 @@ def __init__(self, path=None):
317319
self.ping_scan = "-sP"
318320
self.idle_scan = "-sL"
319321
self.udp_scan = "-sU"
322+
self.ip_scan = "-sO"
320323
self.parser = NmapCommandParser(None)
321324

322325
# Unique method for repetitive tasks - Use of 'target' variable instead of 'host' or 'subnet' - no need to make difference between 2 strings that are used for the same purpose. Creating a scan template as a switcher
@@ -328,12 +331,13 @@ def tpl(i):
328331
3: self.tcp_connt,
329332
4: self.ping_scan,
330333
5: self.idle_scan,
331-
6: self.udp_scan
334+
6: self.udp_scan,
335+
7: self.ip_scan
332336
}
333337

334338
return scan_template.get(i)
335339

336-
for i in range(1, 7):
340+
for i in range(1, 8):
337341
if scan_type == tpl(i):
338342
scan = " {target} {default}".format(target=target, default=scan_type)
339343
scan_type_command = self.default_command() + scan
@@ -419,6 +423,16 @@ def nmap_idle_scan(self, target, args=None):
419423
results = self.parser.filter_top_ports(xml_root)
420424
return results
421425

426+
def nmap_ip_scan(self, target, args=None):
427+
"""
428+
Using nmap ip_scan
429+
430+
@cmd nmap -sO 192.168.178.1
431+
"""
432+
xml_root = self.scan_command(self.ip_scan, target=target, args=args)
433+
results = self.parser.filter_top_ports(xml_root)
434+
return results
435+
422436
class NmapHostDiscovery(Nmap):
423437
"""
424438
This object will perform host discovery
@@ -607,12 +621,13 @@ def tpl(i):
607621
3: self.tcp_connt,
608622
4: self.ping_scan,
609623
5: self.idle_scan,
610-
6: self.udp_scan
624+
6: self.udp_scan,
625+
7: self.ip_scan
611626
}
612627

613628
return scan_template.get(i)
614629

615-
for i in range(1, 7):
630+
for i in range(1, 8):
616631
if scan_type == tpl(i):
617632
scan = " {target} {default}".format(target=target, default=scan_type)
618633
scan_type_command = self.default_command() + scan

0 commit comments

Comments
 (0)