pwn 0.5.525 → 0.5.527

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: 67600c92927578c7598e62ddc4e785dba48057f26a8dfa91e9ea58fbc3737c35
4
- data.tar.gz: 07ef92cad239ffdcbea358e34127d515d9553f4e444c9a069dfba4f196f82b2e
3
+ metadata.gz: 41dad766173e9f532698600df5ad215b77c1536b28d7913ac1ad83650d8f15a3
4
+ data.tar.gz: a620829d63e8fc41d707fb55e6cdc6aef3ca1aa0bab571014631dfb883639c6b
5
5
  SHA512:
6
- metadata.gz: b4203ad36d4dc9cd1f0011e8de8b5c80babf85b5a5aa6dbae19410e8e9014c199990ef7f14216ab9e528af5bfeb7de06ee62d02f405f73a27cb7418f26db9bb2
7
- data.tar.gz: 8d6bef379e1fec99bb489f60b82faa0038ad13cf1e92bbb2bf274ba8a962dff0e0e8fa1455fea93211125217f4fefa1696f3917239cd94ce7ec8c7337bff3819
6
+ metadata.gz: 86c1c7bd2fad5b04e0170d53de9a820be1276cd1e038a7ae2b224b192e5e421075ef890a3eb35280ca624d28237cb1749a869d9d31ac439eb1fd3159b25ec953
7
+ data.tar.gz: c9a934741503e2b271d289a19950dc203167c0a12ed3f66507fe88dcf0da4843a324fd9035d037375a854ec751808c4690aab03ead1dc342ce2aac419b5d3c2f
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.525]:001 >>> PWN.help
40
+ pwn[v0.5.527]: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.7@pwn
52
52
  $ gem uninstall --all --executables pwn
53
53
  $ gem install --verbose pwn
54
54
  $ pwn
55
- pwn[v0.5.525]:001 >>> PWN.help
55
+ pwn[v0.5.527]: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.7@pwn
62
62
  $ rvmsudo gem uninstall --all --executables pwn
63
63
  $ rvmsudo gem install --verbose pwn
64
64
  $ pwn
65
- pwn[v0.5.525]:001 >>> PWN.help
65
+ pwn[v0.5.527]: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:
data/bin/pwn_gqrx_scanner CHANGED
@@ -156,12 +156,6 @@ begin
156
156
  location: location,
157
157
  keep_looping: keep_looping
158
158
  )
159
-
160
- loop_count += 1
161
- gqrx_sock = PWN::SDR::GQRX.connect(target: host, port: port)
162
- log_timestamp = Time.now.strftime('%Y-%m-%d')
163
- scan_log = "/tmp/pwn_sdr_gqrx_scan_#{PWN::SDR.hz_to_s(start_freq)}-#{PWN::SDR.hz_to_s(target_freq)}_#{log_timestamp}-l#{loop_count}.json"
164
- end
165
159
  puts 'Scan Complete.'
166
160
  rescue StandardError => e
167
161
  raise e
data/lib/pwn/sdr/gqrx.rb CHANGED
@@ -178,7 +178,7 @@ module PWN
178
178
  distance_between_unique_samples = (strength_db - prev_strength_db).abs.round(2)
179
179
  strength_measured = true if distance_between_unique_samples.positive? && strength_lock > strength_db
180
180
  end
181
- strength_measured = true if (distance_between_unique_samples.positive? && distance_between_unique_samples < 5) || attempts >= 500
181
+ strength_measured = true if (distance_between_unique_samples.positive? && distance_between_unique_samples < 5) || attempts >= 700
182
182
 
183
183
  break if strength_measured
184
184
 
@@ -658,201 +658,214 @@ module PWN
658
658
 
659
659
  public_class_method def self.scan_range(opts = {})
660
660
  timestamp_start = Time.now.strftime('%Y-%m-%d %H:%M:%S%z')
661
- log_timestamp = Time.now.strftime('%Y-%m-%d')
662
661
 
663
- gqrx_sock = opts[:gqrx_sock]
662
+ loop_count = 1
663
+ loop do
664
+ gqrx_sock = opts[:gqrx_sock]
664
665
 
665
- start_freq = opts[:start_freq]
666
- hz_start = PWN::SDR.hz_to_i(start_freq)
666
+ start_freq = opts[:start_freq]
667
+ hz_start = PWN::SDR.hz_to_i(start_freq)
667
668
 
668
- target_freq = opts[:target_freq]
669
- hz_target = PWN::SDR.hz_to_i(target_freq)
669
+ target_freq = opts[:target_freq]
670
+ hz_target = PWN::SDR.hz_to_i(target_freq)
670
671
 
671
- demodulator_mode = opts[:demodulator_mode]
672
+ demodulator_mode = opts[:demodulator_mode]
672
673
 
673
- bandwidth = opts[:bandwidth] ||= '200.000'
674
-
675
- precision = opts[:precision] ||= 1
676
- strength_lock = opts[:strength_lock] ||= -70.0
677
- squelch = opts[:squelch] ||= (strength_lock - 3.0)
678
- scan_log = opts[:scan_log] ||= "/tmp/pwn_sdr_gqrx_scan_#{PWN::SDR.hz_to_s(hz_start)}-#{PWN::SDR.hz_to_s(hz_target)}_#{log_timestamp}.json"
679
- decoder = opts[:decoder]
680
- location = opts[:location] ||= 'United States'
681
- keep_looping = opts[:keep_looping] || false
674
+ bandwidth = opts[:bandwidth] ||= '200.000'
682
675
 
683
- step_hz = 10**(precision - 1)
684
- step_hz_direction = hz_start > hz_target ? -step_hz : step_hz
676
+ precision = opts[:precision] ||= 1
677
+ strength_lock = opts[:strength_lock] ||= -70.0
678
+ squelch = opts[:squelch] ||= (strength_lock - 3.0)
679
+ decoder = opts[:decoder]
685
680
 
686
- # Set squelch once for the scan
687
- change_squelch_resp = gqrx_cmd(
688
- gqrx_sock: gqrx_sock,
689
- cmd: "L SQL #{squelch}",
690
- resp_ok: 'RPRT 0'
691
- )
681
+ log_timestamp = Time.now.strftime('%Y-%m-%d')
682
+ scan_log = opts[:scan_log] ||= "/tmp/pwn_sdr_gqrx_scan_#{PWN::SDR.hz_to_s(hz_start)}-#{PWN::SDR.hz_to_s(hz_target)}_#{log_timestamp}_l#{loop_count}.json"
683
+ location = opts[:location] ||= 'United States'
684
+ keep_looping = opts[:keep_looping] || false
692
685
 
693
- # We always disable RDS decoding at during the scan
694
- # to prevent unnecessary processing overhead.
695
- # We return the rds boolean in the scan_resp object
696
- # so it will be picked up and used appropriately
697
- # when calling analyze_scan or analyze_log methods.
698
- rds_resp = gqrx_cmd(
699
- gqrx_sock: gqrx_sock,
700
- cmd: 'U RDS 0',
701
- resp_ok: 'RPRT 0'
702
- )
686
+ step_hz = 10**(precision - 1)
687
+ step_hz_direction = hz_start > hz_target ? -step_hz : step_hz
703
688
 
704
- # Set demodulator mode & passband once for the scan
705
- mode_str = demodulator_mode.to_s.upcase
706
- passband_hz = PWN::SDR.hz_to_i(bandwidth)
707
- gqrx_cmd(
708
- gqrx_sock: gqrx_sock,
709
- cmd: "M #{mode_str} #{passband_hz}",
710
- resp_ok: 'RPRT 0'
711
- )
689
+ # Set squelch once for the scan
690
+ change_squelch_resp = gqrx_cmd(
691
+ gqrx_sock: gqrx_sock,
692
+ cmd: "L SQL #{squelch}",
693
+ resp_ok: 'RPRT 0'
694
+ )
712
695
 
713
- audio_gain_db = opts[:audio_gain_db] ||= 6.0
714
- audio_gain_db = audio_gain_db.to_f
715
- audio_gain_db_resp = gqrx_cmd(
716
- gqrx_sock: gqrx_sock,
717
- cmd: "L AF #{audio_gain_db}",
718
- resp_ok: 'RPRT 0'
719
- )
696
+ # We always disable RDS decoding at during the scan
697
+ # to prevent unnecessary processing overhead.
698
+ # We return the rds boolean in the scan_resp object
699
+ # so it will be picked up and used appropriately
700
+ # when calling analyze_scan or analyze_log methods.
701
+ rds_resp = gqrx_cmd(
702
+ gqrx_sock: gqrx_sock,
703
+ cmd: 'U RDS 0',
704
+ resp_ok: 'RPRT 0'
705
+ )
720
706
 
