
محاكاة بلغة Python لثغرة CVE-2026-11117 توضح إعادة تثبيت PTK في المصافحة الرباعية لـ WPA2 وإعادة استخدام nonce لتوضيح هجوم KRACK.
# krack_sim.py - Simulates reinstallation of an already-used PTK
import hashlib, os
class AccessPoint:
def __init__(self):
self.anonce = os.urandom(32)
self.ptk = None
def send_msg3(self, snonce):
# Normally would install PTK, but here we resend msg3 to trigger reinstall
self.ptk = hashlib.sha256(b"PMK" + self.anonce + snonce).digest()
print("Installed PTK")
return self.ptk
class Client:
def __init__(self):
self.snonce = os.urandom(32)
self.ptk = None
def receive_msg3(self, ap):
self.ptk = ap.send_msg3(self.snonce)
# Vulnerability: if AP resends msg3, nonce reuse may reset counters
print("Client installed PTK")
ap = AccessPoint()
client = Client()
client.receive_msg3(ap) # first install
client.receive_msg3(ap) # reinstallation! Nonce reused, replay possible
لا يتتبع عميل Wi‑Fi الرسالة 3 من المصافحة الرباعية الخطوات بشكل صحيح. يمكن للمهاجم إعادة تشغيل الرسالة 3، مما يؤدي إلى قيام العميل بإعادة تثبيت مفتاح جلسة مؤقت (PTK) قيد الاستخدام بالفعل، وإعادة تعيين القيم غير المتكررة (nonces) وعدادات إعادة التشغيل. يتيح ذلك فك تشفير الإطارات وتزويرها.
شغّل المحاكاة:
python krack_sim.py
يُظهر السكربت أن PTK يُعاد تثبيته، مما يسلط الضوء على إعادة استخدام القيمة غير المتكررة (nonce reuse).