forseti-rf 0.1.0a1__tar.gz

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.
Files changed (50) hide show
  1. forseti_rf-0.1.0a1/MANIFEST.in +10 -0
  2. forseti_rf-0.1.0a1/PKG-INFO +245 -0
  3. forseti_rf-0.1.0a1/README.md +219 -0
  4. forseti_rf-0.1.0a1/forseti_rf/__init__.py +10 -0
  5. forseti_rf-0.1.0a1/forseti_rf/analyze/__init__.py +1 -0
  6. forseti_rf-0.1.0a1/forseti_rf/analyze/detectors.py +1040 -0
  7. forseti_rf-0.1.0a1/forseti_rf/analyze/report.py +329 -0
  8. forseti_rf-0.1.0a1/forseti_rf/analyze/stability.py +400 -0
  9. forseti_rf-0.1.0a1/forseti_rf/bench.py +210 -0
  10. forseti_rf-0.1.0a1/forseti_rf/cfo/__init__.py +1 -0
  11. forseti_rf-0.1.0a1/forseti_rf/cfo/coarse.py +49 -0
  12. forseti_rf-0.1.0a1/forseti_rf/cfo/crb.py +30 -0
  13. forseti_rf-0.1.0a1/forseti_rf/cfo/data_aided.py +283 -0
  14. forseti_rf-0.1.0a1/forseti_rf/cfo/estimate.py +96 -0
  15. forseti_rf-0.1.0a1/forseti_rf/cli.py +447 -0
  16. forseti_rf-0.1.0a1/forseti_rf/decode.py +282 -0
  17. forseti_rf-0.1.0a1/forseti_rf/integrations/__init__.py +1 -0
  18. forseti_rf-0.1.0a1/forseti_rf/integrations/ragnar.py +191 -0
  19. forseti_rf-0.1.0a1/forseti_rf/longrun.py +190 -0
  20. forseti_rf-0.1.0a1/forseti_rf/mac/__init__.py +1 -0
  21. forseti_rf-0.1.0a1/forseti_rf/mac/beacon.py +136 -0
  22. forseti_rf-0.1.0a1/forseti_rf/mac/fcs.py +31 -0
  23. forseti_rf-0.1.0a1/forseti_rf/mac/frames.py +96 -0
  24. forseti_rf-0.1.0a1/forseti_rf/monitor.py +153 -0
  25. forseti_rf-0.1.0a1/forseti_rf/phy/__init__.py +1 -0
  26. forseti_rf-0.1.0a1/forseti_rf/phy/bits.py +51 -0
  27. forseti_rf-0.1.0a1/forseti_rf/phy/burst.py +109 -0
  28. forseti_rf-0.1.0a1/forseti_rf/phy/dsss.py +204 -0
  29. forseti_rf-0.1.0a1/forseti_rf/phy/dsss_rx.py +280 -0
  30. forseti_rf-0.1.0a1/forseti_rf/phy/ofdm.py +257 -0
  31. forseti_rf-0.1.0a1/forseti_rf/phy/ofdm_rx.py +357 -0
  32. forseti_rf-0.1.0a1/forseti_rf/phy/pulse.py +99 -0
  33. forseti_rf-0.1.0a1/forseti_rf/sdr/__init__.py +1 -0
  34. forseti_rf-0.1.0a1/forseti_rf/sdr/capture.py +211 -0
  35. forseti_rf-0.1.0a1/forseti_rf/sdr/iqcal.py +68 -0
  36. forseti_rf-0.1.0a1/forseti_rf/sdr/sigmf_io.py +183 -0
  37. forseti_rf-0.1.0a1/forseti_rf/store/__init__.py +1 -0
  38. forseti_rf-0.1.0a1/forseti_rf/store/db.py +151 -0
  39. forseti_rf-0.1.0a1/forseti_rf/synth/__init__.py +1 -0
  40. forseti_rf-0.1.0a1/forseti_rf/synth/generator.py +245 -0
  41. forseti_rf-0.1.0a1/forseti_rf/synth/impairments.py +48 -0
  42. forseti_rf-0.1.0a1/forseti_rf/units.py +51 -0
  43. forseti_rf-0.1.0a1/forseti_rf.egg-info/PKG-INFO +245 -0
  44. forseti_rf-0.1.0a1/forseti_rf.egg-info/SOURCES.txt +48 -0
  45. forseti_rf-0.1.0a1/forseti_rf.egg-info/dependency_links.txt +1 -0
  46. forseti_rf-0.1.0a1/forseti_rf.egg-info/entry_points.txt +2 -0
  47. forseti_rf-0.1.0a1/forseti_rf.egg-info/requires.txt +11 -0
  48. forseti_rf-0.1.0a1/forseti_rf.egg-info/top_level.txt +1 -0
  49. forseti_rf-0.1.0a1/pyproject.toml +51 -0
  50. forseti_rf-0.1.0a1/setup.cfg +4 -0
@@ -0,0 +1,10 @@
1
+ # The PyPI package carries the code and the README only: no recordings, results, notes or tests
2
+ # (tests and notes name the networks they were recorded on).
3
+ prune tests
4
+ prune scripts
5
+ prune captures
6
+ prune results
7
+ prune docs
8
+ prune .github
9
+ exclude SPEC.md RESULTS.md CLAUDE.md
10
+ global-exclude *.db *.sigmf-data *.sigmf-meta *.png __pycache__ *.py[cod]
@@ -0,0 +1,245 @@
1
+ Metadata-Version: 2.4
2
+ Name: forseti-rf
3
+ Version: 0.1.0a1
4
+ Summary: Passive Wi-Fi transmitter fingerprinting by carrier frequency offset. You can clone a MAC, but not a crystal.
5
+ Author: PierreGode
6
+ Project-URL: Homepage, https://pierregode.github.io/Forseti/
7
+ Keywords: wifi,evil twin,wids,sdr,hackrf,rf fingerprinting,carrier frequency offset
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Information Technology
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Security
14
+ Classifier: Topic :: System :: Networking :: Monitoring
15
+ Requires-Python: >=3.11
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: numpy>=1.26
18
+ Requires-Dist: scipy>=1.11
19
+ Requires-Dist: typer>=0.12
20
+ Requires-Dist: sigmf>=1.2
21
+ Provides-Extra: plot
22
+ Requires-Dist: matplotlib>=3.8; extra == "plot"
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=8; extra == "dev"
25
+ Requires-Dist: matplotlib>=3.8; extra == "dev"
26
+
27
+ # Forseti (forseti-rf)
28
+
29
+ you can clone a MAC, but not a crystal
30
+
31
+ forseti-rf identifies Wi-Fi transmitters by their **analog hardware fingerprint**,
32
+ mainly **carrier frequency offset (CFO)**, instead of by MAC, BSSID or SSID. An
33
+ attacker controls those identifiers but can't control their oscillator's error.
34
+ The main target is the evil twin that clones a legitimate AP's SSID *and* BSSID:
35
+ identifier-based tools see one AP, while forseti-rf sees two radios. Its
36
+ verdicts are meant to feed Ragnar's WIDS as physics-level evidence.
37
+
38
+ It is passive. It never transmits. It only parses beacon and probe-response
39
+ management headers, and it doesn't track client devices.
40
+
41
+ `SPEC.md` has the full plan and `RESULTS.md` the measurements.
42
+
43
+ ## Status
44
+
45
+ **Phase 0 is done. Phase 1: the decoder works on real HackRF captures and
46
+ passes the monitor-mode validation for the home AP (95.0 % raw, 99.7 %
47
+ excluding recording gaps). The Pineapple and ESP32 recon are still to do.**
48
+
49
+ | Phase | What | State |
50
+ |---|---|---|
51
+ | 0 | 802.11b synthesizer, CRC/scrambler test vectors, coarse + data-aided CFO, SCO, CRB benchmark | done |
52
+ | 1 | HackRF capture, burst detection, DSSS decoder validated against monitor mode | validated for the home AP; Pineapple/ESP32 recon pending |
53
+ | 2 | Drift removal, stability study, detectors D1-D6, verdicts | done: 10-min short run, a ~6 h overnight run and a 7.6 h daytime run (instead of 24 h). D1 floor holds; D3 redesigned after the long run (tracking reference; CFO alone is only "possible"); D5 added (your network's name from a radio you haven't enrolled); after the daytime run D1 counts only two-radio switches, D2 alone can be "likely", D6 flags a TSF timeline break, and verdicts carry "bare board" hints; MAC-layer tells name a fake TSF and check that one radio's BSSIDs share a sequence counter; a hand-held ESP32 moved 381 ppb in 110 s; a HaleHound on charge drifted up to 218 ppb/min, now a "drift" hint; a pretend twin built from Pierre's ESP32 was caught at every start time, see RESULTS.md |
54
+ | 3 | Twin experiments E1-E6 (Pierre runs the transmitters, Forseti only receives) | E1, E2, E3 detected (E1 confirmed in 81 s; a twin on another band confirmed with two TSF counters running at once); E6 done: 24.9 h without an attack, 0 likely or confirmed; E4 (Pineapple) still to do. RESULTS.md Findings 36-55, `docs/phase3.md` |
55
+ | 4 | Live mode | not started |
56
+ | 5 | Ragnar integration | not started |
57
+ | 6 | Research spikes (OFDM, extra features, ESP32 CSI) | R1 OFDM receiver built (5 GHz and OFDM beacons on 2.4 GHz), tested on synthetic beacons; real 5 GHz captures next |
58
+
59
+ ## Install
60
+
61
+ ```bash
62
+ python3 -m venv .venv && . .venv/bin/activate
63
+ pip install -e ".[dev]" # numpy, scipy, typer, sigmf, pytest, matplotlib
64
+ pytest -q
65
+ ```
66
+
67
+ From PyPI: `pip install forseti-rf` (alpha; the `forseti` command). Capture runs `hackrf_transfer`,
68
+ from the distro's `hackrf` package. Streaming (Phase 4) will need SoapySDR, which isn't on PyPI: then
69
+ install the distro's `python3-soapysdr` and `soapysdr-module-hackrf` and create the venv with
70
+ `--system-site-packages`.
71
+
72
+ ## Commands
73
+
74
+ ```bash
75
+ # Synthetic 802.11b beacons with known impairments -> SigMF + ground truth JSON
76
+ forseti synth out/demo --count 3 --cfo-ppm 12.5 --snr-db 15 --tap 50:0.2+0.1j --dc 2+1j --seed 7
77
+
78
+ # Estimate CFO/SCO per burst and compare with the ground truth (Phase 0: uses truth for bits + timing)
79
+ forseti estimate out/demo.sigmf-meta
80
+
81
+ # Phase 0 acceptance benchmark: RMS CFO error vs SNR and frame length vs the Cramer-Rao bound
82
+ forseti bench-cfo --scenario awgn # writes results/phase0_cfo_awgn.{md,json,png}
83
+ forseti bench-cfo --scenario impaired # + multipath, DC offset, IQ imbalance
84
+
85
+ # Receive-only HackRF capture (16 Msps by default: 20 Msps drops samples on a Pi 5, see RESULTS.md)
86
+ forseti capture captures/ch4 --channel 4 --seconds 10 --lna 16 --vga 20
87
+
88
+ # Decode 802.11b beacons/probe responses + CFO/SCO into SQLite, with a per-BSSID summary
89
+ forseti decode captures/ch4 --db forseti.db # --phy auto: OFDM on 5 GHz channels (36, 40, ...)
90
+
91
+ # Phase 2: survey, duty-cycled recording, analysis, enrollment
92
+ forseti survey --channels 1-13 --seconds 3 --db forseti.db
93
+ forseti record --channel 4 --segment 2 --period 60 --hours 24 --db forseti.db
94
+ forseti analyze --db forseti.db --out results/analysis # --drift auto|on|off, --window, --d1-window
95
+ forseti enroll --bssid aa:bb:cc:dd:ee:ff --name "home AP" --db forseti.db
96
+ # Enroll every AP of yours, including ones that share a name: D5 reports your network's
97
+ # name sent from any radio you haven't enrolled.
98
+
99
+ # Continuous receive-only recording over a channel rotation (what Ragnar runs; JSON lines on stdout)
100
+ forseti monitor --channels 1,6,11,36 --db forseti.db --keep-hours 24 # --serial with two HackRFs
101
+
102
+ # Phase 5: verdicts as events for Ragnar's WIDS (JSONL, optionally HTTP POST). Forseti never acts itself.
103
+ forseti events --db forseti.db --jsonl /var/log/ragnar/forseti.jsonl # Ragnar's Watchtower tails this
104
+ forseti events --db forseti.db --analyze --every 300 # re-run the detectors every 5 min until live mode exists
105
+
106
+ # Placeholder, Phase 4
107
+ forseti live
108
+ ```
109
+
110
+ ### Events for Ragnar
111
+
112
+ One JSON object per verdict, appended to the JSONL file and, with `--url`, POSTed (optional bearer
113
+ token from `--token` or `FORSETI_RAGNAR_TOKEN`):
114
+
115
+ ```json
116
+ {"source": "forseti-rf", "schema": 1, "version": "0.1.0a1", "id": "3f0c9a1e5b7d2c44", "type": "new",
117
+ "ts": "2026-12-01T22:15:15Z", "first_seen": "2026-12-01T22:00:23Z", "level": "confirmed",
118
+ "severity": "critical", "module": "forseti", "detector": "D1+TSF-timelines", "target": "aa:bb:cc:dd:ee:ff",
119
+ "bssid": "aa:bb:cc:dd:ee:ff", "ssid": "homenet", "channels": [10, 36],
120
+ "summary": "confirmed D1+TSF-timelines ...: two TSF counters running at once (141/141 capture pairs ...)",
121
+ "evidence": {"D1": {"clusters": ["..."]}, "d2": {}, "tsf_model": {}}}
122
+ ```
123
+
124
+ - `severity` (possible → medium, likely → high, confirmed → critical) and `target` (the BSSID) are the
125
+ fields Ragnar's Watchtower ranks and de-duplicates on; it picks up any `*.jsonl` in `/var/log/ragnar`.
126
+ - `id` stays the same for one episode at one level, so Ragnar can de-duplicate. An episode that
127
+ escalates (likely → confirmed) is a new event; one that keeps going is an `"update"` at most every
128
+ 10 minutes.
129
+ - Already-sent events are remembered in `<jsonl>.state.json`. A POST that fails is retried on the next
130
+ run.
131
+ - Ragnar should keep "likely" and "confirmed" alerts until someone acknowledges them: a twin that
132
+ replaces an AP becomes the AP's own history after about 20 minutes (SPEC section 10).
133
+
134
+ ## Limitations
135
+
136
+ What follows is measured, unless it says otherwise. Each claim has its experiment in `RESULTS.md`.
137
+ Anything without one is unproven.
138
+
139
+ **What Forseti sees**
140
+
141
+ - **PHY formats.**
142
+ - **802.11b DSSS** (long preamble, 1 Mbit/s) is validated against a monitor-mode adapter.
143
+ - **802.11a/g legacy OFDM** covers 5 GHz, plus 2.4 GHz APs that beacon in OFDM. It decodes real
144
+ 5 GHz beacons with a valid FCS, but hasn't yet been checked against a monitor-mode adapter.
145
+ - Beacons faster than 18 Mbit/s (16/64-QAM) depend on an interleaver detail that is still
146
+ unverified.
147
+ - 802.11n/ac/ax frames are skipped; APs send their beacons in the legacy format. 6 GHz Wi-Fi is not
148
+ covered (the HackRF stops at 6 GHz).
149
+ - **Channels.** One HackRF hears one channel at a time, so Forseti rotates over the channels it is
150
+ given. A twin on a channel outside the rotation is invisible. With 8 channels at a 2 s capture every
151
+ 25 s, each channel is revisited about every 3 minutes, which bounds the detection time. Continuous
152
+ hopping (live mode, Phase 4) isn't built.
153
+ - **5 GHz reception.** 5 GHz needs more gain (LNA 24, VGA 24). At home only one 5 GHz AP was
154
+ receivable, at about 9 dB SNR. The HackRF's 5 GHz tuning offset isn't modelled. It is the same for
155
+ every radio on a channel, and CFO matched SCO within 0.03 ± 0.3 ppm.
156
+ - **Capture on the AP's own channel.** An 802.11b AP leaks into neighbouring channels with a wrong
157
+ CFO. Frames whose advertised channel differs from the capture's are dropped (DS Parameter Set, or
158
+ the HT Operation primary channel on 5 GHz).
159
+
160
+ **What is caught, and how far it goes**
161
+
162
+ - **A twin on the air with the AP** is **confirmed**:
163
+ - on the same channel by two crystals and two TSF counters in one capture (D1+D2; E1: confirmed in
164
+ 81 s);
165
+ - on another channel or band by two crystals and two TSF counters running at the same time (D1 +
166
+ TSF timelines; an idle home AP copied onto 5 GHz: likely in 30 s, then confirmed).
167
+ - **A twin that replaces the AP** (the AP off) stops at **"likely"**:
168
+ - The evidence is a different crystal plus a counter that breaks the AP's TSF timeline (D3 + TSF
169
+ timeline, or D6).
170
+ - Confirming needs both radios alive. A restarted router looks similar for a few minutes: the idle AP
171
+ came back 6.5 ppm off with a fresh counter.
172
+ - After about 20–40 minutes the twin becomes D3's own reference, so a "likely" or "confirmed" alert
173
+ has to stay in Ragnar until someone acknowledges it (SPEC 10).
174
+ - **Close crystals.** D1 can't separate radios closer than 100 ppb: a fixed AP split 82 ppb inside
175
+ captures, so 50 or 30 ppb would false-alarm. A random crystal lands that close about 1 time in 250.
176
+ Such a twin is still caught by its TSF counter (D2, D6, two counters at once), **unless it also
177
+ copies the AP's TSF timeline**, with a TSF rate that matches its own CFO. Then it stays "possible".
178
+ - **Counters that coincide.** Two radios whose counters started within 0.5 s look like one counter to
179
+ the TSF checks. In E2 two counters started 24 ms apart, cause unexplained. Only D1 ("likely") sees
180
+ such a twin.
181
+ - **SDR-equipped attackers** can tune their carrier to the target's CFO. CFO alone doesn't stop them.
182
+ Phase 6 explores extra features (IQ imbalance, turn-on transient, PA nonlinearity), aimed at
183
+ commodity attack hardware (Pineapple, ESP32 tools, hostapd laptops).
184
+ - **Names.**
185
+ - D5 flags your network's name from a radio that isn't yours, look-alikes included: letter case,
186
+ spacing, 0/O, 1/l/I.
187
+ - A name that only starts like yours ("homenet-guest" for "homenet") is not flagged.
188
+ - An open captive portal under its own name isn't a twin, and is left to Ragnar's own checks.
189
+
190
+ **Legitimate APs move, so D3 alone only says "possible"**
191
+
192
+ - **Measured on real APs:**
193
+ - day/night shifts of 38–270 ppb;
194
+ - a one-time step of +250 ppb without a restart;
195
+ - kicks of 0.2–1.1 ppm lasting minutes;
196
+ - a neighbour's router swinging 2.7 ppm in 20 minutes without a restart;
197
+ - after a restart, +6.5 ppm at power-on, settling 100–135 ppb away from the old value.
198
+ - **Busy routers move more** when people are home. The AP that nothing uses stayed within
199
+ 25–62 ppb per recording.
200
+ - **How D3 copes:** it compares with the AP's own median from 40 to 10 minutes earlier, at 0.1 ppm.
201
+ Before that history exists it compares with the enrolled value, at 0.25 ppm. Re-enrol an AP after it
202
+ restarts.
203
+ - **False alarms:** 24.9 h without an attack (E6), with the home APs enrolled, gave 9 "possible" (6 real
204
+ moves of the APs' own crystals, 3 restarts of a test board) and **no "likely" or "confirmed"**.
205
+
206
+ **Hints ("behaves like a bare board") are weak and never change a level**
207
+
208
+ - **The within-frame shift is an 802.11b measurement.** It read −150 … −190 Hz on two ESP32 boards
209
+ (a dev board and the CYD that also runs HaleHound) and about 0 on APs. But one ESP32 read −71 Hz after it was moved, and a Flipper devboard read +5 Hz.
210
+ - **The drift hint fires at 150 ppb/min.** It catches a handheld in its first minutes on charge (the
211
+ HaleHound, 218) and misses a settled one. A fixed AP has reached 107.
212
+
213
+ **Receiver and Pi**
214
+
215
+ - **The HackRF:** its 8-bit ADC clips near a strong AP, and its oscillator has no temperature control.
216
+ It moved ≤ ~3 ppb over 5 h after its first hour, steadier than every AP but one. `analyze --drift
217
+ auto` removes receiver drift only when it is plausibly the receiver's, not the anchors' wander.
218
+ - **The Pi 5:** at 20 Msps it loses about 1.4 % of samples to USB overruns, so captures default to
219
+ 16 Msps. Decoding runs about 10× slower than real time; the recorder decodes in the background and
220
+ skips captures it can't keep up with. The test Pi's supply shows frequent under-voltage.
221
+ - **CFO is not an ID on its own.** Two neighbours' radios sat 62–65 ppb apart. Verdicts lean on
222
+ sequence numbers, TSF continuity and the TSF clock rate.
223
+
224
+ ## Layout
225
+
226
+ ```
227
+ forseti_rf/
228
+ phy/ bits.py, dsss.py (802.11b constants, scrambler, CRC-16, PLCP, DBPSK), pulse.py,
229
+ burst.py (energy detector), dsss_rx.py (SFD scan, blind timing, DBPSK receiver),
230
+ ofdm.py, ofdm_rx.py (802.11a/g OFDM: 5 GHz and OFDM beacons; data-aided CFO/SCO)
231
+ analyze/ stability.py, detectors.py (D1-D6, hints, MAC-layer tells), report.py
232
+ mac/ fcs.py (CRC-32), beacon.py (builder), frames.py (beacon/probe-response parser only)
233
+ store/ db.py (SQLite: captures, frames, devices, verdicts)
234
+ decode.py recording -> front-end cal -> channel filter -> bursts -> decode -> CFO -> DB
235
+ synth/ generator.py (PPDU -> IQ with CFO/SCO/multipath), impairments.py (noise, DC, IQ, 8-bit ADC)
236
+ cfo/ coarse.py (squaring), data_aided.py (timing/SCO + fine CFO), crb.py, estimate.py
237
+ sdr/ sigmf_io.py, capture.py (hackrf_transfer, receive only), iqcal.py (DC + IQ from noise floor)
238
+ bench.py Phase 0 benchmark
239
+ cli.py `forseti` entry point
240
+ tests/ test vectors (IEEE), Wireshark cross-check, estimator truth tests
241
+ results/ benchmark tables and plots
242
+ ```
243
+
244
+ The name lives in three places: `forseti_rf/__init__.py`, `pyproject.toml` and
245
+ this README.
@@ -0,0 +1,219 @@
1
+ # Forseti (forseti-rf)
2
+
3
+ you can clone a MAC, but not a crystal
4
+
5
+ forseti-rf identifies Wi-Fi transmitters by their **analog hardware fingerprint**,
6
+ mainly **carrier frequency offset (CFO)**, instead of by MAC, BSSID or SSID. An
7
+ attacker controls those identifiers but can't control their oscillator's error.
8
+ The main target is the evil twin that clones a legitimate AP's SSID *and* BSSID:
9
+ identifier-based tools see one AP, while forseti-rf sees two radios. Its
10
+ verdicts are meant to feed Ragnar's WIDS as physics-level evidence.
11
+
12
+ It is passive. It never transmits. It only parses beacon and probe-response
13
+ management headers, and it doesn't track client devices.
14
+
15
+ `SPEC.md` has the full plan and `RESULTS.md` the measurements.
16
+
17
+ ## Status
18
+
19
+ **Phase 0 is done. Phase 1: the decoder works on real HackRF captures and
20
+ passes the monitor-mode validation for the home AP (95.0 % raw, 99.7 %
21
+ excluding recording gaps). The Pineapple and ESP32 recon are still to do.**
22
+
23
+ | Phase | What | State |
24
+ |---|---|---|
25
+ | 0 | 802.11b synthesizer, CRC/scrambler test vectors, coarse + data-aided CFO, SCO, CRB benchmark | done |
26
+ | 1 | HackRF capture, burst detection, DSSS decoder validated against monitor mode | validated for the home AP; Pineapple/ESP32 recon pending |
27
+ | 2 | Drift removal, stability study, detectors D1-D6, verdicts | done: 10-min short run, a ~6 h overnight run and a 7.6 h daytime run (instead of 24 h). D1 floor holds; D3 redesigned after the long run (tracking reference; CFO alone is only "possible"); D5 added (your network's name from a radio you haven't enrolled); after the daytime run D1 counts only two-radio switches, D2 alone can be "likely", D6 flags a TSF timeline break, and verdicts carry "bare board" hints; MAC-layer tells name a fake TSF and check that one radio's BSSIDs share a sequence counter; a hand-held ESP32 moved 381 ppb in 110 s; a HaleHound on charge drifted up to 218 ppb/min, now a "drift" hint; a pretend twin built from Pierre's ESP32 was caught at every start time, see RESULTS.md |
28
+ | 3 | Twin experiments E1-E6 (Pierre runs the transmitters, Forseti only receives) | E1, E2, E3 detected (E1 confirmed in 81 s; a twin on another band confirmed with two TSF counters running at once); E6 done: 24.9 h without an attack, 0 likely or confirmed; E4 (Pineapple) still to do. RESULTS.md Findings 36-55, `docs/phase3.md` |
29
+ | 4 | Live mode | not started |
30
+ | 5 | Ragnar integration | not started |
31
+ | 6 | Research spikes (OFDM, extra features, ESP32 CSI) | R1 OFDM receiver built (5 GHz and OFDM beacons on 2.4 GHz), tested on synthetic beacons; real 5 GHz captures next |
32
+
33
+ ## Install
34
+
35
+ ```bash
36
+ python3 -m venv .venv && . .venv/bin/activate
37
+ pip install -e ".[dev]" # numpy, scipy, typer, sigmf, pytest, matplotlib
38
+ pytest -q
39
+ ```
40
+
41
+ From PyPI: `pip install forseti-rf` (alpha; the `forseti` command). Capture runs `hackrf_transfer`,
42
+ from the distro's `hackrf` package. Streaming (Phase 4) will need SoapySDR, which isn't on PyPI: then
43
+ install the distro's `python3-soapysdr` and `soapysdr-module-hackrf` and create the venv with
44
+ `--system-site-packages`.
45
+
46
+ ## Commands
47
+
48
+ ```bash
49
+ # Synthetic 802.11b beacons with known impairments -> SigMF + ground truth JSON
50
+ forseti synth out/demo --count 3 --cfo-ppm 12.5 --snr-db 15 --tap 50:0.2+0.1j --dc 2+1j --seed 7
51
+
52
+ # Estimate CFO/SCO per burst and compare with the ground truth (Phase 0: uses truth for bits + timing)
53
+ forseti estimate out/demo.sigmf-meta
54
+
55
+ # Phase 0 acceptance benchmark: RMS CFO error vs SNR and frame length vs the Cramer-Rao bound
56
+ forseti bench-cfo --scenario awgn # writes results/phase0_cfo_awgn.{md,json,png}
57
+ forseti bench-cfo --scenario impaired # + multipath, DC offset, IQ imbalance
58
+
59
+ # Receive-only HackRF capture (16 Msps by default: 20 Msps drops samples on a Pi 5, see RESULTS.md)
60
+ forseti capture captures/ch4 --channel 4 --seconds 10 --lna 16 --vga 20
61
+
62
+ # Decode 802.11b beacons/probe responses + CFO/SCO into SQLite, with a per-BSSID summary
63
+ forseti decode captures/ch4 --db forseti.db # --phy auto: OFDM on 5 GHz channels (36, 40, ...)
64
+
65
+ # Phase 2: survey, duty-cycled recording, analysis, enrollment
66
+ forseti survey --channels 1-13 --seconds 3 --db forseti.db
67
+ forseti record --channel 4 --segment 2 --period 60 --hours 24 --db forseti.db
68
+ forseti analyze --db forseti.db --out results/analysis # --drift auto|on|off, --window, --d1-window
69
+ forseti enroll --bssid aa:bb:cc:dd:ee:ff --name "home AP" --db forseti.db
70
+ # Enroll every AP of yours, including ones that share a name: D5 reports your network's
71
+ # name sent from any radio you haven't enrolled.
72
+
73
+ # Continuous receive-only recording over a channel rotation (what Ragnar runs; JSON lines on stdout)
74
+ forseti monitor --channels 1,6,11,36 --db forseti.db --keep-hours 24 # --serial with two HackRFs
75
+
76
+ # Phase 5: verdicts as events for Ragnar's WIDS (JSONL, optionally HTTP POST). Forseti never acts itself.
77
+ forseti events --db forseti.db --jsonl /var/log/ragnar/forseti.jsonl # Ragnar's Watchtower tails this
78
+ forseti events --db forseti.db --analyze --every 300 # re-run the detectors every 5 min until live mode exists
79
+
80
+ # Placeholder, Phase 4
81
+ forseti live
82
+ ```
83
+
84
+ ### Events for Ragnar
85
+
86
+ One JSON object per verdict, appended to the JSONL file and, with `--url`, POSTed (optional bearer
87
+ token from `--token` or `FORSETI_RAGNAR_TOKEN`):
88
+
89
+ ```json
90
+ {"source": "forseti-rf", "schema": 1, "version": "0.1.0a1", "id": "3f0c9a1e5b7d2c44", "type": "new",
91
+ "ts": "2026-12-01T22:15:15Z", "first_seen": "2026-12-01T22:00:23Z", "level": "confirmed",
92
+ "severity": "critical", "module": "forseti", "detector": "D1+TSF-timelines", "target": "aa:bb:cc:dd:ee:ff",
93
+ "bssid": "aa:bb:cc:dd:ee:ff", "ssid": "homenet", "channels": [10, 36],
94
+ "summary": "confirmed D1+TSF-timelines ...: two TSF counters running at once (141/141 capture pairs ...)",
95
+ "evidence": {"D1": {"clusters": ["..."]}, "d2": {}, "tsf_model": {}}}
96
+ ```
97
+
98
+ - `severity` (possible → medium, likely → high, confirmed → critical) and `target` (the BSSID) are the
99
+ fields Ragnar's Watchtower ranks and de-duplicates on; it picks up any `*.jsonl` in `/var/log/ragnar`.
100
+ - `id` stays the same for one episode at one level, so Ragnar can de-duplicate. An episode that
101
+ escalates (likely → confirmed) is a new event; one that keeps going is an `"update"` at most every
102
+ 10 minutes.
103
+ - Already-sent events are remembered in `<jsonl>.state.json`. A POST that fails is retried on the next
104
+ run.
105
+ - Ragnar should keep "likely" and "confirmed" alerts until someone acknowledges them: a twin that
106
+ replaces an AP becomes the AP's own history after about 20 minutes (SPEC section 10).
107
+
108
+ ## Limitations
109
+
110
+ What follows is measured, unless it says otherwise. Each claim has its experiment in `RESULTS.md`.
111
+ Anything without one is unproven.
112
+
113
+ **What Forseti sees**
114
+
115
+ - **PHY formats.**
116
+ - **802.11b DSSS** (long preamble, 1 Mbit/s) is validated against a monitor-mode adapter.
117
+ - **802.11a/g legacy OFDM** covers 5 GHz, plus 2.4 GHz APs that beacon in OFDM. It decodes real
118
+ 5 GHz beacons with a valid FCS, but hasn't yet been checked against a monitor-mode adapter.
119
+ - Beacons faster than 18 Mbit/s (16/64-QAM) depend on an interleaver detail that is still
120
+ unverified.
121
+ - 802.11n/ac/ax frames are skipped; APs send their beacons in the legacy format. 6 GHz Wi-Fi is not
122
+ covered (the HackRF stops at 6 GHz).
123
+ - **Channels.** One HackRF hears one channel at a time, so Forseti rotates over the channels it is
124
+ given. A twin on a channel outside the rotation is invisible. With 8 channels at a 2 s capture every
125
+ 25 s, each channel is revisited about every 3 minutes, which bounds the detection time. Continuous
126
+ hopping (live mode, Phase 4) isn't built.
127
+ - **5 GHz reception.** 5 GHz needs more gain (LNA 24, VGA 24). At home only one 5 GHz AP was
128
+ receivable, at about 9 dB SNR. The HackRF's 5 GHz tuning offset isn't modelled. It is the same for
129
+ every radio on a channel, and CFO matched SCO within 0.03 ± 0.3 ppm.
130
+ - **Capture on the AP's own channel.** An 802.11b AP leaks into neighbouring channels with a wrong
131
+ CFO. Frames whose advertised channel differs from the capture's are dropped (DS Parameter Set, or
132
+ the HT Operation primary channel on 5 GHz).
133
+
134
+ **What is caught, and how far it goes**
135
+
136
+ - **A twin on the air with the AP** is **confirmed**:
137
+ - on the same channel by two crystals and two TSF counters in one capture (D1+D2; E1: confirmed in
138
+ 81 s);
139
+ - on another channel or band by two crystals and two TSF counters running at the same time (D1 +
140
+ TSF timelines; an idle home AP copied onto 5 GHz: likely in 30 s, then confirmed).
141
+ - **A twin that replaces the AP** (the AP off) stops at **"likely"**:
142
+ - The evidence is a different crystal plus a counter that breaks the AP's TSF timeline (D3 + TSF
143
+ timeline, or D6).
144
+ - Confirming needs both radios alive. A restarted router looks similar for a few minutes: the idle AP
145
+ came back 6.5 ppm off with a fresh counter.
146
+ - After about 20–40 minutes the twin becomes D3's own reference, so a "likely" or "confirmed" alert
147
+ has to stay in Ragnar until someone acknowledges it (SPEC 10).
148
+ - **Close crystals.** D1 can't separate radios closer than 100 ppb: a fixed AP split 82 ppb inside
149
+ captures, so 50 or 30 ppb would false-alarm. A random crystal lands that close about 1 time in 250.
150
+ Such a twin is still caught by its TSF counter (D2, D6, two counters at once), **unless it also
151
+ copies the AP's TSF timeline**, with a TSF rate that matches its own CFO. Then it stays "possible".
152
+ - **Counters that coincide.** Two radios whose counters started within 0.5 s look like one counter to
153
+ the TSF checks. In E2 two counters started 24 ms apart, cause unexplained. Only D1 ("likely") sees
154
+ such a twin.
155
+ - **SDR-equipped attackers** can tune their carrier to the target's CFO. CFO alone doesn't stop them.
156
+ Phase 6 explores extra features (IQ imbalance, turn-on transient, PA nonlinearity), aimed at
157
+ commodity attack hardware (Pineapple, ESP32 tools, hostapd laptops).
158
+ - **Names.**
159
+ - D5 flags your network's name from a radio that isn't yours, look-alikes included: letter case,
160
+ spacing, 0/O, 1/l/I.
161
+ - A name that only starts like yours ("homenet-guest" for "homenet") is not flagged.
162
+ - An open captive portal under its own name isn't a twin, and is left to Ragnar's own checks.
163
+
164
+ **Legitimate APs move, so D3 alone only says "possible"**
165
+
166
+ - **Measured on real APs:**
167
+ - day/night shifts of 38–270 ppb;
168
+ - a one-time step of +250 ppb without a restart;
169
+ - kicks of 0.2–1.1 ppm lasting minutes;
170
+ - a neighbour's router swinging 2.7 ppm in 20 minutes without a restart;
171
+ - after a restart, +6.5 ppm at power-on, settling 100–135 ppb away from the old value.
172
+ - **Busy routers move more** when people are home. The AP that nothing uses stayed within
173
+ 25–62 ppb per recording.
174
+ - **How D3 copes:** it compares with the AP's own median from 40 to 10 minutes earlier, at 0.1 ppm.
175
+ Before that history exists it compares with the enrolled value, at 0.25 ppm. Re-enrol an AP after it
176
+ restarts.
177
+ - **False alarms:** 24.9 h without an attack (E6), with the home APs enrolled, gave 9 "possible" (6 real
178
+ moves of the APs' own crystals, 3 restarts of a test board) and **no "likely" or "confirmed"**.
179
+
180
+ **Hints ("behaves like a bare board") are weak and never change a level**
181
+
182
+ - **The within-frame shift is an 802.11b measurement.** It read −150 … −190 Hz on two ESP32 boards
183
+ (a dev board and the CYD that also runs HaleHound) and about 0 on APs. But one ESP32 read −71 Hz after it was moved, and a Flipper devboard read +5 Hz.
184
+ - **The drift hint fires at 150 ppb/min.** It catches a handheld in its first minutes on charge (the
185
+ HaleHound, 218) and misses a settled one. A fixed AP has reached 107.
186
+
187
+ **Receiver and Pi**
188
+
189
+ - **The HackRF:** its 8-bit ADC clips near a strong AP, and its oscillator has no temperature control.
190
+ It moved ≤ ~3 ppb over 5 h after its first hour, steadier than every AP but one. `analyze --drift
191
+ auto` removes receiver drift only when it is plausibly the receiver's, not the anchors' wander.
192
+ - **The Pi 5:** at 20 Msps it loses about 1.4 % of samples to USB overruns, so captures default to
193
+ 16 Msps. Decoding runs about 10× slower than real time; the recorder decodes in the background and
194
+ skips captures it can't keep up with. The test Pi's supply shows frequent under-voltage.
195
+ - **CFO is not an ID on its own.** Two neighbours' radios sat 62–65 ppb apart. Verdicts lean on
196
+ sequence numbers, TSF continuity and the TSF clock rate.
197
+
198
+ ## Layout
199
+
200
+ ```
201
+ forseti_rf/
202
+ phy/ bits.py, dsss.py (802.11b constants, scrambler, CRC-16, PLCP, DBPSK), pulse.py,
203
+ burst.py (energy detector), dsss_rx.py (SFD scan, blind timing, DBPSK receiver),
204
+ ofdm.py, ofdm_rx.py (802.11a/g OFDM: 5 GHz and OFDM beacons; data-aided CFO/SCO)
205
+ analyze/ stability.py, detectors.py (D1-D6, hints, MAC-layer tells), report.py
206
+ mac/ fcs.py (CRC-32), beacon.py (builder), frames.py (beacon/probe-response parser only)
207
+ store/ db.py (SQLite: captures, frames, devices, verdicts)
208
+ decode.py recording -> front-end cal -> channel filter -> bursts -> decode -> CFO -> DB
209
+ synth/ generator.py (PPDU -> IQ with CFO/SCO/multipath), impairments.py (noise, DC, IQ, 8-bit ADC)
210
+ cfo/ coarse.py (squaring), data_aided.py (timing/SCO + fine CFO), crb.py, estimate.py
211
+ sdr/ sigmf_io.py, capture.py (hackrf_transfer, receive only), iqcal.py (DC + IQ from noise floor)
212
+ bench.py Phase 0 benchmark
213
+ cli.py `forseti` entry point
214
+ tests/ test vectors (IEEE), Wireshark cross-check, estimator truth tests
215
+ results/ benchmark tables and plots
216
+ ```
217
+
218
+ The name lives in three places: `forseti_rf/__init__.py`, `pyproject.toml` and
219
+ this README.
@@ -0,0 +1,10 @@
1
+ """forseti-rf: identify Wi-Fi transmitters by their oscillator, not their MAC.
2
+
3
+ You can clone a MAC, but not a crystal.
4
+
5
+ The project name lives here, in ``pyproject.toml`` and in the README, so a
6
+ rename only touches those three places.
7
+ """
8
+
9
+ NAME = "forseti-rf"
10
+ __version__ = "0.1.0a1"
@@ -0,0 +1 @@
1
+ """Drift removal, stability statistics, detectors and verdicts (Phase 2)."""