Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LaurentDumont/9559ceabefb986756b75738d969afdba to your computer and use it in GitHub Desktop.
Save LaurentDumont/9559ceabefb986756b75738d969afdba to your computer and use it in GitHub Desktop.
Simpy scapy DHCP Discover packet.
from scapy.layers.inet import IP, TCP, Ether, UDP
from scapy.layers.dhcp import BOOTP, DHCP
from scapy.all import send, sendp, RandMAC
#discover = Ether(dst='ff:ff:ff:ff:ff:ff', src='DE:EA:DE:C0:FF:EE', type=0x0800)/IP(src='0.0.0.0', dst='255.255.255.255' )/UDP(dport=67,sport=68)/BOOTP(op=1,chaddr='DE:EA:DE:C0:FF:EE')/DHCP(options=[('message-type','discover'), ('end')])
#send(discover,iface="wlp3s0")
src_mac = str(RandMAC())
ethernet = Ether(dst='ff:ff:ff:ff:ff:ff', src=src_mac, type=0x800)
ip = IP(src="0.0.0.0", dst="255.255.255.255")
udp = UDP(sport=68, dport=67)
bootps = BOOTP(chaddr=src_mac, ciaddr='0.0.0.0', flags=1)
dhcps = DHCP(options=[("message-type", "discover"), "end"])
packet = ethernet / ip / udp / bootps / dhcps
sendp(packet, iface="wlp3s0", verbose=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment