Class: Ronin::Recon::CLI::Commands::Run Private
- Inherits:
-
Ronin::Recon::CLI::Command
- Object
- Core::CLI::Command
- Ronin::Recon::CLI::Command
- Ronin::Recon::CLI::Commands::Run
- Includes:
- Core::CLI::Logging, DB::CLI::DatabaseOptions, DebugOption, Printing
- Defined in:
- lib/ronin/recon/cli/commands/run.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.
Runs the recon engine with one or more initial values.
Usage
ronin-recon run [options] {IP | IP-range | DOMAIN | HOST | WILDCARD | WEBSITE} ...
Options
-D, --debug Enable debugging output
-C, --config-file FILE Loads the configuration file
-w, --worker WORKER Explicitly uses a worker
-e, --enable WORKER Enables a worker
-d, --disable WORKER Disables a worker
--worker-file FILE Loads a worker from a file
-p, --param WORKER.NAME=VALUE Sets a param for a worker
-c, --concurrency WORKER=NUM Sets the concurrency of a worker
--max-depth NUM The maximum recon depth (Default: 10)
-o, --output FILE The output file to write results to
-I, --ignore VALUE The values to ignore in result
-F txt|list|csv|json|ndjson|dot|svg|png|pdf,
--output-format The output format
--import Imports each newly discovered value into the Ronin database
-h, --help Print help information
Arguments
IP|IP-range|DOMAIN|HOST|WILDCARD|WEBSITE An initial recon value.
Constant Summary
Constants included from Printing
Instance Attribute Summary collapse
-
#config ⇒ Config
readonly
private
The loaded configuration for the Engine.
-
#disable_workers ⇒ Set<String>
readonly
private
Additional set of workers to disable.
-
#enable_workers ⇒ Set<String>
readonly
private
Additional set of workers to enable.
-
#ignore ⇒ Array<Value>
readonly
private
The values that are out of scope.
-
#only_workers ⇒ Set<String>
readonly
private
Explicit set of workers to only use.
-
#worker_concurrency ⇒ Hash{String => Integer}
readonly
private
The concurrency for the workers.
-
#worker_files ⇒ Set<String>
readonly
private
Additional set of worker files to load.
-
#worker_params ⇒ Hash{String => Hash{String => String}}
readonly
private
The params for the workers.
-
#workers ⇒ Workers
readonly
private
The loaded workers for the Engine.
Instance Method Summary collapse
-
#import_connection(value, parent) ⇒ Object
private
Imports a connection between two values into ronin-db.
-
#import_value(value) ⇒ Object
private
Imports a discovered value into ronin-db.
-
#initialize(**kwargs) ⇒ Run
constructor
private
Initializes the
ronin-recon run
command. -
#load_config ⇒ Object
private
Loads the recon configuration file from either the
--config-file
option or~/.config/ronin-recon/config.yml
. -
#load_workers ⇒ Object
private
Loads the worker classes from the Ronin::Recon::Config#workers, as well as additional workers loaded by
--load-worker
. -
#parse_value(value) ⇒ Value
private
Parses the value string.
-
#run(*values) ⇒ Object
private
Runs the
ronin-recon run
command.
Methods included from Printing
#format_value, #print_value, #value_class_name
Methods included from DebugOption
Constructor Details
#initialize(**kwargs) ⇒ Run
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-recon run
command.
238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 238 def initialize(**kwargs) super(**kwargs) @only_workers = Set.new @enable_workers = Set.new @disable_workers = Set.new @worker_files = Set.new @worker_params = Hash.new { |hash,key| hash[key] = {} } @worker_concurrency = {} @ignore = [] end |
Instance Attribute Details
#config ⇒ Config (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 loaded configuration for the Engine.
210 211 212 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 210 def config @config end |
#disable_workers ⇒ Set<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.
Additional set of workers to disable.
200 201 202 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 200 def disable_workers @disable_workers end |
#enable_workers ⇒ Set<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.
Additional set of workers to enable.
195 196 197 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 195 def enable_workers @enable_workers end |
#ignore ⇒ Array<Value> (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 values that are out of scope.
230 231 232 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 230 def ignore @ignore end |
#only_workers ⇒ Set<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.
Explicit set of workers to only use.
190 191 192 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 190 def only_workers @only_workers end |
#worker_concurrency ⇒ Hash{String => 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 concurrency for the workers.
225 226 227 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 225 def worker_concurrency @worker_concurrency end |
#worker_files ⇒ Set<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.
Additional set of worker files to load.
205 206 207 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 205 def worker_files @worker_files end |
#worker_params ⇒ Hash{String => Hash{String => 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 params for the workers.
220 221 222 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 220 def worker_params @worker_params end |
Instance Method Details
#import_connection(value, parent) ⇒ 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.
Imports a connection between two values into ronin-db.
412 413 414 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 412 def import_connection(value,parent) Importer.import_connection(value,parent) end |
#import_value(value) ⇒ 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.
Imports a discovered value into ronin-db.
399 400 401 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 399 def import_value(value) Importer.import_value(value) end |
#load_config ⇒ 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.
Loads the recon configuration file from either
the --config-file
option or ~/.config/ronin-recon/config.yml
.
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 336 def load_config @config = if (path = [:config_file]) Config.load(path) else Config.default end unless @only_workers.empty? @config.workers = @only_workers end @enable_workers.each do |worker_id| @config.workers.add(worker_id) end @disable_workers.each do |worker_id| @config.workers.delete(worker_id) end @worker_params.each do |worker,params| if @config.params.has_key?(params) @config.params[worker].merge!(params) else @config.params[worker] = params end end @worker_concurrency.each do |worker,concurrency| @config.concurrency[worker] = concurrency end end |
#load_workers ⇒ 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.
If the --intensity
option is given, then the workers will be
filtered by intensity.
Loads the worker classes from the Ronin::Recon::Config#workers, as well as
additional workers loaded by --load-worker
.
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 376 def load_workers @workers = Ronin::Recon::Workers.load(@config.workers) unless @worker_files.empty? @worker_files.each do |path| @workers.load_file(path) end end if (level = [:intensity]) @workers = @workers.intensity(level) end rescue Ronin::Recon::ClassNotFound => error print_error(error.) exit(1) end |
#parse_value(value) ⇒ Value
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 the value string.
324 325 326 327 328 329 330 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 324 def parse_value(value) Value.parse(value) rescue UnknownValue => error print_error(error.) print_error("value must be an IP address, CIDR IP-range, domain, sub-domain, wildcard hostname, or website base URL") exit(-1) end |
#run(*values) ⇒ 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-recon run
command.
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/ronin/recon/cli/commands/run.rb', line 258 def run(*values) load_config load_workers values = values.map { |value| parse_value(value) } output_file = if [:output] && [:output_format] [:output_format].open([:output]) end if [:import] require 'ronin/db' require 'ronin/recon/importer' db_connect end begin Engine.run(values, config: @config, workers: @workers, max_depth: [:max_depth], ignore: @ignore) do |engine| engine.on(:value) do |value,parent| print_value(value,parent) end if output_file engine.on(:value) do |value| output_file << value end if output_file.kind_of?(OutputFormats::GraphFormat) engine.on(:connection) do |value,parent| output_file[value] = parent end end end if [:import] engine.on(:connection) do |value,parent| import_connection(value,parent) end end engine.on(:job_failed) do |worker,value,exception| log_error "[#{worker.id}] job failed for value #{value}:" log_error " #{exception.class}: #{exception.}" exception.backtrace.each do |line| log_error " #{line}" end end end ensure output_file.close if [:output] end end |