# knob_attack_sim.py - Simulates negotiation of encryption key size to 1 byte
import random, hashlib
class BluetoothDevice:
def negotiate_key_size(self, proposed_size):
# Vulnerable: accepts any key size down to 1 byte
return max(1, proposed_size) # should enforce minimum 7
def attack():
bob = BluetoothDevice()
# Attacker proposes 1 byte key size
agreed = bob.negotiate_key_size(1)
print(f"Key size negotiated: {agreed} byte")
# Now brute-force 1-byte key (256 possibilities) in seconds
for k in range(256):
# Simulate successful decryption
print(f"Key {k} decrypted traffic.")
attack()
在配对协商过程中,蓝牙设备会接受小至 1 字节的加密密钥长度。攻击者可以强制连接使用极弱的密钥,然后实时暴力破解并窃听通信内容。
运行模拟程序:
python knob_attack_sim.py
程序输出表明,双方协商使用了 1 字节密钥,且该密钥可被瞬间暴力破解。