Parent

Nmap::Parser::Session

This holds session information, such as runtime, Nmap’s arguments, and verbosity/debugging

Attributes

scan_args[R]

Command run to initiate the scan

nmap_version[R]

Version number of the Nmap used to scan

xml_version[R]

XML version of Nmap’s output

start_str[R]

Starting time

start_time[R]

Starting time

stop_str[R]

Ending time

stop_time[R]

Ending time

scan_time[R]

Total scan time in seconds (could differ from stop_time - start_time)

exit[R]

Nmap’s exit status (“success” or “error”)

errormsg[R]

Nmap’s error message if exit status is “error“

verbose[R]

Amount of verbosity (-v) used while scanning

debug[R]

Amount of debugging (-d) used while scanning

Public Instance Methods

numhosts(state = "") click to toggle source

Returns the total number of hosts that were scanned or, if an argument is given, returns the number of hosts scanned that were matching status (e.g. “up” or “down”)

NOTE: Calling parser.sessions.numhosts(status) can be very different than running parser.hosts(status).size because the information there and here are coming from different places in the XML. Nmap will not typically list individual hosts which it doesn’t know or assume are “up”.

# File lib/nmap/parser.rb, line 589
        def numhosts(state = "")
                @numhosts[state.empty? ? "total" : state]
        end
numservices(type = "") click to toggle source

Returns the total number of services that were scanned or, if an argument is given, returns the number of services scanned for type (e.g. “syn”)

# File lib/nmap/parser.rb, line 596
        def numservices(type = "")
                @scaninfo.find_all { |info|
                        type.empty? or info.type == type
                }.inject(0) { |acc, info|
                        acc + info.numservices
                }
        end
scan_type_proto(type) click to toggle source

Returns the protocol associated with the specified scan type (e.g. “tcp” for type “syn”)

# File lib/nmap/parser.rb, line 606
        def scan_type_proto(type)
                @scaninfo.each do |info|
                        return info.proto if info.type == type
                end

                nil
        end
scan_types() click to toggle source

Returns an array of all the scan types performed and yields them each to a block if one if given

# File lib/nmap/parser.rb, line 616
        def scan_types() # :yields: scantype
                @scaninfo.map do |info|
                        yield info.type if block_given?
                        info.type
                end
        end
scanflags(type) click to toggle source

Returns the scanflags associated with the specified scan type (e.g. “PSHACK” for type “ack”)

# File lib/nmap/parser.rb, line 625
        def scanflags(type)
                @scaninfo.each do |info|
                        return info.scanflags if info.type == type
                end

                nil
        end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.