Class: Ronin::Nmap::CLI::Commands::Print Private

Inherits:
Ronin::Nmap::CLI::Command show all
Includes:
FilteringOptions
Defined in:
lib/ronin/nmap/cli/commands/print.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Prints the scanned hosts from nmap XML file(s).

Usage

ronin-nmap print [options] XML_FILE [...]

Options

    --ip IP                      Filters the targets by IP
    --ip-range CIDR              Filter the targets by IP range
    --domain DOMAIN              Filters the targets by domain
    --with-os OS                 Filters the targets by OS
    --with-ports {PORT | PORT1-PORT2},...
                                 Filter targets by port numbers
    --with-service SERVICE[,...] Filters targets by service
    --with-script SCRIPT[,...]   Filters targets with the script
    --with-script-output STRING  Filters targets containing the script output
    --with-script-regex /REGEX/  Filters targets containing the script output
-h, --help                       Print help information

Arguments

XML_FILE ...                     The nmap XML file(s) to parse

Instance Attribute Summary

Attributes included from FilteringOptions

#with_domains, #with_ip_ranges, #with_ips, #with_oses, #with_ports, #with_script_output, #with_scripts, #with_services

Instance Method Summary collapse

Methods included from FilteringOptions

#filter_targets, #filter_targets_by_domain, #filter_targets_by_ip, #filter_targets_by_ip_range, #filter_targets_by_os, #filter_targets_by_port, #filter_targets_by_script, #filter_targets_by_script_output, #filter_targets_by_service, included, #initialize

Instance Method Details

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Prints the targets.

Parameters:

  • host (::Nmap::XML::Host)


90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/ronin/nmap/cli/commands/print.rb', line 90

def print_target(host)
  puts "[ #{host} ]"
  puts

  unless host.addresses.empty?
    puts "  Addresses:"
    host.addresses.each do |address|
      puts "    #{address}"
    end
    puts
  end

  unless host.hostnames.empty?
    puts "  Hostnames:"
    host.hostnames.each do |hostname|
      puts "    #{hostname}"
    end
    puts
  end

  host.each_open_port do |port|
    puts "  #{port.number}/#{port.protocol}\t#{port.state}\t#{port.service}"

    unless port.scripts.empty?
      puts

      port.scripts.each_value do |script|
        puts "    #{script.id}:"

        script.output.strip.each_line do |line|
          puts "      #{line}"
        end

        puts
      end
    end
  end
end

#run(*xml_files) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Runs the ronin-nmap print command.

Parameters:

  • xml_files (Array<String>)

    The nmap XML files to parse.



74
75
76
77
78
79
80
81
82
83
# File 'lib/ronin/nmap/cli/commands/print.rb', line 74

def run(*xml_files)
  xml_files.each do |xml_file|
    xml = ::Nmap::XML.open(xml_file)

    filter_targets(xml).each do |host|
      print_target(host)
      puts
    end
  end
end