Undocumented
Class Method | parse |
Generic class method of NmapParser class. |
Class Method | parse |
Strange method which transforms a python dict representation of a NmapReport and turns it into an NmapReport object. Needs to be reviewed and possibly removed. |
Class Method | parse |
Call generic cls.parse() method and ensure that a correct file path is given as argument. If not, an exception is raised. |
Class Method | parse |
Call generic cls.parse() method and ensure that a string is passed on as argument. If not, an exception is raised. |
Class Method | __parse |
Private method parsing the data from extra scanned ports. X extraports were in state "closed" server returned "conn-refused" tag: <extraports> |
Class Method | __parse |
Private method parsing the data from scripts affecting the target host. Contents of <hostscript> is returned as a list of dict. |
Class Method | __parse |
Private method parsing the hostnames list within a <host> XML tag. |
Class Method | __parse |
Private method parsing the data from an OS fingerprint (-O). Contents of <os> is returned as a dict. |
Class Method | __parse |
This methods parses osclass data and returns a dict. Depending on the nmap xml version, osclass could contain a cpe dict. |
Class Method | __parse |
This methods parses osmatch data and returns a dict. Depending on the nmap xml version, osmatch could contain an osclass dict. |
Class Method | __parse |
Private method parsing a portion of a nmap scan result. Receives a <runstats> XML tag. |
Class Method | __parse |
Private method parsing a portion of a nmap scan result. Receives a <scaninfo> XML tag. |
Class Method | __parse |
Private method parsing the data from NSE scripts output |
Class Method | __parse |
Private method parsing a table from NSE scripts output |
Class Method | __parse |
Parse <service> tag to manage CPE object |
Class Method | _parse |
Protected class method used to process a specific data type. In this case: XML. This method is called by cls.parse class method and receives nmap scan results data (in XML). |
Class Method | _parse |
Protected method parsing a portion of a nmap scan result. Receives a <host> XML tag representing a scanned host with its services. |
Class Method | _parse |
Protected method parsing a scanned service from a targeted host. This protected method cannot be called directly. A <port/> tag can be directly passed to parse() and the below method will be called and return a NmapService object representing the state of the service. |
Class Method | _parse |
Protected method parsing the list of scanned services from a targeted host. This protected method cannot be called directly with a string. A <ports/> tag can be directly passed to parse() and the below method will be called and return a list of nmap scanned services. |
Class Method | _parse |
This method parses out a full nmap scan report from its XML root node: <nmaprun>. |
Static Method | __format |
Private method which converts a single XML tag to a python dict. It also checks that the elt_data given as argument is of type xml.etree.ElementTree.Element |
Static Method | __format |
Private method which ensures that a XML portion to be parsed is of type xml.etree.ElementTree.Element. If elt_data is a string, then it is converted to an XML Element type. |
Generic class method of NmapParser class. The data to be parsed does not need to be a complete nmap scan report. You can possibly give <hosts>...</hosts> or <port> XML tags. :param nmap_data: any portion of nmap scan result. nmap_data should always be a string representing a part or a complete nmap scan report. :type nmap_data: string :param data_type: specifies the type of data to be parsed. :type data_type: string ("XML"|"JSON"|"YAML"). :param incomplete: enable you to parse interrupted nmap scans and/or incomplete nmap xml blocks by adding a </nmaprun> at the end of the scan. :type incomplete: boolean As of today, only XML parsing is supported. :return: NmapObject (NmapHost, NmapService or NmapReport)
Strange method which transforms a python dict representation of a NmapReport and turns it into an NmapReport object. Needs to be reviewed and possibly removed. :param rdict: python dict representation of an NmapReport :type rdict: dict :return: NmapReport
def parse_fromfile(cls, nmap_report_path, data_type='XML', incomplete=False): (source) ¶
Call generic cls.parse() method and ensure that a correct file path is given as argument. If not, an exception is raised. :param nmap_data: Same as for parse(). Any portion of nmap scan reports could be passed as argument. Data type _must be a valid path to a file containing nmap scan results. :param data_type: Specifies the type of serialization in the file. :param incomplete: enable you to parse interrupted nmap scans and/or incomplete nmap xml blocks by adding a </nmaprun> at the end of the scan. :type incomplete: boolean :return: NmapObject
Call generic cls.parse() method and ensure that a string is passed on as argument. If not, an exception is raised. :param nmap_data: Same as for parse(), any portion of nmap scan. Reports could be passed as argument. Data type _must_ be a string. :type nmap_data: string :param data_type: Specifies the type of data passed on as argument. :param incomplete: enable you to parse interrupted nmap scans and/or incomplete nmap xml blocks by adding a </nmaprun> at the end of the scan. :type incomplete: boolean :return: NmapObject
Private method parsing the data from extra scanned ports. X extraports were in state "closed" server returned "conn-refused" tag: <extraports> :param extraports_data: XML data for extraports :type extraports_data: xml.ElementTree.Element or a string :return: python dict with following keys: state, count, reason
Private method parsing the data from scripts affecting the target host. Contents of <hostscript> is returned as a list of dict. :param scripts_data: portion of XML describing the results of the scripts data :type scripts_data: xml.ElementTree.Element or a string :return: python list holding scripts output in a dict
Private method parsing the hostnames list within a <host> XML tag. :param scanhostnames_data: <hostnames> XML tag from a nmap scan :type scanhostnames_data: xml.ElementTree.Element or a string :return: list of hostnames
Private method parsing the data from an OS fingerprint (-O). Contents of <os> is returned as a dict. :param os_data: portion of XML describing the results of the os fingerprinting attempt :type os_data: xml.ElementTree.Element or a string :return: python dict representing the XML os tag
This methods parses osclass data and returns a dict. Depending on the nmap xml version, osclass could contain a cpe dict. :param osclass_data: <osclass> XML tag from a nmap scan :type osclass_data: xml.ElementTree.Element or a string :return: python dict representing the XML osclass tag
This methods parses osmatch data and returns a dict. Depending on the nmap xml version, osmatch could contain an osclass dict. :param osmatch_data: <osmatch> XML tag from a nmap scan :type osmatch_data: xml.ElementTree.Element or a string :return: python dict representing the XML osmatch tag
Private method parsing a portion of a nmap scan result. Receives a <runstats> XML tag. :param scanrunstats_data: <runstats> XML tag from a nmap scan :type scanrunstats_data: xml.ElementTree.Element or a string :return: python dict representing the XML runstats tag
Private method parsing a portion of a nmap scan result. Receives a <scaninfo> XML tag. :param scaninfo_data: <scaninfo> XML tag from a nmap scan :type scaninfo_data: xml.ElementTree.Element or a string :return: python dict representing the XML scaninfo tag
Private method parsing the data from NSE scripts output :param script_data: portion of XML describing the results of the script data :type script_data: xml.ElementTree.Element or a string :return: python dict holding scripts output
Private method parsing a table from NSE scripts output :param sccript_table: poertion of XML containing the table :type script_table: xml.ElementTree.Element :return: python dict of table structure
Protected class method used to process a specific data type. In this case: XML. This method is called by cls.parse class method and receives nmap scan results data (in XML). :param nmap_data: any portion of nmap scan result can be given as argument. nmap_data should always be a string representing a part or a complete nmap scan report. :type nmap_data: string This method checks which portion of a nmap scan is given as argument. It could be: 1. a full nmap scan report; 2. a scanned host: <host> tag in a nmap scan report 3. a scanned service: <port> tag 4. a list of hosts: <hosts/> tag (TODO) 5. a list of ports: <ports/> tag :param incomplete: enable you to parse interrupted nmap scans and/or incomplete nmap xml blocks by adding a </nmaprun> at the end of the scan. :type incomplete: boolean :return: NmapObject (NmapHost, NmapService or NmapReport) or a list of NmapObject
Protected method parsing a portion of a nmap scan result. Receives a <host> XML tag representing a scanned host with its services. :param scaninfo_data: <host> XML tag from a nmap scan :type scaninfo_data: xml.ElementTree.Element or a string :return: NmapHost object
Protected method parsing a scanned service from a targeted host. This protected method cannot be called directly. A <port/> tag can be directly passed to parse() and the below method will be called and return a NmapService object representing the state of the service. :param scanport_data: <port> XML tag from a nmap scan :type scanport_data: xml.ElementTree.Element or a string :return: NmapService
Protected method parsing the list of scanned services from a targeted host. This protected method cannot be called directly with a string. A <ports/> tag can be directly passed to parse() and the below method will be called and return a list of nmap scanned services. :param scanports_data: <ports> XML tag from a nmap scan :type scanports_data: xml.ElementTree.Element or a string :return: list of NmapService
This method parses out a full nmap scan report from its XML root node: <nmaprun>. :param root: Element from xml.ElementTree (top of XML the document) :type root: Element :return: NmapReport object
Private method which converts a single XML tag to a python dict. It also checks that the elt_data given as argument is of type xml.etree.ElementTree.Element :param elt_data: XML Element to be parsed or string to be converted to a XML Element :return: Element