
가로챈 Bluetooth 트래픽에 대한 암호화 키 크기 다운그레이드 및 무차별 대입 복호화를 보여주는 Bluetooth Classic KNOB 공격의 Python 시뮬레이션입니다.
# 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()
Bluetooth 기기는 페어링 협상 중 1바이트만큼 작은 암호화 키 크기를 허용합니다. 공격자는 연결이 극도로 약한 키를 사용하도록 강제한 다음 실시간으로 전수 조사(브루트포스)하여 통신을 도청할 수 있습니다.
시뮬레이션을 실행하세요:
python knob_attack_sim.py
이 스크립트는 1바이트 키가 합의되었고 즉시 전수 조사될 수 있음을 출력합니다.