pwn 0.5.313 → 0.5.314

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 637c524ecea5f16a96ee38e5fb449e6df52289ba726aac5447d7509511745ea5
4
- data.tar.gz: f25475d8329111f5c71a79ebb0f75f677e8a2d2ebdc3f160fdb8623bdd845015
3
+ metadata.gz: 2d666cace1557fc322f75152334daae143e11375e7b9d71bad7dfc48d7ed4b5a
4
+ data.tar.gz: 3511bdbc69c4b0816a97ce3a0c13ccbf2594bf95fe0bef28e13af24e2bda8368
5
5
  SHA512:
6
- metadata.gz: 4ab9ee157c8f6edfd2cfe30f77e0cdea7bd91926bcc1e44959241655e6a7a2665b872f8830cade196e6ba27cc4dec99741999fa22c60cbbc2c4e2e63d87c222d
7
- data.tar.gz: eca463f21dc9ae0ac5c793154a91db82aaea6757212ab004873fade7077369e27401ba167576e2c0d91a8c2e284fb221425f7c64702f9e2121172904321b1a39
6
+ metadata.gz: 8ab653e19fac542cf151905b439a7dacece86c08cadf25d6a68d391913080971875c45b40a3b0f3428ff279994c287fc6ff7be07663bff4aab44645310da3757
7
+ data.tar.gz: 3642ac751c5e97eaed0ae97e6ddd6bab0fd75d216fa5fc9e6d2d8021ff835009c400dbd0d9c78a9e039cb4fddb10f2ed67d6fe78ade01fb7cdb7e063e951d330
data/Gemfile CHANGED
@@ -35,7 +35,7 @@ gem 'gdb', '1.0.0'
35
35
  gem 'gem-wrappers', '1.4.0'
36
36
  gem 'geocoder', '1.8.5'
37
37
  gem 'gist', '6.0.0'
38
- gem 'gruff', '0.27.0'
38
+ gem 'gruff', '0.27.1'
39
39
  # gem 'hidapi', '0.1.9'
40
40
  gem 'htmlentities', '4.3.4'
41
41
  gem 'ipaddress', '0.8.3'
@@ -49,7 +49,7 @@ gem 'luhn', '1.0.2'
49
49
  gem 'mail', '2.8.1'
50
50
  gem 'meshtastic', '0.0.125'
51
51
  gem 'metasm', '1.0.5'
52
- gem 'mongo', '2.21.1'
52
+ gem 'mongo', '2.21.2'
53
53
  gem 'msfrpc-client', '1.1.2'
54
54
  gem 'netaddr', '2.0.6'
55
55
  gem 'net-ldap', '0.19.0'
@@ -61,6 +61,7 @@ gem 'nokogiri-diff', '0.3.0'
61
61
  # gem 'oauth2', '2.0.9'
62
62
  gem 'oily_png', '1.2.1'
63
63
  gem 'open3', '0.2.1'
64
+ gem 'openapi3_parser', '0.10.1'
64
65
  gem 'os', '1.1.4'
65
66
  gem 'ostruct', '0.6.2'
66
67
  gem 'packetfu', '2.0.0'
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.313]:001 >>> PWN.help
40
+ pwn[v0.5.314]: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.4.4@pwn
52
52
  $ gem uninstall --all --executables pwn
53
53
  $ gem install --verbose pwn
54
54
  $ pwn
55
- pwn[v0.5.313]:001 >>> PWN.help
55
+ pwn[v0.5.314]: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.4.4@pwn
62
62
  $ rvmsudo gem uninstall --all --executables pwn
63
63
  $ rvmsudo gem install --verbose pwn
64
64
  $ pwn
65
- pwn[v0.5.313]:001 >>> PWN.help
65
+ pwn[v0.5.314]: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:
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'em/pure_ruby'
4
4
  require 'faye/websocket'
5
+ require 'openapi3_parser'
5
6
  require 'openssl'
6
7
  require 'rest-client'
7
8
  require 'securerandom'
@@ -10,6 +11,7 @@ require 'selenium/devtools'
10
11
  require 'socksify'
11
12
  require 'timeout'
12
13
  require 'watir'
14
+ require 'yaml'
13
15
 
14
16
  module PWN
15
17
  module Plugins
@@ -41,7 +43,7 @@ module PWN
41
43
  # browser_obj1 = PWN::Plugins::TransparentBrowser.open(
42
44
  # browser_type: 'optional - :firefox|:chrome|:headless|:rest|:websocket (defaults to :chrome)',
43
45
  # proxy: 'optional - scheme://proxy_host:port || tor (defaults to nil)',
44
- # devtools: 'optional - boolean (defaults to true)',
46
+ # devtools: 'optional - boolean (defaults to false)',
45
47
  # )
46
48
 
47
49
  public_class_method def self.open(opts = {})
@@ -329,44 +331,32 @@ module PWN
329
331
  return nil
330
332
  end
331
333
 
