bin/pwn_gqrx_scanner in pwn-0.5.79 vs bin/pwn_gqrx_scanner in pwn-0.5.80

- old
+ new

@@ -9,11 +9,19 @@ OptionParser.new do |options| options.banner = "USAGE: #{$PROGRAM_NAME} [opts] " - options.on('-tFREQ', '--target-freq=FREQ', '<Required - Frequency to Conclude Scanning (e.g. 900000000 == 900 mHz>') do |e| + options.on('-aPROFILE', '--assume-profile=PROFILE', '<Required if "--target-freq" is Nil - Profile to assume for common radio protocols. Use "--list-profiles" to display supported protocols (Defaults to nil)') do |p| + opts[:profile] = p + end + + options.on('-l', '--list-profiles', '<Optional - List supported profiles and exit>') do |l| + opts[:list_profiles] = l + end + + options.on('-tFREQ', '--target-freq=FREQ', '<Required if "--assume-profile" is Nil - Frequency to Conclude Scanning (e.g. 900.000.000 == 900 mHz>') do |e| opts[:target_freq] = e end options.on('-sFREQ', '--start-freq=FREQ', '<Optional - Frequency to Set when Scanning Begins (Defaults to last known frequency)>') do |s| opts[:start_freq] = s @@ -33,11 +41,11 @@ options.on('-bHZ', '--bandwidth=HZ', '<Optional - Set Bandwidth 0.0 - SDR Bandwidth Limit, e.g. 20.000.000 (Defaults to 270.000)>') do |b| opts[:bandwidth] = b end - options.on('-DMODE', '--demodulator-mode=MODE', '<Optional - Set Demodulator ModeOFF | RAW | AM | FM | WFM | WFM_ST | WFM_ST_OIRT | LSB |USB | CW | CWL | CWU (Defaults to WFM_ST)>') do |d| + options.on('-DMODE', '--demodulator-mode=MODE', '<Optional - Set Demodulator Mode OFF | RAW | AM | FM | WFM | WFM_ST | WFM_ST_OIRT | LSB | USB | CW | CWL | CWU (Defaults to WFM_ST)>') do |d| opts[:demodulator_mode] = d end options.on('-PINT', '--precision=INT', '<Optional - Precision of Frequency 1-12 (Defaults to 5)>') do |p| opts[:precision] = p @@ -75,14 +83,23 @@ begin pwn_provider = 'ruby-gem' pwn_provider = ENV.fetch('PWN_PROVIDER') if ENV.keys.any? { |s| s == 'PWN_PROVIDER' } + list_profiles = opts[:list_profiles] + if list_profiles + pp PWN::Plugins::GQRX.list_profiles + exit 0 + end + + profile = opts[:profile] + opts = PWN::Plugins::GQRX.assume_profile(profile: profile) unless profile.nil? + target_freq = opts[:target_freq] target_freq = target_freq.to_s.delete('.') unless target_freq.nil? target_freq = target_freq.to_i - raise "ERROR: Invalid target frequency #{target_freq}" if target_freq.zero? + raise 'ERROR: --assume-profile || --target-freq is required.' if target_freq.zero? && profile.nil? host = opts[:host] port = opts[:port] puts "Connecting to GQRX at #{host}:#{port}..." @@ -176,7 +193,7 @@ rescue StandardError => e raise e rescue Interrupt, SystemExit puts "\nGoodbye." ensure - gqrx_sock = PWN::Plugins::GQRX.disconnect(gqrx_sock: gqrx_sock) + gqrx_sock = PWN::Plugins::GQRX.disconnect(gqrx_sock: gqrx_sock) unless gqrx_sock.nil? end