pwn 0.5.514 → 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: 272a60702de23eed1c2e19a6abde33a36151b70afa71b7be490ce9b1645c1c4c
4
- data.tar.gz: e79932a20866563d120069a22dea242af3cb654864161e736481958c53e6148c
3
+ metadata.gz: d607ee5ce171b1d6683a6930a6ef46e636b0ba79b38f636627ac7d3552dba740
4
+ data.tar.gz: c04ae0f7241c14ed7cff5b270ecac11f1558cc28070af7fd15b51a72db5252db
5
5
  SHA512:
6
- metadata.gz: 81ca0bb428762f7263e2841144cb0aa98c7dbb08077ce14f67d9ad34a956503831e3a12e14e15b9fd583ec7587d3d41c5b3c62f918943451bd082bbaa3ccf8b1
7
- data.tar.gz: d43a8edba7549e95cd18a416e5afe795923d033d7b04f8d53080e818b37c46bbb421785f17938ffb35df8dfaccbffa36c1434a45ebb806c6def90ab05880495f
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.514]: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.514]: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.514]: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,28 +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
- print '$'
189
- break if strength_db <= prev_strength_db
190
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
191
200
  prev_strength_db = strength_db
192
- sleep 0.0001
193
201
  end
202
+ puts "Strength Measurement Attempts: #{attempts}"
194
203
 
195
204
  strength_db
196
205
  rescue StandardError => e
197
206
  raise e
198
207
  end
199
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
+
200
240
  # Supported Method Parameters::
201
241
  # candidate_signals = PWN::SDR::GQRX.edge_detection(
202
242
  # gqrx_sock: 'required - GQRX socket object returned from #connect method',
@@ -218,15 +258,11 @@ module PWN
218
258
  strength_db = 99.9
219
259
  puts 'Finding Beginning Edge of Signal...'
220
260
  while strength_db >= strength_lock
221
- gqrx_cmd(gqrx_sock: gqrx_sock, cmd: "F #{hz}")
222
- current_freq = 0
223
- while current_freq.to_s.cast_to_raw_hz != hz.to_s.cast_to_raw_hz
224
- current_freq = gqrx_cmd(
225
- gqrx_sock: gqrx_sock,
226
- cmd: 'f'
227
- )
228
- end
229
- 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
+ )
230
266
  candidate = {
231
267
  hz: hz.to_s.cast_to_raw_hz,
232
268
  freq: hz.to_i.cast_to_pretty_hz,
@@ -247,15 +283,11 @@ module PWN
247
283
  strength_db = 99.9
248
284
  puts 'Finding Ending Edge of Signal...'
249
285
  while strength_db >= strength_lock
250
- gqrx_cmd(gqrx_sock: gqrx_sock, cmd: "F #{hz}")
251
- current_freq = 0
252
- while current_freq.to_s.cast_to_raw_hz != hz.to_s.cast_to_raw_hz
253
- current_freq = gqrx_cmd(
254
- gqrx_sock: gqrx_sock,
255
- cmd: 'f'
256
- )
257
- end
258
- 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
+ )
259
291
  candidate = {
260
292
  hz: hz.to_s.cast_to_raw_hz,
261
293
  freq: hz.to_i.cast_to_pretty_hz,
@@ -441,24 +473,16 @@ module PWN
441
473
  )
442
474
  end
443
475
 
444
- change_freq_resp = gqrx_cmd(
445
- gqrx_sock: gqrx_sock,
446
- cmd: "F #{freq.to_s.cast_to_raw_hz}",
447
- resp_ok: 'RPRT 0'
476
+ tune_to(gqrx_sock: gqrx_sock, hz: freq)
477
+ strength_db = measure_signal_strength(
478
+ gqrx_sock: gqrx_sock
448
479
  )
449
480
 
450
- current_freq = 0
451
- while current_freq.to_s.cast_to_raw_hz != freq.to_s.cast_to_raw_hz
452
- current_freq = gqrx_cmd(
453
- gqrx_sock: gqrx_sock,
454
- cmd: 'f'
455
- )
456
- end
457
-
458
481
  freq_obj = {
459
482
  bandwidth: bandwidth,
460
483
  demodulator_mode: demodulator_mode,
461
484
  rds: rds,
485
+ strength_db: strength_db,
462
486
  freq: freq
463
487
  }
464
488
 
@@ -473,8 +497,6 @@ module PWN
473
497
  cmd: 'l AF'
474
498
  ).to_f
475
499
 
476
- strength_db = measure_signal_strength(gqrx_sock: gqrx_sock)
477
-
478
500
  squelch = gqrx_cmd(
479
501
  gqrx_sock: gqrx_sock,
480
502
  cmd: 'l SQL'
@@ -504,7 +526,6 @@ module PWN
504
526
  freq_obj[:if_gain] = if_gain
505
527
  freq_obj[:rf_gain] = rf_gain
506
528
  freq_obj[:squelch] = squelch
507
- freq_obj[:strength_db] = strength_db
508
529
  freq_obj[:rds] = rds_resp
509
530
  end
510
531
 
@@ -709,8 +730,11 @@ module PWN
709
730
  start_hz_direction.step(by: step_hz_direction, to: end_hz_direction) do |hz|
710
731
  print '>' if direction_up
711
732
  print '<' unless direction_up
712
- gqrx_cmd(gqrx_sock: gqrx_sock, cmd: "F #{hz}")
713
- 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
+ )
714
738
  samples.push({ hz: hz, strength_db: strength_db })
715
739
 
716
740
  # current_hz = gqrx_cmd(gqrx_sock: gqrx_sock, cmd: 'f').to_s.cast_to_raw_hz
@@ -789,16 +813,11 @@ module PWN
789
813
  signals_arr = []
790
814
  hz = hz_start
791
815
  while hz <= hz_target
792
- gqrx_cmd(gqrx_sock: gqrx_sock, cmd: "F #{hz}")
793
- current_freq = 0
794
- while current_freq.to_s.cast_to_raw_hz != hz.to_s.cast_to_raw_hz
795
- current_freq = gqrx_cmd(
796
- gqrx_sock: gqrx_sock,
797
- cmd: 'f'
798
- )
799
- end
800
-
801
- 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
+ )
802
821
 
803
822
  if strength_db >= strength_lock
804
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.514'
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.514
4
+ version: 0.5.515
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.