Skip to content

Commit

Permalink
Merge pull request #70 from almohress/master
Browse files Browse the repository at this point in the history
support ipv6 scanning
  • Loading branch information
nmmapper authored Sep 16, 2021
2 parents b715bda + e5889f7 commit 1c60dff
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions nmap3/nmap3.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,22 @@ class Nmap(object):
by calling nmap3.Nmap()
"""

def __init__(self, path=None):
def __init__(self, enable_ipv6=False, path=None):
"""
Module initialization
:param path: Path where nmap is installed on a user system. On linux system it's typically on /usr/bin/nmap.
"""

self.nmaptool = path if path else get_nmap_path()
self.default_args = "{nmap} {outarg} - "
self.default_args = "{nmap} {outarg} - {enable_ipv6}"
self.maxport = 65389
self.target = ""
self.top_ports = dict()
self.parser = NmapCommandParser(None)
self.raw_ouput = None
self.as_root = False
self.enable_ipv6 = enable_ipv6

def require_root(self, required=True):
"""
Expand All @@ -78,7 +79,10 @@ def default_command(self):
if self.as_root:
return self.default_command_privileged()

return self.default_args.format(nmap=self.nmaptool, outarg="-oX")
if self.enable_ipv6:
return self.default_args.format(nmap=self.nmaptool, outarg="-oX", enable_ipv6="-6")
else:
return self.default_args.format(nmap=self.nmaptool, outarg="-oX")

def default_command_privileged(self):
"""
Expand All @@ -89,7 +93,10 @@ def default_command_privileged(self):
# For windows now is not fully supported so just return the default
return self.default_command()
else:
return self.default_args.format(nmap="sudo " + self.nmaptool, outarg="-oX")
if self.enable_ipv6:
return self.default_args.format(nmap=self.nmaptool, outarg="-oX", enable_ipv6="-6")
else:
return self.default_args.format(nmap=self.nmaptool, outarg="-oX")

def nmap_version(self):
"""
Expand Down

0 comments on commit 1c60dff

Please sign in to comment.