module Ronin::CLI::DNS
Mixin for adding DNS
support to commands.
Constants
- RECORD_TYPES
Mapping of
DNS
record types and lowercase versions.
Attributes
nameservers[R]
The configured nameservers to query.
@return [Array<String>]
Public Class Methods
included(command)
click to toggle source
Adds the ‘-N,–nameserver HOST|IP` option to the command which is including {DNS}.
@param [Class<Command>] command
The command which is including {DNS}.
# File lib/ronin/cli/dns.rb, line 52 def self.included(command) command.option :nameserver, short: '-N', value: { type: String, usage: 'HOST|IP' }, desc: 'Send DNS queries to the nameserver' do |ip| @nameservers << ip end end
new(**kwargs)
click to toggle source
Initializes the command.
Calls superclass method
# File lib/ronin/cli/dns.rb, line 71 def initialize(**kwargs) super(**kwargs) @nameservers = [] end
Public Instance Methods
print_record(record)
click to toggle source
Prints a DNS
record.
@param [Resolv::DNS::Resource] record
The DNS resource record to print.
# File lib/ronin/cli/dns.rb, line 111 def print_record(record) case record when Resolv::DNS::Resource::IN::A, Resolv::DNS::Resource::IN::AAAA puts record.address when Resolv::DNS::Resource::IN::NS, Resolv::DNS::Resource::IN::CNAME, Resolv::DNS::Resource::IN::PTR puts record.name when Resolv::DNS::Resource::IN::MX puts record.exchange when Resolv::DNS::Resource::IN::TXT puts record.strings.join when Resolv::DNS::Resource::IN::HINFO puts "#{record.cpu} #{record.os}" when Resolv::DNS::Resource::IN::LOC puts "#{record.latitude} #{record.longitude}" when Resolv::DNS::Resource::IN::MINFO puts "#{record.emailbx}@#{record.rmailbx}" when Resolv::DNS::Resource::IN::SOA puts "#{record.mname} #{record.rname} #{record.serial} #{record.refresh} #{record.retry} #{record.expire} #{record.ttl}" when Resolv::DNS::Resource::IN::SRV puts "#{record.port} #{record.priority} #{record.weight} #{record.target}" when Resolv::DNS::Resource::IN::WKS puts "#{record.address} #{record.protocol}" end end
print_records(records)
click to toggle source
Prints multiple DNS
records.
@param [Array<Resolv::DNS::Resource>] records
The DNS resource records to print.
# File lib/ronin/cli/dns.rb, line 99 def print_records(records) records.each do |record| print_record(record) end end
resolver()
click to toggle source
The resolver to use.
@return [Ronin::Network::DNS::Resolver]
The DNS resolver.
# File lib/ronin/cli/dns.rb, line 83 def resolver @resolver ||= unless @nameservers.empty? Support::Network::DNS.resolver( nameservers: @nameservers ) else Support::Network::DNS.resolver end end