Python unicorn.x86_const() Examples
The following are 8
code examples of unicorn.x86_const().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
unicorn
, or try the search function
.
Example #1
Source File: emulator.py From cemu with MIT License | 6 votes |
def unicorn_register(self, reg): curarch = self.parent.arch if is_x86(curarch): return getattr(unicorn.x86_const, "UC_X86_REG_%s"%reg.upper()) if is_arm(curarch) or is_arm_thumb(curarch): return getattr(unicorn.arm_const, "UC_ARM_REG_%s"%reg.upper()) if is_aarch64(curarch): return getattr(unicorn.arm64_const, "UC_ARM64_REG_%s"%reg.upper()) # if is_ppc(curarch): # return getattr(unicorn.ppc_const, "UC_PPC_REG_%s" % reg.upper()) if is_mips(curarch) or is_mips64(curarch): return getattr(unicorn.mips_const, "UC_MIPS_REG_%s" % reg.upper()) if is_sparc(curarch) or is_sparc64(curarch): return getattr(unicorn.sparc_const, "UC_SPARC_REG_%s" %reg.upper()) raise Exception("Cannot find register '%s' for arch '%s'" % (reg, curarch))
Example #2
Source File: x64.py From rainbow with GNU Lesser General Public License v3.0 | 6 votes |
def __init__(self, trace=True, sca_mode=False, local_vars={}): super().__init__(trace, sca_mode) self.emu = uc.Uc(uc.UC_ARCH_X86, uc.UC_MODE_64) self.disasm = cs.Cs(cs.CS_ARCH_X86, cs.CS_MODE_64) self.disasm.detail = True self.word_size = 8 self.endianness = "little" self.page_size = self.emu.query(uc.UC_QUERY_PAGE_SIZE) self.page_shift = self.page_size.bit_length() - 1 self.pc = uc.x86_const.UC_X86_REG_RIP # workaround for capstone 4 uc.x86_const.UC_X86_REG_RFLAGS = uc.x86_const.UC_X86_REG_EFLAGS known_regs = [i[len('UC_X86_REG_'):] for i in dir(uc.x86_const) if '_REG' in i] self.reg_map = {r.lower(): getattr(uc.x86_const, 'UC_X86_REG_'+r) for r in known_regs} self.stubbed_functions = local_vars self.setup(sca_mode) self.reset_stack()
Example #3
Source File: x86.py From rainbow with GNU Lesser General Public License v3.0 | 6 votes |
def __init__(self, trace=True, sca_mode=False, local_vars={}): super().__init__(trace, sca_mode) self.emu = uc.Uc(uc.UC_ARCH_X86, uc.UC_MODE_32) self.disasm = cs.Cs(cs.CS_ARCH_X86, cs.CS_MODE_32) self.disasm.detail = True self.word_size = 4 self.endianness = "little" self.page_size = self.emu.query(uc.UC_QUERY_PAGE_SIZE) self.page_shift = self.page_size.bit_length() - 1 self.pc = uc.x86_const.UC_X86_REG_EIP known_regs = [i[len('UC_X86_REG_'):] for i in dir(uc.x86_const) if '_REG' in i] self.reg_map = {r.lower(): getattr(uc.x86_const, 'UC_X86_REG_'+r) for r in known_regs} self.stubbed_functions = local_vars self.setup(sca_mode) self.reset_stack()
Example #4
Source File: qemu.py From Sibyl with GNU General Public License v3.0 | 5 votes |
def __init__(self, *args, **kwargs): import unicorn.x86_const as csts self.regs = { "EAX": csts.UC_X86_REG_EAX, "EBX": csts.UC_X86_REG_EBX, "ECX": csts.UC_X86_REG_ECX, "EDI": csts.UC_X86_REG_EDI, "EDX": csts.UC_X86_REG_EDX, "ESI": csts.UC_X86_REG_ESI, "EBP": csts.UC_X86_REG_EBP, "ESP": csts.UC_X86_REG_ESP, } self.pc_reg_name = "EIP" self.pc_reg_value = csts.UC_X86_REG_EIP super(UcWrapCPU_x86_32, self).__init__(*args, **kwargs)
Example #5
Source File: qemu.py From Sibyl with GNU General Public License v3.0 | 5 votes |
def __init__(self, *args, **kwargs): import unicorn.x86_const as csts self.regs = { "RAX": csts.UC_X86_REG_RAX, "RBX": csts.UC_X86_REG_RBX, "RCX": csts.UC_X86_REG_RCX, "RDI": csts.UC_X86_REG_RDI, "RDX": csts.UC_X86_REG_RDX, "RSI": csts.UC_X86_REG_RSI, "RBP": csts.UC_X86_REG_RBP, "RSP": csts.UC_X86_REG_RSP, "R8": csts.UC_X86_REG_R8, "R11": csts.UC_X86_REG_R11, "R9": csts.UC_X86_REG_R9, "R10": csts.UC_X86_REG_R10, "R12": csts.UC_X86_REG_R12, "R13": csts.UC_X86_REG_R13, "R14": csts.UC_X86_REG_R14, "R15": csts.UC_X86_REG_R15, } self.pc_reg_name = "RIP" self.pc_reg_value = csts.UC_X86_REG_RIP super(UcWrapCPU_x86_64, self).__init__(*args, **kwargs)
Example #6
Source File: emulator.py From cemu with MIT License | 5 votes |
def create_new_vm(self) -> None: """ Create a new VM, and sets up the hooks """ arch, mode, endian = get_arch_mode("unicorn", self.root.arch) self.vm = unicorn.Uc(arch, mode | endian) self.vm.hook_add(unicorn.UC_HOOK_BLOCK, self.hook_block) self.vm.hook_add(unicorn.UC_HOOK_CODE, self.hook_code) self.vm.hook_add(unicorn.UC_HOOK_INTR, self.hook_interrupt) self.vm.hook_add(unicorn.UC_HOOK_MEM_WRITE, self.hook_mem_access) self.vm.hook_add(unicorn.UC_HOOK_MEM_READ, self.hook_mem_access) if is_x86(self.root.arch): self.vm.hook_add(unicorn.UC_HOOK_INSN, self.hook_syscall, None, 1, 0, unicorn.x86_const.UC_X86_INS_SYSCALL) return
Example #7
Source File: x64.py From rainbow with GNU Lesser General Public License v3.0 | 5 votes |
def reset_stack(self): self.emu.reg_write(uc.x86_const.UC_X86_REG_RBP, self.STACK_ADDR) self.emu.reg_write(uc.x86_const.UC_X86_REG_RSP, self.STACK_ADDR)
Example #8
Source File: x86.py From rainbow with GNU Lesser General Public License v3.0 | 5 votes |
def reset_stack(self): self.emu.reg_write(uc.x86_const.UC_X86_REG_EBP, self.STACK_ADDR) self.emu.reg_write(uc.x86_const.UC_X86_REG_ESP, self.STACK_ADDR)