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.

Since:

  • 0.4.0

Instance Method Summary collapse

Instance Method Details

#dns_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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

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



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.

Parameters:

  • new_nameserver (String)

    The address of the new primary DNS nameserver to query.

Returns:

  • (String)

    The address of the new primary DNS nameserver to query.

Since:

  • 0.4.0



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_nameserversArray<String>

The default DNS nameserver(s) to query.

Returns:

  • (Array<String>)

    The addresses of the DNS nameserver(s) to query.

Since:

  • 0.4.0



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.

Parameters:

  • new_nameservers (Array<String>)

    The new DNS nameserver addresses to query.

Returns:

  • (Array<String>)

    The new DNS nameserver addresses to query.

Since:

  • 0.4.0



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.

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:

  • (Resolv, Resolv::DNS)

    The DNS Resolver.

Since:

  • 0.4.0



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