pwn 0.5.192 → 0.5.194

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 943acf516461b6defab89c118dce50021fbe4a54149e383cb94be08570cb4735
4
- data.tar.gz: 88ed9ddeec7d76c97a0b4665b26d14db609b9a820786905ab81a2d1f9115f65b
3
+ metadata.gz: d8e2618c43661322179b1ea623b1dc19c5fc079373197c1ba64d78e63e17d68f
4
+ data.tar.gz: 7c36ee8c5c48c6c181a7a4204911bdb6c9079f945b1814daafa5ccf433e71bd6
5
5
  SHA512:
6
- metadata.gz: 15fea999df3f0b8f05358f285980cf34851d3dde2992e325f8b1cc3d550be9e24a18fe78a7147531d811992f8b15b9ef2e89300cade9d9873534addc513ecd65
7
- data.tar.gz: 13f05cebbee3ddd043f8f397a733a78daa7e8aa1efae393659d2e8f9bd493cc940bcea1d953fd2bcebeaece47eb29f9abad9184f41ce5a3b587e6285a981beb0
6
+ metadata.gz: 8449c2bfcc574dab0613478ac7f9cc249f039c7fc8ea3d27fd14045ce399377f2be3fdcdd760ffeb93f2812c0157e8c6daa99645d965e59835e35d5bf40b8f0b
7
+ data.tar.gz: a5018bad53afa6a41bcf41c9b9c3abc0508ab2430f4905ab0368fd2beb479706c2f117bb48cb2414e641e5f39efe3cc28fd05bd7e5ad74ec165f2f9884ed615b
data/README.md CHANGED
@@ -37,7 +37,7 @@ $ cd /opt/pwn
37
37
  $ ./install.sh
38
38
  $ ./install.sh ruby-gem
39
39
  $ pwn
40
- pwn[v0.5.192]:001 >>> PWN.help
40
+ pwn[v0.5.194]:001 >>> PWN.help
41
41
  ```
42
42
 
43
43
  [![Installing the pwn Security Automation Framework](https://raw.githubusercontent.com/0dayInc/pwn/master/documentation/pwn_install.png)](https://youtu.be/G7iLUY4FzsI)
@@ -52,7 +52,7 @@ $ rvm use ruby-3.3.3@pwn
52
52
  $ gem uninstall --all --executables pwn
53
53
  $ gem install --verbose pwn
54
54
  $ pwn
55
- pwn[v0.5.192]:001 >>> PWN.help
55
+ pwn[v0.5.194]:001 >>> PWN.help
56
56
  ```
57
57
 
58
58
  If you're using a multi-user install of RVM do:
@@ -62,7 +62,7 @@ $ rvm use ruby-3.3.3@pwn
62
62
  $ rvmsudo gem uninstall --all --executables pwn
63
63
  $ rvmsudo gem install --verbose pwn
64
64
  $ pwn
