page1
USB RA
Entry exploit
(Stage 1)
USB BUF
0x02021800
Debugger
0x02069000 to 0x0206f000
USB return address (0x02020f60)
PC
Debug
1) After exploit, we set USB RA at 0x02020f60 to 0x0206900
→ X0=0, LR=0x20219b8
2) We set dbg.state.LR to debug 0x2069000
→ X0=0, LR=0x2069000
3) Send BL1 to device
4) Authenticate BL1, by setting arch_dbg.state.LR to 0x02069000 and restore_stack_and_jump(0x00012848)
→ X0=1, LR=0x20269000
5) FLUSH
: store hijacked_function address
6) Overwrite hijacked_fun with 0x02069000
7) Overwrite 0x02021880 with arch_dbg.sc.branch_absolute
8) Jump into BL1, by setting arch_dbg.state.LR = 0x02069000 and restore_stack_and_jump(0x000002c0)
→ X0=0x2024000, LR=0x2022948
9) Restore state LR to 0x02069000
→ x0=0x02024000, LR=0x02069000
10) Jump into hijacked_function with restore_stack_and_jump(hijacked_fun)
→ Lose debugger
11) Sent BL2 (device awaits one more USB package). Returns to debugger.
→ X0=1, LR=0x02069000
12) Continues with BL1 flow using self.cd.restore_stack_and_jump(0x2022948) and returns to debugger
→ X0=0xf3f3cf1b, LR=0x2021a20
13) Jumps into BL31 using restore_stack_and_jump(0x02024010) and returns debugger
→ X0=0x2048000, LR=0x2024eec
14) Return hijacked_function at 0x020200dc. Using memwrite_region(0x020200dc, p32(hijacked_fun))
-> memdump stops working here. But memwrite still functions.
15) memwrite_region(0x02020, p32(DEBUGGER_ADDR))
16) Debugger gets overwritten. 0X12f0 bytes remaining in stack after sending BL2.
Boot USB func
0x000064e0
Entry exploit
(Stage 1)
USB BUF
0x02021800
AUTH BL1
0x00012848
JUMP BL1
0x000002c0
1
2
3
4
BL2
0x2048000 - 0x206ed10
BL31
0x02024000 - 0x02048000
BL1
0x02021800 - 0x0202a000