expliot.utils.nmap

nmap utility.

Attributes

NOTIMEOUT

Classes

Tool

Representation for a commandline tool.

Nmap

Nmap tool execution class.

Module Contents

class expliot.utils.nmap.Tool(path, default_args='')

Representation for a commandline tool.

run(args, timeout=None)

Run the command as a child with the specified arguments.

Args:

args(str): The arguments to be supplied to the command. timeout(int): The timeout in seconds while waiting

for the output. Default is None. For details check subprocess.Popen() timeout argument.

Returns:
tuple of bytes: Tuple of standard output and standard error

(stdout,stderr). It returns bytes because encoding, error, text arguments of Popen are not specified.

Raises:
FileNotFoundError: In case the tool path/name cannot be found or

executed. This is actually raised by subprocess.Popen

expliot.utils.nmap.NOTIMEOUT = 0
class expliot.utils.nmap.Nmap(path='nmap', default_args='-oX -')

Bases: expliot.utils.Tool

Nmap tool execution class.

run_xmltodict_output(args, timeout=None)

Run the command as a child with the specified arguments.

It will return the output as a dict along with the error if any. The xml to dict format is generated by xmltodict package which is based on the format specified here - https://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html

Args:

args(str): The arguments to be supplied to nmap. timeout(int): The timeout in seconds while waiting

for the output. Default is None. For details check subprocess.Popen() timeout argument.

Returns:
tuple of dict,str: Tuple of xml output converted to dict

and error converted from bytes to str. (stdout,stderr)