pwn 0.5.513 → 0.5.515

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: 82756fa89b985658783dd6a2f59ec1e4c591959dd0ea349e8f68ca5e74fc8715
4
- data.tar.gz: 34f2cc9edcc4eb8a35ad7d91b16fbb760d4a220a3a9d556efe682f009573abcf
3
+ metadata.gz: d607ee5ce171b1d6683a6930a6ef46e636b0ba79b38f636627ac7d3552dba740
4
+ data.tar.gz: c04ae0f7241c14ed7cff5b270ecac11f1558cc28070af7fd15b51a72db5252db
5
5
  SHA512:
6
- metadata.gz: 9bf3f13770d43feeab86c59ab32b389a02e11727b888e7a002248dd8754769c00c1e5e2a335c316db1d1ccc1ad846fc9a39d463bde22a0e9c3f467a69e2d4e55
7
- data.tar.gz: db2d0be522131762b6214e6fb3e4e79500bf4b8bfb25510785ac0eaa3eca81c0984c58d9a7a1dc9d195c1d8873b2a1cc559f0ff0a2085d9f3217341fb03042a3
6
+ metadata.gz: 99378a68ba8484746d057a7082064dfbd7c0011e15e6b85fd1c746fe3084f4811fa973d99d6c9d41da74fcc78bf56dbe9a8a98e12206e6f9f8de31ac3906aaa1
7
+ data.tar.gz: 7c9f89ff3be93b1914cfe20075a5f30c4062be1e5525d4a650c052ccaba4b10d7f884742baaffabb41cd956729e8a58dd4d0b55bd032e125c2bc7452d0db50b3
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.513]:001 >>> PWN.help
40
+ pwn[v0.5.515]: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.513]:001 >>> PWN.help
55
+ pwn[v0.5.515]: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.513]:001 >>> PWN.help
65
+ pwn[v0.5.515]: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/lib/pwn/sdr/gqrx.rb CHANGED
@@ -141,11 +141,7 @@ module PWN
141
141
  response.push(gqrx_sock.readline.chomp)
142
142
  # Drain any additional lines quickly
143
143
  loop do
144
- # This is the main contributing factor to this scanner being slow.
145
- # We're trading speed for accuracy here.
146
- # break if gqrx_sock.wait_readable(0.0625).nil? && cmd == 'l STRENGTH'
147
- break if gqrx_sock.wait_readable(0.04).nil? && cmd == 'l STRENGTH'
148
- break if gqrx_sock.wait_readable(0.001).nil? && cmd != 'l STRENGTH'
144
+ break if gqrx_sock.wait_readable(0.0001).nil?
149
145
 
150
146
  response.push(gqrx_sock.readline.chomp)
151
147
  end
@@ -175,26 +171,72 @@ module PWN
175
171
 
176
172
  # Supported Method Parameters::
177
173
  # strength_db = PWN::SDR::GQRX.measure_signal_strength(
178
- # gqrx_sock: 'required - GQRX socket object returned from #connect method'
174
+ # gqrx_sock: 'required - GQRX socket object returned from #connect method',
175
+ # strength_lock: 'optional - Strength lock in dBFS to determine signal edges (defaults to -70.0)'
179
176
  # )
180
177
  private_class_method def self.measure_signal_strength(opts = {})
181
178
  gqrx_sock = opts[:gqrx_sock]
179
+ strength_lock = opts[:strength_lock] ||= -70.0
182
180
 
181
+ attempts = 0
183
182
  strength_db = -99.9
184
- prev_strength_db = strength_db
185
- # While strength_db is rising, keep measuring
183
+ prev_strength_db = -99.9
186
184
  loop do
185
+ attempts += 1
187
186
  strength_db = gqrx_cmd(gqrx_sock: gqrx_sock, cmd: 'l STRENGTH').to_f
188
- break if strength_db <= prev_strength_db
189
187
 
188
+ # Suprisingly accurate but takes longer
189
+ # `break if strength_db < prev_strength_db` || attempts >= 300
190
+ # is VERY accurate with
191
+ # `sleep 0.0001`
192
+ # but with more sampling == longer time
193
+ # break if attempts >= 100 && (strength_lock > strength_db || strength_db < prev_strength_db)
194
+
195
+ break if attempts >= 30 && strength_lock > strength_db
196
+
197
+ break if attempts >= 300 || strength_db < prev_strength_db
198
+
199
+ sleep 0.001
190
200
  prev_strength_db = strength_db
