Class: Ronin::CLI::Commands::Url Private

Inherits:
ValueProcessorCommand show all
Defined in:
lib/ronin/cli/commands/url.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.

Parses URL(s).

Usage

ronin url [options] [URL ...]

Options

-f, --file FILE                  Optional file to read values from
-u, --user                       Print the URL's user name
    --password                   Print the URL's password
    --user-password              Print the URL's user name and password
-H, --host                       Print the URL's host name
    --port                       Print the URL's port
    --host-port                  Print the URL's host:port
-P, --path                       Print the URL's path
    --path-query                 Print the URL's path and query string
-Q, --query                      Print the URL's query string
-q, --query-param NAME           Print the query param from the URL's query string
-F, --fragment                   Print the URL's fragment
-S, --status                     Print the HTTP status of each URL
-h, --help                       Print help information

Arguments

[URL ...]                        The URL(s) to parse

Examples

ronin url --host https://example.com/foo
ronin url --host-port https://example.com:8080/foo
ronin url --param id https://example.com/page?id=100

Since:

  • 2.0.0

Instance Attribute Summary

Attributes inherited from ValueProcessorCommand

#files

Instance Method Summary collapse

Methods inherited from ValueProcessorCommand

#initialize, #process_file, #run

Constructor Details

This class inherits a constructor from Ronin::CLI::ValueProcessorCommand

Instance Method Details

#process_value(url) ⇒ 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 an individual URL.

Parameters:

  • url (String)

Since:

  • 2.0.0



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/ronin/cli/commands/url.rb', line 120

def process_value(url)
  uri = URI(url)

  if options[:user]
    puts uri.user
  elsif options[:password]
    puts uri.password
  elsif options[:user_password]
    puts "#{uri.user}:#{uri.password}"
  elsif options[:host]
    puts uri.host
  elsif options[:host_port]
    puts "#{uri.host}:#{uri.port}"
  elsif options[:path]
    puts uri.path
  elsif options[:query]
    puts uri.query
  elsif options[:path_query]
    puts uri.request_uri
  elsif options[:param]
    puts uri.query_params[options[:param]]
  elsif options[:fragment]
    puts uri.fragment
  elsif options[:status]
    puts "#{uri.status} #{uri}"
  else
    puts uri
  end
end