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.
print_records(records) click to toggle source

Prints multiple DNS records.

@param [Array<Resolv::DNS::Resource>] records

The DNS resource records to print.
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