-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverse.py
More file actions
32 lines (28 loc) · 805 Bytes
/
reverse.py
File metadata and controls
32 lines (28 loc) · 805 Bytes
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
import subprocess
import usb.core
import sys
# Find the requested USB device
dev = usb.core.find(idVendor = 0x20d6, idProduct = 0xa713)
if not dev:
print("Device not connected")
exit()
# Retrieve the right interface/endpoint data
i = dev[0].interfaces()[0].bInterfaceNumber
ep = dev[0].interfaces()[0].endpoints()[0]
if ep.bEndpointAddress == 0x02:
ep = dev[0].interfaces()[0].endpoints()[1]
# Connect to the device
dev.reset()
if dev.is_kernel_driver_active(i):
dev.detach_kernel_driver(i)
dev.set_configuration()
# Print whatever we read from the device
last = []
eaddr = (ep.bEndpointAddress)
print("Reverse engineering tool is online")
last = None
while True:
r = dev.read(eaddr, 8)
if len(r) > 0 and r != last:
print(", ".join(list(map(str, r))))
last = r