Module: Ronin::Support::Network::DNS::Mixin
- Included in:
- Mixin
- Defined in:
- lib/ronin/support/network/dns/mixin.rb
Overview
Provides helper methods for performing DNS queries.
Instance Method Summary collapse
-
#dns_get_a_address(name, **kwargs) ⇒ String?
Queries the first IPv4 address belonging to the host name.
-
#dns_get_a_addresses(name, **kwargs) ⇒ Array<String>
Queries all IPv4 addresses belonging to the host name.
-
#dns_get_a_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::A?
Queries the first
A
record belonging to the host name. -
#dns_get_a_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::A>
Queries all
A
records belonging to the host name. -
#dns_get_aaaa_address(name, **kwargs) ⇒ String?
Queries the first IPv6 address belonging to the host name.
-
#dns_get_aaaa_addresses(name, **kwargs) ⇒ Array<String>
Queries all IPv6 addresses belonging to the host name.
-
#dns_get_aaaa_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::AAAA?
Queries the first
AAAA
DNS records belonging to the host name. -
#dns_get_aaaa_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::AAAA>
Queries all
AAAA
DNS records belonging to the host name. -
#dns_get_address(host, **kwargs) ⇒ String?
(also: #dns_lookup)
Looks up the address of a hostname.
-
#dns_get_addresses(host, **kwargs) ⇒ Array<String>
Looks up all addresses of a hostname.
-
#dns_get_any_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource>
Queries all records of the host name using the
ANY
DNS query. -
#dns_get_cname(name, **kwargs) ⇒ String?
Queries the canonical name for the host name.
-
#dns_get_cname_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::CNAME?
Queries the
CNAME
record for the host name. -
#dns_get_hinfo_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::HINFO?
Queries the
HINFO
record for the host name. -
#dns_get_loc_record(name, **kwargs) ⇒ Resolv::DNS::Resource::LOC?
Queries the
LOC
(Location) DNS record of the host name. -
#dns_get_mailservers(name, **kwargs) ⇒ Array<String>
Queries the mailservers for the host name.
-
#dns_get_minfo_record(name, **kwargs) ⇒ Resolv::DNS::Resource::MINFO?
Queries the
MINFO
(Machine-Info) DNS record of the host name. -
#dns_get_mx_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::MX>
Queries all
MX
DNS records belonging to the host name. -
#dns_get_name(ip, **kwargs) ⇒ String?
(also: #dns_reverse_lookup)
Looks up the hostname of the address.
-
#dns_get_names(ip, **kwargs) ⇒ Array<String>
Looks up all hostnames associated with the address.
-
#dns_get_nameservers(name, **kwargs) ⇒ Array<String>
Queries the nameservers for the host name.
-
#dns_get_ns_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::NS>
Queries all
NS
DNS records belonging to the host name. -
#dns_get_ptr_name(ip, **kwargs) ⇒ String?
Queries the
PTR
host name for the IP address. -
#dns_get_ptr_names(ip, **kwargs) ⇒ Array<String>
Queries all
PTR
names for the IP address. -
#dns_get_ptr_record(ip, **kwargs) ⇒ Resolv::DNS::Resource::PTR?
Queries the first
PTR
DNS record for the IP address. -
#dns_get_ptr_records(ip, **kwargs) ⇒ Array<Resolv::DNS::Resource::PTR>
Queries all
PTR
DNS records for the IP address. -
#dns_get_record(name, record_type, **kwargs) ⇒ Resolv::DNS::Resource?
Queries a single matching DNS record for the host name.
-
#dns_get_records(name, record_type, **kwargs) ⇒ Array<Resolv::DNS::Resource>
Queries all matching DNS records for the host name.
-
#dns_get_soa_record(name, **kwargs) ⇒ Resolv::DNS::Resource::SOA?
Queries the first
SOA
DNS record belonging to the host name. -
#dns_get_srv_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::SRV>
Queries all
SRV
DNS records belonging to the host name. -
#dns_get_txt_record(name, **kwargs) ⇒ Resolv::DNS::Resource::TXT?
Queiries the first
TXT
DNS record belonging to the host name. -
#dns_get_txt_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::TXT>
Queries all
TXT
DNS records belonging to the host name. -
#dns_get_txt_string(name, **kwargs) ⇒ String?
Queries the first
TXT
string belonging to the host name. -
#dns_get_txt_strings(name, **kwargs) ⇒ Array<String>
Queries all of the
TXT
string values of the host name. -
#dns_get_wks_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::WKS>
Queries all
WKS
(Well-Known-Service) DNS records belonging to the host name. -
#dns_nameserver=(new_nameserver) ⇒ String
Sets the primary DNS nameserver to query.
-
#dns_nameservers ⇒ Array<String>
The default DNS nameserver(s) to query.
-
#dns_nameservers=(new_nameservers) ⇒ Array<String>
Sets the DNS nameservers to query.
-
#dns_resolver(nameservers: nil, nameserver: nil) ⇒ Resolv, Resolv::DNS
Creates a DNS Resolver for the nameserver.
Instance Method Details
#dns_get_a_address(name, **kwargs) ⇒ String?
Queries the first IPv4 address belonging to the host name.
383 384 385 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 383 def dns_get_a_address(name,**kwargs) dns_resolver(**kwargs).get_a_address(name.to_s) end |
#dns_get_a_addresses(name, **kwargs) ⇒ Array<String>
Queries all IPv4 addresses belonging to the host name.
429 430 431 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 429 def dns_get_a_addresses(name,**kwargs) dns_resolver(**kwargs).get_a_addresses(name.to_s) end |
#dns_get_a_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::A?
Queries the first A
record belonging to the host name.
361 362 363 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 361 def dns_get_a_record(name,**kwargs) dns_resolver(**kwargs).get_a_record(name.to_s) end |
#dns_get_a_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::A>
Queries all A
records belonging to the host name.
407 408 409 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 407 def dns_get_a_records(name,**kwargs) dns_resolver(**kwargs).get_a_records(name.to_s) end |
#dns_get_aaaa_address(name, **kwargs) ⇒ String?
Queries the first IPv6 address belonging to the host name.
477 478 479 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 477 def dns_get_aaaa_address(name,**kwargs) dns_resolver(**kwargs).get_aaaa_address(name.to_s) end |
#dns_get_aaaa_addresses(name, **kwargs) ⇒ Array<String>
Queries all IPv6 addresses belonging to the host name.
523 524 525 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 523 def dns_get_aaaa_addresses(name,**kwargs) dns_resolver(**kwargs).get_aaaa_addresses(name.to_s) end |
#dns_get_aaaa_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::AAAA?
Queries the first AAAA
DNS records belonging to the host name.
454 455 456 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 454 def dns_get_aaaa_record(name,**kwargs) dns_resolver(**kwargs).get_aaaa_record(name.to_s) end |
#dns_get_aaaa_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::AAAA>
Queries all AAAA
DNS records belonging to the host name.
501 502 503 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 501 def dns_get_aaaa_records(name,**kwargs) dns_resolver(**kwargs).get_aaaa_records(name.to_s) end |
#dns_get_address(host, **kwargs) ⇒ String? Also known as: dns_lookup
Looks up the address of a hostname.
114 115 116 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 114 def dns_get_address(host,**kwargs) dns_resolver(**kwargs).get_address(host.to_s) end |
#dns_get_addresses(host, **kwargs) ⇒ Array<String>
Looks up all addresses of a hostname.
138 139 140 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 138 def dns_get_addresses(host,**kwargs) dns_resolver(**kwargs).get_addresses(host.to_s) end |
#dns_get_any_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource>
Queries all records of the host name using the ANY
DNS query.
263 264 265 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 263 def dns_get_any_records(name,**kwargs) dns_resolver(**kwargs).get_any_records(name.to_s) end |
#dns_get_cname(name, **kwargs) ⇒ String?
Queries the canonical name for the host name.
311 312 313 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 311 def dns_get_cname(name,**kwargs) dns_resolver(**kwargs).get_cname(name.to_s) end |
#dns_get_cname_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::CNAME?
Queries the CNAME
record for the host name.
288 289 290 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 288 def dns_get_cname_record(name,**kwargs) dns_resolver(**kwargs).get_cname_record(name.to_s) end |
#dns_get_hinfo_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::HINFO?
Queries the HINFO
record for the host name.
336 337 338 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 336 def dns_get_hinfo_record(name,**kwargs) dns_resolver(**kwargs).get_hinfo_record(name.to_s) end |
#dns_get_loc_record(name, **kwargs) ⇒ Resolv::DNS::Resource::LOC?
Queries the LOC
(Location) DNS record of the host name.
597 598 599 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 597 def dns_get_loc_record(name,**kwargs) dns_resolver(**kwargs).get_loc_record(name.to_s) end |
#dns_get_mailservers(name, **kwargs) ⇒ Array<String>
Queries the mailservers for the host name.
668 669 670 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 668 def dns_get_mailservers(name,**kwargs) dns_resolver(**kwargs).get_mailservers(name.to_s) end |
#dns_get_minfo_record(name, **kwargs) ⇒ Resolv::DNS::Resource::MINFO?
Queries the MINFO
(Machine-Info) DNS record of the host name.
622 623 624 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 622 def dns_get_minfo_record(name,**kwargs) dns_resolver(**kwargs).get_minfo_record(name.to_s) end |
#dns_get_mx_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::MX>
Queries all MX
DNS records belonging to the host name.
646 647 648 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 646 def dns_get_mx_records(name,**kwargs) dns_resolver(**kwargs).get_mx_records(name.to_s) end |
#dns_get_name(ip, **kwargs) ⇒ String? Also known as: dns_reverse_lookup
Looks up the hostname of the address.
160 161 162 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 160 def dns_get_name(ip,**kwargs) dns_resolver(**kwargs).get_name(ip.to_s) end |
#dns_get_names(ip, **kwargs) ⇒ Array<String>
Looks up all hostnames associated with the address.
184 185 186 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 184 def dns_get_names(ip,**kwargs) dns_resolver(**kwargs).get_names(ip.to_s) end |
#dns_get_nameservers(name, **kwargs) ⇒ Array<String>
Queries the nameservers for the host name.
714 715 716 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 714 def dns_get_nameservers(name,**kwargs) dns_resolver(**kwargs).get_nameservers(name.to_s) end |
#dns_get_ns_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::NS>
Queries all NS
DNS records belonging to the host name.
692 693 694 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 692 def dns_get_ns_records(name,**kwargs) dns_resolver(**kwargs).get_ns_records(name.to_s) end |
#dns_get_ptr_name(ip, **kwargs) ⇒ String?
Queries the PTR
host name for the IP address.
761 762 763 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 761 def dns_get_ptr_name(ip,**kwargs) dns_resolver(**kwargs).get_ptr_name(ip.to_s) end |
#dns_get_ptr_names(ip, **kwargs) ⇒ Array<String>
Queries all PTR
names for the IP address.
807 808 809 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 807 def dns_get_ptr_names(ip,**kwargs) dns_resolver(**kwargs).get_ptr_names(ip.to_s) end |
#dns_get_ptr_record(ip, **kwargs) ⇒ Resolv::DNS::Resource::PTR?
Queries the first PTR
DNS record for the IP address.
739 740 741 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 739 def dns_get_ptr_record(ip,**kwargs) dns_resolver(**kwargs).get_ptr_record(ip.to_s) end |
#dns_get_ptr_records(ip, **kwargs) ⇒ Array<Resolv::DNS::Resource::PTR>
Queries all PTR
DNS records for the IP address.
785 786 787 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 785 def dns_get_ptr_records(ip,**kwargs) dns_resolver(**kwargs).get_ptr_records(ip.to_s) end |
#dns_get_record(name, record_type, **kwargs) ⇒ Resolv::DNS::Resource?
Queries a single matching DNS record for the host name.
212 213 214 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 212 def dns_get_record(name,record_type,**kwargs) dns_resolver(**kwargs).get_record(name.to_s,record_type) end |
#dns_get_records(name, record_type, **kwargs) ⇒ Array<Resolv::DNS::Resource>
Queries all matching DNS records for the host name.
239 240 241 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 239 def dns_get_records(name,record_type,**kwargs) dns_resolver(**kwargs).get_records(name.to_s,record_type) end |
#dns_get_soa_record(name, **kwargs) ⇒ Resolv::DNS::Resource::SOA?
Queries the first SOA
DNS record belonging to the host name.
832 833 834 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 832 def dns_get_soa_record(name,**kwargs) dns_resolver(**kwargs).get_soa_record(name.to_s) end |
#dns_get_srv_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::SRV>
Queries all SRV
DNS records belonging to the host name.
547 548 549 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 547 def dns_get_srv_records(name,**kwargs) dns_resolver(**kwargs).get_srv_records(name.to_s) end |
#dns_get_txt_record(name, **kwargs) ⇒ Resolv::DNS::Resource::TXT?
Queiries the first TXT
DNS record belonging to the host name.
857 858 859 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 857 def dns_get_txt_record(name,**kwargs) dns_resolver(**kwargs).get_txt_record(name.to_s) end |
#dns_get_txt_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::TXT>
Queries all TXT
DNS records belonging to the host name.
904 905 906 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 904 def dns_get_txt_records(name,**kwargs) dns_resolver(**kwargs).get_txt_records(name.to_s) end |
#dns_get_txt_string(name, **kwargs) ⇒ String?
Queries the first TXT
string belonging to the host name.
880 881 882 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 880 def dns_get_txt_string(name,**kwargs) dns_resolver(**kwargs).get_txt_string(name.to_s) end |
#dns_get_txt_strings(name, **kwargs) ⇒ Array<String>
Queries all of the TXT
string values of the host name.
926 927 928 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 926 def dns_get_txt_strings(name,**kwargs) dns_resolver(**kwargs).get_txt_strings(name.to_s) end |
#dns_get_wks_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::WKS>
Queries all WKS
(Well-Known-Service) DNS records belonging to the
host name.
572 573 574 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 572 def dns_get_wks_records(name,**kwargs) dns_resolver(**kwargs).get_wks_records(name.to_s) end |
#dns_nameserver=(new_nameserver) ⇒ String
Sets the primary DNS nameserver to query.
67 68 69 70 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 67 def dns_nameserver=(new_nameserver) self.dns_nameservers = [new_nameserver] return new_nameserver end |
#dns_nameservers ⇒ Array<String>
The default DNS nameserver(s) to query.
54 55 56 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 54 def dns_nameservers @dns_nameservers ||= Network::DNS.nameservers end |
#dns_nameservers=(new_nameservers) ⇒ Array<String>
Sets the DNS nameservers to query.
40 41 42 43 44 45 46 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 40 def dns_nameservers=(new_nameservers) @dns_nameservers = new_nameservers.map(&:to_s) @dns_resolver = Network::DNS.resolver( nameservers: @dns_nameservers ) return new_nameservers end |
#dns_resolver(nameservers: nil, nameserver: nil) ⇒ Resolv, Resolv::DNS
Creates a DNS Resolver for the nameserver.
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/ronin/support/network/dns/mixin.rb', line 84 def dns_resolver(nameservers: nil, nameserver: nil) if nameserver Network::DNS.resolver(nameserver: nameserver) elsif nameservers Network::DNS.resolver(nameservers: nameservers) else @dns_resolver ||= Network::DNS.resolver( nameservers: dns_nameservers ) end end |