Class: Ronin::Support::Network::Host
- Inherits:
-
Object
- Object
- Ronin::Support::Network::Host
- Defined in:
- lib/ronin/support/network/host.rb
Overview
Represents a host or host name.
Examples
host = Host.new('www.example.com')
Resolve parent domain:
host.domain
# => #<Ronin::Support::Network::Domain: example.co.uk>
Resolve IP addresses:
host.get_address
# => "172.67.128.149"
host.get_addresses
# => ["104.21.2.18", "172.67.128.149"]
host.get_ip
# => #<Ronin::Support::Network::IP: 172.67.128.149>
host.get_ips
# => [#<Ronin::Support::Network::IP: 104.21.2.18>, #<Ronin::Support::Network::IP: 172.67.128.149>]
host.ip
# => #<Ronin::Support::Network::IP: 172.67.128.149>
host.ips
# => [#<Ronin::Support::Network::IP: 104.21.2.18>, #<Ronin::Support::Network::IP: 172.67.128.149>]
Other DNS queries:
host = Host.new('www.github.com')
host.get_record(:txt)
# => #<Resolv::DNS::Resource::IN::TXT:0x00007f7e500777d8 @strings=["MS=ms58704441"], @ttl=3575>
host.get_records(:txt)
# => [#<Resolv::DNS::Resource::IN::TXT:0x00007f7e500777d8 @strings=["MS=ms58704441"], @ttl=3575>, ...]
host.get_cname_record
# => #<Resolv::DNS::Resource::IN::CNAME:0x00007f7e50063da0 @name=#<Resolv::DNS::Name: github.com.>, @ttl=3500>
host.get_cname
# => "github.com"
host.cname
# => "github.com"
host.get_mx_records
# => [#<Resolv::DNS::Resource::IN::MX:0x00007f7e50035658 @exchange=#<Resolv::DNS::Name: aspmx.l.google.com.>, @preference=1, @ttl=3600>, ...]
host.get_mailservers
# => ["alt1.aspmx.l.google.com",
# "alt4.aspmx.l.google.com",
# "alt3.aspmx.l.google.com",
# "alt2.aspmx.l.google.com",
# "aspmx.l.google.com"]
host.mailservers
# => ["alt1.aspmx.l.google.com",
# "alt4.aspmx.l.google.com",
# "alt3.aspmx.l.google.com",
# "alt2.aspmx.l.google.com",
# "aspmx.l.google.com"]
host.get_ns_records
# => [#<Resolv::DNS::Resource::IN::NS:0x00007f7e4f972258 @name=#<Resolv::DNS::Name: dns1.p08.nsone.net.>, @ttl=900>, ...]
host.get_nameservers
# => ["dns3.p08.nsone.net",
# "ns-1707.awsdns-21.co.uk",
# "dns2.p08.nsone.net",
# "ns-1283.awsdns-32.org",
# "dns4.p08.nsone.net",
# "ns-421.awsdns-52.com",
# "dns1.p08.nsone.net",
# "ns-520.awsdns-01.net"]
host.nameservers
# => ["dns3.p08.nsone.net",
# "ns-1707.awsdns-21.co.uk",
# "dns2.p08.nsone.net",
# "ns-1283.awsdns-32.org",
# "dns4.p08.nsone.net",
# "ns-421.awsdns-52.com",
# "dns1.p08.nsone.net",
# "ns-520.awsdns-01.net"]
host.get_soa_record
# => #<Resolv::DNS::Resource::IN::SOA:0x00007f7e4f63d0b0 @mname=#<Resolv::DNS::Name: ns-1707.awsdns-21.co.uk.>, @rname=#<Resolv::DNS::Name: awsdns-hostmaster.amazon.com.>, @serial=1, @refresh=7200, @retry=900, @expire=1209600, @minimum=86400, @ttl=880>
host.soa_record
# => #<Resolv::DNS::Resource::IN::SOA:0x00007f7e4f63d0b0 @mname=#<Resolv::DNS::Name: ns-1707.awsdns-21.co.uk.>, @rname=#<Resolv::DNS::Name: awsdns-hostmaster.amazon.com.>, @serial=1, @refresh=7200, @retry=900, @expire=1209600, @minimum=86400, @ttl=880>
host.get_txt_record
# => #<Resolv::DNS::Resource::IN::TXT:0x00007f7e4f8cbbb0 @strings=[\"adobe-idp-site-verification=b92c9e999aef825edc36e0a3d847d2dbad5b2fc0e05c79ddd7a16139b48ecf4b\"], @ttl=2887>
host.get_txt_string
# => "stripe-verification=f88ef17321660a01bab1660454192e014defa29ba7b8de9633c69d6b4912217f"
host.get_txt_records
# => [#<Resolv::DNS::Resource::IN::TXT:0x00007f7e4f67c648 @strings=[\"apple-domain-verification=RyQhdzTl6Z6x8ZP4\"], @ttl=2852>, ...]
host.get_txt_strings
# => ["apple-domain-verification=RyQhdzTl6Z6x8ZP4",
# "MS=ms58704441",
# "atlassian-domain-verification=jjgw98AKv2aeoYFxiL/VFaoyPkn3undEssTRuMg6C/3Fp/iqhkV4HVV7WjYlVeF8",
# "MS=6BF03E6AF5CB689E315FB6199603BABF2C88D805",
# "v=spf1 ip4:192.30.252.0/22 include:_netblocks.google.com include:_netblocks2.google.com include:_netblocks3.google.com include:spf.protection.outlook.com include:mail.zendesk.com include:_spf.salesforce.com include:servers.mcsv.net ip4:166.78.69.169 ip4:1",
# "66.78.69.170 ip4:166.78.71.131 ip4:167.89.101.2 ip4:167.89.101.192/28 ip4:192.254.112.60 ip4:192.254.112.98/31 ip4:192.254.113.10 ip4:192.254.113.101 ip4:192.254.114.176 ip4:62.253.227.114 ~all",
# "docusign=087098e3-3d46-47b7-9b4e-8a23028154cd",
# "google-site-verification=UTM-3akMgubp6tQtgEuAkYNYLyYAvpTnnSrDMWoDR3o",
# "stripe-verification=f88ef17321660a01bab1660454192e014defa29ba7b8de9633c69d6b4912217f",
# "adobe-idp-site-verification=b92c9e999aef825edc36e0a3d847d2dbad5b2fc0e05c79ddd7a16139b48ecf4b",
# "MS=ms44452932"]
host.txt_strings
# => ["apple-domain-verification=RyQhdzTl6Z6x8ZP4",
# "MS=ms58704441",
# "atlassian-domain-verification=jjgw98AKv2aeoYFxiL/VFaoyPkn3undEssTRuMg6C/3Fp/iqhkV4HVV7WjYlVeF8",
# "MS=6BF03E6AF5CB689E315FB6199603BABF2C88D805",
# "v=spf1 ip4:192.30.252.0/22 include:_netblocks.google.com include:_netblocks2.google.com include:_netblocks3.google.com include:spf.protection.outlook.com include:mail.zendesk.com include:_spf.salesforce.com include:servers.mcsv.net ip4:166.78.69.169 ip4:1",
# "66.78.69.170 ip4:166.78.71.131 ip4:167.89.101.2 ip4:167.89.101.192/28 ip4:192.254.112.60 ip4:192.254.112.98/31 ip4:192.254.113.10 ip4:192.254.113.101 ip4:192.254.114.176 ip4:62.253.227.114 ~all",
# "docusign=087098e3-3d46-47b7-9b4e-8a23028154cd",
# "google-site-verification=UTM-3akMgubp6tQtgEuAkYNYLyYAvpTnnSrDMWoDR3o",
# "stripe-verification=f88ef17321660a01bab1660454192e014defa29ba7b8de9633c69d6b4912217f",
# "adobe-idp-site-verification=b92c9e999aef825edc36e0a3d847d2dbad5b2fc0e05c79ddd7a16139b48ecf4b",
# "MS=ms44452932"]
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The host name.
Instance Method Summary collapse
-
#addresses ⇒ Array<String>
The addreses of the hostname.
-
#change_suffix(new_suffix) ⇒ Host
(also: #change_tld)
Changes the suffix of the hostname.
-
#cname ⇒ String?
The
CNAME
record for the host. -
#domain ⇒ Domain
Returns the associated domain for the hostname.
-
#each_suffix(type: nil) {|host| ... } ⇒ Enumerator
Enumerates over every hostname with a different public suffix.
-
#each_tld {|host| ... } ⇒ Enumerator
Enumerates over every hostname with a different TLD.
-
#get_a_address(name = nil, **kwargs) ⇒ String?
Queries the first IPv4 address belonging to the host name.
-
#get_a_addresses(name = nil, **kwargs) ⇒ Array<String>
Queries all IPv4 addresses belonging to the host name.
-
#get_a_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::IN::A?
Queries the first
A
record belonging to the host name. -
#get_a_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::A>
Queries all
A
records belonging to the host name. -
#get_aaaa_address(name = nil, **kwargs) ⇒ String?
Queries the first IPv6 address belonging to the host name.
-
#get_aaaa_addresses(name = nil, **kwargs) ⇒ Array<String>
Queries all IPv6 addresses belonging to the host name.
-
#get_aaaa_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::IN::AAAA?
Queries the first
AAAA
DNS records belonging to the host name. -
#get_aaaa_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::AAAA>
Queries all
AAAA
DNS records belonging to the host name. -
#get_address(**kwargs) ⇒ String?
(also: #lookup)
Looks up the address of a hostname.
-
#get_addresses(**kwargs) ⇒ Array<String>
Looks up all addresses of a hostname.
-
#get_any_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource>
Queries all records of the host name using the
ANY
DNS query. -
#get_cname(name = nil, **kwargs) ⇒ String?
Queries the canonical name for the host name.
-
#get_cname_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::IN::CNAME?
Queries the
CNAME
record for the host name. -
#get_hinfo_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::IN::HINFO?
Queries the
HINFO
record for the host name. -
#get_ip(**kwargs) ⇒ String?
Looks up the IPs of the host.
-
#get_ips(**kwargs) ⇒ Array<IP>
Looks up all IPs for the host.
-
#get_loc_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::LOC?
Queries the
LOC
(Location) DNS record of the host name. -
#get_mailservers(**kwargs) ⇒ Array<String>
Queries the mailservers for the host name.
-
#get_minfo_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::MINFO?
Queries the
MINFO
(Machine-Info) DNS record of the host name. -
#get_mx_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::MX>
Queries all
MX
DNS records belonging to the host name. -
#get_nameservers(**kwargs) ⇒ Array<String>
Queries the nameservers for the host name.
-
#get_ns_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::NS>
Queries all
NS
DNS records belonging to the host name. -
#get_record(name = nil, record_type, **kwargs) ⇒ Resolv::DNS::Resource?
Queries a single matching DNS record for the host name.
-
#get_records(name = nil, record_type, **kwargs) ⇒ Array<Resolv::DNS::Resource>
Queries all matching DNS records for the host name.
-
#get_soa_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::SOA?
Queries the first
SOA
DNS record belonging to the host name. -
#get_srv_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::SRV>
Queries all
SRV
DNS records belonging to the host name. -
#get_txt_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::TXT?
Queiries the first
TXT
DNS record belonging to the host name. -
#get_txt_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::TXT>
Queries all
TXT
DNS records belonging to the host name. -
#get_txt_string(name = nil, **kwargs) ⇒ String?
Queries the first
TXT
string belonging to the host name. -
#get_txt_strings(name = nil, **kwargs) ⇒ Array<String>
Queries all of the
TXT
string values of the host name. -
#get_wks_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::WKS>
Queries all
WKS
(Well-Known-Service) DNS records belonging to the host name. -
#has_addresses? ⇒ Boolean
Determines if the hostname has any addresses.
-
#has_mailservers? ⇒ Boolean
Determines if the hostname has any associated mailservers?.
-
#has_nameservers? ⇒ Boolean
Determines if the hostname has any associated nameservers?.
-
#hinfo_record ⇒ Resolv::DNS::Resource::IN::HINFO?
The
HINFO
record for the host. -
#idn? ⇒ Boolean
(also: #unicode?)
Determines if the hostname is an [IDN] hostname.
-
#initialize(name) ⇒ Host
constructor
Initializes the host.
-
#inspect ⇒ String
Inspects the host.
-
#ip ⇒ IP?
The IP for the host.
-
#ips ⇒ Array<IP>
The IPs for the host.
-
#mailservers ⇒ Array<String>
The mailservers for the host.
-
#nameservers ⇒ Array<String>
The nameservers for the host.
-
#punycode ⇒ Host
Converts the hostname to it's [punycode] version.
-
#punycode? ⇒ Boolean
Determines if the hostname is a [punycode] hostnmae.
-
#registered? ⇒ Boolean
Determines if the host name is registered.
-
#soa_record ⇒ Resolv::DNS::Resource::SOA?
The
SOA
record for the host. -
#subdomain(subname) ⇒ Host
Creates a sub-domain under the hostname.
-
#suffix ⇒ String
The public suffix of the hostname.
-
#tld ⇒ String
The Top-Level Domain of the hostnmae.
-
#to_s ⇒ String
Converts the host to a String.
-
#to_str ⇒ String
Converts the host to a String.
-
#txt_strings ⇒ Array<String>
The
TXT
strings for the host. -
#unregistered? ⇒ Boolean
Determines if the host name is not registered.
Constructor Details
#initialize(name) ⇒ Host
Initializes the host.
157 158 159 |
# File 'lib/ronin/support/network/host.rb', line 157 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ String (readonly)
The host name.
146 147 148 |
# File 'lib/ronin/support/network/host.rb', line 146 def name @name end |
Instance Method Details
#addresses ⇒ Array<String>
This method returns memoized data.
The addreses of the hostname.
440 441 442 |
# File 'lib/ronin/support/network/host.rb', line 440 def addresses @addresses ||= get_addresses end |
#change_suffix(new_suffix) ⇒ Host Also known as: change_tld
Changes the suffix of the hostname.
312 313 314 315 316 317 318 319 320 321 |
# File 'lib/ronin/support/network/host.rb', line 312 def change_suffix(new_suffix) name, _suffix = PublicSuffix.list.split(@name) new_suffix = new_suffix.to_s if new_suffix.start_with?('.') return self.class.new("#{name}#{new_suffix}") else return self.class.new("#{name}.#{new_suffix}") end end |
#cname ⇒ String?
This method returns memoized data.
The CNAME
record for the host.
710 711 712 |
# File 'lib/ronin/support/network/host.rb', line 710 def cname @cname ||= get_cname end |
#domain ⇒ Domain
This method returns memoized data.
Returns the associated domain for the hostname.
265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/ronin/support/network/host.rb', line 265 def domain @domain ||= begin domain, suffix = PublicSuffix.list.split(@name) if (last_dot = domain.rindex('.')) domain = domain[(last_dot + 1)..] end Domain.new("#{domain}.#{suffix}") end end |
#each_suffix(type: nil) {|host| ... } ⇒ Enumerator
Enumerates over every hostname with a different public suffix.
363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/ronin/support/network/host.rb', line 363 def each_suffix(type: nil) return enum_for(__method__, type: type) unless block_given? PublicSuffix.list.each do |suffix| unless suffix.wildcard? if type.nil? || (suffix.type == type) yield change_suffix(suffix) end end end return nil end |
#each_tld {|host| ... } ⇒ Enumerator
Enumerates over every hostname with a different TLD.
337 338 339 340 341 342 343 344 345 |
# File 'lib/ronin/support/network/host.rb', line 337 def each_tld return enum_for(__method__) unless block_given? TLD.list.each do |tld| yield change_suffix(tld) end return nil end |
#get_a_address(name = nil, **kwargs) ⇒ String?
Queries the first IPv4 address belonging to the host name.
810 811 812 813 814 815 816 |
# File 'lib/ronin/support/network/host.rb', line 810 def get_a_address(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_a_address(name) end |
#get_a_addresses(name = nil, **kwargs) ⇒ Array<String>
Queries all IPv4 addresses belonging to the host name.
867 868 869 870 871 872 873 |
# File 'lib/ronin/support/network/host.rb', line 867 def get_a_addresses(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_a_addresses(name) end |
#get_a_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::IN::A?
Queries the first A
record belonging to the host name.
782 783 784 785 786 787 788 |
# File 'lib/ronin/support/network/host.rb', line 782 def get_a_record(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_a_record(name) end |
#get_a_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::A>
Queries all A
records belonging to the host name.
839 840 841 842 843 844 845 |
# File 'lib/ronin/support/network/host.rb', line 839 def get_a_records(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_a_records(name) end |
#get_aaaa_address(name = nil, **kwargs) ⇒ String?
Queries the first IPv6 address belonging to the host name.
926 927 928 929 930 931 932 |
# File 'lib/ronin/support/network/host.rb', line 926 def get_aaaa_address(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_aaaa_address(name) end |
#get_aaaa_addresses(name = nil, **kwargs) ⇒ Array<String>
Queries all IPv6 addresses belonging to the host name.
983 984 985 986 987 988 989 |
# File 'lib/ronin/support/network/host.rb', line 983 def get_aaaa_addresses(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_aaaa_addresses(name) end |
#get_aaaa_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::IN::AAAA?
Queries the first AAAA
DNS records belonging to the host name.
897 898 899 900 901 902 903 |
# File 'lib/ronin/support/network/host.rb', line 897 def get_aaaa_record(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_aaaa_record(name) end |
#get_aaaa_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::AAAA>
Queries all AAAA
DNS records belonging to the host name.
955 956 957 958 959 960 961 |
# File 'lib/ronin/support/network/host.rb', line 955 def get_aaaa_records(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_aaaa_records(name) end |
#get_address(**kwargs) ⇒ String? Also known as: lookup
Looks up the address of a hostname.
397 398 399 |
# File 'lib/ronin/support/network/host.rb', line 397 def get_address(**kwargs) DNS.resolver(**kwargs).get_address(@name) end |
#get_addresses(**kwargs) ⇒ Array<String>
Looks up all addresses of a hostname.
423 424 425 |
# File 'lib/ronin/support/network/host.rb', line 423 def get_addresses(**kwargs) DNS.resolver(**kwargs).get_addresses(@name) end |
#get_any_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource>
Queries all records of the host name using the ANY
DNS query.
632 633 634 635 636 637 638 |
# File 'lib/ronin/support/network/host.rb', line 632 def get_any_records(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_any_records(name) end |
#get_cname(name = nil, **kwargs) ⇒ String?
Queries the canonical name for the host name.
692 693 694 695 696 697 698 |
# File 'lib/ronin/support/network/host.rb', line 692 def get_cname(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_cname(name) end |
#get_cname_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::IN::CNAME?
Queries the CNAME
record for the host name.
662 663 664 665 666 667 668 |
# File 'lib/ronin/support/network/host.rb', line 662 def get_cname_record(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_cname_record(name) end |
#get_hinfo_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::IN::HINFO?
Queries the HINFO
record for the host name.
736 737 738 739 740 741 742 |
# File 'lib/ronin/support/network/host.rb', line 736 def get_hinfo_record(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_hinfo_record(name) end |
#get_ip(**kwargs) ⇒ String?
Looks up the IPs of the host.
481 482 483 484 485 |
# File 'lib/ronin/support/network/host.rb', line 481 def get_ip(**kwargs) if (address = get_address(**kwargs)) IP.new(address) end end |
#get_ips(**kwargs) ⇒ Array<IP>
Looks up all IPs for the host.
507 508 509 |
# File 'lib/ronin/support/network/host.rb', line 507 def get_ips(**kwargs) get_addresses(**kwargs).map { |address| IP.new(address) } end |
#get_loc_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::LOC?
Queries the LOC
(Location) DNS record of the host name.
1072 1073 1074 1075 1076 1077 1078 |
# File 'lib/ronin/support/network/host.rb', line 1072 def get_loc_record(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_loc_record(name) end |
#get_mailservers(**kwargs) ⇒ Array<String>
Queries the mailservers for the host name.
1156 1157 1158 |
# File 'lib/ronin/support/network/host.rb', line 1156 def get_mailservers(**kwargs) DNS.resolver(**kwargs).get_mailservers(@name) end |
#get_minfo_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::MINFO?
Queries the MINFO
(Machine-Info) DNS record of the host name.
1102 1103 1104 1105 1106 1107 1108 |
# File 'lib/ronin/support/network/host.rb', line 1102 def get_minfo_record(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_minfo_record(name) end |
#get_mx_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::MX>
Queries all MX
DNS records belonging to the host name.
1131 1132 1133 1134 1135 1136 1137 |
# File 'lib/ronin/support/network/host.rb', line 1131 def get_mx_records(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_mx_records(name) end |
#get_nameservers(**kwargs) ⇒ Array<String>
Queries the nameservers for the host name.
1229 1230 1231 |
# File 'lib/ronin/support/network/host.rb', line 1229 def get_nameservers(**kwargs) DNS.resolver(**kwargs).get_nameservers(@name) end |
#get_ns_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::NS>
Queries all NS
DNS records belonging to the host name.
1204 1205 1206 1207 1208 1209 1210 |
# File 'lib/ronin/support/network/host.rb', line 1204 def get_ns_records(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_ns_records(name) end |
#get_record(name = nil, record_type, **kwargs) ⇒ Resolv::DNS::Resource?
Queries a single matching DNS record for the host name.
572 573 574 575 576 577 578 |
# File 'lib/ronin/support/network/host.rb', line 572 def get_record(name=nil,record_type,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_record(name,record_type) end |
#get_records(name = nil, record_type, **kwargs) ⇒ Array<Resolv::DNS::Resource>
Queries all matching DNS records for the host name.
604 605 606 607 608 609 610 |
# File 'lib/ronin/support/network/host.rb', line 604 def get_records(name=nil,record_type,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_records(name,record_type) end |
#get_soa_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::SOA?
Queries the first SOA
DNS record belonging to the host name.
1278 1279 1280 1281 1282 1283 1284 |
# File 'lib/ronin/support/network/host.rb', line 1278 def get_soa_record(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_soa_record(name) end |
#get_srv_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::SRV>
Queries all SRV
DNS records belonging to the host name.
1012 1013 1014 1015 1016 1017 1018 |
# File 'lib/ronin/support/network/host.rb', line 1012 def get_srv_records(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_srv_records(name) end |
#get_txt_record(name = nil, **kwargs) ⇒ Resolv::DNS::Resource::TXT?
Queiries the first TXT
DNS record belonging to the host name.
1324 1325 1326 1327 1328 1329 1330 |
# File 'lib/ronin/support/network/host.rb', line 1324 def get_txt_record(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_txt_record(name) end |
#get_txt_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::TXT>
Queries all TXT
DNS records belonging to the host name.
1382 1383 1384 1385 1386 1387 1388 |
# File 'lib/ronin/support/network/host.rb', line 1382 def get_txt_records(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_txt_records(name) end |
#get_txt_string(name = nil, **kwargs) ⇒ String?
Queries the first TXT
string belonging to the host name.
1353 1354 1355 1356 1357 1358 1359 |
# File 'lib/ronin/support/network/host.rb', line 1353 def get_txt_string(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_txt_string(name) end |
#get_txt_strings(name = nil, **kwargs) ⇒ Array<String>
Queries all of the TXT
string values of the host name.
1410 1411 1412 1413 1414 1415 1416 |
# File 'lib/ronin/support/network/host.rb', line 1410 def get_txt_strings(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_txt_strings(name) end |
#get_wks_records(name = nil, **kwargs) ⇒ Array<Resolv::DNS::Resource::IN::WKS>
Queries all WKS
(Well-Known-Service) DNS records belonging to the
host name.
1042 1043 1044 1045 1046 1047 1048 |
# File 'lib/ronin/support/network/host.rb', line 1042 def get_wks_records(name=nil,**kwargs) name = if name then "#{name}.#{@name}" else @name end DNS.resolver(**kwargs).get_wks_records(name) end |
#has_addresses? ⇒ Boolean
Determines if the hostname has any addresses.
457 458 459 |
# File 'lib/ronin/support/network/host.rb', line 457 def has_addresses? !addresses.empty? end |
#has_mailservers? ⇒ Boolean
Determines if the hostname has any associated mailservers?
1179 1180 1181 |
# File 'lib/ronin/support/network/host.rb', line 1179 def has_mailservers? !mailservers.empty? end |
#has_nameservers? ⇒ Boolean
Determines if the hostname has any associated nameservers?
1252 1253 1254 |
# File 'lib/ronin/support/network/host.rb', line 1252 def has_nameservers? !nameservers.empty? end |
#hinfo_record ⇒ Resolv::DNS::Resource::IN::HINFO?
This method returns memoized data.
The HINFO
record for the host.
756 757 758 |
# File 'lib/ronin/support/network/host.rb', line 756 def hinfo_record @hinfo_record ||= get_hinfo_record end |
#idn? ⇒ Boolean Also known as: unicode?
Determines if the hostname is an IDN hostname.
173 174 175 |
# File 'lib/ronin/support/network/host.rb', line 173 def idn? @name !~ /\A[A-Za-z0-9._-]+\z/ end |
#inspect ⇒ String
Inspects the host.
1492 1493 1494 |
# File 'lib/ronin/support/network/host.rb', line 1492 def inspect "#<#{self.class}: #{@name}>" end |
#ip ⇒ IP?
The IP for the host.
540 541 542 |
# File 'lib/ronin/support/network/host.rb', line 540 def ip ips.first end |
#ips ⇒ Array<IP>
This method returns memoized data.
The IPs for the host.
525 526 527 |
# File 'lib/ronin/support/network/host.rb', line 525 def ips @ips ||= get_ips end |
#mailservers ⇒ Array<String>
This method returns memoized data.
The mailservers for the host.
1170 1171 1172 |
# File 'lib/ronin/support/network/host.rb', line 1170 def mailservers @mailservers ||= get_mailservers end |
#nameservers ⇒ Array<String>
This method returns memoized data.
The nameservers for the host.
1243 1244 1245 |
# File 'lib/ronin/support/network/host.rb', line 1243 def nameservers @nameservers ||= get_nameservers end |
#punycode ⇒ Host
Converts the hostname to it's punycode version.
208 209 210 |
# File 'lib/ronin/support/network/host.rb', line 208 def punycode self.class.new(DNS::IDN.to_ascii(@name)) end |
#punycode? ⇒ Boolean
Determines if the hostname is a punycode hostnmae.
191 192 193 |
# File 'lib/ronin/support/network/host.rb', line 191 def punycode? @name.include?('xn--') end |
#registered? ⇒ Boolean
This method will query 8.8.8.8
which supports ANY
queries.
Determines if the host name is registered.
1447 1448 1449 |
# File 'lib/ronin/support/network/host.rb', line 1447 def registered? !get_any_records(nameserver: '8.8.8.8').empty? end |
#soa_record ⇒ Resolv::DNS::Resource::SOA?
This method returns memoized data.
The SOA
record for the host.
1298 1299 1300 |
# File 'lib/ronin/support/network/host.rb', line 1298 def soa_record @soa_record ||= get_soa_record end |
#subdomain(subname) ⇒ Host
Creates a sub-domain under the hostname.
291 292 293 |
# File 'lib/ronin/support/network/host.rb', line 291 def subdomain(subname) Host.new("#{subname}.#{@name}") end |
#suffix ⇒ String
The public suffix of the hostname.
244 245 246 |
# File 'lib/ronin/support/network/host.rb', line 244 def suffix @suffix ||= PublicSuffix.list.split(@name).last end |
#tld ⇒ String
The Top-Level Domain of the hostnmae.
226 227 228 |
# File 'lib/ronin/support/network/host.rb', line 226 def tld @tld ||= TLD.list.split(@name).last end |
#to_s ⇒ String
Converts the host to a String.
1473 1474 1475 |
# File 'lib/ronin/support/network/host.rb', line 1473 def to_s @name.to_s end |
#to_str ⇒ String
Converts the host to a String.
1482 1483 1484 |
# File 'lib/ronin/support/network/host.rb', line 1482 def to_str @name.to_str end |
#txt_strings ⇒ Array<String>
This method returns memoized data.
The TXT
strings for the host.
1428 1429 1430 |
# File 'lib/ronin/support/network/host.rb', line 1428 def txt_strings @txt_strings ||= get_txt_strings end |
#unregistered? ⇒ Boolean
Determines if the host name is not registered.
1458 1459 1460 |
# File 'lib/ronin/support/network/host.rb', line 1458 def unregistered? !registered? end |