Skip to content

Commit 1c60dff

Browse files
authored
Merge pull request #70 from almohress/master
support ipv6 scanning
2 parents b715bda + e5889f7 commit 1c60dff

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

nmap3/nmap3.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,22 @@ class Nmap(object):
4747
by calling nmap3.Nmap()
4848
"""
4949

50-
def __init__(self, path=None):
50+
def __init__(self, enable_ipv6=False, path=None):
5151
"""
5252
Module initialization
5353
5454
:param path: Path where nmap is installed on a user system. On linux system it's typically on /usr/bin/nmap.
5555
"""
5656

5757
self.nmaptool = path if path else get_nmap_path()
58-
self.default_args = "{nmap} {outarg} - "
58+
self.default_args = "{nmap} {outarg} - {enable_ipv6}"
5959
self.maxport = 65389
6060
self.target = ""
6161
self.top_ports = dict()
6262
self.parser = NmapCommandParser(None)
6363
self.raw_ouput = None
6464
self.as_root = False
65+
self.enable_ipv6 = enable_ipv6
6566

6667
def require_root(self, required=True):
6768
"""
@@ -78,7 +79,10 @@ def default_command(self):
7879
if self.as_root:
7980
return self.default_command_privileged()
8081

81-
return self.default_args.format(nmap=self.nmaptool, outarg="-oX")
82+
if self.enable_ipv6:
83+
return self.default_args.format(nmap=self.nmaptool, outarg="-oX", enable_ipv6="-6")
84+
else:
85+
return self.default_args.format(nmap=self.nmaptool, outarg="-oX")
8286

8387
def default_command_privileged(self):
8488
"""
@@ -89,7 +93,10 @@ def default_command_privileged(self):
8993
# For windows now is not fully supported so just return the default
9094
return self.default_command()
9195
else:
92-
return self.default_args.format(nmap="sudo " + self.nmaptool, outarg="-oX")
96+
if self.enable_ipv6:
97+
return self.default_args.format(nmap=self.nmaptool, outarg="-oX", enable_ipv6="-6")
98+
else:
99+
return self.default_args.format(nmap=self.nmaptool, outarg="-oX")
93100

94101
def nmap_version(self):
95102
"""

0 commit comments

Comments
 (0)