|
1 | 1 | from unicorn.mips_const import UC_MIPS_REG_PC, UC_MIPS_REG_29, UC_MIPS_REG_4 |
2 | 2 | from unicorn.arm_const import UC_ARM_REG_PC, UC_ARM_REG_SP, UC_ARM_REG_R0 |
3 | 3 | from unicorn.x86_const import UC_X86_REG_EIP, UC_X86_REG_ESP, UC_X86_REG_RDI |
| 4 | +from unicorn.ppc_const import UC_PPC_REG_PC, UC_PPC_REG_1, UC_PPC_REG_3 |
4 | 5 |
|
5 | 6 | from shellblocks.compiler_archs import CompilerArchOption |
6 | 7 |
|
@@ -58,6 +59,34 @@ def get_curr_func_arg(self, mu, func_arg): |
58 | 59 | ) |
59 | 60 |
|
60 | 61 |
|
| 62 | +class PowerPCHelper(ArchHelper): |
| 63 | + def __init__(self, compiler_arch_option): |
| 64 | + super().__init__(compiler_arch_option) |
| 65 | + |
| 66 | + assert compiler_arch_option in [ |
| 67 | + CompilerArchOption.POWERPC, |
| 68 | + ] |
| 69 | + |
| 70 | + def get_ret_bytes(self): |
| 71 | + val = 0x4E800020 |
| 72 | + return val.to_bytes(4, 'little') |
| 73 | + |
| 74 | + def get_curr_pc(self, mu): |
| 75 | + return mu.reg_read(UC_PPC_REG_PC) |
| 76 | + |
| 77 | + def set_curr_sp(self, mu, new_stack): |
| 78 | + mu.reg_write(UC_PPC_REG_1, new_stack) |
| 79 | + |
| 80 | + def get_curr_sp(self, mu): |
| 81 | + return mu.reg_read(UC_PPC_REG_1) |
| 82 | + |
| 83 | + def get_curr_func_arg(self, mu, func_arg): |
| 84 | + if func_arg == 0: |
| 85 | + return mu.reg_read(UC_PPC_REG_3) |
| 86 | + |
| 87 | + raise NotImplementedError(f"Getting {func_arg} func arg") |
| 88 | + |
| 89 | + |
61 | 90 | class ARMHelper(ArchHelper): |
62 | 91 | def __init__(self, compiler_arch_option): |
63 | 92 | super().__init__(compiler_arch_option) |
|
0 commit comments