Class: Workers::Masscan
- Inherits:
-
Object
- Object
- Workers::Masscan
- Includes:
- Ronin::App, Sidekiq::Worker
- Defined in:
- workers/masscan.rb
Overview
masscan
scanner worker.
Constant Summary collapse
- Params =
The accepted JSON params which will be passed to #perform.
Dry::Schema::JSON() do required(:ips).array(:string).each(:string) required(:ports).filled(:string) optional(:banners).maybe(:bool) optional(:rate).maybe(:integer) optional(:config_file).maybe(:string) optional(:adapter).maybe(:string) optional(:adapter_ip).maybe(:string) optional(:adapter_port).maybe(:string) optional(:adapter_mac).maybe(:string) optional(:adapter_vlan).maybe(:string) optional(:router_mac).maybe(:string) optional(:ping).maybe(:bool) optional(:exclude).maybe(:string) optional(:exclude_file).maybe(:string) optional(:include_file).maybe(:string) optional(:pcap_payloads).maybe(:string) optional(:nmap_payloads).maybe(:string) optional(:http_method).maybe(Types::HTTPMethod) optional(:http_url).maybe(:string) optional(:http_version).maybe(:string) optional(:http_host).maybe(:string) optional(:http_user_agent).maybe(:string) optional(:http_field).maybe(:string) optional(:http_cookie).maybe(:string) optional(:http_payload).maybe(:string) optional(:open_only).maybe(:bool) optional(:pcap).maybe(:string) optional(:packet_trace).maybe(:bool) optional(:pfring).maybe(:bool) optional(:shards).maybe(:string) optional(:seed).maybe(:integer) optional(:ttl).maybe(:integer) optional(:wait).maybe(:integer) optional(:retries).maybe(:integer) end
Constants included from Ronin::App
Ronin::App::ROOT, Ronin::App::VERSION
Instance Method Summary collapse
-
#perform(params) ⇒ Object
Processes an
masscan
job. -
#validate(params) ⇒ Hash{Symbol => Object}
Validates the given job params.
Instance Method Details
#perform(params) ⇒ Object
Processes an masscan
job.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'workers/masscan.rb', line 90 def perform(params) kwargs = validate(params) Tempfile.open(['masscan-', '.bin']) do |tempfile| status = ::Masscan::Command.run( **kwargs, interactive: true, output_format: :binary, output_file: tempfile.path ) case status when true Ronin::Masscan::Importer.import_file(tempfile.path) when false raise("masscan command failed") when nil raise("masscan command not installed") end end end |
#validate(params) ⇒ Hash{Symbol => Object}
Validates the given job params.
124 125 126 127 128 129 130 131 132 |
# File 'workers/masscan.rb', line 124 def validate(params) result = Params.call(params) if result.failure? raise(ArgumentError,"invalid masscan params (#{params.inspect}): #{result.errors.inspect}") end return result.to_h end |