Class: Ronin::CLI::Commands::Host Private

Inherits:
ValueProcessorCommand show all
Includes:
DNS
Defined in:
lib/ronin/cli/commands/host.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Processes hostname(s) and performs DNS queries.

Usage

ronin host [options] {HOST ... | --file FILE}

Options

-f, --file FILE                  Optional file to read values from
    --subdomain SUBNAME          Converts the hostname to a sub-domain
-d, --domain                     Converts the hostname to a domain
-T, --tld                        Converts the hostname to it's TLD
-s, --suffix                     Converts the hostname to it's suffix
-S, --change-suffix SUFFIX       Changes the suffix of each hostname
    --enum-tlds                  Enumerates over every TLD
    --enum-suffixes[={icann|private}]
                                 Enumerates over every domain suffix
    --enum-subdomains FILE       Enumerates over every subdomain in the wordlist
-N, --nameserver HOST|IP         Send DNS queries to the nameserver
-I, --ips                        Converts the hostname to it's IP addresses
-r, --registered                 Filters hostnames that are registered
-u, --unregistered               Filters hostnames that are unregistered
-A, --has-addresses              Filters hostnames that have addresses
-H A|AAAA|ANY|CNAME|HINFO|LOC|MINFO|MX|NS|PTR|SOA|SRV|TXT|WKS,
    --has-records                Filters hostnames that have a certain DNS record type
-t A|AAAA|ANY|CNAME|HINFO|LOC|MINFO|MX|NS|PTR|SOA|SRV|TXT|WKS,
    --query                      Queries a specific type of DNS record
-h, --help                       Print help information

Arguments

[HOST ...]                       The host name(s) to query

Since:

  • 2.0.0

Constant Summary

Constants included from DNS

DNS::RECORD_TYPES

Instance Attribute Summary

Attributes included from DNS

#nameservers

Attributes inherited from ValueProcessorCommand

#files

Instance Method Summary collapse

Methods included from DNS

included, #initialize, #print_record, #print_records, #resolver

Methods inherited from ValueProcessorCommand

#initialize, #process_file, #run

Instance Method Details

#process_hostname(host) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Processes a single hostname.

Parameters:

  • host (Ronin::Support::Network::Host)

    The host object to process.

Since:

  • 2.0.0



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/ronin/cli/commands/host.rb', line 177

def process_hostname(host)
  if options[:subdomain]
    puts host.subdomain(options[:subdomain])
  elsif options[:domain]
    puts host.domain
  elsif options[:tld]
    puts host.tld
  elsif options[:suffix]
    puts host.suffix
  elsif options[:ips]
    puts host.get_addresses
  elsif options[:registered]
    puts host if host.registered?
  elsif options[:unregistered]
    puts host if host.unregistered?
  elsif options[:has_addresses]
    puts host if host.has_addresses?
  elsif options[:has_records]
    records = host.get_records(options[:has_records])

    puts host unless records.empty?
  elsif options[:query]
    print_records(host.get_records(options[:query]))
  else
    puts host.name
  end
end

#process_value(host) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Queries the given host.

Parameters:

  • host (String)

Since:

  • 2.0.0



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/ronin/cli/commands/host.rb', line 142

def process_value(host)
  host = Support::Network::Host.new(host)

  if options[:change_suffix]
    process_host(host.change_suffix(options[:change_suffix]))
  elsif options[:enum_tlds]
    host.each_tld(&method(:process_hostname))
  elsif options.has_key?(:enum_suffixes)
    host.each_suffix(
      type: options[:enum_suffixes], &method(:process_hostname)
    )
  elsif options[:enum_subdomains]
    path = options[:enum_subdomains]

    unless File.file?(path)
      print_error "wordlist file not found: #{path.inspect}"
      exit(-1)
    end

    Wordlist::File.open(path) do |wordlist|
      wordlist.each do |subname|
        process_hostname(host.subdomain(subname))
      end
    end
  else
    process_hostname(host)
  end
end