dhcp-request.py 517 B

1234567891011121314151617181920
  1. #!/usr/bin/env python2
  2. from scapy.all import *
  3. import sys
  4. def main(clientmac):
  5. discover = Ether(dst='ff:ff:ff:ff:ff:ff', src=clientmac, type=0x0800) \
  6. / IP(src='0.0.0.0', dst='255.255.255.255') \
  7. / UDP(dport=67, sport=68) \
  8. / BOOTP(op=1, chaddr=clientmac, flags=0x8000) \
  9. / DHCP(options=[('message-type', 'discover'), ('end')])
  10. sendp(discover)
  11. if __name__ == "__main__":
  12. if len(sys.argv) != 3:
  13. print "Usage:", sys.argv[0], "interface clientmac"
  14. quit(1)
  15. conf.iface = sys.argv[1]
  16. main(sys.argv[2])