65
- pwn[v0.5.192]:001 >>> PWN.help
65
+ pwn[v0.5.194]:001 >>> PWN.help
66
66
  ```
67
67
 
68
68
  PWN periodically upgrades to the latest version of Ruby which is reflected in `/opt/pwn/.ruby-version`. The easiest way to upgrade to the latest version of Ruby from a previous PWN installation is to run the following script:
@@ -605,7 +605,8 @@ module PWN
605
605
  model: model,
606
606
  request: request.chomp,
607
607
  response_history: response_history,
608
- speak_answer: speak_answer
608
+ speak_answer: speak_answer,
609
+ spinner: true
609
610
  )
610
611
  when :openai
611
612
  response = PWN::Plugins::OpenAI.chat(
@@ -613,7 +614,8 @@ module PWN
613
614
  model: model,
614
615
  request: request.chomp,
615
616
  response_history: response_history,
616
- speak_answer: speak_answer
617
+ speak_answer: speak_answer,
618
+ spinner: true
617
619
  )
618
620
  else
619
621
  raise "ERROR: Unsupported AI Engine: #{ai_engine}"
@@ -42,7 +42,6 @@ module PWN
42
42
  # browser_type: 'optional - :firefox|:chrome|:headless|:rest|:websocket (defaults to :chrome)',
43
43
  # proxy: 'optional - scheme://proxy_host:port || tor (defaults to nil)',
44
44
  # devtools: 'optional - boolean (defaults to true)',
45
- # url: 'optional - URL to navigate to after opening browser (Defaults to about:about#RANDID)'
46
45
  # )
47
46
 
48
47
  public_class_method def self.open(opts = {})
@@ -63,8 +62,6 @@ module PWN
63
62
  devtools = opts[:devtools] ||= false
64
63
  devtools = true if devtools_supported.include?(browser_type) && devtools
65
64
 
66
- url = opts[:url] ||= "about:about##{SecureRandom.hex(8)}"
67
-
68
65
  # Let's crank up the default timeout from 30 seconds to 15 min for slow sites
69
66
  Watir.default_timeout = 900
70
67
 
@@ -130,7 +127,7 @@ module PWN
130
127
  end
131
128
  end
132
129
 
133
- args.push('--devtools') if devtools
130
+ # args.push('--devtools') if devtools
134
131
  options = Selenium::WebDriver::Firefox::Options.new(
135
132
  args: args,
136
133
  accept_insecure_certs: true
@@ -161,7 +158,8 @@ module PWN
161
158
  accept_insecure_certs: true
162
159
  )
163
160
 
164
- options.web_socket_url = true
161
+ # This is for bidi, once it's ready
162
+ # options.web_socket_url = true
165
163
  options.profile = this_profile
166
164
  driver = Selenium::WebDriver.for(:chrome, options: options)
167
165
  browser_obj[:browser] = Watir::Browser.new(driver)
@@ -221,7 +219,8 @@ module PWN
221
219
  accept_insecure_certs: true
222
220
  )
223
221
 
224
- options.web_socket_url = true
222
+ # This is for bidi, once it's ready
223
+ # options.web_socket_url = true
225
224
  options.profile = this_profile
226
225
  driver = Selenium::WebDriver.for(:firefox, options: options)
227
226
  browser_obj[:browser] = Watir::Browser.new(driver)
@@ -243,7 +242,8 @@ module PWN
243
242
  accept_insecure_certs: true
244
243
  )
245
244
 
246
- options.web_socket_url = true
245
+ # This is for bidi, once it's ready
246
+ # options.web_socket_url = true
247
247
  options.profile = this_profile
248
248
  driver = Selenium::WebDriver.for(:chrome, options: options)
249
249
  browser_obj[:browser] = Watir::Browser.new(driver)
@@ -258,7 +258,6 @@ module PWN
258
258
  browser_obj[:browser].proxy = proxy
259
259
  end
260
260
  end
261
- puts browser_obj[:browser].get(url).body if url
262
261
 
263
262
  when :websocket
264
263
  if proxy
@@ -285,10 +284,6 @@ module PWN
285
284
  end
286
285
 
287
286
  if devtools_supported.include?(browser_type)
288
- rand_tab = SecureRandom.hex(8)
289
- browser_obj[:browser].goto(url)
290
- browser_obj[:browser].execute_script("document.title = '#{rand_tab}'")
291
-
292
287
  if devtools
293
288
  driver = browser_obj[:browser].driver
294
289
  browser_obj[:devtools] = driver.devtools
@@ -307,11 +302,13 @@ module PWN
307
302
  browser_obj[:devtools].send_cmd('DOMSnapshot.enable')
308
303
  end
309
304
 
310
- browser_obj[:bidi] = driver.bidi
305
+ # Future BiDi API that's more universally supported across browsers
306
+ # browser_obj[:bidi] = driver.bidi
311
307
 
312
308
  jmp_devtools_panel(browser_obj: browser_obj, panel: :elements)
313
- browser_obj[:browser].send_keys(:escape)
314
309
  end
310
+
311
+ new_tab(browser_obj: browser_obj, first_tab: true)
315
312
  end
316
313
 
317
314
  browser_obj
@@ -458,7 +455,8 @@ module PWN
458
455
  # Supported Method Parameters::
459
456
  # tab = PWN::Plugins::TransparentBrowser.jmp_tab(
460
457
  # browser_obj: 'required - browser_obj returned from #open method)',
461
- # keyword: 'required - keyword in title or url used to switch tabs'
458
+ # keyword: 'required - keyword in title or url used to switch tabs',
459
+ # explicit: 'optional - boolean to indicate if the keyword is an exact match (Defaults to false)'
462
460
  # )
463
461
 
464
462
  public_class_method def self.jmp_tab(opts = {})
@@ -468,9 +466,16 @@ module PWN
468
466
  keyword = opts[:keyword]
469
467
  raise 'ERROR: keyword parameter is required' if keyword.nil?
470
468
 
469
+ explicit = opts[:explicit] ||= false
470
+
471
471
  browser = browser_obj[:browser]
472
472
  all_tabs = browser.windows
473
- tab_sel = all_tabs.select { |tab| tab.use if tab.title.include?(keyword) || tab.url.include?(keyword) }
473
+ if explicit
474
+ tab_sel = all_tabs.select { |tab| tab.use if tab.title == keyword || tab.url == keyword }
475
+ else
476
+ tab_sel = all_tabs.select { |tab| tab.use if tab.title.include?(keyword) || tab.url.include?(keyword) }
477
+ end
478
+
474
479
  { title: tab_sel.last.title, url: tab_sel.last.url, state: :active } if tab_sel.any?
475
480
  rescue StandardError => e
476
481
  raise e
@@ -479,31 +484,33 @@ module PWN
479
484
  # Supported Method Parameters::
480
485
  # tab = PWN::Plugins::TransparentBrowser.new_tab(
481
486
  # browser_obj: 'required - browser_obj returned from #open method)',
482
- # url: 'optional - URL to navigate to after opening new tab (Defaults to nil)'
487
+ # first_tab: 'optional - boolean to indicate if this is the first tab (Defaults to false)'
483
488
  # )
484
489
 
485
490
  public_class_method def self.new_tab(opts = {})
486
491
  browser_obj = opts[:browser_obj]
487
492
  verify_devtools_browser(browser_obj: browser_obj)
488
493
 
489
- url = opts[:url]
494
+ chrome_types = %i[chrome headless_chrome]
495
+
496
+ first_tab = opts[:first_tab] ||= false
490
497
 
491
- firefox_types = %i[firefox headless_firefox]
492
498
  browser = browser_obj[:browser]
493
499
  browser_type = browser_obj[:type]
494
500
  devtools = browser_obj[:devtools]
495
- browser.execute_script('window.open()')
496
- jmp_tab(browser_obj: browser_obj, keyword: 'about:blank')
497
- rand_tab = SecureRandom.hex(8)
498
- if url.nil?
499
- browser.goto("about:about##{rand_tab}")
500
- browser.execute_script("document.title = '#{rand_tab}'")
501
+ unless first_tab
502
+ browser.execute_script('window.open()')
503
+ jmp_tab(browser_obj: browser_obj, keyword: 'about:blank')
501
504
  end
502
- # Open the DevTools for Firefox, Chrome opens them automatically
503
- browser.send_keys(:f12) if firefox_types.include?(browser_type)
504
- # Open Console drawer if DevTools are open
505
- browser.send_keys(:escape) unless devtools.nil?
506
- browser.goto(url) unless url.nil?
505
+
506
+ rand_tab = SecureRandom.hex(8)
507
+ url = 'about:about'
508
+ url = 'chrome://chrome-urls/' if chrome_types.include?(browser_type)
509
+ browser.goto(url)
510
+ # TODO: replace sleep with something more reliable like an event listener
511
+ sleep 1
512
+ browser.execute_script("document.title = 'about:about-#{rand_tab}'")
513
+ toggle_devtools(browser_obj: browser_obj, first_tab: first_tab) if devtools
507
514
 
508
515
  { title: browser.title, url: browser.url, state: :active }
509
516
  rescue StandardError => e
@@ -653,15 +660,29 @@ module PWN
653
660
 
654
661
  # Supported Method Parameters::
655
662
  # PWN::Plugins::TransparentBrowser.toggle_devtools(
656
- # browser_obj: 'required - browser_obj returned from #open method)'
663
+ # browser_obj: 'required - browser_obj returned from #open method)',
664
+ # first_tab: 'optional - boolean to indicate if this is the first tab (Defaults to false)',
657
665
  # )
658
666
 
659
667
  public_class_method def self.toggle_devtools(opts = {})
660
668
  browser_obj = opts[:browser_obj]
661
669
  verify_devtools_browser(browser_obj: browser_obj)
662
670
 
671
+ first_tab = opts[:first_tab] ||= false
672
+
663
673
  browser = browser_obj[:browser]
674
+ tab_id = browser.title.split('-').last.strip
675
+ devtools_tab_title = "DevTools-#{tab_id}"
676
+ jmp_tab(browser_obj: browser_obj, keyword: 'DevTools', explicit: true)
677
+ browser.execute_script("document.title = '#{devtools_tab_title}'")
664
678
  browser.send_keys(:f12)
679
+ if first_tab
680
+ # TODO: replace sleep with something more reliable like an event listener
681
+ sleep 1
682
+ browser.send_keys(:escape)
683
+ end
684
+ tab_tied_to_devtools = "about:about-#{devtools_tab_title.split('-').last.strip}"
685
+ jmp_tab(browser_obj: browser_obj, keyword: tab_tied_to_devtools, explicit: true)
665
686
  rescue StandardError => e
666
687
  raise e
667
688
  end
@@ -697,7 +718,12 @@ module PWN
697
718
  hotkey.push('j') if chrome_types.include?(browser_type)
698
719
  hotkey.push('k') if firefox_types.include?(browser_type)
699
720
  when :debugger, :sources
700
- hotkey.push('z') if firefox_types.include?(browser_type)
721
+ if firefox_types.include?(browser_type)
722
+ # If we're in the console, we need to switch to the inspector first
723
+ jmp_devtools_panel(browser_obj: browser_obj, panel: :inspector)
724
+ sleep 1
725
+ hotkey.push('z') if firefox_types.include?(browser_type)
726
+ end
701
727
  when :network
702
728
  hotkey.push('e') if firefox_types.include?(browser_type)
703
729
  else
@@ -705,9 +731,11 @@ module PWN
705
731
  end
706
732
 
707
733
  # Have to call twice for Chrome, otherwise devtools stays closed
708
- browser.body.click
734
+ browser_obj[:browser].send_keys(:escape)
735
+ # browser.body.click!
709
736
  browser.send_keys(hotkey)
710
737
  browser.send_keys(hotkey) if chrome_types.include?(browser_type)
738
+ browser.send_keys(:escape)
711
739
  rescue StandardError => e
712
740
  raise e
713
741
  end
@@ -867,7 +895,7 @@ module PWN
867
895
 
868
896
  tab = #{self}.new_tab(
869
897
  browser_obj: 'required - browser_obj returned from #open method)',
870
- url: 'optional - URL to navigate to after opening new tab (Defaults to nil)'
898
+ first_tab: 'optional - boolean to indicate if this is the first tab (Defaults to false)'
871
899
  )
872
900
 
873
901
  tab = #{self}.close_tab(
data/lib/pwn/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PWN
4
- VERSION = '0.5.192'
4
+ VERSION = '0.5.194'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.192
4
+ version: 0.5.194
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.