Advertisement
teknoraver

sender_mt

Jul 2nd, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. import sys
  4. import random
  5. from threading import Thread
  6. import scapy.all as scapy
  7.  
  8. ifaces = sys.argv[1:]
  9.  
  10. print(str(ifaces))
  11.  
  12. def randomMAC():
  13.     mac = [ random.randint(0x00, 0xff),
  14.         random.randint(0x00, 0xff),
  15.         random.randint(0x00, 0xff),
  16.         random.randint(0x00, 0xff),
  17.         random.randint(0x00, 0xff),
  18.         random.randint(0x00, 0xff) ];
  19.  
  20.     # unicast
  21.     mac[0] &= 0xFE
  22.     # locally assigned
  23.     mac[0] |= 2
  24.  
  25.     return "{0:02x}:{1:02x}:{2:02x}:{3:02x}:{4:02x}:{5:02x}".format(
  26.         mac[0], mac[1], mac[2], mac[3], mac[4], mac[5])
  27.  
  28. class Sender(Thread):
  29.     def __init__(self, iface):
  30.         Thread.__init__(self)
  31.         self.iface = iface
  32.         self.socket = scapy.conf.L2socket(iface=iface)
  33.     def run(self):
  34.         while True:
  35.             pkt = scapy.Ether(src=randomMAC(), dst=randomMAC())/scapy.IP(src="10.0.0.254", dst="10.0.0.105")/scapy.UDP(dport=random.randint(1, 65535), sport=random.randint(1, 65535))
  36.             self.socket.send(pkt)
  37.  
  38. for iface in ifaces:
  39.     Sender(iface).start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement