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 741 def addr @ip4_addr or @ip6_addr end
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
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
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
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
Returns the first hostname
# File lib/nmap/parser.rb, line 755 def hostname @hostnames[0] end
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
Just like getport(:ip, protonum)
# File lib/nmap/parser.rb, line 922
Just like getportlist(:ip, state)
# File lib/nmap/parser.rb, line 928
Just like getports(:ip, state)
# File lib/nmap/parser.rb, line 925
Returns the state of IP proto protonum
# File lib/nmap/parser.rb, line 931
Returns the Port::Service for IP proto protonum
# File lib/nmap/parser.rb, line 937
Returns the state reason of IP proto protonum
# File lib/nmap/parser.rb, line 934
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
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
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
Just like getport(:sctp, portnum)
# File lib/nmap/parser.rb, line 904
Just like getportlist(:sctp, state)
# File lib/nmap/parser.rb, line 910
Just like getports(:sctp, state)
# File lib/nmap/parser.rb, line 907
Returns the state reason of SCTP port portnum
# File lib/nmap/parser.rb, line 916
Returns the Port::Service for SCTP port portnum
# File lib/nmap/parser.rb, line 919
Returns the state of SCTP port portnum
# File lib/nmap/parser.rb, line 913
Just like getport(:tcp, portnum)
# File lib/nmap/parser.rb, line 846
Just like getportlist(:tcp, state)
# File lib/nmap/parser.rb, line 852
Just like getports(:tcp, state)
# File lib/nmap/parser.rb, line 849
Returns the state reason of TCP port portnum
# File lib/nmap/parser.rb, line 858
Returns the Script object for the script name run against the TCP port portnum
# File lib/nmap/parser.rb, line 865
Returns the output of the script name on the TCP port portnum
# File lib/nmap/parser.rb, line 872
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
Returns the Port::Service for TCP port portnum
# File lib/nmap/parser.rb, line 861
Returns the state of TCP port portnum
# File lib/nmap/parser.rb, line 855
Just like getport(:udp, portnum)
# File lib/nmap/parser.rb, line 875
Just like getportlist(:udp, state)
# File lib/nmap/parser.rb, line 881
Just like getports(:udp, state)
# File lib/nmap/parser.rb, line 878
Returns the state reason of UDP port portnum
# File lib/nmap/parser.rb, line 887
Returns the Script object for the script name run against the UDP port portnum
# File lib/nmap/parser.rb, line 894
Returns the output of the script name on the UDP port portnum
# File lib/nmap/parser.rb, line 901
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
Returns the Port::Service for UDP port portnum
# File lib/nmap/parser.rb, line 890
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.