332
- if devtools_supported.include?(browser_type)
333
- if devtools
334
- driver = browser_obj[:browser].driver
335
- chrome_browser_types = %i[chrome headless_chrome]
336
- if chrome_browser_types.include?(browser_type)
337
- browser_obj[:devtools] = driver.devtools
338
- browser_obj[:devtools].send_cmd('DOM.enable')
339
- browser_obj[:devtools].send_cmd('Log.enable')
340
- browser_obj[:devtools].send_cmd('Network.enable')
341
- browser_obj[:devtools].send_cmd('Page.enable')
342
- browser_obj[:devtools].send_cmd('Runtime.enable')
343
- browser_obj[:devtools].send_cmd('Security.enable')
344
- browser_obj[:devtools].send_cmd('Debugger.enable')
345
- browser_obj[:devtools].send_cmd('DOMStorage.enable')
346
- browser_obj[:devtools].send_cmd('DOMSnapshot.enable')
347
- end
348
-
349
- firefox_browser_types = %i[firefox headless_firefox]
350
- if firefox_browser_types.include?(browser_type)
351
- browser_obj[:devtools] = driver.bidi
352
- # browser_obj[:devtools].send_cmd(
353
- # 'EventBreakpoints.setInstrumentationBreakpoint',
354
- # eventName: 'script'
355
- # )
356
- end
334
+ if devtools && devtools_supported.include?(browser_type)
335
+ chrome_types = %i[chrome headless_chrome]
336
+ firefox_types = %i[firefox headless_firefox]
357
337
 
358
- # Future BiDi API that's more universally supported across browsers
359
- browser_obj[:bidi] = driver.bidi
338
+ # Future BiDi API that's more universally supported across browsers
339
+ sleep 0.01 until browser_obj[:browser].driver.window_handles.any?
340
+ target_window_handle = browser_obj[:browser].driver.window_handles.last
341
+ browser_obj[:browser].driver.switch_to.window(target_window_handle)
360
342
 
361
- jmp_devtools_panel(browser_obj: browser_obj, panel: :elements)
362
- end
343
+ url = 'about:about'
344
+ url = 'chrome://chrome-urls/' if chrome_types.include?(browser_type)
345
+ browser_obj[:browser].goto(url)
346
+ rand_tab = SecureRandom.hex(8)
347
+ browser_obj[:browser].execute_script("document.title = 'about:about-#{rand_tab}'")
363
348
 
364
349
  browser_obj[:browser].driver.manage.window.maximize
365
- new_tab(browser_obj: browser_obj, first_tab: true)
350
+ toggle_devtools(browser_obj: browser_obj)
351
+
352
+ browser_obj[:bidi] = browser_obj[:browser].driver.bidi
353
+ browser_obj[:devtools] = browser_obj[:browser].driver.devtools if chrome_types.include?(browser_type)
354
+ browser_obj[:devtools] = browser_obj[:browser].driver.bidi if firefox_types.include?(browser_type)
366
355
  end
367
356
 
368
357
  browser_obj
369
358
  rescue StandardError => e
359
+ puts e.backtrace
370
360
  raise e
371
361
  end
372
362
 
@@ -378,10 +368,8 @@ module PWN
378
368
  public_class_method def self.dump_links(opts = {})
379
369
  browser_obj = opts[:browser_obj]
380
370
 
381
- links = browser_obj[:browser].links
382
-
383
371
  dump_links_arr = []
384
- links.each do |link|
372
+ browser_obj[:browser].links.each do |link|
385
373
  link_hash = {}
386
374
 
387
375
  link_hash[:text] = link.text
@@ -473,7 +461,6 @@ module PWN
473
461
  return_to = opts[:return_to] ||= :console
474
462
  raise 'ERROR: return_to parameter must be :console or :stdout' unless %i[console stdout].include?(return_to.to_s.downcase.to_sym)
475
463
 
476
- browser = browser_obj[:browser]
477
464
  case js
478
465
  when 'clear', 'clear;', 'clear()', 'clear();'
479
466
  script = 'console.clear()'
@@ -488,7 +475,7 @@ module PWN
488
475
 
489
476
  console_resp = nil
490
477
  begin
491
- Timeout.timeout(1) { console_resp = browser.execute_script(script) }
478
+ Timeout.timeout(1) { console_resp = browser_obj[:browser].execute_script(script) }
492
479
  rescue Timeout::Error, Timeout::ExitException
493
480
  console_resp
494
481
  rescue Selenium::WebDriver::Error::JavascriptError
@@ -658,8 +645,7 @@ module PWN
658
645
  JAVASCRIPT
659
646
 
660
647
  console(browser_obj: browser_obj, js: 'clear();')
661
- browser = browser_obj[:browser]
662
- browser.execute_script(js)
648
+ browser_obj[:browser].execute_script(js)
663
649
  rescue StandardError => e
664
650
  raise e
665
651
  end
@@ -692,8 +678,7 @@ module PWN
692
678
  JAVASCRIPT
693
679
 
694
680
  console(browser_obj: browser_obj, js: 'clear();')
695
- browser = browser_obj[:browser]
696
- browser.execute_script(js)
681
+ browser_obj[:browser].execute_script(js)
697
682
  rescue StandardError => e
698
683
  raise e
699
684
  end
@@ -715,16 +700,15 @@ module PWN
715
700
  value = opts[:value]
716
701
  raise 'ERROR: value parameter is required' if value.nil?
717
702
 
718
- browser = browser_obj[:browser]
719
703
  browser_type = browser_obj[:type]
720
704
  # chrome_types = %i[chrome headless_chrome]
721
705
  firefox_types = %i[firefox headless_firefox]
722
706
 
723
- browser.goto('about:config')
707
+ browser_obj[:browser].goto('about:config')
724
708
  # Confirmed working in Firefox
725
709
  js = %{Services.prefs.setStringPref("#{key}", "#{value}")} if firefox_types.include?(browser_type)
726
710
  console(browser_obj: browser_obj, js: js)
727
- browser.back
711
+ browser_obj[:browser].back
728
712
  rescue Timeout::Error, Timeout::ExitException
729
713
  console_resp
730
714
  rescue StandardError => e
