Module: PWN::SDR::Decoder::Bluetooth
- Defined in:
- lib/pwn/sdr/decoder/bluetooth.rb
Overview
True-air + detector-fallback decoder for Bluetooth. Prefers PWN::FFI I/Q (RTL-SDR / ADALM-Pluto / HackRF / capture file) via Base.run_iq; degrades to Base.run_detector with no hardware.
Defined Under Namespace
Classes: DemodIQ
Class Method Summary collapse
-
.authors ⇒ Object
- Author(s)
0day Inc.
-
.decode(opts = {}) ⇒ Object
- Supported Method Parameters
PWN::SDR::Decoder::Bluetooth.decode( freq_obj: 'required - freq_obj returned from PWN::SDR::GQRX.init_freq' ).
- .help ⇒ Object
- .parse_line(opts = {}) ⇒ Object
Class Method Details
.authors ⇒ Object
- Author(s)
0day Inc. support@0dayinc.com
126 127 128 |
# File 'lib/pwn/sdr/decoder/bluetooth.rb', line 126 public_class_method def self. "AUTHOR(S):\n 0day Inc. <support@0dayinc.com>\n" end |
.decode(opts = {}) ⇒ Object
- Supported Method Parameters
PWN::SDR::Decoder::Bluetooth.decode( freq_obj: 'required - freq_obj returned from PWN::SDR::GQRX.init_freq' )
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/pwn/sdr/decoder/bluetooth.rb', line 80 public_class_method def self.decode(opts = {}) freq_obj = opts[:freq_obj] hz = PWN::SDR.hz_to_i(freq: freq_obj[:freq]) ble = freq_obj[:ble] || freq_obj[:mode].to_s.casecmp('ble').zero? ch = ble ? ((hz - 2_402_000_000) / 2_000_000).clamp(0, 39) : ((hz - 2_402_000_000) / 1_000_000).clamp(0, 78) rate = (opts[:sample_rate] || freq_obj[:iq_rate] || 2_000_000).to_i proto = ble ? 'BLE' : 'BT-BR/EDR' demod = DemodIQ.new( rate: rate, protocol: proto, modulation: 'GFSK', extra: { threshold: 9.0 } ) PWN::SDR::Decoder::Base.run_iq( freq_obj: freq_obj, protocol: proto, sample_rate: rate, source: opts[:source], file: opts[:file], demod: demod, threshold: 9.0, note: '1 Mbit/s GFSK FHSS — true-air I/Q path reports hop-burst density per tuned channel.', describe: proc { |b| { modulation: 'GFSK', channel: begin b[:channel] rescue StandardError nil end, hop_slots: (b[:duration_ms] / 0.625).round } } ) end |
.help ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/pwn/sdr/decoder/bluetooth.rb', line 130 public_class_method def self.help puts "USAGE (true-air I/Q via PWN::FFI + detector fallback): #{self}.decode( freq_obj: 'required - freq_obj returned from PWN::SDR::GQRX.init_freq', source: 'optional - :auto|:rtlsdr|:adalm_pluto|:file', file: 'optional - .cu8/.cs16 capture' ) #{self}.authors " end |
.parse_line(opts = {}) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/pwn/sdr/decoder/bluetooth.rb', line 111 public_class_method def self.parse_line(opts = {}) line = opts[:line].to_s out = { protocol: 'Bluetooth' } out[:lap] = ::Regexp.last_match(1) if line =~ /LAP[=: ]([0-9a-fA-F]{6})/ out[:uap] = ::Regexp.last_match(1) if line =~ /UAP[=: ]([0-9a-fA-F]{2})/ out[:bd_addr] = ::Regexp.last_match(1) if line =~ /(?:AdvA|BD_ADDR)[=: ]([0-9a-fA-F:]{12,17})/ out[:pdu_type] = ::Regexp.last_match(1) if line =~ /\b(ADV_\w+|SCAN_\w+|CONNECT_REQ)\b/ out[:channel] = ::Regexp.last_match(1) if line =~ /ch[=: ]?(\d{1,2})\b/i out[:rssi] = ::Regexp.last_match(1) if line =~ /rssi[=: ]?(-?\d+)/i out[:summary] = "BT #{out.values_at(:pdu_type, :bd_addr, :lap).compact.join(' ')}".strip out.compact end |