Skip to content

Commit cfac323

Browse files
committed
Add stm32f407 testcase
1 parent a117346 commit cfac323

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/test_mcu.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,36 @@ def counter():
169169

170170
del ql
171171

172+
def test_mcu_hacklock_stm32f407(self):
173+
def crack(passwd):
174+
ql = Qiling(["../examples/rootfs/mcu/stm32f407/backdoorlock.hex"],
175+
archtype="cortex_m", profile="stm32f407", verbose=QL_VERBOSE.OFF)
176+
177+
ql.hw.create('spi2')
178+
ql.hw.create('gpioe')
179+
ql.hw.create('gpiof')
180+
ql.hw.create('usart1')
181+
ql.hw.create('rcc')
182+
183+
print('Testing passwd', passwd)
184+
185+
ql.patch(0x8000238, b'\x00\xBF' * 4)
186+
ql.patch(0x80031e4, b'\x00\xBF' * 11)
187+
ql.patch(0x80032f8, b'\x00\xBF' * 13)
188+
ql.patch(0x80013b8, b'\x00\xBF' * 10)
189+
190+
ql.hw.usart1.send(passwd.encode() + b'\r')
191+
192+
ql.hw.systick.set_ratio(400)
193+
194+
ql.run(count=400000, end=0x8003225)
195+
196+
return ql.arch.get_pc() == 0x8003225
197+
198+
self.assertTrue(crack('618618'))
199+
self.assertTrue(crack('778899'))
200+
self.assertFalse(crack('123456'))
201+
172202
if __name__ == "__main__":
173203
unittest.main()
174204

0 commit comments

Comments
 (0)