Skip to content

Commit 500c562

Browse files
committed
pwn_gqrx_scanner Driver - implement error checks and refactor redundant blocks of xode
1 parent 242df8d commit 500c562

File tree

3 files changed

+45
-25
lines changed

3 files changed

+45
-25
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $ cd /opt/pwn
3737
$ ./install.sh
3838
$ ./install.sh ruby-gem
3939
$ pwn
40-
pwn[v0.5.50]:001 >>> PWN.help
40+
pwn[v0.5.51]:001 >>> PWN.help
4141
```
4242

4343
[![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.0@pwn
5252
$ gem uninstall --all --executables pwn
5353
$ gem install --verbose pwn
5454
$ pwn
55-
pwn[v0.5.50]:001 >>> PWN.help
55+
pwn[v0.5.51]:001 >>> PWN.help
5656
```
5757

5858
If you're using a multi-user install of RVM do:
@@ -62,7 +62,7 @@ $ rvm use ruby-3.3.0@pwn
6262
$ rvmsudo gem uninstall --all --executables pwn
6363
$ rvmsudo gem install --verbose pwn
6464
$ pwn
65-
pwn[v0.5.50]:001 >>> PWN.help
65+
pwn[v0.5.51]:001 >>> PWN.help
6666
```
6767

6868
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:

bin/pwn_gqrx_scanner

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ OptionParser.new do |options|
3030
opts[:port] = p
3131
end
3232

33-
options.on('-PPLACE', '--precision=PLACE', '<Optional - Precision of Frequency 1-9 (Defaults to 3)>') do |p|
33+
options.on('-PPLACE', '--precision=PLACE', '<Optional - Precision of Frequency 1-12 (Defaults to 3)>') do |p|
3434
opts[:precision] = p
3535
end
3636

@@ -67,37 +67,57 @@ def gqrx_cmd(opts = {})
6767
gqrx_sock.readline.chomp if does_respond
6868
end
6969

70+
def init_freq(opts = {})
71+
gqrx_sock = opts[:gqrx_sock]
72+
this_freq = opts[:this_freq]
73+
sleep_between_hops = opts[:sleep_between_hops]
74+
75+
resp = gqrx_cmd(
76+
gqrx_sock: gqrx_sock,
77+
cmd: "F #{this_freq}"
78+
)
79+
raise "ERROR: Failed to set frequency to #{this_freq}" unless resp == 'RPRT 0'
80+
81+
resp = gqrx_cmd(
82+
gqrx_sock: gqrx_sock,
83+
cmd: 'f'
84+
)
85+
86+
# Split the response from NNNNNNNNN
87+
# to NNN.NNN.NNN
88+
this_freq = resp.to_s.chars.insert(-4, '.').insert(-8, '.').join
89+
puts ">>> #{this_freq}"
90+
sleep sleep_between_hops
91+
end
92+
7093
def scan_range(opts = {})
7194
gqrx_sock = opts[:gqrx_sock]
7295
start_freq = opts[:start_freq]
7396
target_freq = opts[:target_freq]
7497
precision = opts[:precision]
75-
multiplier = 10**(precision - 1)
7698
sleep_between_hops = opts[:sleep_between_hops]
7799

100+
multiplier = 10**(precision - 1)
78101
if start_freq > target_freq
79-
start_freq.downto(target_freq) do |i|
102+
start_freq.downto(target_freq) do |this_freq|
80103
next unless (i % multiplier).zero?
81104

82-
this_freq = i
83-
gqrx_cmd(gqrx_sock: gqrx_sock, cmd: "F #{this_freq}")
84-
resp = gqrx_cmd(gqrx_sock: gqrx_sock, cmd: 'f')
85-
# Split the response from NNNNNNNNN to NNN.NNN.NNN
86-
this_freq = resp.to_s.chars.insert(-4, '.').insert(-8, '.').join
87-
puts ">>> #{this_freq}"
88-
sleep sleep_between_hops
105+
init_freq(
106+
gqrx_sock: gqrx_sock,
107+
this_freq: this_freq,
108+
sleep_between_hops: sleep_between_hops
109+
)
89110
end
90111
else
91-
while start_freq <= target_freq
92-
this_freq = start_freq
93-
gqrx_cmd(gqrx_sock: gqrx_sock, cmd: "F #{this_freq}")
94-
resp = gqrx_cmd(gqrx_sock: gqrx_sock, cmd: 'f')
95-
# Split the response from NNNNNNNNN to NNN.NNN.NNN
96-
this_freq = resp.to_s.chars.insert(-4, '.').insert(-8, '.').join
97-
puts ">>> #{this_freq}"
98-
sleep sleep_between_hops
99-
100-
start_freq += multiplier
112+
this_freq = start_freq
113+
while this_freq <= target_freq
114+
init_freq(
115+
gqrx_sock: gqrx_sock,
116+
this_freq: this_freq,
117+
sleep_between_hops: sleep_between_hops
118+
)
119+
120+
this_freq += multiplier
101121
end
102122
end
103123
end
@@ -131,7 +151,7 @@ begin
131151

132152
precision = opts[:precision] ||= 3
133153
precision = precision.to_i
134-
raise "ERROR: Invalid precision: #{precision}" unless (1..9).include?(precision)
154+
raise "ERROR: Invalid precision: #{precision}" unless (1..12).include?(precision)
135155

136156
sleep_between_hops = opts[:sleep_between_hops] ||= 0
137157
sleep_between_hops = sleep_between_hops.to_f

lib/pwn/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module PWN
4-
VERSION = '0.5.50'
4+
VERSION = '0.5.51'
55
end

0 commit comments

Comments
 (0)