Skip to content

Commit 3a49179

Browse files
committed
tests: jump_hook: Add is_pic() test
1 parent 25c7326 commit 3a49179

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

tests/test_jump_hook.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
SECTOR_SIZE = 0x2000
1010

1111

12+
@pytest.mark.parametrize('shellcode_run_addr', [
13+
(0x82000010),
14+
(0xbc100010),
15+
(0xbcd00010),
16+
(0x91100118),
17+
])
1218
@pytest.mark.parametrize('jump_hook_location', [
1319
0x81000010,
1420
0xbc000010,
@@ -21,11 +27,12 @@
2127
0xbcf00070,
2228
0x910f0218,
2329
])
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):
2531
# Generate shellcode
2632
# ------------------
2733
shellcode_address = 0xbfc00000
2834
jump_hook_sector = int(jump_hook_location/SECTOR_SIZE) * SECTOR_SIZE
35+
shellcode_run_sector = int(shellcode_run_addr/SECTOR_SIZE) * SECTOR_SIZE
2936

3037
step = ShellcodeStep(
3138
"first_step",
@@ -57,15 +64,15 @@ def test_jump_hook_sanity(temp_dir_path, jump_hook_location, jump_hook_goto):
5764
# --------------------
5865

5966
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)
6168
mu.mem_map(jump_hook_sector, 0x2000)
6269

6370
# write machine code to be emulated to memory
64-
mu.mem_write(shellcode_address, shellcode)
71+
mu.mem_write(shellcode_run_addr, shellcode)
6572
mu.mem_write(jump_hook_sector, b"\x00" * 0x1000)
6673

6774
# 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))
6976

7077
assert mu.mem_read(jump_hook_location, len(EXPECTED_HOOK)) == EXPECTED_HOOK
7178
assert mu.mem_read(jump_hook_location+len(EXPECTED_HOOK), 1) == (b"\x00")

0 commit comments

Comments
 (0)