721
- rf_gain = opts[:rf_gain] ||= 0.0
722
- rf_gain = rf_gain.to_f
723
- rf_gain_resp = gqrx_cmd(
724
- gqrx_sock: gqrx_sock,
725
- cmd: "L RF_GAIN #{rf_gain}",
726
- resp_ok: 'RPRT 0'
727
- )
707
+ # Set demodulator mode & passband once for the scan
708
+ mode_str = demodulator_mode.to_s.upcase
709
+ passband_hz = PWN::SDR.hz_to_i(bandwidth)
710
+ gqrx_cmd(
711
+ gqrx_sock: gqrx_sock,
712
+ cmd: "M #{mode_str} #{passband_hz}",
713
+ resp_ok: 'RPRT 0'
714
+ )
728
715
 
729
- intermediate_gain = opts[:intermediate_gain] ||= 32.0
730
- intermediate_gain = intermediate_gain.to_f
731
- intermediate_resp = gqrx_cmd(
732
- gqrx_sock: gqrx_sock,
733
- cmd: "L IF_GAIN #{intermediate_gain}",
734
- resp_ok: 'RPRT 0'
735
- )
716
+ audio_gain_db = opts[:audio_gain_db] ||= 6.0
717
+ audio_gain_db = audio_gain_db.to_f
718
+ audio_gain_db_resp = gqrx_cmd(
719
+ gqrx_sock: gqrx_sock,
720
+ cmd: "L AF #{audio_gain_db}",
721
+ resp_ok: 'RPRT 0'
722
+ )
736
723
 
737
- baseband_gain = opts[:baseband_gain] ||= 10.0
738
- baseband_gain = baseband_gain.to_f
739
- baseband_resp = gqrx_cmd(
740
- gqrx_sock: gqrx_sock,
741
- cmd: "L BB_GAIN #{baseband_gain}",
742
- resp_ok: 'RPRT 0'
743
- )
724
+ rf_gain = opts[:rf_gain] ||= 0.0
725
+ rf_gain = rf_gain.to_f
726
+ rf_gain_resp = gqrx_cmd(
727
+ gqrx_sock: gqrx_sock,
728
+ cmd: "L RF_GAIN #{rf_gain}",
729
+ resp_ok: 'RPRT 0'
730
+ )
744
731
 
745
- prev_freq_obj = init_freq(
746
- gqrx_sock: gqrx_sock,
747
- freq: hz_start,
748
- demodulator_mode: demodulator_mode,
749
- bandwidth: bandwidth,
750
- squelch: squelch,
751
- decoder: decoder,
752
- suppress_details: true,
753
- keep_alive: true
754
- )
732
+ intermediate_gain = opts[:intermediate_gain] ||= 32.0
733
+ intermediate_gain = intermediate_gain.to_f
734
+ intermediate_resp = gqrx_cmd(
735
+ gqrx_sock: gqrx_sock,
736
+ cmd: "L IF_GAIN #{intermediate_gain}",
737
+ resp_ok: 'RPRT 0'
738
+ )
755
739
 
756
- candidate_signals = []
740
+ baseband_gain = opts[:baseband_gain] ||= 10.0
741
+ baseband_gain = baseband_gain.to_f
742
+ baseband_resp = gqrx_cmd(
743
+ gqrx_sock: gqrx_sock,
744
+ cmd: "L BB_GAIN #{baseband_gain}",
745
+ resp_ok: 'RPRT 0'
746
+ )
757
747
 
