Module: Ronin::CLI::DNS Private
- Included in:
- Commands::Dns, Commands::Host
- Defined in:
- lib/ronin/cli/dns.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Mixin for adding DNS support to commands.
Constant Summary collapse
- RECORD_TYPES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Mapping of DNS record types and lowercase versions.
{ A: :a, AAAA: :aaaa, ANY: :any, CNAME: :cname, HINFO: :hinfo, LOC: :loc, MINFO: :minfo, MX: :mx, NS: :ns, PTR: :ptr, SOA: :soa, SRV: :srv, TXT: :txt, WKS: :wks }
Instance Attribute Summary collapse
-
#nameservers ⇒ Array<String>
readonly
private
The configured nameservers to query.
Class Method Summary collapse
-
.included(command) ⇒ Object
private
Adds the
-N,--nameserver HOST|IP
option to the command which is including DNS.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ Object
private
Initializes the command.
-
#print_record(record) ⇒ Object
private
Prints a DNS record.
-
#print_records(records) ⇒ Object
private
Prints multiple DNS records.
-
#resolver ⇒ Ronin::Network::DNS::Resolver
private
The resolver to use.
Instance Attribute Details
#nameservers ⇒ Array<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 configured nameservers to query.
66 67 68 |
# File 'lib/ronin/cli/dns.rb', line 66 def nameservers @nameservers end |
Class Method Details
.included(command) ⇒ 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.
Adds the -N,--nameserver HOST|IP
option to the command which is
including Ronin::CLI::DNS.
52 53 54 55 56 57 58 59 60 61 |
# 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 |
Instance Method Details
#initialize(**kwargs) ⇒ 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.
Initializes the command.
71 72 73 74 75 |
# File 'lib/ronin/cli/dns.rb', line 71 def initialize(**kwargs) super(**kwargs) @nameservers = [] end |
#print_record(record) ⇒ 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.
Prints a DNS record.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# 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) ⇒ 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.
Prints multiple DNS records.
99 100 101 102 103 |
# File 'lib/ronin/cli/dns.rb', line 99 def print_records(records) records.each do |record| print_record(record) end end |
#resolver ⇒ Ronin::Network::DNS::Resolver
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 resolver to use.
83 84 85 86 87 88 89 90 91 |
# 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 |