|
10 | 10 | from qiling.core import Qiling |
11 | 11 | from qiling.const import QL_VERBOSE |
12 | 12 | from qiling.extensions.mcu.stm32f4 import stm32f407, stm32f411 |
| 13 | +from qiling.extensions.mcu.stm32f1 import stm32f103 |
13 | 14 | from qiling.extensions.mcu.gd32vf1 import gd32vf103 |
14 | 15 |
|
15 | 16 | class MCUTest(unittest.TestCase): |
@@ -347,6 +348,34 @@ def indicator(ql): |
347 | 348 |
|
348 | 349 | del ql |
349 | 350 |
|
| 351 | + def test_mcu_usart_stm32f103(self): |
| 352 | + ql = Qiling(["../examples/rootfs/mcu/stm32f103/sctf2020-password-lock-plus.hex"], |
| 353 | + archtype="cortex_m", env=stm32f103, verbose=QL_VERBOSE.DEFAULT) |
| 354 | + |
| 355 | + ql.hw.create('rcc') |
| 356 | + ql.hw.create('flash interface') |
| 357 | + ql.hw.create('exti') |
| 358 | + ql.hw.create('usart1') |
| 359 | + ql.hw.create('gpioa') |
| 360 | + ql.hw.create('afio') |
| 361 | + ql.hw.create('dma1').watch() |
| 362 | + |
| 363 | + data = [] |
| 364 | + def gpio_set_cb(pin): |
| 365 | + data.append(pin) |
| 366 | + |
| 367 | + ql.hw.gpioa.hook_set(1, gpio_set_cb, '1') |
| 368 | + ql.hw.gpioa.hook_set(2, gpio_set_cb, '2') |
| 369 | + ql.hw.gpioa.hook_set(3, gpio_set_cb, '3') |
| 370 | + ql.hw.gpioa.hook_set(4, gpio_set_cb, '4') |
| 371 | + |
| 372 | + ql.run(count=400000) |
| 373 | + |
| 374 | + self.assertTrue((''.join(data)).find('1442413') != -1) |
| 375 | + self.assertTrue(ql.hw.usart1.recv()[:23] == b'SCTF{that1s___r1ghtflag') |
| 376 | + |
| 377 | + del ql |
| 378 | + |
350 | 379 |
|
351 | 380 | if __name__ == "__main__": |
352 | 381 | unittest.main() |
|
0 commit comments