Skip to content

fix(sniffer): resolve beacon channel mismatch - #2670

Merged
bmorcelli merged 3 commits into
BruceDevices:devfrom
Mysteriza:dev
Jul 20, 2026
Merged

fix(sniffer): resolve beacon channel mismatch#2670
bmorcelli merged 3 commits into
BruceDevices:devfrom
Mysteriza:dev

Conversation

@Mysteriza

Copy link
Copy Markdown
Contributor

Proposed Changes

registerBeacon() was storing the channel index (ch) rather than the actual Wi‑Fi channel number. This caused two downstream bugs:

  1. countActiveBeaconsOnChannel() and recentSsidsOnChannel() compared the stored index against a real channel number, so the check never matched – both functions effectively returned empty results.
  2. The deauth loop passed the index to wsl_bypasser_send_raw_frame(), which called esp_wifi_set_channel() with a value of 0–11 instead of a valid 1–12 channel, sending deauth frames on the wrong frequency.

The fix stores all_wifi_channels[ch] so beacon records always hold a real channel number. This automatically corrects the comparison in countActiveBeaconsOnChannel, recentSsidsOnChannel, and the deauth path.

Two other review items from Copilot were addressed in the same area:

  • The deauth loop now iterates by const auto & to avoid copying each BeaconList.
  • vTaskDelay(2 / portTICK_RATE_MS) was replaced with pdMS_TO_TICKS(2) for correctness on any tick rate.

Types of Changes

  • Bugfix

Verification

  1. Build with platformio run -e reaper (or the target board) – no warnings.
  2. Flash and run the sniffer; check that handshake capture counts are non-zero on channels with active APs.
  3. Trigger the periodic deauth and verify it deauthenticates clients on the correct channel.

Testing

Existing build pipeline only; no unit tests are currently in place for the sniffer module.

Linked Issues

PR #2667 – Copilot review comments

User-Facing Change

Fix beacon channel storage so handshake capture and deauth work on the correct channel

- Use all_wifi_channels[ch] for beacon.channel in registerBeacon
- Iterate registeredBeacons by const reference in sniffer_setup
- Compare against all_wifi_channels[ch] instead of ch
- Use pdMS_TO_TICKS(2) for the two-millisecond delay
Fix beacon channel mapping and deauth timing
@bmorcelli
bmorcelli merged commit d178989 into BruceDevices:dev Jul 20, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants