Browse Source

krackattacks: send DHCP reply from gateway IP

Mathy Vanhoef 7 years ago
parent
commit
26d1ba2d95
1 changed files with 5 additions and 0 deletions
  1. 5 0
      krackattack/krack-test-client.py

+ 5 - 0
krackattack/krack-test-client.py

@@ -169,6 +169,7 @@ def hostapd_command(hostapd_ctrl, cmd):
 class DHCP_sock(DHCP_am):
 	def __init__(self, **kwargs):
 		self.sock = kwargs.pop("sock")
+		self.server_ip = kwargs["gw"]
 		super(DHCP_sock, self).__init__(**kwargs)
 
 	def make_reply(self, req):
@@ -179,6 +180,10 @@ class DHCP_sock(DHCP_am):
 			if req[BOOTP].flags & 0x8000 != 0 and req[BOOTP].giaddr == '0.0.0.0' and req[BOOTP].ciaddr == '0.0.0.0':
 				rep[IP].dst = "255.255.255.255"
 
+		# Explicitly set source IP if requested
+		if not self.server_ip is None:
+			rep[IP].src = self.server_ip
+
 		return rep
 
 	def send_reply(self, reply):