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

distance[R]

Network distance (not necessarily the same as from traceroute)

endtime[R]

Host start and end times

ip4_addr[R]

The IPv4 address

ip6_addr[R]

The IPv6 address

ipidsequence_class[R]

IPID Sequence Number information

ipidsequence_values[R]

IPID Sequence Number information

ipv4_addr[R]

The IPv4 address

ipv6_addr[R]

The IPv6 address

mac_addr[R]

The MAC address

mac_vendor[R]

The MAC vendor

os[R]

OS object holding Operating System information

reason[R]

The reason for the status

smurf[R]

The number of "weird responses"

starttime[R]

Host start and end times

status[R]

The status of the host, typically "up" or "down"

tcpsequence_class[R]

TCP Sequence Number information

tcpsequence_difficulty[R]

TCP Sequence Number information

tcpsequence_index[R]

TCP Sequence Number information

tcpsequence_values[R]

TCP Sequence Number information

tcptssequence_class[R]

TCP Timestamp Sequence Number information

tcptssequence_values[R]

TCP Timestamp Sequence Number information

times[R]

Times object holding timing information

traceroute[R]

Traceroute object

uptime_lastboot[R]

Uptime information

uptime_seconds[R]

Uptime information

Public Class Methods

new(hostinfo) click to toggle source
# File lib/nmap/parser.rb, line 783
def initialize(hostinfo)
        parse(hostinfo)
end

Public Instance Methods

addr() click to toggle source

Returns the IPv4 or IPv6 address of host

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

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

# File lib/nmap/parser.rb, line 519
def all_hostnames
        @hostnames.each { |hostname| yield hostname } if block_given?

        @hostnames
end
Also aliased as: hostnames
extraports() click to toggle source

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

# File lib/nmap/parser.rb, line 534
def extraports # :yields: extraports
        @extraports.each { |e| yield e } if block_given?

        @extraports
end
hostname() click to toggle source

Returns the first hostname, or nil if unavailable

# File lib/nmap/parser.rb, line 528
def hostname
        @hostnames[0]
end
hostnames() click to toggle source
Alias for: all_hostnames
ip_proto(protonum) click to toggle source

Returns the Port object for the IP protocol protonum, and passes it to a block if one is given

# File lib/nmap/parser.rb, line 704
def ip_proto(protonum) # :yields: proto
        proto = @ipProtos[protonum.to_i]
        yield proto if block_given?
        proto
end
ip_proto_list(state = "") click to toggle source

Returns an array of IP protocol numbers, and passes them each to a block if one given

If an argument is given, only protocols matching state are given.

# File lib/nmap/parser.rb, line 732
def ip_proto_list(state = "")
        list = ip_protos(state).map { |p| p.num }
        list.each { |proto| yield proto } if block_given?
        list
end
ip_protos(state = "") click to toggle source

Returns an array of Port objects for each IP protocol, and passes them each to a block if one is given

If an argument is given, only protocols matching state are given. Note that combinations like "open|filtered" will get matched by "open" and "filtered"

# File lib/nmap/parser.rb, line 716
def ip_protos(state = "")
        list = @ipProtos.values.find_all { |proto|
                state.empty? or
                proto.state == state or
                proto.state.split(/\|/).include?(state)
        }.sort

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

        list
end
ip_reason(protonum) click to toggle source

Returns the state reason of IP protocol protonum

# File lib/nmap/parser.rb, line 739
def ip_reason(protonum)
        proto = ip_proto(protonum)
        return nil if proto.nil?
        proto.reason
end
ip_service(protonum) click to toggle source

Returns a Port::Service object for IP protocol protonum

# File lib/nmap/parser.rb, line 746
def ip_service(protonum)
        proto = ip_proto(protonum)
        return nil if proto.nil?
        proto.service
end
ip_state(protonum) click to toggle source

Returns the state of IP protocol protonum

# File lib/nmap/parser.rb, line 753
def ip_state(protonum)
        proto = ip_proto(protonum)
        return nil if proto.nil?
        proto.state
end
script(name) click to toggle source

Returns the Script object for the specified host script name

# File lib/nmap/parser.rb, line 760
def script(name)
        @scripts.find { |script| script.id == name }
end
script_output(name) click to toggle source

Returns the output of the specified host script name

# File lib/nmap/parser.rb, line 773
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 passes them each to a block if given

