-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathspoof.py
34 lines (28 loc) · 821 Bytes
/
spoof.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
import hid, time, sys, socket
paths = [t['path'] for t in hid.enumerate(5824, 1158) if t['usage'] == 512]
teensy = hid.device()
teensy.open_path(paths[0])
teensy.set_nonblocking(1)
buf = bytearray([0]*64)
#reset
buf[0:2] = [0x01, 0x01]
teensy.write(buf)
buf[0:2] = [0x00, 0x00]
with socket.create_connection((sys.argv[1], sys.argv[2])) as sock:
sock.setblocking(False)
while True:
try:
data_in = teensy.read(64)[0]
except IndexError:
pass
else:
print(">>", hex(data_in))
sock.send(bytearray([data_in]))
try:
data_out = ord(sock.recv(1))
except BlockingIOError:
pass
else:
print("<<", hex(data_out))
buf[0] = data_out
teensy.write(buf)