@@ -740,12 +724,27 @@ module PWN
740
724
  browser_obj = opts[:browser_obj]
741
725
  verify_devtools_browser(browser_obj: browser_obj)
742
726
 
743
- browser = browser_obj[:browser]
744
- browser.windows.map do |tab|
727
+ idx = 0
728
+ current_window_handle = browser_obj[:browser].driver.window_handle
729
+
730
+ tabs_arr_hash = browser_obj[:browser].windows.map do |tab|
731
+ next if tab.url.include?('devtools://')
732
+
745
733
  state = :inactive
746
- state = :active if browser.title == tab.title && browser.url == tab.url
747
- { title: tab.title, url: tab.url, state: state }
748
- end
734
+ window_handle = browser_obj[:browser].driver.window_handles[idx]
735
+ state = :active if window_handle == current_window_handle
736
+
737
+ idx += 1
738
+
739
+ { index: window_handle, title: tab.title, url: tab.url, state: state }
740
+ end.compact
741
+
742
+ # Ensure we have a visible tab that's active
743
+ active_tab = tabs_arr_hash.find { |tab| tab[:state] == :active } || tabs_arr_hash.first
744
+ # Ensure we're back to the active tab
745
+ browser_obj[:browser].driver.switch_to.window(active_tab[:index])
746
+
747
+ tabs_arr_hash
749
748
  rescue StandardError => e
750
749
  raise e
751
750
  end
@@ -753,41 +752,39 @@ module PWN
753
752
  # Supported Method Parameters::
754
753
  # tab = PWN::Plugins::TransparentBrowser.jmp_tab(
755
754
  # browser_obj: 'required - browser_obj returned from #open method)',
756
- # keyword: 'optional - keyword in title or url used to switch tabs (defaults to switching to next tab)',
757
- # explicit: 'optional - boolean to indicate if the keyword is an exact match (Defaults to false)'
755
+ # index: 'optional - index of tab to switch to (defaults to switching to next tab)',
756
+ # keyword: 'optional - keyword in title or url used to switch tabs (defaults to switching to next tab)'
758
757
  # )
759
758
 
760
759
  public_class_method def self.jmp_tab(opts = {})
761
760
  browser_obj = opts[:browser_obj]
762
761
  verify_devtools_browser(browser_obj: browser_obj)
763
762
 
763
+ index = opts[:index]
764
764
  keyword = opts[:keyword]
765
- if keyword.nil?
765
+
766
+ tabs_arr_hash = list_tabs(browser_obj: browser_obj)
767
+
768
+ if index.nil? && keyword.nil?
766
769
  # If no keyword is provided, switch to the next tab in the list
767
- tab_list = list_tabs(browser_obj: browser_obj)
768
- active_tab = tab_list.find { |tab| tab[:state] == :active }
769
- # Next tab in the tab_list. If active tab is the last tab, switch to the first tab
770
- next_tab_index = (tab_list.index(active_tab) + 1) % tab_list.size
771
- next_tab = tab_list[next_tab_index]
772
-
773
- if next_tab[:url] == active_tab[:url]
774
- keyword = next_tab[:title]
775
- else
776
- keyword = next_tab[:url]
777
- end
770
+ active_tab_index = tabs_arr_hash.find_index { |tab| tab[:state] == :active }
771
+ next_tab_index = (active_tab_index + 1) % tabs_arr_hash.size
772
+ # Find value of :index key from tabs_arr_hash
773
+ tab_sel = tabs_arr_hash[next_tab_index]
774
+ elsif index
775
+ tab_sel = tabs_arr_hash.find { |tab| tab[:index] == index }
776
+ else
777
+ tab_sel = tabs_arr_hash.find { |tab| tab[:title].include?(keyword) || tab[:url].include?(keyword) }
778
778
  end
779
779
 
780
- explicit = opts[:explicit] ||= false
781
-
782
- browser = browser_obj[:browser]
783
- all_tabs = browser.windows
784
- if explicit
785
- tab_sel = all_tabs.select { |tab| tab.use if tab.title == keyword || tab.url == keyword }
780
+ if tab_sel.is_a?(Hash) && tab_sel[:index]
781
+ index = tab_sel[:index]
782
+ browser_obj[:browser].driver.switch_to.window(index)
786
783
  else
787
- tab_sel = all_tabs.select { |tab| tab.use if tab.title.include?(keyword) || tab.url.include?(keyword) }
784
+ tab_sel = { index: index, error: 'not found' }
788
785
  end
789
786
 
790
- { title: tab_sel.last.title, url: tab_sel.last.url, state: :active } if tab_sel.any?
787
+ tab_sel
791
788
  rescue StandardError => e
792
789
  raise e
793
790
  end
@@ -795,70 +792,100 @@ module PWN
795
792
  # Supported Method Parameters::
796
793
  # tab = PWN::Plugins::TransparentBrowser.new_tab(
797
794
  # browser_obj: 'required - browser_obj returned from #open method)',
798
- # first_tab: 'optional - boolean to indicate if this is the first tab (Defaults to false)'
795
+ # url: 'optional - URL to open in new tab'
799
796
  # )
800
797
 
801
798
  public_class_method def self.new_tab(opts = {})
802
799
  browser_obj = opts[:browser_obj]
803
800
  verify_devtools_browser(browser_obj: browser_obj)
804
801
 
802
+ url = opts[:url]
805
803
  chrome_types = %i[chrome headless_chrome]
804
+ firefox_types = %i[firefox headless_firefox]
806
805
 
