class Ronin::CLI::HTTPShell
The interactive HTTP shell for the ‘ronin http –shell` command.
Attributes
The base URI.
@return [URI::HTTP]
The HTTP session.
@return [Ronin::Support::Network::HTTP]
Public Class Methods
Initializes the HTTP Shell.
@param [Addressable::URI] base_url
The base URL to connect to.
@param [Hash{Symbol => Object}] kwargs
Additional arguments for `Ronin::Support::Network::HTTP#connect_uri`.
# File lib/ronin/cli/http_shell.rb, line 52 def initialize(base_url, **kwargs) @base_url = base_url @http = Support::Network::HTTP.connect_uri(@base_url,**kwargs) super() end
Public Instance Methods
The ‘cd` shell command.
@param [String] path
# File lib/ronin/cli/http_shell.rb, line 76 def cd(path) @base_url.path = join(path) end
The ‘copy` shell command.
@param [String] path
@param [String] dest
# File lib/ronin/cli/http_shell.rb, line 158 def copy(path,dest) request(:copy,path, destination: dest) end
The ‘delete` shell command.
@param [String] path
# File lib/ronin/cli/http_shell.rb, line 170 def delete(path) request(:delete,path) end
The ‘get` shell command.
@param [String] path
@param [String, nil] body
# File lib/ronin/cli/http_shell.rb, line 90 def get(path,body=nil) request(:get,path, body: body) end
The ‘head` shell command.
@param [String] path
# File lib/ronin/cli/http_shell.rb, line 102 def head(path) request(:head,path) end
The ‘set_header` shell command.
@param [String, nil] subcommand
The optional sub-command (ex: `"set"` or `"unset"`).
@param [String, nil] name
The optional header name to set/unset.
@param [String, nil] value
The optional value of the header to set.
# File lib/ronin/cli/http_shell.rb, line 286 def headers(subcommand=nil,name=nil,value=nil) case subcommand when 'set' if (name && value) @http.headers[name] = value else puts "headers: must specify both NAME and VALUE arguments" end when 'unset' if name @http.headers.delete(name) else puts "headers: must specify NAME argument" end when nil unless @http.headers.empty? @http.headers.each do |name,value| puts "#{colors.bold(name)}: #{value}" end else puts "No request headers set" end else puts "headers: unknown sub-command: #{subcommand.inspect}" end end
Joins the given path with the {#base_url}.
@param [String] path
The path to join.
@return [String]
The resulting joined path.
# File lib/ronin/cli/http_shell.rb, line 347 def join(path) if path.start_with?('/') path else File.expand_path(File.join(@base_url.path,path)) end end
The ‘lock` shell command.
@param [String] path
# File lib/ronin/cli/http_shell.rb, line 182 def lock(path) request(:lock,path) end
The ‘mkcol` shell command.
@param [String] path
# File lib/ronin/cli/http_shell.rb, line 206 def mkcol(path) request(:mkcol,path) end
The ‘move` shell command.
@param [String] path
@param [String] dest
# File lib/ronin/cli/http_shell.rb, line 220 def move(path,dest) request(:move,path, destination: dest) end
The ‘options` shell command.
@param [String] path
# File lib/ronin/cli/http_shell.rb, line 194 def options(path) request(:options,path) end
The ‘patch` shell command.
@param [String] path
@param [String] body
# File lib/ronin/cli/http_shell.rb, line 116 def patch(path,body=nil) request(:patch,path, body: body) end
The ‘post` shell command.
@param [String] path
@param [String, nil] body
# File lib/ronin/cli/http_shell.rb, line 130 def post(path,body) request(:post,path, body: body) end
Prints an HTTP response.
@param [Net::HTTPResponse] response
The HTTP response object.
@see HTTPMethods#print_response
Ronin::CLI::Printing::HTTP#print_response
# File lib/ronin/cli/http_shell.rb, line 384 def print_response(response) super(response, show_headers: true) end
The ‘propfind` shell command.
@param [String] path
# File lib/ronin/cli/http_shell.rb, line 232 def propfind(path) request(:propfind,path) end
The ‘proppatch` shell command.
@param [String] path
# File lib/ronin/cli/http_shell.rb, line 243 def proppatch(path) request(:proppatch,path) end
The ‘patch` shell command.
@param [String] path
@param [String, nil] body
# File lib/ronin/cli/http_shell.rb, line 144 def put(path,body=nil) request(:put,path, body: body) end
Sends an HTTP request.
@param [Symbol] method
The HTTP request method name.
@param [String] path
The path for the request.
@param [Hash{Symbol => Object}] kwargs
Additional keyword arguments for `Ronin::Support::Network::HTTP#request`.
# File lib/ronin/cli/http_shell.rb, line 368 def request(method,path,**kwargs) path = join(path) @http.request(method,path,**kwargs) do |response| print_response(response) end end
The shell prompt name.
@return [String]
Returns the {#base_url} as a String.
# File lib/ronin/cli/http_shell.rb, line 64 def shell_name "#{@base_url}" end
The ‘trace` shell command.
@param [String] path
# File lib/ronin/cli/http_shell.rb, line 255 def trace(path) request(:trace,path) end
The ‘unlock` shell command.
@param [String] path
# File lib/ronin/cli/http_shell.rb, line 267 def unlock(path) request(:unlock,path) end