Class: Ronin::Masscan::CLI::Commands::Print Private
- Inherits:
-
Ronin::Masscan::CLI::Command
- Object
- Core::CLI::Command
- Ronin::Masscan::CLI::Command
- Ronin::Masscan::CLI::Commands::Print
- Includes:
- CommandKit::Printing::Indent, FilteringOptions
- Defined in:
- lib/ronin/masscan/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 IPs and ports from masscan scan file(s).
Usage
ronin-masscan print [options] MASSCAN_FILE [...]
Options
-P, --protocol tcp|udp Filters the targets by protocol
--ip IP Filters the targets by IP
--ip-range CIDR Filters the targets by IP range
-p, --ports {PORT | PORT1-PORT2},...
Filter targets by port number
--with-app-protocol APP_PROTOCOL[,...]
Filters targets with the app protocol
--with-payload STRING Filters targets containing the payload
--with-payload-regex /REGEX/ Filters targets with the matching payload
-h, --help Print help information
Arguments
MASSCAN_FILE ... The masscan scan file(s) to parse
Instance Attribute Summary
Attributes included from FilteringOptions
#ip_ranges, #ips, #ports, #protocols, #with_app_protocols, #with_payloads
Instance Method Summary collapse
-
#print_banner_record(banner) ⇒ Object
private
Prints a masscan banner record.
-
#print_records(records) ⇒ Object
private
Prints the open ports for the IP.
-
#print_status_record(status) ⇒ Object
private
Prints a masscan status record.
-
#run(*masscan_files) ⇒ Object
private
Runs the
ronin-masscan print
command.
Methods included from FilteringOptions
#filter_banner_records, #filter_records, #filter_records_by_app_protocol, #filter_records_by_ip, #filter_records_by_ip_range, #filter_records_by_payload, #filter_records_by_port, #filter_records_by_protocol, #filter_status_records, included, #initialize
Instance Method Details
#print_banner_record(banner) ⇒ 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.
Prints a masscan banner record.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/ronin/masscan/cli/commands/print.rb', line 141 def () payload = .payload app_protocol = .app_protocol if payload.include?("\n") # multiline? puts app_protocol indent do payload.chomp.each_line(chomp: true) do |line| puts line end end else puts "#{app_protocol}\t#{payload}" end end |
#print_records(records) ⇒ 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.
Prints the open ports for the IP.
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 |
# File 'lib/ronin/masscan/cli/commands/print.rb', line 96 def print_records(records) records.group_by(&:ip).each do |ip,records_for_ip| puts "[ #{ip} ]" puts records_for_ip.group_by { |record| [record.port, record.protocol] }.each_value do |records_for_port| status = records_for_port.first = records_for_port[1..] indent do print_status_record(status) unless .empty? indent do .each do || () end end puts end end end end end |
#print_status_record(status) ⇒ 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.
Prints a masscan status record.
130 131 132 |
# File 'lib/ronin/masscan/cli/commands/print.rb', line 130 def print_status_record(status) puts "#{status.port}/#{status.protocol}\t#{status.status}" end |
#run(*masscan_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-masscan print
command.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ronin/masscan/cli/commands/print.rb', line 76 def run(*masscan_files) masscan_files.each do |masscan_file| output_file = begin ::Masscan::OutputFile.new(masscan_file) rescue ArgumentError => error print_error(error.) exit(1) end records = filter_records(output_file) print_records(records) end end |