Skip to content

Commit

Permalink
Increase USB timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
axi0mX committed Jun 7, 2017
1 parent 4127253 commit 8927b84
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions dfu.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def release_device(device):

def reset_counters(device):
#print 'Resetting USB counters.'
assert device.ctrl_transfer(0x21, 4, 0, 0, 0, 100) == 0
assert device.ctrl_transfer(0x21, 4, 0, 0, 0, 1000) == 0

def usb_reset(device):
#print 'Performing USB port reset.'
Expand Down Expand Up @@ -56,8 +56,8 @@ def get_data(device, amount):

def request_image_validation(device):
#print 'Requesting image validation.'
assert device.ctrl_transfer(0x21, 1, 0, 0, '', 100) == 0
device.ctrl_transfer(0xA1, 3, 0, 0, 6, 100)
device.ctrl_transfer(0xA1, 3, 0, 0, 6, 100)
device.ctrl_transfer(0xA1, 3, 0, 0, 6, 100)
assert device.ctrl_transfer(0x21, 1, 0, 0, '', 1000) == 0
device.ctrl_transfer(0xA1, 3, 0, 0, 6, 1000)
device.ctrl_transfer(0xA1, 3, 0, 0, 6, 1000)
device.ctrl_transfer(0xA1, 3, 0, 0, 6, 1000)
usb_reset(device)
4 changes: 2 additions & 2 deletions limera1n.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ def exploit():

dfu.send_data(device, generate_payload(chosenConfig.constants, chosenConfig.exploit_lr))

assert len(device.ctrl_transfer(0xA1, 1, 0, 0, 1, 100)) == 1
assert len(device.ctrl_transfer(0xA1, 1, 0, 0, 1, 1000)) == 1

limera1n_libusb1_async_ctrl_transfer(device, 0x21, 1, 0, 0, 'A' * 0x800, 10)

try:
device.ctrl_transfer(0x21, 2, 0, 0, 0, 1)
device.ctrl_transfer(0x21, 2, 0, 0, 0, 10)
print 'ERROR: This request succeeded, but it should have raised an exception. Exiting.'
sys.exit(1)
except usb.core.USBError:
Expand Down
6 changes: 3 additions & 3 deletions recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def release_device(device):

def send_command(device, command):
# TODO: Add assert?
device.ctrl_transfer(0x40, 0, 0, 0, command + '\x00', 20000)
device.ctrl_transfer(0x40, 0, 0, 0, command + '\x00', 30000)

def send_data(device, data):
#print 'Sending 0x%x of data to device.' % len(data)
assert device.ctrl_transfer(0x41, 0, 0, 0, 0, 100) == 0
assert device.ctrl_transfer(0x41, 0, 0, 0, 0, 1000) == 0
index = 0
while index < len(data):
amount = min(len(data) - index, MAX_PACKET_SIZE)
assert device.write(0x04, data[index:index + amount], 1) == amount
assert device.write(0x04, data[index:index + amount], 1000) == amount
index += amount
2 changes: 1 addition & 1 deletion steaks4uce.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def exploit():
dfu.reset_counters(device)
dfu.send_data(device, generate_shellcode(chosenConfig.constants))
dfu.send_data(device, payload)
assert len(device.ctrl_transfer(0xA1, 1, 0, 0, len(payload), 100)) == len(payload)
assert len(device.ctrl_transfer(0xA1, 1, 0, 0, len(payload), 1000)) == len(payload)
dfu.release_device(device)

time.sleep(0.01)
Expand Down

0 comments on commit 8927b84

Please sign in to comment.