# File lib/nmap/parser.rb, line 766
def scripts
        @scripts.each { |script| yield script } if block_given?

        @scripts
end
tcp_port(portnum) click to toggle source

Returns the Port object for the TCP port portnum, and passes it to a block if one is given

# File lib/nmap/parser.rb, line 542
def tcp_port(portnum) # :yields: port
        port = @tcpPorts[portnum.to_i]
        yield port if block_given?
        port
end
tcp_port_list(state = "") click to toggle source

Returns an array of TCP port numbers, and passes them each to a block if one given

If an argument is given, only ports matching state are given.

# File lib/nmap/parser.rb, line 570
def tcp_port_list(state = "")
        list = tcp_ports(state).map { |p| p.num }
        list.each { |port| yield port } if block_given?
        list
end
tcp_ports(state = "") click to toggle source

Returns an array of Port objects for each TCP port, and passes them each to a block if one is given

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

# File lib/nmap/parser.rb, line 554
def tcp_ports(state = "")
        list = @tcpPorts.values.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
tcp_reason(portnum) click to toggle source

Returns the state reason of TCP port portnum

# File lib/nmap/parser.rb, line 577
def tcp_reason(portnum)
        port = tcp_port(portnum)
        return nil if port.nil?
        port.reason
end
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 585
def tcp_script(portnum, name)
        port = tcp_port(portnum)
        return nil if port.nil?
        port.script(name)
end
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 601
def tcp_script_output(portnum, name)
        port = tcp_port(portnum)
        return nil if port.nil?
        port.script_output(name)
end
tcp_scripts(portnum) click to toggle source

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

# File lib/nmap/parser.rb, line 593
def tcp_scripts(portnum) # :yields: script
        port = tcp_port(portnum)
        return nil if port.nil?
        port.scripts { |s| yield s } if block_given?
        port.scripts
end
tcp_service(portnum) click to toggle source

Returns a Port::Service object for TCP port portnum

# File lib/nmap/parser.rb, line 608
def tcp_service(portnum)
        port = tcp_port(portnum)
        return nil if port.nil?
        port.service
end
tcp_state(portnum) click to toggle source

Returns the state of TCP port portnum

# File lib/nmap/parser.rb, line 615
def tcp_state(portnum)
        port = tcp_port(portnum)
        return nil if port.nil?
        port.state
end
udp_port(portnum) click to toggle source

Returns the Port object for the UDP port portnum, and passes it to a block if one is given

# File lib/nmap/parser.rb, line 623
def udp_port(portnum) # :yields: port
        port = @udpPorts[portnum.to_i]
        yield port if block_given?
        port
end
udp_port_list(state = "") click to toggle source

Returns an array of UDP port numbers, and passes them each to a block if one is given

If an argument is given, only ports matching state are given.

# File lib/nmap/parser.rb, line 651
def udp_port_list(state = "")
        list = udp_ports(state).map { |p| p.num }
        list.each { |port| yield port } if block_given?
        list
end
udp_ports(state = "") click to toggle source

Returns an array of Port objects for each UDP port, and passes them each to a block if one is given

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

# File lib/nmap/parser.rb, line 635
def udp_ports(state = "")
        list = @udpPorts.values.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
udp_reason(portnum) click to toggle source

Returns the state reason of UDP port portnum

# File lib/nmap/parser.rb, line 658
def udp_reason(portnum)
        port = udp_port(portnum)
        return nil if port.nil?
        port.reason
end
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 666
def udp_script(portnum, name)
        port = udp_port(portnum)
        return nil if port.nil?
        port.script(name)
end
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 682
def udp_script_output(portnum, name)
        port = udp_port(portnum)
        return nil if port.nil?
        port.script_output(name)
end
udp_scripts(portnum) click to toggle source

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

# File lib/nmap/parser.rb, line 674
def udp_scripts(portnum) # :yields: script
        port = udp_port(portnum)
        return nil if port.nil?
        port.scripts { |s| yield s } if block_given?
        port.scripts
end
udp_service(portnum) click to toggle source

Returns a Port::Service object for UDP port portnum

# File lib/nmap/parser.rb, line 689
def udp_service(portnum)
        port = udp_port(portnum)
        return nil if port.nil?
        port.service
end
udp_state(portnum) click to toggle source

Returns the state of UDP port portnum

# File lib/nmap/parser.rb, line 696
def udp_state(portnum)
        port = udp_port(portnum)
        return nil if port.nil?
        port.state
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.