Module: PWN::Plugins::TransparentBrowser
- Defined in:
- lib/pwn/plugins/transparent_browser.rb
Overview
This plugin rocks. Chrome, Firefox, PhantomJS, IE, REST Client, all from the comfort of one plugin. Proxy support (e.g. Burp Suite Professional) is completely available for all browsers except for limited functionality within IE (IE has interesting protections in place to prevent this). This plugin also supports taking screenshots :)
Constant Summary collapse
Class Method Summary collapse
-
.authors ⇒ Object
- Author(s)
-
0day Inc.
-
.close(opts = {}) ⇒ Object
- Supported Method Parameters
-
browser_obj1 = PWN::Plugins::TransparentBrowser.close( browser_obj: ‘required - browser_obj returned from #open method)’ ).
-
.help ⇒ Object
Display Usage for this Module.
-
.linkout(opts = {}) ⇒ Object
- Supported Method Parameters
-
browser_obj = PWN::Plugins::TransparentBrowser.linkout( browser_obj: browser_obj1 ).
-
.open(opts = {}) ⇒ Object
- Supported Method Parameters
-
browser_obj1 = PWN::Plugins::TransparentBrowser.open( browser_type: :firefox|:chrome|:headless|:rest|:websocket, proxy: ‘optional - scheme://proxy_host:port’, with_tor: ‘optional - boolean (defaults to false)’ with_devtools: ‘optional - boolean (defaults to false)’ ).
-
.type_as_human(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::TransparentBrowser.type_as_human( string: ‘required - string to type as human’, rand_sleep_float: ‘optional - float timing in between keypress (defaults to 0.09)’ ).
Class Method Details
.authors ⇒ Object
- Author(s)
-
0day Inc. <[email protected]>
310 311 312 313 314 |
# File 'lib/pwn/plugins/transparent_browser.rb', line 310 public_class_method def self. "AUTHOR(S): 0day Inc. <[email protected]> " end |
.close(opts = {}) ⇒ Object
- Supported Method Parameters
-
browser_obj1 = PWN::Plugins::TransparentBrowser.close(
browser_obj: 'required - browser_obj returned from #open method)')
296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/pwn/plugins/transparent_browser.rb', line 296 public_class_method def self.close(opts = {}) this_browser_obj = opts[:browser_obj] unless this_browser_obj.to_s.include?('RestClient') # Close the browser unless this_browser_obj.nil? (thus the &) this_browser_obj&.close end nil rescue StandardError => e raise e end |
.help ⇒ Object
Display Usage for this Module
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
# File 'lib/pwn/plugins/transparent_browser.rb', line 318 public_class_method def self.help puts "USAGE: browser_obj1 = #{self}.open( browser_type: :firefox|:chrome|:headless_chrome|:headless_firefox|:rest|:websocket, proxy: 'optional scheme://proxy_host:port', with_tor: 'optional boolean (defaults to false)', with_devtools: 'optional - boolean (defaults to false)' ) puts browser_obj1.public_methods ******************************************************** * DevTools Interaction Only works w/ Chrome * All DevTools Commands can be found here: * https://chromedevtools.github.io/devtools-protocol/ * Examples devtools = browser_obj1.driver.devtools puts devtools.public_methods puts devtools.instance_variables puts devtools.instance_variable_get('@messages') * Tracing devtools.send_cmd('Tracing.start') devtools.send_cmd('Tracing.requestMemoryDump') devtools.send_cmd('Tracing.end') puts devtools.instance_variable_get('@messages') * Network devtools.send_cmd('Network.enable') last_ws_resp = devtools.instance_variable_get('@messages').last if devtools.instance_variable_get('@messages').last['method'] == 'Network.webSocketFrameReceived' puts last_ws_resp devtools.send_cmd('Network.disable') * Debugging DOM and Sending JavaScript to Console devtools.send_cmd('Runtime.enable') devtools.send_cmd('Console.enable') devtools.send_cmd('DOM.enable') devtools.send_cmd('Page.enable') devtools.send_cmd('Log.enable') devtools.send_cmd('Debugger.enable') devtools.send_cmd('Debugger.pause') step = 1 next_step = 60 loop do devtools.send_cmd('Console.clearMessages') devtools.send_cmd('Log.clear') console_events = [] b.driver.on_log_event(:console) { |event| console_events.push(event) } devtools.send_cmd('Debugger.stepInto') puts \"Step: \#{step}\" this_document = devtools.send_cmd('DOM.getDocument') puts \"This #document:\\n\#{this_document}\\n\\n\\n\" console_cmd = { expression: 'for(var pop_var in window) { if (window.hasOwnProperty(pop_var) && window[pop_var] != null) console.log(pop_var + \" = \" + window[pop_var]); }' } puts devtools.send_cmd('Runtime.evaluate', **console_cmd) print '-' * 180 print \"\\n\" console_events.each do |event| puts event.args end puts \"Console Response Length: \#{console_events.length}\" console_events_digest = OpenSSL::Digest::SHA256.hexdigest( console_events.inspect ) puts \"Console Events Array SHA256 Digest: \#{console_events_digest}\" print '-' * 180 puts \"\\n\\n\\n\" print \"Next Step in \" next_step.downto(1) {|n| print \"\#{n} \"; sleep 1 } puts 'READY!' step += 1 end devtools.send_cmd('Debugger.disable') devtools.send_cmd('Log.disable') devtools.send_cmd('Page.disable') devtools.send_cmd('DOM.disable') devtools.send_cmd('Console.disable') devtools.send_cmd('Runtime.disable') * End of DevTools Examples ******************************************************** browser_obj1 = #{self}.linkout( browser_obj: 'required - browser_obj returned from #open method)' ) #{self}.type_as_human( string: 'required - string to type as human', rand_sleep_float: 'optional - float timing in between keypress (defaults to 0.09)' ) {|char| browser_obj1.text_field(name: \"search\").send_keys(char) } browser_obj1 = #{self}.close( browser_obj: 'required - browser_obj returned from #open method)' ) #{self}.authors " end |
.linkout(opts = {}) ⇒ Object
- Supported Method Parameters
-
browser_obj = PWN::Plugins::TransparentBrowser.linkout(
browser_obj: browser_obj1)
256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/pwn/plugins/transparent_browser.rb', line 256 public_class_method def self.linkout(opts = {}) this_browser_obj = opts[:browser_obj] this_browser_obj.links.each do |link| @@logger.info("#{link.text} => #{link.href}\n\n\n") unless link.text == '' end this_browser_obj rescue StandardError => e raise e end |
.open(opts = {}) ⇒ Object
- Supported Method Parameters
-
browser_obj1 = PWN::Plugins::TransparentBrowser.open(
browser_type: :firefox|:chrome|:headless|:rest|:websocket, proxy: 'optional - scheme://proxy_host:port', with_tor: 'optional - boolean (defaults to false)' with_devtools: 'optional - boolean (defaults to false)')
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/pwn/plugins/transparent_browser.rb', line 31 public_class_method def self.open(opts = {}) this_browser = nil browser_type = opts[:browser_type] proxy = opts[:proxy].to_s unless opts[:proxy].nil? opts[:with_tor] ? (with_tor = true) : (with_tor = false) opts[:with_devtools] ? (with_devtools = true) : (with_devtools = false) # Let's crank up the default timeout from 30 seconds to 15 min for slow sites Watir.default_timeout = 900 case browser_type when :firefox this_profile = Selenium::WebDriver::Firefox::Profile.new # Increase Web Assembly Verbosity this_profile['javascript.options.wasm_verbose'] = true # Downloads reside in ~/Downloads this_profile['browser.download.folderList'] = 1 this_profile['browser.helperApps.neverAsk.saveToDisk'] = 'application/pdf' # disable Firefox's built-in PDF viewer this_profile['pdfjs.disabled'] = true # disable Adobe Acrobat PDF preview plugin this_profile['plugin.scan.plid.all'] = false this_profile['plugin.scan.Acrobat'] = '99.0' # ensure localhost proxy capabilities are enabled this_profile['network.proxy.no_proxies_on'] = '' # allow scripts to run a bit longer # this_profile['dom.max_chrome_script_run_time'] = 180 # this_profile['dom.max_script_run_time'] = 180 # disable browser cache this_profile['browser.cache.disk.enable'] = false this_profile['browser.cache.disk_cache_ssl.enable'] = false this_profile['browser.cache.memory.enable'] = false this_profile['browser.cache.offline.enable'] = false this_profile['devtools.cache.disabled'] = true this_profile['dom.caches.enabled'] = false # caps = Selenium::WebDriver::Remote::Capabilities.firefox # caps[:acceptInsecureCerts] = true if proxy this_profile['network.proxy.type'] = 1 this_profile['network.proxy.allow_hijacking_localhost'] = true if with_tor this_profile['network.proxy.socks_version'] = 5 this_profile['network.proxy.socks'] = URI(proxy).host this_profile['network.proxy.socks_port'] = URI(proxy).port else this_profile['network.proxy.ftp'] = URI(proxy).host this_profile['network.proxy.ftp_port'] = URI(proxy).port this_profile['network.proxy.http'] = URI(proxy).host this_profile['network.proxy.http_port'] = URI(proxy).port this_profile['network.proxy.ssl'] = URI(proxy).host this_profile['network.proxy.ssl_port'] = URI(proxy).port end end args = [] args.push('--devtools') if with_devtools = Selenium::WebDriver::Firefox::Options.new(args: args, accept_insecure_certs: true) .profile = this_profile driver = Selenium::WebDriver.for(:firefox, capabilities: ) this_browser = Watir::Browser.new(driver) when :chrome this_profile = Selenium::WebDriver::Chrome::Profile.new this_profile['download.prompt_for_download'] = false this_profile['download.default_directory'] = '~/Downloads' switches = [] switches.push('--start-maximized') switches.push('--disable-notifications') if proxy switches.push("--host-resolver-rules='MAP * 0.0.0.0 , EXCLUDE #{URI(proxy).host}'") if with_tor switches.push("--proxy-server=#{proxy}") end if with_devtools switches.push('--auto-open-devtools-for-tabs') switches.push('--disable-hang-monitor') end = Selenium::WebDriver::Chrome::Options.new( args: switches, accept_insecure_certs: true ) .profile = this_profile driver = Selenium::WebDriver.for(:chrome, capabilities: ) this_browser = Watir::Browser.new(driver) when :headless, :headless_firefox this_profile = Selenium::WebDriver::Firefox::Profile.new # Increase Web Assembly Verbosity this_profile['javascript.options.wasm_verbose'] = true # Downloads reside in ~/Downloads this_profile['browser.download.folderList'] = 1 this_profile['browser.helperApps.neverAsk.saveToDisk'] = 'application/pdf' # disable Firefox's built-in PDF viewer this_profile['pdfjs.disabled'] = true # disable Adobe Acrobat PDF preview plugin this_profile['plugin.scan.plid.all'] = false this_profile['plugin.scan.Acrobat'] = '99.0' # ensure localhost proxy capabilities are enabled this_profile['network.proxy.no_proxies_on'] = '' # allow scripts to run a bit longer # this_profile['dom.max_chrome_script_run_time'] = 180 # this_profile['dom.max_script_run_time'] = 180 # disable browser cache this_profile['browser.cache.disk.enable'] = false this_profile['browser.cache.disk_cache_ssl.enable'] = false this_profile['browser.cache.memory.enable'] = false this_profile['browser.cache.offline.enable'] = false this_profile['devtools.cache.disabled'] = true this_profile['dom.caches.enabled'] = false # caps = Selenium::WebDriver::Remote::Capabilities.firefox # caps[:acceptInsecureCerts] = true if proxy this_profile['network.proxy.type'] = 1 this_profile['network.proxy.allow_hijacking_localhost'] = true if with_tor this_profile['network.proxy.socks_version'] = 5 this_profile['network.proxy.socks'] = URI(proxy).host this_profile['network.proxy.socks_port'] = URI(proxy).port else this_profile['network.proxy.ftp'] = URI(proxy).host this_profile['network.proxy.ftp_port'] = URI(proxy).port this_profile['network.proxy.http'] = URI(proxy).host this_profile['network.proxy.http_port'] = URI(proxy).port this_profile['network.proxy.ssl'] = URI(proxy).host this_profile['network.proxy.ssl_port'] = URI(proxy).port end end = Selenium::WebDriver::Firefox::Options.new(args: ['-headless'], accept_insecure_certs: true) .profile = this_profile driver = Selenium::WebDriver.for(:firefox, capabilities: ) this_browser = Watir::Browser.new(driver) when :headless_chrome this_profile = Selenium::WebDriver::Chrome::Profile.new this_profile['download.prompt_for_download'] = false this_profile['download.default_directory'] = '~/Downloads' switches = [] switches.push('--headless') switches.push('--start-maximized') switches.push('--disable-notifications') if proxy switches.push("--host-resolver-rules='MAP * 0.0.0.0 , EXCLUDE #{URI(proxy).host}'") if with_tor switches.push("--proxy-server=#{proxy}") end = Selenium::WebDriver::Chrome::Options.new( args: switches, accept_insecure_certs: true ) .profile = this_profile driver = Selenium::WebDriver.for(:chrome, capabilities: ) this_browser = Watir::Browser.new(driver) when :rest this_browser = RestClient if proxy if with_tor TCPSocket.socks_server = URI(proxy).host TCPSocket.socks_port = URI(proxy).port else this_browser.proxy = proxy end end when :websocket if proxy if with_tor TCPSocket.socks_server = URI(proxy).host TCPSocket.socks_port = URI(proxy).port end proxy_opts = { origin: proxy } tls_opts = { verify_peer: false } this_browser = Faye::WebSocket::Client.new( '', [], { tls: tls_opts, proxy: proxy_opts } ) else this_browser = Faye::WebSocket::Client.new('') end else puts 'Error: browser_type only supports :firefox, :chrome, :headless, :rest, or :websocket' return nil end this_browser rescue StandardError => e raise e end |
.type_as_human(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::TransparentBrowser.type_as_human(
string: 'required - string to type as human', rand_sleep_float: 'optional - float timing in between keypress (defaults to 0.09)')
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/pwn/plugins/transparent_browser.rb', line 274 public_class_method def self.type_as_human(opts = {}) string = opts[:string].to_s rand_sleep_float = if opts[:rand_sleep_float] opts[:rand_sleep_float].to_f else 0.09 end string.each_char do |char| yield char sleep Random.rand(rand_sleep_float) end rescue StandardError => e raise e end |