807
- first_tab = opts[:first_tab] ||= false
808
-
809
- browser = browser_obj[:browser]
810
806
  browser_type = browser_obj[:type]
811
- devtools = browser_obj[:devtools]
812
- browser.driver.switch_to.new_window(:tab) unless first_tab
807
+
808
+ if url.nil? || url.empty?
809
+ url = 'about:about' if firefox_types.include?(browser_type)
810
+ url = 'chrome://chrome-urls/' if chrome_types.include?(browser_type)
811
+ end
812
+
813
+ # Open a new tab
814
+ console(
815
+ browser_obj: browser_obj,
816
+ js: "window.open('#{url}', '_blank')",
817
+ return_to: :stdout
818
+ )
819
+
820
+ # tabs_arr_hash = list_tabs(browser_obj: browser_obj)
821
+ # new_tab_index = tabs_arr_hash.find { |tab| tab[:state] == :inactive && tab[:url] == url }[:index]
822
+ # jmp_tab(browser_obj: browser_obj, index: new_tab_index)
823
+ jmp_tab(browser_obj: browser_obj)
824
+ new_tab_index = browser_obj[:browser].driver.window_handles.last
825
+
813
826
  rand_tab = SecureRandom.hex(8)
814
- url = 'about:about'
815
- url = 'chrome://chrome-urls/' if chrome_types.include?(browser_type)
816
- browser.goto(url)
817
- # TODO: replace sleep with something more reliable like an event listener
818
- sleep 1
819
- browser.execute_script("document.title = 'about:about-#{rand_tab}'")
820
- toggle_devtools(browser_obj: browser_obj, first_tab: first_tab) if devtools
821
-
822
- { title: browser.title, url: browser.url, state: :active }
827
+ browser_obj[:browser].execute_script("document.title = 'about:about-#{rand_tab}'")
828
+ toggle_devtools(browser_obj: browser_obj) if browser_obj[:devtools]
829
+
830
+ { index: new_tab_index, title: browser_obj[:browser].title, url: browser_obj[:browser].url, state: :active }
823
831
  rescue StandardError => e
832
+ puts e.backtrace
824
833
  raise e
825
834
  end
826
835
 
827
836
  # Supported Method Parameters::
828
837
  # tab = PWN::Plugins::TransparentBrowser.close_tab(
829
838
  # browser_obj: 'required - browser_obj returned from #open method)',
830
- # keyword: 'required - keyword in title or url used to close tabs'
839
+ # index: 'optional - index of tab to close (defaults to closing active tab)',
840
+ # keyword: 'optional - keyword in title or url used to close tabs (defaults to closing active tab)'
831
841
  # )
832
842
 
833
843
  public_class_method def self.close_tab(opts = {})
834
844
  browser_obj = opts[:browser_obj]
835
845
  verify_devtools_browser(browser_obj: browser_obj)
836
846
 
847
+ index = opts[:index]
837
848
  keyword = opts[:keyword]
838
- raise 'ERROR: keyword parameter is required' if keyword.nil?
839
849
 
840
- browser = browser_obj[:browser]
841
- # Switch to an inactive tab before closing the active tab if it's currently active
842
- tab_list = list_tabs(browser_obj: browser_obj)
843
- active_tab = tab_list.find { |tab| tab[:state] == :active }
844
- if active_tab[:url].include?(keyword)
845
- inactive_tabs = tab_list.reject { |tab| tab[:url] == browser.url }
846
- if inactive_tabs.any?
847
- tab_to_activate = inactive_tabs.last[:url]
848
- jmp_tab(browser_obj: browser_obj, keyword: tab_to_activate)
850
+ tabs_arr_hash = list_tabs(browser_obj: browser_obj)
851
+ browser_ready_to_close = true if tabs_arr_hash.length == 1
852
+
853
+ if browser_ready_to_close
854
+ close(browser_obj: browser_obj)
855
+ return [{ index: nil, title: nil, url: nil, state: :browser_closed }]
856
+ elsif index.nil? && keyword.nil?
857
+ index = browser_obj[:browser].driver.window_handle
858
+ browser_obj[:browser].driver.switch_to.window(index)
859
+ browser_obj[:browser].driver.close
860
+ new_tab_index_arr = browser_obj[:browser].driver.window_handles
861
+ if new_tab_index_arr.any?
862
+ new_tab_index = new_tab_index_arr.last
863
+ browser_obj[:browser].driver.switch_to.window(new_tab_index)
849
864
  end
850
- end
851
- all_tabs = browser.windows
852
-
853
- tabs_to_close = all_tabs.select { |tab| tab.title.include?(keyword) || tab.url.include?(keyword) }
865
+ elsif index
866
+ browser_obj[:browser].driver.switch_to.window(index)
867
+ browser_obj[:browser].driver.close
868
+ new_tab_index_arr = browser_obj[:browser].driver.window_handles
869
+ if new_tab_index_arr.any?
870
+ new_tab_index = new_tab_index_arr.last
871
+ browser_obj[:browser].driver.switch_to.window(new_tab_index)
872
+ end
873
+ else
874
+ active_tab = tabs_arr_hash.find { |tab| tab[:state] == :active }
875
+ if active_tab[:url].include?(keyword)
876
+ inactive_tabs = tabs_arr_hash.reject { |tab| tab[:url] == browser_obj[:browser].url }
877
+ if inactive_tabs.any?
878
+ tab_to_activate = inactive_tabs.last[:url]
879
+ jmp_tab(browser_obj: browser_obj, keyword: tab_to_activate)
880
+ end
881
+ end
882
+ all_tabs = browser_obj[:browser].windows
854
883
 
