Class: Ronin::Web::CLI::BrowserShell Private
- Inherits:
-
Core::CLI::CommandShell
- Object
- Core::CLI::CommandShell
- Ronin::Web::CLI::BrowserShell
- Defined in:
- lib/ronin/web/cli/browser_shell.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.
The interactive browser shell used by the ronin-web browser --shell
command.
Instance Attribute Summary collapse
-
#browser ⇒ Ronin::Web::Browser::Agent
readonly
private
The browser instance.
Instance Method Summary collapse
-
#at_css(css_path) ⇒ Object
private
The
at_css
command. -
#at_xpath(xpath) ⇒ Object
private
The
at_xpath
command. -
#back ⇒ Object
private
The
back
command. -
#basic_auth(user, password) ⇒ Object
private
The
basic_auth
command. -
#body ⇒ Object
private
The
body
command. -
#bypass_csp ⇒ Object
private
The
bypass_csp
command. -
#clear_cache ⇒ Object
private
The
clear_cache
command. -
#cookies ⇒ Object
private
The
cookies
command. -
#css(css_path) ⇒ Object
private
The
css
path command. -
#eval_js(javascript) ⇒ Object
private
The
eval_js
command. -
#foreward ⇒ Object
private
The
foreward
command. -
#goto(url) ⇒ Object
private
The
goto
command. -
#initialize(browser, **kwargs) ⇒ BrowserShell
constructor
private
Initializes the browser shell.
-
#inject_js(javascript) ⇒ Object
private
The
inject_js
command. -
#js ⇒ Object
private
The
js
command. -
#load_cookies(path) ⇒ Object
private
The
load_cookies
command. -
#load_css(url_or_css) ⇒ Object
private
The
load_css
command. -
#load_js(url_or_js) ⇒ Object
private
The
load_js
command. -
#mhtml(path) ⇒ Object
private
The
mhtml
command. -
#pdf(path) ⇒ Object
private
The
pdf
command. -
#pos(x, y) ⇒ Object
private
The
pos
command. -
#refresh ⇒ Object
private
The
refresh
command. -
#requests ⇒ Object
private
The
requests
command. -
#reset ⇒ Object
private
The
reset
command. -
#save_cookies(path) ⇒ Object
private
The
save_cookies
command. -
#screenshot(path) ⇒ Object
private
The
screenshot
command. -
#session_cookies ⇒ Object
private
The
session_cookies
command. -
#set_cookie(*args) ⇒ Object
private
The
set_cookie
command. -
#url ⇒ Object
private
The
url
command. -
#wait ⇒ Object
private
The
wait
command. -
#xpath(xpath) ⇒ Object
private
The
xpath
command.
Constructor Details
#initialize(browser, **kwargs) ⇒ BrowserShell
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.
Initializes the browser shell.
50 51 52 53 54 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 50 def initialize(browser,**kwargs) super(**kwargs) @browser = browser end |
Instance Attribute Details
#browser ⇒ Ronin::Web::Browser::Agent (readonly)
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.
The browser instance.
39 40 41 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 39 def browser @browser end |
Instance Method Details
#at_css(css_path) ⇒ 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.
The at_css
command.
160 161 162 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 160 def at_css(css_path) puts @browser.at_css(css_path) end |
#at_xpath(xpath) ⇒ 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.
The at_xpath
command.
134 135 136 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 134 def at_xpath(xpath) puts @browser.at_xpath(xpath) end |
#back ⇒ 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.
The back
command.
74 75 76 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 74 def back @browser.back end |
#basic_auth(user, password) ⇒ 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.
The basic_auth
command.
346 347 348 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 346 def basic_auth(user,password) @browser.network.(user: user, password: password, &:continue) end |
#body ⇒ 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.
The body
command.
258 259 260 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 258 def body puts @browser.body end |
#bypass_csp ⇒ 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.
The bypass_csp
command.
240 241 242 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 240 def bypass_csp @browser.bypass_csp = true end |
#clear_cache ⇒ 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.
The clear_cache
command.
330 331 332 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 330 def clear_cache @browser.clear(:cache) end |
#cookies ⇒ 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.
The cookies
command.
355 356 357 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 355 def (@browser.) end |
#css(css_path) ⇒ 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.
The css
path command.
147 148 149 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 147 def css(css_path) puts @browser.css(css_path) end |
#eval_js(javascript) ⇒ 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.
The eval_js
command.
173 174 175 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 173 def eval_js(javascript) p @browser.eval_js(javascript) end |
#foreward ⇒ 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.
The foreward
command.
83 84 85 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 83 def foreward @browser.foreward end |
#goto(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.
The goto
command.
65 66 67 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 65 def goto(url) @browser.goto(url) end |
#inject_js(javascript) ⇒ 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.
The inject_js
command.
186 187 188 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 186 def inject_js(javascript) @browser.evaluate_on_new_document(javascript) end |
#js ⇒ 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.
The js
command.
213 214 215 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 213 def js JSShell.start(@browser) end |
#load_cookies(path) ⇒ 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.
The load_cookies
command.
396 397 398 399 400 401 402 403 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 396 def (path) unless File.file?(path) print_error "no such file or directory: #{path}" return false end @browser.(path) end |
#load_css(url_or_css) ⇒ 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.
The load_css
command.
226 227 228 229 230 231 232 233 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 226 def load_css(url_or_css) if url_or_css.start_with('http://') || url_or_css.start_with('https://') @browser.load_css(url: url_or_css) else @browser.load_css(content: url_or_css) end end |
#load_js(url_or_js) ⇒ 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.
The load_js
command.
199 200 201 202 203 204 205 206 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 199 def load_js(url_or_js) if url_or_js.start_with('http://') || url_or_js.start_with('https://') @browser.load_js(url: url_or_js) else @browser.load_js(content: url_or_js) end end |
#mhtml(path) ⇒ 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.
The mhtml
command.
294 295 296 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 294 def mhtml(path) @browser.mhtml(path: path) end |
#pdf(path) ⇒ 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.
The pdf
command.
284 285 286 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 284 def pdf(path) @browser.pdf(path: path) end |
#pos(x, y) ⇒ 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.
The pos
command.
108 109 110 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 108 def pos(x,y) @browser.position = {left: x.to_i, top: y.to_i} end |
#refresh ⇒ 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.
The refresh
command.
92 93 94 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 92 def refresh @browser.refresh end |
#requests ⇒ 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.
The requests
command.
312 313 314 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 312 def requests puts @browser.network.traffic end |
#reset ⇒ 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.
The reset
command.
303 304 305 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 303 def reset @browser.reset end |
#save_cookies(path) ⇒ 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.
The save_cookies
command.
414 415 416 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 414 def (path) @browser.(path) end |
#screenshot(path) ⇒ 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.
The screenshot
command.
271 272 273 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 271 def screenshot(path) @browser.screenshot(path: path) end |
#session_cookies ⇒ 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.
The session_cookies
command.
364 365 366 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 364 def (@browser.) end |
#set_cookie(*args) ⇒ 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.
The set_cookie
command.
376 377 378 379 380 381 382 383 384 385 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 376 def (*args) if args.empty? print_error "must specify at least a NAME=VALUE" return false end = Web::Browser::Cookie.parse(args.join(' ')) @browser..set() end |
#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.
The url
command.
249 250 251 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 249 def url puts @browser.current_url end |
#wait ⇒ 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.
The wait
command.
321 322 323 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 321 def wait @browser.wait_for_idle end |
#xpath(xpath) ⇒ 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.
The xpath
command.
121 122 123 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 121 def xpath(xpath) puts @browser.xpath(xpath) end |