Module: Ronin::Support::Network::DNS
- Defined in:
- lib/ronin/support/network/dns.rb,
lib/ronin/support/network/dns/idn.rb,
lib/ronin/support/network/dns/mixin.rb,
lib/ronin/support/network/dns/resolver.rb
Overview
Defined Under Namespace
Modules: Mixin Classes: Resolver
Constant Summary collapse
- IDN =
Supports International Domain Names (IDN).
Addressable::IDNA
Class Method Summary collapse
-
.get_a_address(name, **kwargs) ⇒ String?
Queries the first IPv4 address belonging to the host name.
-
.get_a_addresses(name, **kwargs) ⇒ Array<String>
Queries all IPv4 addresses belonging to the host name.
-
.get_a_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::A?
Queries the first
A
record belonging to the host name. -
.get_a_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::A>
Queries all
A
records belonging to the host name. -
.get_aaaa_address(name, **kwargs) ⇒ String?
Queries the first IPv6 address belonging to the host name.
-
.get_aaaa_addresses(name, **kwargs) ⇒ Array<String>
Queries all IPv6 addresses belonging to the host name.
-
.get_aaaa_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::AAAA?
Queries the first
AAAA
DNS records belonging to the host name. -
.get_aaaa_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::AAAA>
Queries all
AAAA
DNS records belonging to the host name. -
.get_address(host, **kwargs) ⇒ String?
Looks up the address of a hostname.
-
.get_addresses(host, **kwargs) ⇒ Array<String>
Looks up all addresses of a hostname.
-
.get_any_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource>
Queries all records of the host name using the
ANY
DNS query. -
.get_cname(name, **kwargs) ⇒ String?
Queries the canonical name for the host name.
-
.get_cname_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::CNAME?
Queries the
CNAME
record for the host name. -
.get_hinfo_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::HINFO?
Queries the
HINFO
record for the host name. -
.get_ip_address(name, **kwargs) ⇒ String?
Queries the first IPv4 or IPv6 address belonging to the host name.
-
.get_ip_addresses(name, **kwargs) ⇒ Array<String>
Queries all IP addresses belonging to the host name.
-
.get_ipv4_address(name, **kwargs) ⇒ String?
Queries the first IPv4 address belonging to the host name.
-
.get_ipv4_addresses(name, **kwargs) ⇒ Array<String>
Queries all IPv4 addresses belonging to the host name.
-
.get_ipv6_address(name, **kwargs) ⇒ String?
Queries the first IPv6 address belonging to the host name.
-
.get_ipv6_addresses(name, **kwargs) ⇒ Array<String>
Queries all IPv6 addresses belonging to the host name.
-
.get_loc_record(name, **kwargs) ⇒ Resolv::DNS::Resource::LOC?
Queries the
LOC
(Location) DNS record of the host name. -
.get_mailservers(name, **kwargs) ⇒ Array<String>
Queries the mailservers for the host name.
-
.get_minfo_record(name, **kwargs) ⇒ Resolv::DNS::Resource::MINFO?
Queries the
MINFO
(Machine-Info) DNS record of the host name. -
.get_mx_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::MX>
Queries all
MX
DNS records belonging to the host name. -
.get_name(ip, **kwargs) ⇒ String?
Looks up the hostname of the address.
-
.get_names(ip, **kwargs) ⇒ Array<String>
Looks up all hostnames associated with the address.
-
.get_nameservers(name, **kwargs) ⇒ Array<String>
Queries the nameservers for the host name.
-
.get_ns_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::NS>
Queries all
NS
DNS records belonging to the host name. -
.get_ptr_name(ip, **kwargs) ⇒ String?
Queries the
PTR
host name for the IP address. -
.get_ptr_names(ip, **kwargs) ⇒ Array<String>
Queries all
PTR
names for the IP address. -
.get_ptr_record(ip, **kwargs) ⇒ Resolv::DNS::Resource::PTR?
Queries the first
PTR
DNS record for the IP address. -
.get_ptr_records(ip, **kwargs) ⇒ Array<Resolv::DNS::Resource::PTR>
Queries all
PTR
DNS records for the IP address. -
.get_record(name, record_type, **kwargs) ⇒ Resolv::DNS::Resource?
Queries a single matching DNS record for the host name.
-
.get_records(name, record_type, **kwargs) ⇒ Array<Resolv::DNS::Resource>
Queries all matching DNS records for the host name.
-
.get_soa_record(name, **kwargs) ⇒ Resolv::DNS::Resource::SOA?
Queries the first
SOA
DNS record belonging to the host name. -
.get_srv_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::SRV>
Queries all
SRV
DNS records belonging to the host name. -
.get_txt_record(name, **kwargs) ⇒ Resolv::DNS::Resource::TXT?
Queiries the first
TXT
DNS record belonging to the host name. -
.get_txt_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::TXT>
Queries all
TXT
DNS records belonging to the host name. -
.get_txt_string(name, **kwargs) ⇒ String?
Queries the first
TXT
string belonging to the host name. -
.get_txt_strings(name, **kwargs) ⇒ Array<String>
Queries all of the
TXT
string values of the host name. -
.get_wks_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::WKS>
Queries all
WKS
(Well-Known-Service) DNS records belonging to the host name. -
.lookup(host, **kwargs) ⇒ String?
Alias for DNS.get_address.
-
.nameserver=(new_nameserver) ⇒ String
Sets the primary DNS nameserver to be queried.
-
.nameservers ⇒ Array<String>
The primary DNS nameserver(s) to query.
-
.nameservers=(new_nameservers) ⇒ Array<String>
Sets the DNS nameserver to be queried.
-
.resolver(nameservers: nil, nameserver: nil) ⇒ Resolver
Creates a DNS Resolver for the given nameserver(s).
-
.reverse_lookup(ip, **kwargs) ⇒ String?
Alias for DNS.get_name.
Class Method Details
.get_a_address(name, **kwargs) ⇒ String?
Queries the first IPv4 address belonging to the host name.
426 427 428 |
# File 'lib/ronin/support/network/dns.rb', line 426 def self.get_a_address(name,**kwargs) resolver(**kwargs).get_a_address(name.to_s) end |
.get_a_addresses(name, **kwargs) ⇒ Array<String>
Queries all IPv4 addresses belonging to the host name.
494 495 496 |
# File 'lib/ronin/support/network/dns.rb', line 494 def self.get_a_addresses(name,**kwargs) resolver(**kwargs).get_a_addresses(name.to_s) end |
.get_a_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::A?
Queries the first A
record belonging to the host name.
404 405 406 |
# File 'lib/ronin/support/network/dns.rb', line 404 def self.get_a_record(name,**kwargs) resolver(**kwargs).get_a_record(name.to_s) end |
.get_a_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::A>
Queries all A
records belonging to the host name.
472 473 474 |
# File 'lib/ronin/support/network/dns.rb', line 472 def self.get_a_records(name,**kwargs) resolver(**kwargs).get_a_records(name.to_s) end |
.get_aaaa_address(name, **kwargs) ⇒ String?
Queries the first IPv6 address belonging to the host name.
564 565 566 |
# File 'lib/ronin/support/network/dns.rb', line 564 def self.get_aaaa_address(name,**kwargs) resolver(**kwargs).get_aaaa_address(name.to_s) end |
.get_aaaa_addresses(name, **kwargs) ⇒ Array<String>
Queries all IPv6 addresses belonging to the host name.
633 634 635 |
# File 'lib/ronin/support/network/dns.rb', line 633 def self.get_aaaa_addresses(name,**kwargs) resolver(**kwargs).get_aaaa_addresses(name.to_s) end |
.get_aaaa_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::AAAA?
Queries the first AAAA
DNS records belonging to the host name.
541 542 543 |
# File 'lib/ronin/support/network/dns.rb', line 541 def self.get_aaaa_record(name,**kwargs) resolver(**kwargs).get_aaaa_record(name.to_s) end |
.get_aaaa_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::AAAA>
Queries all AAAA
DNS records belonging to the host name.
611 612 613 |
# File 'lib/ronin/support/network/dns.rb', line 611 def self.get_aaaa_records(name,**kwargs) resolver(**kwargs).get_aaaa_records(name.to_s) end |
.get_address(host, **kwargs) ⇒ String?
Looks up the address of a hostname.
119 120 121 |
# File 'lib/ronin/support/network/dns.rb', line 119 def self.get_address(host,**kwargs) resolver(**kwargs).get_address(host.to_s) end |
.get_addresses(host, **kwargs) ⇒ Array<String>
Looks up all addresses of a hostname.
161 162 163 |
# File 'lib/ronin/support/network/dns.rb', line 161 def self.get_addresses(host,**kwargs) resolver(**kwargs).get_addresses(host.to_s) end |
.get_any_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource>
Queries all records of the host name using the ANY
DNS query.
306 307 308 |
# File 'lib/ronin/support/network/dns.rb', line 306 def self.get_any_records(name,**kwargs) resolver(**kwargs).get_any_records(name.to_s) end |
.get_cname(name, **kwargs) ⇒ String?
Queries the canonical name for the host name.
354 355 356 |
# File 'lib/ronin/support/network/dns.rb', line 354 def self.get_cname(name,**kwargs) resolver(**kwargs).get_cname(name.to_s) end |
.get_cname_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::CNAME?
Queries the CNAME
record for the host name.
331 332 333 |
# File 'lib/ronin/support/network/dns.rb', line 331 def self.get_cname_record(name,**kwargs) resolver(**kwargs).get_cname_record(name.to_s) end |
.get_hinfo_record(name, **kwargs) ⇒ Resolv::DNS::Resource::IN::HINFO?
Queries the HINFO
record for the host name.
379 380 381 |
# File 'lib/ronin/support/network/dns.rb', line 379 def self.get_hinfo_record(name,**kwargs) resolver(**kwargs).get_hinfo_record(name.to_s) end |
.get_ip_address(name, **kwargs) ⇒ String?
Queries the first IPv4 or IPv6 address belonging to the host name.
678 679 680 |
# File 'lib/ronin/support/network/dns.rb', line 678 def self.get_ip_address(name,**kwargs) resolver(**kwargs).get_ip_address(name.to_s) end |
.get_ip_addresses(name, **kwargs) ⇒ Array<String>
Queries all IP addresses belonging to the host name.
700 701 702 |
# File 'lib/ronin/support/network/dns.rb', line 700 def self.get_ip_addresses(name,**kwargs) resolver(**kwargs).get_ip_addresses(name.to_s) end |
.get_ipv4_address(name, **kwargs) ⇒ String?
Queries the first IPv4 address belonging to the host name.
448 449 450 |
# File 'lib/ronin/support/network/dns.rb', line 448 def self.get_ipv4_address(name,**kwargs) resolver(**kwargs).get_ipv4_address(name.to_s) end |
.get_ipv4_addresses(name, **kwargs) ⇒ Array<String>
Queries all IPv4 addresses belonging to the host name.
516 517 518 |
# File 'lib/ronin/support/network/dns.rb', line 516 def self.get_ipv4_addresses(name,**kwargs) resolver(**kwargs).get_ipv4_addresses(name.to_s) end |
.get_ipv6_address(name, **kwargs) ⇒ String?
Queries the first IPv6 address belonging to the host name.
587 588 589 |
# File 'lib/ronin/support/network/dns.rb', line 587 def self.get_ipv6_address(name,**kwargs) resolver(**kwargs).get_ipv6_address(name.to_s) end |
.get_ipv6_addresses(name, **kwargs) ⇒ Array<String>
Queries all IPv6 addresses belonging to the host name.
655 656 657 |
# File 'lib/ronin/support/network/dns.rb', line 655 def self.get_ipv6_addresses(name,**kwargs) resolver(**kwargs).get_ipv6_addresses(name.to_s) end |
.get_loc_record(name, **kwargs) ⇒ Resolv::DNS::Resource::LOC?
Queries the LOC
(Location) DNS record of the host name.
774 775 776 |
# File 'lib/ronin/support/network/dns.rb', line 774 def self.get_loc_record(name,**kwargs) resolver(**kwargs).get_loc_record(name.to_s) end |
.get_mailservers(name, **kwargs) ⇒ Array<String>
Queries the mailservers for the host name.
845 846 847 |
# File 'lib/ronin/support/network/dns.rb', line 845 def self.get_mailservers(name,**kwargs) resolver(**kwargs).get_mailservers(name.to_s) end |
.get_minfo_record(name, **kwargs) ⇒ Resolv::DNS::Resource::MINFO?
Queries the MINFO
(Machine-Info) DNS record of the host name.
799 800 801 |
# File 'lib/ronin/support/network/dns.rb', line 799 def self.get_minfo_record(name,**kwargs) resolver(**kwargs).get_minfo_record(name.to_s) end |
.get_mx_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::MX>
Queries all MX
DNS records belonging to the host name.
823 824 825 |
# File 'lib/ronin/support/network/dns.rb', line 823 def self.get_mx_records(name,**kwargs) resolver(**kwargs).get_mx_records(name.to_s) end |
.get_name(ip, **kwargs) ⇒ String?
Looks up the hostname of the address.
185 186 187 |
# File 'lib/ronin/support/network/dns.rb', line 185 def self.get_name(ip,**kwargs) resolver(**kwargs).get_name(ip.to_s) end |
.get_names(ip, **kwargs) ⇒ Array<String>
Looks up all hostnames associated with the address.
227 228 229 |
# File 'lib/ronin/support/network/dns.rb', line 227 def self.get_names(ip,**kwargs) resolver(**kwargs).get_names(ip.to_s) end |
.get_nameservers(name, **kwargs) ⇒ Array<String>
Queries the nameservers for the host name.
891 892 893 |
# File 'lib/ronin/support/network/dns.rb', line 891 def self.get_nameservers(name,**kwargs) resolver(**kwargs).get_nameservers(name.to_s) end |
.get_ns_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::NS>
Queries all NS
DNS records belonging to the host name.
869 870 871 |
# File 'lib/ronin/support/network/dns.rb', line 869 def self.get_ns_records(name,**kwargs) resolver(**kwargs).get_ns_records(name.to_s) end |
.get_ptr_name(ip, **kwargs) ⇒ String?
Queries the PTR
host name for the IP address.
938 939 940 |
# File 'lib/ronin/support/network/dns.rb', line 938 def self.get_ptr_name(ip,**kwargs) resolver(**kwargs).get_ptr_name(ip.to_s) end |
.get_ptr_names(ip, **kwargs) ⇒ Array<String>
Queries all PTR
names for the IP address.
984 985 986 |
# File 'lib/ronin/support/network/dns.rb', line 984 def self.get_ptr_names(ip,**kwargs) resolver(**kwargs).get_ptr_names(ip.to_s) end |
.get_ptr_record(ip, **kwargs) ⇒ Resolv::DNS::Resource::PTR?
Queries the first PTR
DNS record for the IP address.
916 917 918 |
# File 'lib/ronin/support/network/dns.rb', line 916 def self.get_ptr_record(ip,**kwargs) resolver(**kwargs).get_ptr_record(ip.to_s) end |
.get_ptr_records(ip, **kwargs) ⇒ Array<Resolv::DNS::Resource::PTR>
Queries all PTR
DNS records for the IP address.
962 963 964 |
# File 'lib/ronin/support/network/dns.rb', line 962 def self.get_ptr_records(ip,**kwargs) resolver(**kwargs).get_ptr_records(ip.to_s) end |
.get_record(name, record_type, **kwargs) ⇒ Resolv::DNS::Resource?
Queries a single matching DNS record for the host name.
255 256 257 |
# File 'lib/ronin/support/network/dns.rb', line 255 def self.get_record(name,record_type,**kwargs) resolver(**kwargs).get_record(name.to_s,record_type) end |
.get_records(name, record_type, **kwargs) ⇒ Array<Resolv::DNS::Resource>
Queries all matching DNS records for the host name.
282 283 284 |
# File 'lib/ronin/support/network/dns.rb', line 282 def self.get_records(name,record_type,**kwargs) resolver(**kwargs).get_records(name.to_s,record_type) end |
.get_soa_record(name, **kwargs) ⇒ Resolv::DNS::Resource::SOA?
Queries the first SOA
DNS record belonging to the host name.
1009 1010 1011 |
# File 'lib/ronin/support/network/dns.rb', line 1009 def self.get_soa_record(name,**kwargs) resolver(**kwargs).get_soa_record(name.to_s) end |
.get_srv_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::SRV>
Queries all SRV
DNS records belonging to the host name.
724 725 726 |
# File 'lib/ronin/support/network/dns.rb', line 724 def self.get_srv_records(name,**kwargs) resolver(**kwargs).get_srv_records(name.to_s) end |
.get_txt_record(name, **kwargs) ⇒ Resolv::DNS::Resource::TXT?
Queiries the first TXT
DNS record belonging to the host name.
1034 1035 1036 |
# File 'lib/ronin/support/network/dns.rb', line 1034 def self.get_txt_record(name,**kwargs) resolver(**kwargs).get_txt_record(name.to_s) end |
.get_txt_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::TXT>
Queries all TXT
DNS records belonging to the host name.
1081 1082 1083 |
# File 'lib/ronin/support/network/dns.rb', line 1081 def self.get_txt_records(name,**kwargs) resolver(**kwargs).get_txt_records(name.to_s) end |
.get_txt_string(name, **kwargs) ⇒ String?
Queries the first TXT
string belonging to the host name.
1057 1058 1059 |
# File 'lib/ronin/support/network/dns.rb', line 1057 def self.get_txt_string(name,**kwargs) resolver(**kwargs).get_txt_string(name.to_s) end |
.get_txt_strings(name, **kwargs) ⇒ Array<String>
Queries all of the TXT
string values of the host name.
1103 1104 1105 |
# File 'lib/ronin/support/network/dns.rb', line 1103 def self.get_txt_strings(name,**kwargs) resolver(**kwargs).get_txt_strings(name.to_s) end |
.get_wks_records(name, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::WKS>
Queries all WKS
(Well-Known-Service) DNS records belonging to the
host name.
749 750 751 |
# File 'lib/ronin/support/network/dns.rb', line 749 def self.get_wks_records(name,**kwargs) resolver(**kwargs).get_wks_records(name.to_s) end |
.lookup(host, **kwargs) ⇒ String?
Alias for get_address.
137 138 139 |
# File 'lib/ronin/support/network/dns.rb', line 137 def self.lookup(host,**kwargs) get_address(host,**kwargs) end |
.nameserver=(new_nameserver) ⇒ String
Sets the primary DNS nameserver to be queried.
68 69 70 71 |
# File 'lib/ronin/support/network/dns.rb', line 68 def self.nameserver=(new_nameserver) self.nameservers = [new_nameserver] return new_nameserver end |
.nameservers ⇒ Array<String>
The primary DNS nameserver(s) to query.
38 39 40 |
# File 'lib/ronin/support/network/dns.rb', line 38 def self.nameservers @nameservers ||= Resolver.default_nameservers end |
.nameservers=(new_nameservers) ⇒ Array<String>
Sets the DNS nameserver to be queried.
53 54 55 56 57 |
# File 'lib/ronin/support/network/dns.rb', line 53 def self.nameservers=(new_nameservers) @nameservers = new_nameservers.map(&:to_s) @resolver = Resolver.new(nameservers: @nameservers) return new_nameservers end |
.resolver(nameservers: nil, nameserver: nil) ⇒ Resolver
Creates a DNS Resolver for the given nameserver(s).
89 90 91 92 93 94 95 96 97 |
# File 'lib/ronin/support/network/dns.rb', line 89 def self.resolver(nameservers: nil, nameserver: nil) if nameserver Resolver.new(nameserver: nameserver.to_s) elsif nameservers Resolver.new(nameservers: nameservers.map(&:to_s)) else @resolver ||= Resolver.new(nameservers: self.nameservers) end end |