Class: Ronin::Masscan::CLI::Commands::New Private
- Inherits:
-
Ronin::Masscan::CLI::Command
- Object
- Core::CLI::Command
- Ronin::Masscan::CLI::Command
- Ronin::Masscan::CLI::Commands::New
- Includes:
- Core::CLI::Generator
- Defined in:
- lib/ronin/masscan/cli/commands/new.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.
Usage
ronin-masscan new [options] FILE
Options
--parser Generate a masscan output file parser script
--scanner Generate a masscan scanner script
--printing Adds additional printing of the masscan scan data
--import Also import the masscan scan data
--output-file OUTPUT_FILE Sets the output file to write to or parse
-p {PORT | [PORT1]-[PORT2]},..., Sets the port range to scan
--ports
--ips {IP | IP-range}[,..] Sets the targets to scan (Defaults: ARGV[0])
-h, --help Print help information
Arguments
PATH The path to the new masscan ruby script
Examples
ronin-masscan new scanner.rb --ports 22,80,443,8000-9000 --ips '192.168.1.*'
ronin-masscan new parser.rb --parser --output-file path/to/masscan.bin --printing
Instance Attribute Summary collapse
-
#features ⇒ Hash{Symbol => Boolean}
readonly
private
Additional features.
-
#ips ⇒ Array<String>
readonly
private
The IP addresses or ranges to scan.
-
#output_file ⇒ String?
readonly
private
The optioanl output file to write to or parse.
-
#ports ⇒ Array<Integer, Range(Integer,Integer)>?
readonly
private
The optional ports to scan.
-
#script_type ⇒ :scanner, :parser
readonly
private
The script type.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ New
constructor
private
Initializes the
ronin-masscan new
command. -
#parse_port_range(ports) ⇒ Array<Integer, Range(Integer,Integer)>
private
Parses a port range.
-
#run(file) ⇒ Object
private
Runs the
ronin-masscan new
command.
Constructor Details
#initialize(**kwargs) ⇒ New
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.
Initializes the ronin-masscan new
command.
149 150 151 152 153 154 155 |
# File 'lib/ronin/masscan/cli/commands/new.rb', line 149 def initialize(**kwargs) super(**kwargs) @script_type = :scanner @ips = [] @features = {} end |
Instance Attribute Details
#features ⇒ Hash{Symbol => Boolean} (readonly)
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.
Additional features.
141 142 143 |
# File 'lib/ronin/masscan/cli/commands/new.rb', line 141 def features @features end |
#ips ⇒ Array<String> (readonly)
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.
The IP addresses or ranges to scan.
136 137 138 |
# File 'lib/ronin/masscan/cli/commands/new.rb', line 136 def ips @ips end |
#output_file ⇒ String? (readonly)
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.
The optioanl output file to write to or parse.
126 127 128 |
# File 'lib/ronin/masscan/cli/commands/new.rb', line 126 def output_file @output_file end |
#ports ⇒ Array<Integer, Range(Integer,Integer)>? (readonly)
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.
The optional ports to scan.
131 132 133 |
# File 'lib/ronin/masscan/cli/commands/new.rb', line 131 def ports @ports end |
#script_type ⇒ :scanner, :parser (readonly)
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.
The script type.
121 122 123 |
# File 'lib/ronin/masscan/cli/commands/new.rb', line 121 def script_type @script_type end |
Instance Method Details
#parse_port_range(ports) ⇒ Array<Integer, Range(Integer,Integer)>
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.
Parses a port range.
184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/ronin/masscan/cli/commands/new.rb', line 184 def parse_port_range(ports) ports.split(',').map do |port| case port when /\A\d+-\d+\z/ start, stop = port.split('-',2) (start.to_i..stop.to_i) when /\A\d+\z/ port.to_i else raise(ArgumentError,"invalid port range: #{ports.inspect}") end end end |
#run(file) ⇒ 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 new
command.
163 164 165 166 167 168 169 170 |
# File 'lib/ronin/masscan/cli/commands/new.rb', line 163 def run(file) @directory = File.dirname(file) mkdir @directory unless File.directory?(@directory) erb "script.rb.erb", file chmod '+x', file end |