Skip to content

Commit

Permalink
macstealer: handle multiple DHCP offers
Browse files Browse the repository at this point in the history
When multiple different DHCP offers arrive, the script would reply to
all of them. This confuses some DHCP servers. Prevent this by only
replying to the first offered IP address.

This should fix #6
  • Loading branch information
vanhoefm committed Jun 20, 2023
1 parent ef9820f commit 819a4ca
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions research/macstealer.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def __init__(self, iface, options):
self.bssid_victim=None

self.mac = get_macaddress(self.nic_iface)
self.offered_ip = None
self.clientip = None
self.routermac = None
self.routerip = None
Expand Down Expand Up @@ -398,9 +399,14 @@ def handle_eth_dhcp(self, p):

# DHCP Offer
if req_type == 2:
log(STATUS, f"Received DHCP offer for {p[BOOTP].yiaddr}, sending DHCP request.")
self.send_dhcp_request(p)
self.dhcp_offer_frame = p
offered_ip = p[BOOTP].yiaddr
if self.offered_ip != None and self.offered_ip != offered_ip:
log(WARNING, f"Ignoring DHCP offer for the different IP address {offered_ip}.")
else:
log(STATUS, f"Received DHCP offer for {offered_ip}, sending DHCP request.")
self.send_dhcp_request(p)
self.dhcp_offer_frame = p
self.offered_ip = offered_ip

# DHCP Ack
elif req_type == 5:
Expand Down

0 comments on commit 819a4ca

Please sign in to comment.