Module: Ronin::Recon::Importer
- Defined in:
- lib/ronin/recon/importer.rb
Overview
Handles importing recon values into ronin-db.
Examples
require 'ronin/db'
require 'ronin/recon/importer'
Ronin::DB.connect
values = [Ronin::Recon::Values::Domain.new('...'), ...]
Ronin::Recon::Engine.run(values) do |engine|
engine.on(:value) do |value|
puts "Fond new value #{value}"
Ronin::Recon::Importer.import_value(value)
end
end
Class Method Summary collapse
-
.import_cert(cert) ⇒ Ronin::DB::Cert
Imports a SSL/TLS certificate.
-
.import_connection(value, parent) ⇒ (Ronin::DB::Model, Ronin::DB::Model)
Imports the connection between two values.
-
.import_host_name(host_name) ⇒ Ronin::DB::HostName
Imports a host value.
-
.import_ip_address(address) ⇒ Ronin::DB::IPAddress
Imports a IP address.
-
.import_open_port(open_port) ⇒ Ronin::DB::Open_port
Imports an open port value.
-
.import_port(protocol, number) ⇒ Ronin::DB::Port
Imports a port number.
-
.import_service(service) ⇒ Ronin::DB::Service
Imports a service name.
-
.import_url(url) ⇒ Ronin::DB::URL
Imports a URL.
-
.import_value(value) ⇒ Ronin::DB::HostName, ...
Imports a value into the database.
Class Method Details
.import_cert(cert) ⇒ Ronin::DB::Cert
Imports a SSL/TLS certificate.
217 218 219 220 221 |
# File 'lib/ronin/recon/importer.rb', line 217 def self.import_cert(cert) DB::Cert.transaction do DB::Cert.find_or_import(cert) end end |
.import_connection(value, parent) ⇒ (Ronin::DB::Model, Ronin::DB::Model)
Imports the connection between two values.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ronin/recon/importer.rb', line 61 def self.import_connection(value,parent) imported_value = import_value(value) imported_parent = import_value(parent) if imported_value.kind_of?(DB::IPAddress) && imported_parent.kind_of?(DB::HostName) imported_value.host_name_ip_addresses.find_or_create_by( host_name: imported_parent ) elsif imported_value.kind_of?(DB::Cert) && imported_parent.kind_of?(DB::OpenPort) imported_parent.update(cert: imported_value) end return imported_value, imported_parent end |
.import_host_name(host_name) ⇒ Ronin::DB::HostName
Imports a host value.
110 111 112 113 114 |
# File 'lib/ronin/recon/importer.rb', line 110 def self.import_host_name(host_name) DB::HostName.transaction do DB::HostName.find_or_import(host_name) end end |
.import_ip_address(address) ⇒ Ronin::DB::IPAddress
Imports a IP address.
125 126 127 128 129 |
# File 'lib/ronin/recon/importer.rb', line 125 def self.import_ip_address(address) DB::IPAddress.transaction do DB::IPAddress.find_or_import(address) end end |
.import_open_port(open_port) ⇒ Ronin::DB::Open_port
Imports an open port value.
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/ronin/recon/importer.rb', line 191 def self.import_open_port(open_port) imported_ip_address = import_ip_address(open_port.address) imported_port = import_port(open_port.protocol,open_port.number) imported_service = if (service = open_port.service) import_service(service) end imported_open_port = DB::OpenPort.transaction do DB::OpenPort.find_or_create_by( ip_address: imported_ip_address, port: imported_port, service: imported_service ) end return imported_open_port end |
.import_port(protocol, number) ⇒ Ronin::DB::Port
Imports a port number.
158 159 160 161 162 163 164 165 |
# File 'lib/ronin/recon/importer.rb', line 158 def self.import_port(protocol,number) DB::Port.transaction do DB::Port.find_or_create_by( protocol: protocol, number: number ) end end |
.import_service(service) ⇒ Ronin::DB::Service
Imports a service name.
176 177 178 179 180 |
# File 'lib/ronin/recon/importer.rb', line 176 def self.import_service(service) DB::Service.transaction do DB::Service.find_or_import(service) end end |
.import_url(url) ⇒ Ronin::DB::URL
Imports a URL.
140 141 142 143 144 |
# File 'lib/ronin/recon/importer.rb', line 140 def self.import_url(url) DB::URL.transaction do DB::URL.find_or_import(url) end end |
.import_value(value) ⇒ Ronin::DB::HostName, ...
Imports a value into the database.
The imported record.
91 92 93 94 95 96 97 98 99 |
# File 'lib/ronin/recon/importer.rb', line 91 def self.import_value(value) case value when Values::Host then import_host_name(value.name) when Values::IP then import_ip_address(value.address) when Values::OpenPort then import_open_port(value) when Values::URL then import_url(value.uri) when Values::Cert then import_cert(value.cert) end end |