|
9 | 9 | SECTOR_SIZE = 0x2000 |
10 | 10 |
|
11 | 11 |
|
| 12 | +@pytest.mark.parametrize('shellcode_run_addr', [ |
| 13 | + (0x82000010), |
| 14 | + (0xbc100010), |
| 15 | + (0xbcd00010), |
| 16 | + (0x91100118), |
| 17 | +]) |
12 | 18 | @pytest.mark.parametrize('jump_hook_location', [ |
13 | 19 | 0x81000010, |
14 | 20 | 0xbc000010, |
|
21 | 27 | 0xbcf00070, |
22 | 28 | 0x910f0218, |
23 | 29 | ]) |
24 | | -def test_jump_hook_sanity(temp_dir_path, jump_hook_location, jump_hook_goto): |
| 30 | +def test_jump_hook_sanity(temp_dir_path, shellcode_run_addr, jump_hook_location, jump_hook_goto): |
25 | 31 | # Generate shellcode |
26 | 32 | # ------------------ |
27 | 33 | shellcode_address = 0xbfc00000 |
28 | 34 | jump_hook_sector = int(jump_hook_location/SECTOR_SIZE) * SECTOR_SIZE |
| 35 | + shellcode_run_sector = int(shellcode_run_addr/SECTOR_SIZE) * SECTOR_SIZE |
29 | 36 |
|
30 | 37 | step = ShellcodeStep( |
31 | 38 | "first_step", |
@@ -57,15 +64,15 @@ def test_jump_hook_sanity(temp_dir_path, jump_hook_location, jump_hook_goto): |
57 | 64 | # -------------------- |
58 | 65 |
|
59 | 66 | mu = Uc(UC_ARCH_MIPS, UC_MODE_32 | UC_MODE_BIG_ENDIAN) |
60 | | - mu.mem_map(shellcode_address, 0x2000) |
| 67 | + mu.mem_map(shellcode_run_sector, 0x2000) |
61 | 68 | mu.mem_map(jump_hook_sector, 0x2000) |
62 | 69 |
|
63 | 70 | # write machine code to be emulated to memory |
64 | | - mu.mem_write(shellcode_address, shellcode) |
| 71 | + mu.mem_write(shellcode_run_addr, shellcode) |
65 | 72 | mu.mem_write(jump_hook_sector, b"\x00" * 0x1000) |
66 | 73 |
|
67 | 74 | # emulate code in infinite time & unlimited instructions |
68 | | - mu.emu_start(shellcode_address, shellcode_address + len(shellcode)) |
| 75 | + mu.emu_start(shellcode_run_addr, shellcode_run_addr + len(shellcode)) |
69 | 76 |
|
70 | 77 | assert mu.mem_read(jump_hook_location, len(EXPECTED_HOOK)) == EXPECTED_HOOK |
71 | 78 | assert mu.mem_read(jump_hook_location+len(EXPECTED_HOOK), 1) == (b"\x00") |
0 commit comments