File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff 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+
172202if __name__ == "__main__" :
173203 unittest .main ()
174204
You can’t perform that action at this time.
0 commit comments