forked from woodenphone/lego_dimensions_protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadafuzz.py
53 lines (39 loc) · 1.13 KB
/
adafuzz.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
53
import usb.core
import usb.util
import sys
# find our device
dev = usb.core.find(idVendor=0xE6f, idProduct=0x241)
# was it found?
if dev is None:
raise ValueError('Device not found')
# set the active configuration. With no arguments, the first
# configuration will be the active one
dev.set_configuration()
### get an endpoint instance
##cfg = dev.get_active_configuration()
##intf = cfg[(0,0)]
##
##ep = usb.util.find_descriptor(
## intf,
## # match the first OUT endpoint
## custom_match = \
## lambda e: \
## usb.util.endpoint_direction(e.bEndpointAddress) == \
## usb.util.ENDPOINT_OUT)
##
##assert ep is not None
##print "got endpoint"
### write the data
##ep.write('test')
# Let's fuzz around!
# Lets start by Reading 1 byte from the Device using different Requests
# bRequest is a byte so there are 255 different values
for bRequest in range(256):
try:
#ctrl_transfer( bmRequestType, bmRequest, wValue, wIndex, nBytes)
ret = dev.ctrl_transfer(0x00, bRequest, 0, 0, 1)
print "bRequest ",bRequest
print ret
except:
# failed to get data for this request
pass