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_csscommand. -
#at_xpath(xpath) ⇒ Object
private
The
at_xpathcommand. -
#back ⇒ Object
private
The
backcommand. -
#basic_auth(user, password) ⇒ Object
private
The
basic_authcommand. -
#body ⇒ Object
private
The
bodycommand. -
#bypass_csp ⇒ Object
private
The
bypass_cspcommand. -
#clear_cache ⇒ Object
private
The
clear_cachecommand. -
#cookies ⇒ Object
private
The
cookiescommand. -
#css(css_path) ⇒ Object
private
The
csspath command. -
#eval_js(javascript) ⇒ Object
private
The
eval_jscommand. -
#foreward ⇒ Object
private
The
forewardcommand. -
#goto(url) ⇒ Object
private
The
gotocommand. -
#initialize(browser, **kwargs) ⇒ BrowserShell
constructor
private
Initializes the browser shell.
-
#inject_js(javascript) ⇒ Object
private
The
inject_jscommand. -
#js ⇒ Object
private
The
jscommand. -
#load_cookies(path) ⇒ Object
private
The
load_cookiescommand. -
#load_css(url_or_css) ⇒ Object
private
The
load_csscommand. -
#load_js(url_or_js) ⇒ Object
private
The
load_jscommand. -
#mhtml(path) ⇒ Object
private
The
mhtmlcommand. -
#pdf(path) ⇒ Object
private
The
pdfcommand. -
#pos(x, y) ⇒ Object
private
The
poscommand. -
#refresh ⇒ Object
private
The
refreshcommand. -
#requests ⇒ Object
private
The
requestscommand. -
#reset ⇒ Object
private
The
resetcommand. -
#save_cookies(path) ⇒ Object
private
The
save_cookiescommand. -
#screenshot(path) ⇒ Object
private
The
screenshotcommand. -
#session_cookies ⇒ Object
private
The
session_cookiescommand. -
#set_cookie(*args) ⇒ Object
private
The
set_cookiecommand. -
#url ⇒ Object
private
The
urlcommand. -
#wait ⇒ Object
private
The
waitcommand. -
#xpath(xpath) ⇒ Object
private
The
xpathcommand.
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.
51 52 53 54 55 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 51 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.
40 41 42 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 40 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.
161 162 163 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 161 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.
135 136 137 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 135 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.
75 76 77 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 75 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.
347 348 349 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 347 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.
259 260 261 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 259 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.
241 242 243 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 241 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.
331 332 333 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 331 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.
356 357 358 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 356 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.
148 149 150 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 148 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.
174 175 176 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 174 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.
84 85 86 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 84 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.
66 67 68 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 66 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.
187 188 189 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 187 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.
214 215 216 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 214 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.
397 398 399 400 401 402 403 404 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 397 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.
227 228 229 230 231 232 233 234 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 227 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.
200 201 202 203 204 205 206 207 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 200 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.
295 296 297 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 295 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.
285 286 287 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 285 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.
109 110 111 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 109 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.
93 94 95 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 93 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.
313 314 315 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 313 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.
304 305 306 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 304 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.
415 416 417 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 415 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.
272 273 274 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 272 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.
365 366 367 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 365 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.
377 378 379 380 381 382 383 384 385 386 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 377 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.
250 251 252 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 250 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.
322 323 324 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 322 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.
122 123 124 |
# File 'lib/ronin/web/cli/browser_shell.rb', line 122 def xpath(xpath) puts @browser.xpath(xpath) end |