855
- tabs_closed = tabs_to_close.map do |tab|
856
- { title: tab.title, url: tab.url, state: :closed }
884
+ tabs_to_close = all_tabs.select { |tab| tab.title.include?(keyword) || tab.url.include?(keyword) }
885
+ tabs_to_close.each(&:close)
857
886
  end
858
887
 
859
- tabs_to_close.each(&:close)
860
-
861
- tabs_closed
888
+ list_tabs(browser_obj: browser_obj)
862
889
  rescue StandardError => e
863
890
  raise e
864
891
  end
@@ -874,48 +901,45 @@ module PWN
874
901
  browser_obj = opts[:browser_obj]
875
902
  supported = %i[chrome headless_chrome]
876
903
  verify_devtools_browser(browser_obj: browser_obj, supported: supported)
877
- browser = browser_obj[:browser]
878
904
  action = opts[:action] ||= :pause
879
905
  url = opts[:url]
880
906
 
881
- devtools = browser_obj[:devtools]
882
-
883
907
  case action.to_s.downcase.to_sym
884
908
  when :pause
885
- devtools.send_cmd(
909
+ browser_obj[:devtools].send_cmd(
886
910
  'EventBreakpoints.setInstrumentationBreakpoint',
887
911
  eventName: 'scriptFirstStatement'
888
912
  )
889
- # devtools.send_cmd('Debugger.enable')
890
- # devtools.send_cmd(
913
+ # browser_obj[:devtools].send_cmd('Debugger.enable')
914
+ # browser_obj[:devtools].send_cmd(
891
915
  # 'Debugger.setInstrumentationBreakpoint',
892
916
  # instrumentation: 'beforeScriptExecution'
893
917
  # )
894
918
 
895
- # devtools.send_cmd(
919
+ # browser_obj[:devtools].send_cmd(
896
920
  # 'EventBreakpoints.setInstrumentationBreakpoint',
897
921
  # eventName: 'load'
898
922
  # )
899
923
 
900
- # devtools.send_cmd(
924
+ # browser_obj[:devtools].send_cmd(
901
925
  # 'Debugger.setPauseOnExceptions',
902
926
  # state: 'all'
903
927
  # )
904
928
 
905
929
  begin
906
930
  Timeout.timeout(1) do
907
- browser.refresh if url.nil?
908
- browser.goto(url) unless url.nil?
931
+ browser_obj[:browser].refresh if url.nil?
932
+ browser_obj[:browser].goto(url) unless url.nil?
909
933
  end
910
934
  rescue Timeout::Error
911
935
  url
912
936
  end
913
937
  when :resume
914
- devtools.send_cmd(
938
+ browser_obj[:devtools].send_cmd(
915
939
  'EventBreakpoints.removeInstrumentationBreakpoint',
916
940
  eventName: 'scriptFirstStatement'
917
941
  )
918
- devtools.send_cmd('Debugger.resume')
942
+ browser_obj[:devtools].send_cmd('Debugger.resume')
919
943
  else
920
944
  raise 'ERROR: action parameter must be :pause or :resume'
921
945
  end
@@ -933,9 +957,8 @@ module PWN
933
957
  supported = %i[chrome headless_chrome]
934
958
  verify_devtools_browser(browser_obj: browser_obj, supported: supported)
935
959
 
936
- devtools = browser_obj[:devtools]
937
960
  computed_styles = %i[display color font-size font-family]
938
- devtools.send_cmd(
961
+ browser_obj[:devtools].send_cmd(
939
962
  'DOMSnapshot.captureSnapshot',
940
963
  computedStyles: computed_styles
941
964
  ).transform_keys(&:to_sym)
@@ -958,7 +981,6 @@ module PWN
958
981
  steps = 1 if steps.zero? || steps.negative?
959
982
 
960
983
  diff_arr = []
961
- devtools = browser_obj[:devtools]
962
984
  steps.times do |s|
963
985
  diff_hash = {}
964
986
  step = s + 1
@@ -967,7 +989,7 @@ module PWN
967
989
  dom_before = dom(browser_obj: browser_obj)
968
990
  diff_hash[:dom_before_step] = dom_before
969
991
 
970
- devtools.send_cmd('Debugger.stepInto')
992
+ browser_obj[:devtools].send_cmd('Debugger.stepInto')
971
993
 
972
994
  dom_after = dom(browser_obj: browser_obj)
973
995
  diff_hash[:dom_after_step] = dom_after
@@ -998,7 +1020,6 @@ module PWN
998
1020
  steps = 1 if steps.zero? || steps.negative?
999
1021
 
1000
1022
  diff_arr = []
1001
- devtools = browser_obj[:devtools]
1002
1023
  steps.times do |s|
1003
1024
  diff_hash = {}
1004
1025
  step = s + 1
@@ -1007,7 +1028,7 @@ module PWN
1007
1028
  dom_before = dom(browser_obj: browser_obj)
1008
1029
  diff_hash[:pre_step] = dom_before
1009
1030
 
1010
- devtools.send_cmd('Debugger.stepOut')
1031
+ browser_obj[:devtools].send_cmd('Debugger.stepOut')
1011
1032
 
1012
1033
  dom_after = dom(browser_obj: browser_obj, step_sum: step_sum)
1013
1034
  diff_hash[:post_step] = dom_after
@@ -1038,7 +1059,6 @@ module PWN
1038
1059
  steps = 1 if steps.zero? || steps.negative?
1039
1060
 
1040
1061
  diff_arr = []
1041
- devtools = browser_obj[:devtools]
1042
1062
  steps.times do |s|
1043
1063
  diff_hash = {}
1044
1064
  step = s + 1
@@ -1047,7 +1067,7 @@ module PWN
1047
1067
  dom_before = dom(browser_obj: browser_obj)
1048
1068
  diff_hash[:dom_before_step] = dom_before
1049
1069
 
1050
- devtools.send_cmd('Debugger.stepOver')
1070
+ browser_obj[:devtools].send_cmd('Debugger.stepOver')
1051
1071
 
1052
1072
  dom_after = dom(browser_obj: browser_obj, step_sum: step_sum)
1053
1073
  diff_hash[:dom_after_step] = dom_after
@@ -1065,35 +1085,15 @@ module PWN
1065
1085
 
1066
1086
  # Supported Method Parameters::
1067
1087
  # PWN::Plugins::TransparentBrowser.toggle_devtools(
1068
- # browser_obj: 'required - browser_obj returned from #open method)',
1069
- # first_tab: 'optional - boolean to indicate if this is the first tab (Defaults to false)',
1088
+ # browser_obj: 'required - browser_obj returned from #open method)'
1070
1089
  # )
1071
1090
 
1072
1091
  public_class_method def self.toggle_devtools(opts = {})
1073
1092
  browser_obj = opts[:browser_obj]
1074
1093
  verify_devtools_browser(browser_obj: browser_obj)
1075
1094
 
1076
- first_tab = opts[:first_tab] ||= false
1077
-
1078
- browser = browser_obj[:browser]
1079
- browser_type = browser_obj[:type]
1080
- chrome_types = %i[chrome headless_chrome]
1081
- tab_id = browser.title.split('-').last.strip
1082
- if chrome_types.include?(browser_type)
1083
- devtools_tab_title = "DevTools-#{tab_id}"
1084
- jmp_tab(browser_obj: browser_obj, keyword: 'DevTools', explicit: true)
1085
- browser.execute_script("document.title = '#{devtools_tab_title}'")
1086
- end
1087
-
1088
1095
  # TODO: Find replacement for hotkey - there must be a better way.
1089
- browser.send_keys(:f12)
1090
- if first_tab
1091
- # TODO: replace sleep with something more reliable like an event listener
1092
- sleep 1
1093
- browser.send_keys(:escape)
1094
- end
1095
- tab_tied_to_devtools = "about:about-#{tab_id}"
1096
- jmp_tab(browser_obj: browser_obj, keyword: tab_tied_to_devtools, explicit: true)
1096
+ browser_obj[:browser].send_keys(:f12)
1097
1097
  rescue StandardError => e
1098
1098
  raise e
1099
1099
  end
@@ -1136,7 +1136,7 @@ module PWN
1136
1136
  # If we're in the console, we need to switch to the inspector first
1137
1137
  jmp_devtools_panel(browser_obj: browser_obj, panel: :inspector)
1138
1138
  sleep 1
1139
- hotkey.push('z') if firefox_types.include?(browser_type)
1139
+ hotkey.push('z')
1140
1140
  end
1141
1141
  when :network
1142
1142
  hotkey.push('e') if firefox_types.include?(browser_type)
@@ -1144,11 +1144,11 @@ module PWN
1144
1144
  raise 'ERROR: panel parameter must be :elements|:inspector|:console|:debugger|:sources|:network'
1145
1145
  end
1146
1146
 
1147
- # Have to call twice for Chrome, otherwise devtools stays closed
1148
1147
  browser_obj[:browser].send_keys(:escape)
1149
- # browser.body.click!
1150
- browser.send_keys(hotkey)
1151
- browser.send_keys(hotkey) if chrome_types.include?(browser_type)
1148
+
1149
+ # Have to call twice for Chrome, otherwise devtools stays closed
1150
+ browser_obj[:browser].send_keys(hotkey)
1151
+ # browser.send_keys(hotkey) if chrome_types.include?(browser_type)
1152
1152
  browser.send_keys(:escape)
1153
1153
  rescue StandardError => e
1154
1154
  raise e
@@ -1192,7 +1192,7 @@ module PWN
1192
1192
  browser_obj1 = #{self}.open(
1193
1193
  browser_type: 'optional - :firefox|:chrome|:headless|:rest|:websocket (defaults to :chrome)',
1194
1194
  proxy: 'optional scheme://proxy_host:port || tor (defaults to nil)',
1195
- devtools: 'optional - boolean (defaults to true)'
1195
+ devtools: 'optional - boolean (defaults to false)'
1196
1196
  )
1197
1197
  browser = browser_obj1[:browser]
1198
1198
  puts browser.public_methods
@@ -1295,7 +1295,8 @@ module PWN
1295
1295
 
1296
1296
  console_resp = #{self}.console(
1297
1297
  browser_obj: 'required - browser_obj returned from #open method)',
1298
- js: 'required - JavaScript expression to evaluate'
1298
+ js: 'required - JavaScript expression to evaluate',
1299
+ return_to: 'optional - return to :console or :stdout (defaults to :console)'
1299
1300
  )
1300
1301
 
1301
1302
  console_resp = #{self}.view_dom_mutations(
@@ -1321,17 +1322,19 @@ module PWN
1321
1322
 
1322
1323
  tab = #{self}.jmp_tab(
1323
1324
  browser_obj: 'required - browser_obj returned from #open method)',
1325
+ index: 'optional - index of tab to switch to (defaults to switching to next tab)',
1324
1326
  keyword: 'optional - keyword in title or url used to switch tabs (defaults to switching to next tab)',
1325
1327
  )
