Created
February 6, 2019 18:27
-
-
Save sebschrader/e031fedea629e4da80ef518a3315cb39 to your computer and use it in GitHub Desktop.
Spoof DHCP Requests with Scapy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import codecs | |
from scapy.all import BOOTP, DHCP, Ether, IP, UDP, sendp | |
def do_request(iface, hwaddr, ip): | |
pkt = Ether(src=hwaddr, dst="ff:ff:ff:ff:ff:ff") | |
pkt /= IP(src="0.0.0.0", dst="255.255.255.255") | |
pkt /= UDP(sport=68, dport=67) | |
pkt /= BOOTP( | |
chaddr=codecs.decode(hwaddr.replace(':', ''), 'hex'), | |
xid=random.randint(0, 2 ** 32), | |
) | |
pkt /= DHCP(options=[ | |
("message-type", "request"), | |
("requested_addr", ip), | |
("end"), | |
]) | |
sendp(pkt, iface=iface) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment