Make ubertooth-btle -v1 (CRC verify) actually filter bad-CRC packets in LE sniffing#550
Open
Oliver0804 wants to merge 2 commits into
Open
Make ubertooth-btle -v1 (CRC verify) actually filter bad-CRC packets in LE sniffing#550Oliver0804 wants to merge 2 commits into
Oliver0804 wants to merge 2 commits into
Conversation
The modern LE engine (le_phy.c, used by ubertooth-btle -n/-f) forwarded every received packet including bit-errored ones, so UBERTOOTH_SET_CRC_VERIFY had no effect there — only the legacy bt_le_sync() path (now just promiscuous mode) honoured le.crc_verify. Bit-flipped phantom advertisers leaked to the host. Verify the CRC after dewhitening and drop bad-CRC packets when le.crc_verify is set. Advertising-channel PDUs use the fixed CRCInit (reversed 0xAAAAAA); data-channel PDUs use the value recovered from CONNECT_IND. Disabled by default, so legacy behaviour is unchanged.
ubertooth-btle handled -v (do_crc) only after the streaming loop returned, so cmd_set_crc_verify ran after capture had already ended — making -v1 a silent no-op for all sniffing modes. Move the call to just before the capture loop (after mode start, since mode entry resets crc_verify).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ubertooth-btle -v1(CRC verification) is documented but is currently a silent no-op for all LE sniffing modes (-n,-f). As a result, bit-errored packets are streamed to the host and show up as "phantom" advertisers — bit-flipped copies of real advertising addresses.There are actually two independent reasons
-v1does nothing during sniffing:1. Host: CRC verify is set after the capture loop (
ubertooth-btle.c)In
main(), thedo_follow || do_no_follow || do_promiscblock runs the entirewhile (running) { cmd_poll(...) }capture loop and only returns on Ctrl-C. Thedo_crchandling that callscmd_set_crc_verify()sits after that block, so for sniffing it executes only once capture has already ended.Fix: issue
cmd_set_crc_verify()just before the capture loop — after the mode has started, since mode entry runsreset_le()which clearscrc_verify.2. Firmware: the modern LE engine never checked the CRC (
le_phy.c)-n/-fare serviced byle_phy_main()(le_phy.c), which forwarded every received packet regardless of CRC. Only the legacybt_le_sync()path (now reached only for promiscuous mode) honouredle.crc_verify.Fix: after dewhitening, compute the CRC and drop bad-CRC packets when
le.crc_verifyis set. Advertising-channel PDUs use the fixed CRCInit (reversed0xAAAAAA); data-channel PDUs use the value recovered fromCONNECT_IND. Gated onle.crc_verify, so the default behaviour is unchanged.Testing
Built host tools + firmware and flashed an Ubertooth One (was
2020-12-R1, now this branch). Captured advertising on channel 37 for 15 s with and without-v1, validating CRCs in Wireshark (btle.crc.incorrect):-n(no-v1)-n -v1With
-v1the bad-CRC packets are dropped on-device and the phantom advertisers disappear; without it, behaviour is unchanged.Notes
-v1work end-to-end for LE sniffing.-v1is passed.