Parent

Nmap::Parser::Host

This holds all of the information about a target host.

Status, IP/MAC addresses, hostnames, all that. Port information is available in this class; either accessed through here or directly from a Port object.

Attributes

status[R]

Status of the host, typically “up” or “down“

reason[R]

Reason for the status

ip4_addr[R]

IPv4 address

ip6_addr[R]

IPv6 address

mac_addr[R]

MAC address

mac_vendor[R]

MAC vendor

os[R]

OS object holding Operating System information

smurf[R]

Number of “weird responses“

tcpsequence_index[R]

TCP Sequence Number information

tcpsequence_class[R]

TCP Sequence Number information

tcpsequence_values[R]

TCP Sequence Number information

tcpsequence_difficulty[R]

TCP Sequence Number information

ipidsequence_class[R]

IPID Sequence Number information

ipidsequence_values[R]

IPID Sequence Number information

tcptssequence_class[R]

TCP Timestamp Sequence Number information

tcptssequence_values[R]

TCP Timestamp Sequence Number information

uptime_seconds[R]

Uptime information

uptime_lastboot[R]

Uptime information

traceroute[R]

Traceroute object

distance[R]

Network distance (not necessarily the same as from traceroute)

times[R]

Times object holding timing information

starttime[R]

Host start and end times

endtime[R]

Host start and end times

Public Instance Methods

addr() click to toggle source

Returns the IPv4 or IPv6 address of host

# File lib/nmap/parser.rb, line 741
        def addr
                @ip4_addr or @ip6_addr
        end
all_hostnames() click to toggle source

Alias for hostnames

extraports() click to toggle source

Returns an array of ExtraPorts objects and yields them each to a block if one if given

# File lib/nmap/parser.rb, line 761
        def extraports # :yields: extraports
                @extraports.each { |e| yield e } if block_given?
                @extraports
        end
getport(type, portnum) click to toggle source

Returns the Port object for the port portnum of protocol type (:tcp, :udp, :sctp or :ip) and yields it to a block if one is given.

# File lib/nmap/parser.rb, line 768
        def getport(type, portnum) # :yields: port
                type = type.to_sym

                port = case type
                when :tcp, :udp, :sctp, :ip
                        @ports[type][portnum.to_i]
                else
                        raise ArgumentError, "Invalid protocol type"
                end

                yield port if block_given?

                port
        end
getportlist(type, state = "") click to toggle source

Returns an array of port numbers of protocol type (:tcp, :udp, :sctp or :ip) and yields them each to a block if one given

If state is given, only ports matching that state are given. Note that combinations like “open|filtered” will get matched by “open” and “filtered“

# File lib/nmap/parser.rb, line 836
        def getportlist(type, state = "") # :yields: port
                getports(type, state).map do |port|
                        yield port.num if block_given?
                        port.num
                end
        end
getports(type, state = "") click to toggle source

Returns an array of Port objects for each port of protocol type (:tcp, :udp, :sctp or :ip) and yields them each to a block if one is given

If type is :any rather than a protocol name, then matching ports from all protocols are given.

If type is an array, it’s assumed to be filled with any combination of the aforementioned protocol types. Some handling is done on the array, but you could do [:tcp, :udp, :any] if you really want.

If state is given, only ports matching that state are given. Note that combinations like “open|filtered” will get matched by “open” and “filtered“

# File lib/nmap/parser.rb, line 797
        def getports(type, state = "")
                if type.instance_of?(Array)
                        list = type.flatten.uniq.inject([]) { |acc, typ|
                                acc + getports(typ, state)
                        }.sort

                        list.each { |port| yield port } if block_given?

                        return list
                end

                type = type.to_sym

                ports = case type
                when :tcp, :udp, :sctp, :ip
                        @ports[type].values
                when :any
                        @ports.map { |ent| ent[1].values }.flatten
                else
                        raise ArgumentError, "Invalid protocol type (#{type})"
                end

                list = ports.find_all { |port|
                        state.empty? or
                        port.state == state or
                        port.state.split(/\|/).include?(state)
                }.sort

                list.each { |port| yield port } if block_given?

                list
        end
hostname() click to toggle source

Returns the first hostname

# File lib/nmap/parser.rb, line 755
        def hostname
                @hostnames[0]
        end
hostnames() click to toggle source

Returns an array containing all of the hostnames for this host and yields them each to a block if one is given

# File lib/nmap/parser.rb, line 747
        def hostnames
                @hostnames.each { |hostname| yield hostname } if block_given?
                @hostnames
        end
Also aliased as: all_hostnames
ip_proto(protonum) click to toggle source

Just like getport(:ip, protonum)

# File lib/nmap/parser.rb, line 922
        
ip_proto_list(state="") click to toggle source