758
- # Begin scanning range
759
- puts "\n"
760
- puts '-' * 86
761
- puts "INFO: Scanning from #{PWN::SDR.hz_to_s(hz_start)} to #{PWN::SDR.hz_to_s(hz_target)} in steps of #{PWN::SDR.hz_to_s(step_hz_direction.abs)} Hz."
762
- puts "If scans are slow and/or you're experiencing false positives/negatives,"
763
- puts 'consider adjusting the following:'
764
- puts "1. The SDR's sample rate in GQRX"
765
- puts "\s\s- Click on `Configure I/O devices`."
766
- puts "\s\s- A lower `Input rate` value seems counter-intuitive but works well (e.g. ADALM PLUTO ~ 1000000)."
767
- puts '2. Adjust the :strength_lock parameter.'
768
- puts '3. Adjust the :precision parameter.'
769
- puts '4. Disable AI introspection in PWN::Env'
770
- puts 'Happy scanning!'
771
- puts '-' * 86
772
- puts "\n\n\n"
773
-
774
- signals_arr = []
775
- hz = hz_start
776
-
777
- while step_hz_direction.positive? ? hz <= hz_target : hz >= hz_target
778
- tune_to(gqrx_sock: gqrx_sock, hz: hz)
779
- strength_db = measure_signal_strength(
748
+ prev_freq_obj = init_freq(
780
749
  gqrx_sock: gqrx_sock,
781
- freq: hz,
782
- strength_lock: strength_lock,
783
- phase: :find_candidates
750
+ freq: hz_start,
751
+ demodulator_mode: demodulator_mode,
752
+ bandwidth: bandwidth,
753
+ squelch: squelch,
754
+ decoder: decoder,
755
+ suppress_details: true,
756
+ keep_alive: true
784
757
  )
785
758
 
786
- if strength_db >= strength_lock
787
- puts '-' * 86
788
- # Find left and right edges of the signal
789
- candidate_signals = edge_detection(
790
- gqrx_sock: gqrx_sock,
791
- hz: hz,
792
- step_hz: step_hz,
793
- strength_lock: strength_lock
794
- )
795
- elsif candidate_signals.length.positive?
796
- best_peak = find_best_peak(
759
+ candidate_signals = []
760
+
761
+ # Begin scanning range
762
+ puts "\n"
763
+ puts '-' * 86
764
+ puts "INFO: Scanning from #{PWN::SDR.hz_to_s(hz_start)} to #{PWN::SDR.hz_to_s(hz_target)} in steps of #{PWN::SDR.hz_to_s(step_hz_direction.abs)} Hz."
765
+ puts "If scans are slow and/or you're experiencing false positives/negatives,"
766
+ puts 'consider adjusting the following:'
767
+ puts "1. The SDR's sample rate in GQRX"
768
+ puts "\s\s- Click on `Configure I/O devices`."
769
+ puts "\s\s- A lower `Input rate` value seems counter-intuitive but works well (e.g. ADALM PLUTO ~ 1000000)."
770
+ puts '2. Adjust the :strength_lock parameter.'
771
+ puts '3. Adjust the :precision parameter.'
772
+ puts '4. Disable AI introspection in PWN::Env'
773
+ puts 'Happy scanning!'
774
+ puts '-' * 86
775
+ puts "\n\n\n"
776
+
777
+ signals_arr = []
778
+ hz = hz_start
779
+
780
+ while step_hz_direction.positive? ? hz <= hz_target : hz >= hz_target
781
+ tune_to(gqrx_sock: gqrx_sock, hz: hz)
782
+ strength_db = measure_signal_strength(
797
783
  gqrx_sock: gqrx_sock,
798
- candidate_signals: candidate_signals,
799
- step_hz: step_hz,
800
- strength_lock: strength_lock
784
+ freq: hz,
785
+ strength_lock: strength_lock,
786
+ phase: :find_candidates
801
787
  )
802
788
 
803
- if best_peak[:hz] && best_peak[:strength_db] > strength_lock
804
- puts "\n**** Detected Signal ****"
805
- best_freq = PWN::SDR.hz_to_s(best_peak[:hz])
806
- best_strength_db = best_peak[:strength_db]
807
- prev_freq_obj = init_freq(
789
+ if strength_db >= strength_lock
790
+ puts '-' * 86
791
+ # Find left and right edges of the signal
792
+ candidate_signals = edge_detection(
808
793
  gqrx_sock: gqrx_sock,
809
- freq: best_freq,
810
- demodulator_mode: demodulator_mode,
811
- bandwidth: bandwidth,
812
- squelch: squelch,
813
- decoder: decoder,
814
- suppress_details: true,
815
- keep_alive: true
794
+ hz: hz,
795
+ step_hz: step_hz,
796
+ strength_lock: strength_lock
816
797
  )
817
- prev_freq_obj[:strength_lock] = strength_lock
818
- prev_freq_obj[:strength_db] = best_strength_db
819
-
820
- system_role_content = "Analyze signal data captured by a software-defined-radio using GQRX at the following location: #{location}. Respond with just FCC information about the transmission if available. If the frequency is unlicensed or not found in FCC records, state that clearly. Be clear and concise in your analysis."
821
- ai_analysis = PWN::AI::Introspection.reflect_on(
822
- request: prev_freq_obj.to_json,
823
- system_role_content: system_role_content,
824
- suppress_pii_warning: true
798
+ elsif candidate_signals.length.positive?
799
+ best_peak = find_best_peak(
800
+ gqrx_sock: gqrx_sock,
801
+ candidate_signals: candidate_signals,
802
+ step_hz: step_hz,
803
+ strength_lock: strength_lock
825
804
  )
826
805
 
827
- prev_freq_obj[:ai_analysis] = ai_analysis unless ai_analysis.nil?
828
- puts JSON.pretty_generate(prev_freq_obj)
829
- puts '-' * 86
830
- puts "\n\n\n"
831
- signals_arr.push(prev_freq_obj)
832
- log_signals(
833
- signals_arr: signals_arr,
834
- timestamp_start: timestamp_start,
835
- scan_log: scan_log
836
- )
837
- hz = candidate_signals.last[:hz]
838
- # gets
806
+ if best_peak[:hz] && best_peak[:strength_db] > strength_lock
807
+ puts "\n**** Detected Signal ****"
808
+ best_freq = PWN::SDR.hz_to_s(best_peak[:hz])
809
+ best_strength_db = best_peak[:strength_db]
810
+ prev_freq_obj = init_freq(
811
+ gqrx_sock: gqrx_sock,
812
+ freq: best_freq,
813
+ demodulator_mode: demodulator_mode,
814
+ bandwidth: bandwidth,
815
+ squelch: squelch,
816
+ decoder: decoder,
817
+ suppress_details: true,
818
+ keep_alive: true
819
+ )
820
+ prev_freq_obj[:strength_lock] = strength_lock
821
+ prev_freq_obj[:strength_db] = best_strength_db
822
+
823
+ system_role_content = "Analyze signal data captured by a software-defined-radio using GQRX at the following location: #{location}. Respond with just FCC information about the transmission if available. If the frequency is unlicensed or not found in FCC records, state that clearly. Be clear and concise in your analysis."
824
+ ai_analysis = PWN::AI::Introspection.reflect_on(
825
+ request: prev_freq_obj.to_json,
826
+ system_role_content: system_role_content,
827
+ suppress_pii_warning: true
828
+ )
829
+
830
+ prev_freq_obj[:ai_analysis] = ai_analysis unless ai_analysis.nil?
831
+ puts JSON.pretty_generate(prev_freq_obj)
832
+ puts '-' * 86
833
+ puts "\n\n\n"
834
+ signals_arr.push(prev_freq_obj)
835
+ log_signals(
836
+ signals_arr: signals_arr,
837
+ timestamp_start: timestamp_start,
838
+ scan_log: scan_log
839
+ )
840
+ hz = candidate_signals.last[:hz]
841
+ # gets
842
+ end
843
+ candidate_signals.clear
839
844
  end
840
- candidate_signals.clear
845
+ hz += step_hz_direction
841
846
  end
842
- hz += step_hz_direction
843
- end
844
847
 
845
- log_signals(
846
- signals_arr: signals_arr,
847
- timestamp_start: timestamp_start,
848
- scan_log: scan_log
849
- )
848
+ log_signals(
849
+ signals_arr: signals_arr,
850
+ timestamp_start: timestamp_start,
851
+ scan_log: scan_log
852
+ )
853
+ break unless keep_looping
854
+
855
+ print "\nScan iteration ##{loop_count} complete. Resuming in 30 seconds. Press CTRL+C to exit"
856
+ 30.times do
857
+ print '.'
858
+ sleep 1
859
+ end
860
+ puts "\n"
861
+ loop_count += 1
862
+ end
850
863
  rescue Interrupt
851
864
  puts "\nCTRL+C detected - goodbye."
852
865
  rescue StandardError => e
853
866
  raise e
854
867
  ensure
855
- disconnect(gqrx_sock: gqrx_sock)
868
+ disconnect(gqrx_sock: gqrx_sock) if defined?(gqrx_sock) && gqrx_sock.is_a?(TCPSocket)
856
869
  end
857
870
 
858
871
  # Supported Method Parameters::
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.525'
4
+ VERSION = '0.5.527'
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.525
4
+ version: 0.5.527
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.