1326
1328
 
1327
1329
  tab = #{self}.new_tab(
1328
1330
  browser_obj: 'required - browser_obj returned from #open method)',
1329
- first_tab: 'optional - boolean to indicate if this is the first tab (Defaults to false)'
1331
+ url: 'optional - URL to open in new tab'
1330
1332
  )
1331
1333
 
1332
1334
  tab = #{self}.close_tab(
1333
1335
  browser_obj: 'required - browser_obj returned from #open method)',
1334
- keyword: 'required - keyword in title or url used to close tabs'
1336
+ index: 'optional - index of tab to close (defaults to closing active tab)',
1337
+ keyword: 'optional - keyword in title or url used to close tabs (defaults to closing active tab)'
1335
1338
  )
1336
1339
 
1337
1340
  #{self}.debugger(
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.313'
4
+ VERSION = '0.5.314'
5
5
  end
@@ -944,14 +944,15 @@
944
944
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.authors Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.authors`: Author(s)\n\n0day Inc. <support@0dayinc.com>\n"}]}
945
945
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.close Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.close`: Supported Method Parameters\n\nbrowser_obj1 = PWN::Plugins::TransparentBrowser.close(\n\nbrowser_obj: 'required - browser_obj returned from #open method)'\n\n)\n"}]}
946
946
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.close_tab Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.close_tab`: Supported Method Parameters\n\ntab = PWN::Plugins::TransparentBrowser.close_tab(\n\nbrowser_obj: 'required - browser_obj returned from #open method)',\nkeyword: 'required - keyword in title or url used to close tabs'\n\n)\n"}]}
947
- {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.console Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.console`: Supported Method Parameters\n\nconsole_resp = PWN::Plugins::TransparentBrowser.console(\n\nbrowser_obj: browser_obj1,\njs: 'required - JavaScript expression to evaluate'\n\n)\n"}]}
947
+ {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.console Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.console`: Supported Method Parameters\n\nconsole_resp = PWN::Plugins::TransparentBrowser.console(\n\nbrowser_obj: browser_obj1,\njs: 'required - JavaScript expression to evaluate',\nreturn_to: 'optional - return to :console or :stdout (defaults to :console)'\n\n)\n"}]}
948
948
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.debugger Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.debugger`: Supported Method Parameters\n\nPWN::Plugins::TransparentBrowser.debugger(\n\nbrowser_obj: 'required - browser_obj returned from #open method)',\naction: 'optional - action to take :pause|:resume (Defaults to :pause)',\nurl: 'optional - URL to navigate to after pausing debugger (Defaults to nil)'\n\n)\n"}]}
949
949
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.dom Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.dom`: Supported Method Parameters\n\ncurrent_dom = PWN::Plugins::TransparentBrowser.dom(\n\nbrowser_obj: 'required - browser_obj returned from #open method)'\n\n)\n"}]}
950
950
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.dump_links Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.dump_links`: Supported Method Parameters\n\nbrowser_obj = PWN::Plugins::TransparentBrowser.dump_links(\n\nbrowser_obj: browser_obj1\n\n)\n"}]}
951
951
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.find_elements_by_text Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.find_elements_by_text`: Supported Method Parameters\n\nbrowser_obj = PWN::Plugins::TransparentBrowser.find_elements_by_text(\n\nbrowser_obj: browser_obj1,\ntext: 'required - text to search for in the DOM'\n\n)\n"}]}
952
952
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.help Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.help`: "}]}
953
+ {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.hide_dom_mutations Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.hide_dom_mutations`: Supported Method Parameters\n\nconsole_resp = PWN::Plugins::TransparentBrowser.hide_dom_mutations(\n\nbrowser_obj: browser_obj1,\ntab_keyword: 'optional - keyword in title or url to switch to tab (defaults to active tab per list_tabs method)'\n\n)\n"}]}
953
954
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.jmp_devtools_panel Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.jmp_devtools_panel`: Supported Method Parameters\n\nPWN::Plugins::TransparentBrowser.jmp_devtools_panel(\n\nbrowser_obj: 'required - browser_obj returned from #open method)',\npanel: 'optional - panel to switch to :elements|:inspector|:console|:debugger|:sources|:network\n\n)\n"}]}
954
- {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.jmp_tab Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.jmp_tab`: Supported Method Parameters\n\ntab = PWN::Plugins::TransparentBrowser.jmp_tab(\n\nbrowser_obj: 'required - browser_obj returned from #open method)',\nkeyword: 'required - keyword in title or url used to switch tabs',\nexplicit: 'optional - boolean to indicate if the keyword is an exact match (Defaults to false)'\n\n)\n"}]}
955
+ {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.jmp_tab Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.jmp_tab`: Supported Method Parameters\n\ntab = PWN::Plugins::TransparentBrowser.jmp_tab(\n\nbrowser_obj: 'required - browser_obj returned from #open method)',\nkeyword: 'optional - keyword in title or url used to switch tabs (defaults to switching to next tab)',\nexplicit: 'optional - boolean to indicate if the keyword is an exact match (Defaults to false)'\n\n)\n"}]}
955
956
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.list_tabs Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.list_tabs`: Supported Method Parameters\n\ntabs = PWN::Plugins::TransparentBrowser.list_tabs(\n\nbrowser_obj: 'required - browser_obj returned from #open method)'\n\n)\n"}]}
956
957
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.new_tab Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.new_tab`: Supported Method Parameters\n\ntab = PWN::Plugins::TransparentBrowser.new_tab(\n\nbrowser_obj: 'required - browser_obj returned from #open method)',\nfirst_tab: 'optional - boolean to indicate if this is the first tab (Defaults to false)'\n\n)\n"}]}
957
958
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.open Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.open`: Supported Method Parameters\n\nbrowser_obj1 = PWN::Plugins::TransparentBrowser.open(\n\nbrowser_type: 'optional - :firefox|:chrome|:headless|:rest|:websocket (defaults to :chrome)',\nproxy: 'optional - scheme://proxy_host:port || tor (defaults to nil)',\ndevtools: 'optional - boolean (defaults to true)',\n\n)\n"}]}
@@ -962,6 +963,7 @@
962
963
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.type_as_human Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.type_as_human`: Supported Method Parameters\n\nPWN::Plugins::TransparentBrowser.type_as_human(\n\nstring: 'required - string to type as human',\nrand_sleep_float: 'optional - float timing in between keypress (defaults to 0.09)'\n\n)\n"}]}
963
964
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.update_about_config Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.update_about_config`: Supported Method Parameters\n\nPWN::Plugins::TransparentBrowser.update_about_config(\n\nbrowser_obj: browser_obj1,\nkey: 'required - key to update in about:config',\nvalue: 'required - value to set for key in about:config'\n\n)\n"}]}
964
965
  {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.verify_devtools_browser Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.verify_devtools_browser`: Supported Method Parameters\n\nverify_devtools_browser(\n\nbrowser_obj: 'required - browser_obj returned from #open method',\nsupported: 'optional - array of supported browser types (defaults to [:chrome, :headless_chrome, :firefox, :headless_firefox, :headless])'\n\n)\n"}]}
966
+ {"messages":[{"role":"user","content":"PWN::Plugins::TransparentBrowser.view_dom_mutations Usage"},{"role":"assistant","content":"`PWN::Plugins::TransparentBrowser.view_dom_mutations`: Supported Method Parameters\n\nconsole_resp = PWN::Plugins::TransparentBrowser.view_dom_mutations(\n\nbrowser_obj: browser_obj1,\ntab_keyword: 'optional - keyword in title or url to switch to tab (defaults to active tab per list_tabs method)',\ntarget: 'optional - target JavaScript node to observe (defaults to document.body)'\n\n)\n"}]}
965
967
  {"messages":[{"role":"user","content":"PWN::Plugins::TwitterAPI.app_only_login Usage"},{"role":"assistant","content":"`PWN::Plugins::TwitterAPI.app_only_login`: Supported Method Parameters\n\nbearer_token = PWN::Plugins::TwitterAPI.app_only_login(\n\nconsumer_key: 'required - consumer key for app-only authentication',\nconsumer_secret: 'optional - consumer secret (will prompt if nil)'\n\n)\n"}]}
966
968
  {"messages":[{"role":"user","content":"PWN::Plugins::TwitterAPI.app_only_logout Usage"},{"role":"assistant","content":"`PWN::Plugins::TwitterAPI.app_only_logout`: Supported Method Parameters\n\nPWN::Plugins::TwitterAPI.logout(\n\nbearer_token: 'required bearer_token returned from #app_only_login method'\n\n)\n"}]}
967
969
  {"messages":[{"role":"user","content":"PWN::Plugins::TwitterAPI.authors Usage"},{"role":"assistant","content":"`PWN::Plugins::TwitterAPI.authors`: Author(s)\n\n0day Inc. <support@0dayinc.com>\n"}]}
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.313
4
+ version: 0.5.314
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
@@ -337,14 +337,14 @@ dependencies:
337
337
  requirements:
338
338
  - - '='
339
339
  - !ruby/object:Gem::Version
340
- version: 0.27.0
340
+ version: 0.27.1
341
341
  type: :runtime
342
342
  prerelease: false
343
343
  version_requirements: !ruby/object:Gem::Requirement
344
344
  requirements:
345
345
  - - '='
346
346
  - !ruby/object:Gem::Version
347
- version: 0.27.0
347
+ version: 0.27.1
348
348
  - !ruby/object:Gem::Dependency
349
349
  name: htmlentities
350
350
  requirement: !ruby/object:Gem::Requirement
@@ -519,14 +519,14 @@ dependencies:
519
519
  requirements:
520
520
  - - '='
521
521
  - !ruby/object:Gem::Version
522
- version: 2.21.1
522
+ version: 2.21.2
523
523
  type: :runtime
524
524
  prerelease: false
525
525
  version_requirements: !ruby/object:Gem::Requirement
526
526
  requirements:
527
527
  - - '='
528
528
  - !ruby/object:Gem::Version
529
- version: 2.21.1
529
+ version: 2.21.2
530
530
  - !ruby/object:Gem::Dependency
531
531
  name: msfrpc-client
532
532
  requirement: !ruby/object:Gem::Requirement
@@ -667,6 +667,20 @@ dependencies:
667
667
  - - '='
668
668
  - !ruby/object:Gem::Version
669
669
  version: 0.2.1
670
+ - !ruby/object:Gem::Dependency
671
+ name: openapi3_parser
672
+ requirement: !ruby/object:Gem::Requirement
673
+ requirements:
674
+ - - '='
675
+ - !ruby/object:Gem::Version
676
+ version: 0.10.1
677
+ type: :runtime
678
+ prerelease: false
679
+ version_requirements: !ruby/object:Gem::Requirement
680
+ requirements:
681
+ - - '='
682
+ - !ruby/object:Gem::Version
683
+ version: 0.10.1
670
684
  - !ruby/object:Gem::Dependency
671
685
  name: os
672
686
  requirement: !ruby/object:Gem::Requirement