Just like getportlist(:ip, state)

# File lib/nmap/parser.rb, line 928
        
ip_protos(state="") click to toggle source

Just like getports(:ip, state)

# File lib/nmap/parser.rb, line 925
        
ip_reason(protonum) click to toggle source

Returns the state of IP proto protonum

# File lib/nmap/parser.rb, line 931
        
ip_service(protonum) click to toggle source

Returns the Port::Service for IP proto protonum

# File lib/nmap/parser.rb, line 937
        
ip_state(protonum) click to toggle source

Returns the state reason of IP proto protonum

# File lib/nmap/parser.rb, line 934
        
script(name) click to toggle source

Returns the Script object for the specified host script name

# File lib/nmap/parser.rb, line 999
        def script(name)
                sc = @scripts.find { |script| script.id == name }
                return if not sc
                yield sc if block_given?
                sc
        end
script_output(name) click to toggle source

Returns the output of the specified host script name

# File lib/nmap/parser.rb, line 1014
        def script_output(name)
                @scripts.each do |script|
                        return script.output if script.id == name
                end

                nil
        end
scripts() click to toggle source

Returns an array of Script objects for each host script run and yields them each to a block if given

# File lib/nmap/parser.rb, line 1008
        def scripts
                @scripts.each { |script| yield script } if block_given?
                @scripts
        end
sctp_port(portnum) click to toggle source

Just like getport(:sctp, portnum)

# File lib/nmap/parser.rb, line 904
        
sctp_port_list(state="") click to toggle source

Just like getportlist(:sctp, state)

# File lib/nmap/parser.rb, line 910
        
sctp_ports(state="") click to toggle source

Just like getports(:sctp, state)

# File lib/nmap/parser.rb, line 907
        
sctp_reason(portnum) click to toggle source

Returns the state reason of SCTP port portnum

# File lib/nmap/parser.rb, line 916
        
sctp_service(portnum) click to toggle source

Returns the Port::Service for SCTP port portnum

# File lib/nmap/parser.rb, line 919
        
sctp_state(portnum) click to toggle source

Returns the state of SCTP port portnum

# File lib/nmap/parser.rb, line 913
        
tcp_port(portnum) click to toggle source

Just like getport(:tcp, portnum)

# File lib/nmap/parser.rb, line 846
        
tcp_port_list(state="") click to toggle source

Just like getportlist(:tcp, state)

# File lib/nmap/parser.rb, line 852
        
tcp_ports(state="") click to toggle source

Just like getports(:tcp, state)

# File lib/nmap/parser.rb, line 849
        
tcp_reason(portnum) click to toggle source

Returns the state reason of TCP port portnum

# File lib/nmap/parser.rb, line 858
        
tcp_script(portnum,name) click to toggle source

Returns the Script object for the script name run against the TCP port portnum

# File lib/nmap/parser.rb, line 865
        
tcp_script_output(portnum,name) click to toggle source

Returns the output of the script name on the TCP port portnum

# File lib/nmap/parser.rb, line 872
        
tcp_scripts(portnum) click to toggle source

Returns an array of Script objects for each script run on the TCP port portnum and yields them each to a block if one is given

# File lib/nmap/parser.rb, line 869
        
tcp_service(portnum) click to toggle source

Returns the Port::Service for TCP port portnum

# File lib/nmap/parser.rb, line 861
        
tcp_state(portnum) click to toggle source

Returns the state of TCP port portnum

# File lib/nmap/parser.rb, line 855
        
udp_port(portnum) click to toggle source

Just like getport(:udp, portnum)

# File lib/nmap/parser.rb, line 875
        
udp_port_list(state="") click to toggle source

Just like getportlist(:udp, state)

# File lib/nmap/parser.rb, line 881
        
udp_ports(state="") click to toggle source

Just like getports(:udp, state)

# File lib/nmap/parser.rb, line 878
        
udp_reason(portnum) click to toggle source

Returns the state reason of UDP port portnum

# File lib/nmap/parser.rb, line 887
        
udp_script(portnum,name) click to toggle source

Returns the Script object for the script name run against the UDP port portnum

# File lib/nmap/parser.rb, line 894
        
udp_script_output(portnum,name) click to toggle source

Returns the output of the script name on the UDP port portnum

# File lib/nmap/parser.rb, line 901
        
udp_scripts(portnum) click to toggle source

Returns an array of Script objects for each script run on the UDP port portnum and yields them each to a block if one is given

# File lib/nmap/parser.rb, line 898
        
udp_service(portnum) click to toggle source

Returns the Port::Service for UDP port portnum

# File lib/nmap/parser.rb, line 890
        
udp_state(portnum) click to toggle source

Returns the state of UDP port portnum

# File lib/nmap/parser.rb, line 884
        

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.