Object
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.
Returns the IPv4 or IPv6 address of host
# File lib/nmap/parser.rb, line 513 def addr @ip4_addr or @ip6_addr end
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
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
Returns the first hostname, or nil if unavailable
# File lib/nmap/parser.rb, line 528 def hostname @hostnames[0] end
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Generated with the Darkfish Rdoc Generator 2.