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

Since:

  • 0.4.0

Defined Under Namespace

Modules: Mixin Classes: Resolver

Constant Summary collapse

IDN =

Since:

  • 1.0.0

Addressable::IDNA

Class Method Summary collapse

Class Method Details

.get_a_address(name, **kwargs) ⇒ String?

Queries the first IPv4 address belonging to the host name.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (String, nil)

    The first IPv4 address belonging to the host name.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<String>)

    All of the IPv4 addresses belonging to the host name.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Resolv::DNS::Resource::IN::A, nil)

    The first A DNS record or nil if the host name has no A records.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<Resolv::DNS::Resource::IN::A>)

    All of the A DNS records belonging to the host name.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (String, nil)

    The first IPv6 address or nil if the host name has no IPv6 addresses.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<String>)

    All IPv6 addresses belonging to the host name.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Resolv::DNS::Resource::IN::AAAA, nil)

    The first AAAA DNS record or nil if the host name has no AAAA records.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<Resolv::DNS::Resource::IN::AAAA>)

    All of the AAAA DNS records belonging to the host name.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • host (String)

    The hostname to lookup.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (String, nil)

    The address of the hostname.

Since:

  • 0.4.0



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.

Parameters:

  • host (String)

    The hostname to lookup.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<Resolv::DNS::Resource>)

    All of the DNS records belonging to the host name.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (String, nil)

    The canonical name for the host or nil if the host has no CNAME record.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Resolv::DNS::Resource::IN::CNAME, nil)

    The CNAME record or nil if the host name has no CNAME record.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Resolv::DNS::Resource::IN::HINFO, nil)

    The HINFO DNS record or nil if the host name has no HINFO record.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (String, nil)

    The first IPv4 or IPv6 address or nil if the host name has no IPv4 or IPv6 addresses.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<String>)

    All IPv4 or IPv6 addresses belonging to the host name.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (String, nil)

    The first IPv4 address belonging to the host name.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<String>)

    All of the IPv4 addresses belonging to the host name.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (String, nil)

    The first IPv6 address or nil if the host name has no IPv6 addresses.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<String>)

    All IPv6 addresses belonging to the host name.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Resolv::DNS::Resource::LOC, nil)

    The LOC DNS record of the host name or nil if the host name has no LOC record.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<String>)

    The host names of the mailservers serving the given host name.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Resolv::DNS::Resource::MINFO, nil)

    The MINFO DNS record of the host name or nil if the host name has no MINFO record.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<Resolv::DNS::Resource::MX>)

    All MX DNS records belonging to the host name.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • ip (String)

    The IP address to lookup.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (String, nil)

    The hostname of the address.

Since:

  • 0.4.0



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.

Parameters:

  • ip (String)

    The IP address to lookup.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<String>)

    The host names of the nameservers serving the given host name.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<Resolv::DNS::Resource::NS>)

    All NS DNS records belonging to the host name.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • ip (String)

    The IP address to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (String, nil)

    The host name that points to the given IP.

Since:

  • 0.4.0



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.

Parameters:

  • ip (String)

    The IP address to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

Since:

  • 0.4.0



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.

Parameters:

  • ip (String)

    The IP address to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Resolv::DNS::Resource::PTR, nil)

    The first PTR DNS record of the host name or nil if the host name has no PTR records.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • ip (String)

    The IP address to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<Resolv::DNS::Resource::PTR>)

    All PTR DNS records for the given IP.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • record_type (:a, :aaaa, :any, :cname, :hinfo, :loc, :minfo, :mx, :ns, :ptr, :soa, :srv, :txt, :wks)

    The record type.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Resolv::DNS::Resource, nil)

    The matching DNS records or nil if no matching DNS records could be found.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • record_type (:a, :aaaa, :any, :cname, :hinfo, :loc, :minfo, :mx, :ns, :ptr, :soa, :srv, :txt, :wks)

    The record type.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<Resolv::DNS::Resource>)

    All matching DNS records.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Resolv::DNS::Resource::SOA, nil)

    The first SOA DNS record for the host name or nil if the host name has no SOA records.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<Resolv::DNS::Resource::IN::SRV>)

    All SRV DNS records belonging to the host name.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Resolv::DNS::Resource::TXT, nil)

    The first TXT DNS record for the host name or nil if the host name has no TXT records.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<Resolv::DNS::Resource::TXT>)

    All of the TXT DNS records belonging to the host name.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (String, nil)

    The first TXT string belonging to the host name or nil if the host name has no TXT records.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<String>)

    All TXT string values belonging of the host name.

Since:

  • 0.4.0



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.

Parameters:

  • name (String)

    The host name to query.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

  • [Array<String>, (Hash)

    a customizable set of options

  • [String, (Hash)

    a customizable set of options

Returns:

  • (Array<Resolv::DNS::Resource::IN::WKS>)

    All WKS DNS records belonging to the host name.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • host (String)

    The hostname to lookup.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for get_address.

Returns:

  • (String, nil)

    The address of the hostname.

See Also:

Since:

  • 0.4.0



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.

Parameters:

  • new_nameserver (String)

    The new primary nameserver address.

Returns:

  • (String)

    The address of the primary nameserver.

Since:

  • 0.4.0



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

.nameserversArray<String>

The primary DNS nameserver(s) to query.

Returns:

  • (Array<String>)

    The addresses of the nameservers.

Since:

  • 0.4.0



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.

Parameters:

  • new_nameservers (Array<String>)

    The addresses of the new nameservers.

Returns:

  • (Array<String>)

    The addresses of the new nameservers.

Since:

  • 0.4.0



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).

Parameters:

  • nameservers (Array<String>, String, nil) (defaults to: nil)

    Optional DNS nameserver(s) to query.

  • nameserver (String, nil) (defaults to: nil)

    Optional DNS nameserver to query.

Returns:

Since:

  • 0.6.0



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

.reverse_lookup(ip, **kwargs) ⇒ String?

Alias for get_name.

Parameters:

  • ip (String)

    The IP address to lookup.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for get_name.

Returns:

  • (String, nil)

    The hostname of the address.

See Also:

Since:

  • 0.4.0



203
204
205
# File 'lib/ronin/support/network/dns.rb', line 203

def self.reverse_lookup(ip,**kwargs)
  get_name(ip,**kwargs)
end