The invention provides a state-aware lightweight
Bluetooth security framework, which comprises a state-based rule construction module used for extracting
attack steps and
attack data packets from a
Bluetooth low-
power attack database, constructing a finite-state
machine model based on
Bluetooth specifications, and determining a state-aware state by defining a
normal state, an illegal state and a transfer path between the states, generating a state conversion rule for the malicious path; the eBPF rule deployment module is used for compiling the state conversion rule into an eBPF
byte code by utilizing an LLVM
compiler, transmitting the eBPF
byte code to target BLE equipment through Bluetooth service, and loading the eBPF
byte code into a kernel environment of the target BLE equipment, so that the eBPF rule takes effect in real time; and the
session state extraction module is used for deploying hooks at a
link layer and a
security management protocol layer to capture session traffic, analyzing a captured session event according to a deployed eBPF rule so as to update the state of the finite-state
machine in real time, triggering a defense mechanism when a malicious path is detected, preventing an
attack behavior and resetting the state of the finite-state
machine.