class Nmap::Parser::Session
This holds session information, such as runtime, Nmap's arguments, and verbosity/debugging
Attributes
Amount of debugging (-d) used while scanning
Amount of debugging (-d) used while scanning
Nmap's error message if exit status is “error”
Nmap's exit status (“success” or “error”)
Version number of the Nmap used to scan
Command run to initiate the scan
Total scan time in seconds (could differ from #stop_time - #start_time)
Starting time
Starting time
Ending time
Ending time
Amount of verbosity (-v) used while scanning
Amount of verbosity (-v) used while scanning
XML version of Nmap's output
Public Instance Methods
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
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
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
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
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