191
201
  end
202
+ puts "Strength Measurement Attempts: #{attempts}"
192
203
 
193
204
  strength_db
194
205
  rescue StandardError => e
195
206
  raise e
196
207
  end
197
208
 
209
+ # Supported Method Parameters::
210
+ # tune_resp = PWN::SDR::GQRX.tune_to(
211
+ # gqrx_sock: 'required - GQRX socket object returned from #connect method',
212
+ # hz: 'required - Frequency to tune to'
213
+ # )
214
+ private_class_method def self.tune_to(opts = {})
215
+ gqrx_sock = opts[:gqrx_sock]
216
+ hz = opts[:hz].to_s.cast_to_raw_hz
217
+
218
+ current_freq = 0
219
+ attempts = 0
220
+ loop do
221
+ attempts += 1
222
+ gqrx_cmd(
223
+ gqrx_sock: gqrx_sock,
224
+ cmd: "F #{hz}",
225
+ resp_ok: 'RPRT 0'
226
+ )
227
+
228
+ current_freq = gqrx_cmd(
229
+ gqrx_sock: gqrx_sock,
230
+ cmd: 'f'
231
+ )
232
+
233
+ break if current_freq.to_s.cast_to_raw_hz == hz
234
+ end
235
+ # puts "Tuned to #{current_freq} in #{attempts} attempt(s)."
236
+ rescue StandardError => e
237
+ raise e
238
+ end
239
+
198
240
  # Supported Method Parameters::
199
241
  # candidate_signals = PWN::SDR::GQRX.edge_detection(
200
242
  # gqrx_sock: 'required - GQRX socket object returned from #connect method',
@@ -216,15 +258,11 @@ module PWN
216
258
  strength_db = 99.9
217
259
  puts 'Finding Beginning Edge of Signal...'
218
260
  while strength_db >= strength_lock
