Class: Ronin::Web::CLI::Commands::SessionCookie Private
- Inherits:
-
Ronin::Web::CLI::Command
- Object
- Core::CLI::Command
- Ronin::Web::CLI::Command
- Ronin::Web::CLI::Commands::SessionCookie
- Includes:
- CommandKit::Options::Verbose, CommandKit::Printing::Indent
- Defined in:
- lib/ronin/web/cli/commands/session_cookie.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 and deserializes various session cookie formats.
Usage
ronin-web session_cookie [options] {URL | COOKIE}
Options
-v, --verbose Enables verbose output
-F, --format ruby|json|yaml The format to print the session cookie params (Default: ruby)
-h, --help Print help information
Arguments
URL | COOKIE The URL or the session cookie to parse
Instance Method Summary collapse
-
#fetch_session_cookie(url) ⇒ Ronin::Web::SessionCookie::Django, ...
private
Fetches the session cookie from the URL.
-
#format_params(params) ⇒ Object
private
Formats the params based on the
--format
option. -
#parse_session_cookie(cookie) ⇒ Ronin::Web::SessionCookie::Django, ...
private
Parses a session cookie.
-
#print_django_session_cookie(session_cookie) ⇒ Object
private
Prints a Django session cookie.
-
#print_jwt_session_cookie(session_cookie) ⇒ Object
private
Prints a JWT session cookie.
-
#print_params(params) ⇒ Object
private
Prints the session cookie params as JSON.
-
#print_rack_session_cookie(session_cookie) ⇒ Object
private
Prints a Rack session cookie.
-
#print_session_cookie(session_cookie) ⇒ Object
private
Prints a session cookie.
-
#run(arg) ⇒ Object
private
Runs the
ronin-web session-cookie
command.
Instance Method Details
#fetch_session_cookie(url) ⇒ Ronin::Web::SessionCookie::Django, ...
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.
Fetches the session cookie from the URL.
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/ronin/web/cli/commands/session_cookie.rb', line 109 def (url) response = begin Support::Network::HTTP.get(url) rescue => error print_error "failed to request URL (#{url.inspect}): #{error.}" exit(-1) end Web::SessionCookie.extract(response) end |
#format_params(params) ⇒ 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.
Formats the params based on the --format
option.
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/ronin/web/cli/commands/session_cookie.rb', line 246 def format_params(params) case [:format] when :ruby require 'pp' params.pretty_print_inspect when :json require 'json' JSON.pretty_generate(params) when :yaml require 'yaml' YAML.dump(params) else raise(NotImplementedError,"unsupported format: #{[:format].inspect}") end end |
#parse_session_cookie(cookie) ⇒ Ronin::Web::SessionCookie::Django, ...
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.
Parses a session cookie.
129 130 131 |
# File 'lib/ronin/web/cli/commands/session_cookie.rb', line 129 def () Web::SessionCookie.parse() end |
#print_django_session_cookie(session_cookie) ⇒ 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.
Prints a Django session cookie.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/ronin/web/cli/commands/session_cookie.rb', line 161 def () if verbose? puts "Type: Django" puts "Params:" puts indent do print_params(.params) end puts puts "Salt: #{.salt}" puts "HMAC: #{Support::Encoding::Hex.quote(.hmac)}" else print_params(.params) end end |
#print_jwt_session_cookie(session_cookie) ⇒ 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.
Prints a JWT session cookie.
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/ronin/web/cli/commands/session_cookie.rb', line 184 def () if verbose? puts "Type: JWT" puts "Header:" puts indent do print_params(.header) end puts puts "Params:" puts indent do print_params(.params) end puts puts "HMAC: #{Support::Encoding::Hex.quote(.hmac)}" else print_params(.params) end end |
#print_params(params) ⇒ 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.
Prints the session cookie params as JSON.
237 238 239 240 241 |
# File 'lib/ronin/web/cli/commands/session_cookie.rb', line 237 def print_params(params) format_params(params).each_line do |line| puts line end end |
#print_rack_session_cookie(session_cookie) ⇒ 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.
Prints a Rack session cookie.
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/ronin/web/cli/commands/session_cookie.rb', line 214 def () if verbose? puts "Type: Rack" puts "Params:" puts indent do print_params(.params) end puts puts "HMAC: #{.hmac}" else print_params(.params) end end |
#print_session_cookie(session_cookie) ⇒ 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.
Prints a session cookie.
143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/ronin/web/cli/commands/session_cookie.rb', line 143 def () case when Web::SessionCookie::Django () when Web::SessionCookie::JWT () when Web::SessionCookie::Rack () else raise(NotImplementedError,"cannot print session cookie: #{.inspect}") end end |
#run(arg) ⇒ 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.
Runs the ronin-web session-cookie
command.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/ronin/web/cli/commands/session_cookie.rb', line 84 def run(arg) = if arg.start_with?('https://') || arg.start_with?('http://') (arg) else (arg) end if () else print_error "no session cookie found" exit(-1) end end |