Class: Ronin::UI::CLI::Commands::IPs

Inherits:
ResourcesCommand show all
Defined in:
lib/ronin/ui/cli/commands/ips.rb

Overview

The ronin-ips command.

Instance Method Summary collapse

Methods inherited from ResourcesCommand

model, #print_resources

Methods inherited from ModelCommand

each_query_option, model, #query, query_option, query_options, #setup

Methods inherited from Ronin::UI::CLI::Command

banner, command_name, #indent, inherited, #initialize, #print_array, #print_exception, #print_hash, #print_section, #print_title, #puts, run, #setup

Constructor Details

This class inherits a constructor from Ronin::UI::CLI::Command

Instance Method Details

#executeObject

Queries the IPAddress model.

Since:

  • 1.0.0



67
68
69
70
71
72
73
# File 'lib/ronin/ui/cli/commands/ips.rb', line 67

def execute
  if options[:lookup]
    lookup options[:lookup]
  else
    super
  end
end

#lookup(host) ⇒ Object (protected)

Looks up a host name.

Parameters:

  • host (String)

    The host name to lookup.

Since:

  • 1.0.0



85
86
87
88
89
90
91
92
93
# File 'lib/ronin/ui/cli/commands/ips.rb', line 85

def lookup(host)
  print_info "Looking up #{host} ..."

  IPAddress.lookup(host).each do |ip|
    print_info "  #{ip}"
  end

  print_info "Looked up #{host}"
end

Prints an IP Address.

Parameters:

  • ip (IPAddress)

    The IP Address to print.

Since:

  • 1.0.0



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/ronin/ui/cli/commands/ips.rb', line 103

def print_resource(ip)
  return super(ip) unless options.verbose?

  print_title ip.address

  indent do
    if (org = ip.organization)
      print_hash 'Organization' => org
    end

    if (last_scanned_at = ip.last_scanned_at)
      print_hash 'Last Scanned' => last_scanned_at
    end

    unless ip.mac_addresses.empty?
      print_array ip.mac_addresses, :title => 'MAC Addresses'
    end

    unless ip.host_names.empty?
      print_array ip.host_names, :title => 'Hostnames'
    end

    unless ip.open_ports.empty?
      print_section 'Open Ports' do
        ip.open_ports.each do |port|
          if port.service
            puts "#{port}\t#{port.service}"
          else
            puts port
          end
        end
      end
    end
  end
end