219
- gqrx_cmd(gqrx_sock: gqrx_sock, cmd: "F #{hz}")
220
- current_freq = 0
221
- while current_freq.to_s.cast_to_raw_hz != hz.to_s.cast_to_raw_hz
222
- current_freq = gqrx_cmd(
223
- gqrx_sock: gqrx_sock,
224
- cmd: 'f'
225
- )
226
- end
227
- strength_db = measure_signal_strength(gqrx_sock: gqrx_sock)
261
+ tune_to(gqrx_sock: gqrx_sock, hz: hz)
262
+ strength_db = measure_signal_strength(
263
+ gqrx_sock: gqrx_sock,
264
+ strength_lock: strength_lock
265
+ )
228
266
  candidate = {
229
267
  hz: hz.to_s.cast_to_raw_hz,
230
268
  freq: hz.to_i.cast_to_pretty_hz,
@@ -245,15 +283,11 @@ module PWN
245
283
  strength_db = 99.9
246
284
  puts 'Finding Ending Edge of Signal...'
247
285
  while strength_db >= strength_lock
248
- gqrx_cmd(gqrx_sock: gqrx_sock, cmd: "F #{hz}")
249
- current_freq = 0
250
- while current_freq.to_s.cast_to_raw_hz != hz.to_s.cast_to_raw_hz
251
- current_freq = gqrx_cmd(
252
- gqrx_sock: gqrx_sock,
253
- cmd: 'f'
254
- )
255
- end
256
- strength_db = measure_signal_strength(gqrx_sock: gqrx_sock)
286
+ tune_to(gqrx_sock: gqrx_sock, hz: hz)
287
+ strength_db = measure_signal_strength(
288
+ gqrx_sock: gqrx_sock,
289
+ strength_lock: strength_lock
290
+ )
257
291
  candidate = {
258
292
  hz: hz.to_s.cast_to_raw_hz,
259
293
  freq: hz.to_i.cast_to_pretty_hz,
@@ -287,7 +321,7 @@ module PWN
287
321
 
288
322
  signals = signals_arr.sort_by { |s| s[:freq].to_s.cast_to_raw_hz }
289
323
  # Unique signals by frequency
290
- signals.uniq! { |s| s[:hz] }
324
+ signals.uniq! { |s| s[:freq].to_s.cast_to_raw_hz }
291
325
 
292
326
  timestamp_end = Time.now.strftime('%Y-%m-%d %H:%M:%S%z')
293
327
  duration_secs = Time.parse(timestamp_end) - Time.parse(timestamp_start)
@@ -439,24 +473,16 @@ module PWN
439
473
  )
440
474
  end
441
475
 
442
- change_freq_resp = gqrx_cmd(
443
- gqrx_sock: gqrx_sock,
444
- cmd: "F #{freq.to_s.cast_to_raw_hz}",
445
- resp_ok: 'RPRT 0'
476
+ tune_to(gqrx_sock: gqrx_sock, hz: freq)
477
+ strength_db = measure_signal_strength(
478
+ gqrx_sock: gqrx_sock
446
479
  )
447
480
 
448
- current_freq = 0
449
- while current_freq.to_s.cast_to_raw_hz != freq.to_s.cast_to_raw_hz
450
- current_freq = gqrx_cmd(
451
- gqrx_sock: gqrx_sock,
452
- cmd: 'f'
453
- )
454
- end
455
-
456
481
  freq_obj = {
457
482
  bandwidth: bandwidth,
458
483
  demodulator_mode: demodulator_mode,
459
484
  rds: rds,
485
+ strength_db: strength_db,
460
486
  freq: freq
461
487
  }
462
488
 
@@ -471,8 +497,6 @@ module PWN
471
497
  cmd: 'l AF'
472
498
  ).to_f
473
499
 
474
- strength_db = measure_signal_strength(gqrx_sock: gqrx_sock)
475
-
476
500
  squelch = gqrx_cmd(
477
501
  gqrx_sock: gqrx_sock,
478
502
  cmd: 'l SQL'
@@ -502,7 +526,6 @@ module PWN
502
526
  freq_obj[:if_gain] = if_gain
503
527
  freq_obj[:rf_gain] = rf_gain
504
528
  freq_obj[:squelch] = squelch
505
- freq_obj[:strength_db] = strength_db
506
529
  freq_obj[:rds] = rds_resp
507
530
  end
508
531
 
@@ -707,8 +730,11 @@ module PWN
707
730
  start_hz_direction.step(by: step_hz_direction, to: end_hz_direction) do |hz|
708
731
  print '>' if direction_up
709
732
  print '<' unless direction_up
710
- gqrx_cmd(gqrx_sock: gqrx_sock, cmd: "F #{hz}")
711
- strength_db = measure_signal_strength(gqrx_sock: gqrx_sock)
733
+ tune_to(gqrx_sock: gqrx_sock, hz: hz)
734
+ strength_db = measure_signal_strength(
735
+ gqrx_sock: gqrx_sock,
736
+ strength_lock: strength_lock
737
+ )
712
738
  samples.push({ hz: hz, strength_db: strength_db })
713
739
 
714
740
  # current_hz = gqrx_cmd(gqrx_sock: gqrx_sock, cmd: 'f').to_s.cast_to_raw_hz
@@ -787,16 +813,11 @@ module PWN
787
813
  signals_arr = []
788
814
  hz = hz_start
789
815
  while hz <= hz_target
790
- gqrx_cmd(gqrx_sock: gqrx_sock, cmd: "F #{hz}")
791
- current_freq = 0
792
- while current_freq.to_s.cast_to_raw_hz != hz.to_s.cast_to_raw_hz
793
- current_freq = gqrx_cmd(
794
- gqrx_sock: gqrx_sock,
795
- cmd: 'f'
796
- )
797
- end
798
-
799
- strength_db = measure_signal_strength(gqrx_sock: gqrx_sock)
816
+ tune_to(gqrx_sock: gqrx_sock, hz: hz)
817
+ strength_db = measure_signal_strength(
818
+ gqrx_sock: gqrx_sock,
819
+ strength_lock: strength_lock
820
+ )
800
821
 
801
822
  if strength_db >= strength_lock
802
823
  puts '-' * 86
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.513'
4
+ VERSION = '0.5.515'
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.513
4
+ version: 0.5.515
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.