Module: Ronin::Payloads::Mixins::ResolveHost
- Included in:
- Shellcode::BindShellPayload, Shellcode::ReverseShellPayload
- Defined in:
- lib/ronin/payloads/mixins/resolve_host.rb
Overview
Adds methods for resolving the host
parameter and converting it to
IP address(es).
Instance Method Summary collapse
-
#host_address ⇒ String?
Resolves the
host
parameter and returns the first address. -
#host_addresses ⇒ Array<String>
Resolves the
host
and returns it's IP addresses. -
#host_ip_address ⇒ String?
Resolves the
host
parameter and returns the first IPv4 or IPv6 address. -
#host_ip_addresses ⇒ Array<String>
Resolves the
host
and returns it's IPv4 and IPv6 addresses. -
#host_ipv4_address ⇒ String?
Resolves the
host
parameter and returns the first IPv4 address. -
#host_ipv4_addresses ⇒ Array<String>
Resolves the
host
parameter and returns the IPv4 addresses. -
#host_ipv6_address ⇒ String?
Resolves the
host
parameter and returns the first IPv6 address. -
#host_ipv6_addresses ⇒ Array<String>
Resolves the
host
parameter and returns the IPv6 addresses.
Instance Method Details
#host_address ⇒ String?
Resolves the host
parameter and returns the first address.
61 62 63 |
# File 'lib/ronin/payloads/mixins/resolve_host.rb', line 61 def host_address host_addresses.first end |
#host_addresses ⇒ Array<String>
Resolves the host
and returns it's IP addresses.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ronin/payloads/mixins/resolve_host.rb', line 43 def host_addresses host = params[:host] # check if the `host` value is already an IP address if host =~ IPAddr::RE_IPV4ADDRLIKE || host =~ IPAddr::RE_IPV6ADDRLIKE_COMPRESSED || host =~ IPAddr::RE_IPV6ADDRLIKE_FULL [host] else Support::Network::DNS.get_addresses(host) end end |
#host_ip_address ⇒ String?
Resolves the host
parameter and returns the first IPv4 or IPv6
address.
89 90 91 |
# File 'lib/ronin/payloads/mixins/resolve_host.rb', line 89 def host_ip_address host_ip_addresses.first end |
#host_ip_addresses ⇒ Array<String>
Resolves the host
and returns it's IPv4 and IPv6 addresses.
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ronin/payloads/mixins/resolve_host.rb', line 70 def host_ip_addresses host = params[:host] # check if the `host` value is already an IP address if host =~ IPAddr::RE_IPV4ADDRLIKE || host =~ IPAddr::RE_IPV6ADDRLIKE_COMPRESSED || host =~ IPAddr::RE_IPV6ADDRLIKE_FULL [host] else Support::Network::DNS.get_ip_addresses(host) end end |
#host_ipv4_address ⇒ String?
Resolves the host
parameter and returns the first IPv4 address.
116 117 118 |
# File 'lib/ronin/payloads/mixins/resolve_host.rb', line 116 def host_ipv4_address host_ipv4_addresses.first end |
#host_ipv4_addresses ⇒ Array<String>
Resolves the host
parameter and returns the IPv4 addresses.
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/ronin/payloads/mixins/resolve_host.rb', line 98 def host_ipv4_addresses host = params[:host] if host =~ IPAddr::RE_IPV4ADDRLIKE [host] elsif host =~ IPAddr::RE_IPV6ADDRLIKE_COMPRESSED || host =~ IPAddr::RE_IPV6ADDRLIKE_FULL raise(ValidationError,"host must be a hostname or an IPv4 address, was an IPv6 address: #{host.inspect}") else Support::Network::DNS.get_ipv4_addresses(host) end end |
#host_ipv6_address ⇒ String?
Resolves the host
parameter and returns the first IPv6 address.
143 144 145 |
# File 'lib/ronin/payloads/mixins/resolve_host.rb', line 143 def host_ipv6_address host_ipv6_addresses.first end |
#host_ipv6_addresses ⇒ Array<String>
Resolves the host
parameter and returns the IPv6 addresses.
125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/ronin/payloads/mixins/resolve_host.rb', line 125 def host_ipv6_addresses host = params[:host] if host =~ IPAddr::RE_IPV4ADDRLIKE ["::ffff:#{host}"] elsif host =~ IPAddr::RE_IPV6ADDRLIKE_COMPRESSED || host =~ IPAddr::RE_IPV6ADDRLIKE_FULL [host] else Support::Network::DNS.get_ipv6_addresses(host) end end |