libnmap.objects.host

Using libnmap.objects.host module

TODO

NmapHost methods

class libnmap.objects.NmapHost(starttime='', endtime='', address=None, status=None, hostnames=None, services=None, extras=None)[source]

NmapHost is a class representing a host object of NmapReport

address

Accessor for the IP address of the scanned host

Returns:IP address as a string
changed(other)[source]

return the number of attribute who have changed :param other: NmapHost object to compare :return int

diff(other)[source]

Calls NmapDiff to check the difference between self and another NmapHost object.

Will return a NmapDiff object.

This objects return python set() of keys describing the elements which have changed, were added, removed or kept unchanged.

Parameters:other – NmapHost to diff with
Returns:NmapDiff object
distance

Number of hops to host

Returns:int
endtime

Accessor for the unix timestamp of when the scan ended

Returns:string
extraports_reasons

dictionnary containing reasons why extra ports scanned for which a common state, usually, closed was discovered.

Returns:array of dict containing keys ‘state’ and ‘count’ or None
extraports_state

dictionnary containing state and amount of extra ports scanned for which a common state, usually, closed was discovered.

Returns:dict with keys ‘state’ and ‘count’ or None
get_dict()[source]

Return a dict representation of the object.

This is needed by NmapDiff to allow comparaison

:return dict

get_open_ports()[source]

Same as get_ports() but only for open ports

Returns:list: of tuples (port,’proto’) ie:[(22,’tcp’),(25, ‘tcp’)]
get_ports()[source]

Retrieve a list of the port used by each service of the NmapHost

Returns:list: of tuples (port,’proto’) ie:[(22,’tcp’),(25, ‘tcp’)]
get_service(portno, protocol='tcp')[source]
Parameters:
  • portno – int the portnumber
  • protocol='tcp' – string (‘tcp’,’udp’)
Returns:

NmapService or None

get_service_byid(service_id)[source]

Returns a NmapService by providing its id.

The id of a nmap service is a python tupl made of (protocol, port)

hostnames

Accessor returning the list of hostnames (array of strings).

Returns:array of string
id

id of the host. Used for diff()ing NmapObjects

Returns:string
ipsequence

Return the class of ip sequence of the remote hosts.

Returns:string
ipv4

Accessor for the IPv4 address of the scanned host

Returns:IPv4 address as a string
ipv6

Accessor for the IPv6 address of the scanned host

Returns:IPv6 address as a string
is_up()[source]

method to determine if host is up or not

Returns:bool
lastboot

Since when the host was booted.

Returns:string
mac

Accessor for the MAC address of the scanned host

Returns:MAC address as a string
os_class_probabilities()[source]

Returns an array of possible OS class detected during the OS fingerprinting.

Returns:Array of NmapOSClass objects
os_fingerprint

Returns the fingerprint of the scanned system.

Returns:string
os_fingerprinted

Specify if the host has OS fingerprint data available

Returns:Boolean
os_match_probabilities()[source]

Returns an array of possible OS match detected during the OS fingerprinting

Returns:array of NmapOSMatches objects
os_ports_used()[source]

Returns an array of the ports used for OS fingerprinting

Returns:array of ports used: [{‘portid’: ‘22’, ‘proto’: ‘tcp’, ‘state’: ‘open’},]
scripts_results

Scripts results specific to the scanned host

Returns:array of <script> dictionary
services

Accessor for the array of scanned services for that host.

An array of NmapService objects is returned.

Returns:array of NmapService
starttime

Accessor for the unix timestamp of when the scan was started

Returns:string
status

Accessor for the host’s status (up, down, unknown...)

Returns:string
tcpsequence

Returns the difficulty to determine remotely predict the tcp sequencing.

return: string

uptime

uptime of the remote host (if nmap was able to determine it)

Returns:string (in seconds)
vendor

Accessor for the vendor attribute of the scanned host

Returns:string (vendor) of empty string if no vendor defined