Module: Ronin::Recon::CLI::Printing Private

Includes:
Core::CLI::Logging
Included in:
Commands::Run, Commands::Test, Commands::Worker
Defined in:
lib/ronin/recon/cli/printing.rb

Overview

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

Helper methods for printing Value objects.

Constant Summary collapse

VALUE_CLASS_NAMES =

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

Mapping of Value classes to printable names.

{
  Values::Domain       => 'domain',
  Values::Mailserver   => 'mailserver',
  Values::Nameserver   => 'nameserver',
  Values::Wildcard     => 'wildcard host name',
  Values::Host         => 'host',
  Values::IP           => 'IP address',
  Values::IPRange      => 'IP range',
  Values::OpenPort     => 'open port',
  Values::Cert         => 'SSL/TLS certificate',
  Values::Website      => 'website',
  Values::URL          => 'URL',
  Values::EmailAddress => 'email addresse'
}

Instance Method Summary collapse

Instance Method Details

#format_value(value) ⇒ String

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.

Formats a value object into a human readable string.

Parameters:

  • value (Value)

    The value object to format.

Returns:

  • (String)

    The formatted value.

Raises:

  • (NotImplementedError)

    The given value object was not supported.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/ronin/recon/cli/printing.rb', line 78

def format_value(value)
  case value
  when Values::Domain       then "domain #{value}"
  when Values::Mailserver   then "mailserver #{value}"
  when Values::Nameserver   then "nameserver #{value}"
  when Values::Wildcard     then "wildcard host name #{value}"
  when Values::Host         then "host #{value}"
  when Values::IP           then "IP address #{value}"
  when Values::IPRange      then "IP range #{value}"
  when Values::OpenPort     then "open #{value.protocol.upcase} port #{value}"
  when Values::Cert         then "SSL/TLS certificate #{value.subject}"
  when Values::Website      then "website #{value}"
  when Values::URL          then "URL #{value}"
  when Values::EmailAddress then "email address #{value}"
  else
    raise(NotImplementedError,"value class #{value.class} not supported")
  end
end

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.

Prints a newly discovered value.

Parameters:

  • value (Value)

    The value to print.

  • parent (Value, nil) (defaults to: nil)

    The optional parent value.

Raises:

  • (NotImplementedError)

    The given value object was not supported.



109
110
111
112
113
114
115
116
117
118
119
# File 'lib/ronin/recon/cli/printing.rb', line 109

def print_value(value,parent=nil)
  if stdout.tty?
    if parent
      log_info "Found new #{format_value(value)} for #{format_value(parent)}"
    else
      log_info "Found new #{format_value(value)}"
    end
  else
    puts value
  end
end

#value_class_name(value_class) ⇒ String

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.

Converts the value class into a printable name.

Parameters:

  • value_class (Class<Value>)

    The value class.

Returns:

  • (String)

    The descriptive name for the value class.

Raises:

  • (NotImplementedError)


60
61
62
63
64
# File 'lib/ronin/recon/cli/printing.rb', line 60

def value_class_name(value_class)
  VALUE_CLASS_NAMES.fetch(value_class) do
    raise(NotImplementedError,"unknown value class: #{value_class.inspect}")
  end
end