当前位置: 首页>>代码示例>>Python>>正文


Python capstone.CS_MODE_THUMB属性代码示例

本文整理汇总了Python中capstone.CS_MODE_THUMB属性的典型用法代码示例。如果您正苦于以下问题:Python capstone.CS_MODE_THUMB属性的具体用法?Python capstone.CS_MODE_THUMB怎么用?Python capstone.CS_MODE_THUMB使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在capstone的用法示例。


在下文中一共展示了capstone.CS_MODE_THUMB属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_disassembler_engine

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def init_disassembler_engine(self):
        # init state for disasambler
        # set capstone, lexer, asmline

        arch, mode = self.plugin.hintDisasm()

        self.disasm_engine = capstone.Cs(arch, mode)
        self.disasm_engine.detail = True

        if arch == capstone.CS_ARCH_X86:
            Lexer = X86_Lexer()

        if arch == capstone.CS_ARCH_ARM and mode in [capstone.CS_MODE_ARM, capstone.CS_MODE_THUMB]:
            Lexer = ARM_Lexer()

        if arch == capstone.CS_ARCH_ARM64:
            Lexer = ARM64_Lexer()

        # todo: ASM_ARM_Line?
        self.ASMLine = ASMx86Line
        Lexer.build()
        self.lexer = Lexer.lexer() 
开发者ID:mtivadar,项目名称:qiew,代码行数:24,代码来源:DisasmViewMode.py

示例2: __setup_available_disassemblers

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def __setup_available_disassemblers(self):
        arch_map = {
            ARCH_ARM_MODE_ARM:   CS_MODE_ARM,
            ARCH_ARM_MODE_THUMB: CS_MODE_THUMB,
        }

        self._available_disassemblers = {
            ARCH_ARM_MODE_ARM:   Cs(CS_ARCH_ARM, arch_map[ARCH_ARM_MODE_ARM]),
            ARCH_ARM_MODE_THUMB: Cs(CS_ARCH_ARM, arch_map[ARCH_ARM_MODE_THUMB]),
        }

        self._available_disassemblers[ARCH_ARM_MODE_ARM].detail = True
        self._available_disassemblers[ARCH_ARM_MODE_THUMB].detail = True

    # Casptone to BARF translation
    # ======================================================================== # 
开发者ID:programa-stic,项目名称:barf-project,代码行数:18,代码来源:disassembler.py

示例3: __init__

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def __init__(self, trace=True, sca_mode=False, local_vars={}):
        super().__init__(trace, sca_mode)
        self.emu = uc.Uc(uc.UC_ARCH_ARM, uc.UC_MODE_ARM)
        self.disasm = cs.Cs(cs.CS_ARCH_ARM, cs.CS_MODE_ARM | cs.CS_MODE_THUMB)
        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.arm_const.UC_ARM_REG_PC

        known_regs = [i[len('UC_ARM_REG_'):] for i in dir(uc.arm_const) if '_REG' in i]
        self.reg_map = {r.lower(): getattr(uc.arm_const, 'UC_ARM_REG_'+r) for r in known_regs}

        self.stubbed_functions = local_vars
        self.setup(sca_mode)
    
        self.reset_stack() 
开发者ID:Ledger-Donjon,项目名称:rainbow,代码行数:20,代码来源:arm.py

示例4: __init__

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def __init__(self, trace=True, sca_mode=False, local_vars={}):
        super().__init__(trace, sca_mode)
        self.emu = uc.Uc(uc.UC_ARCH_ARM, uc.UC_MODE_THUMB | uc.UC_MODE_MCLASS)
        self.disasm = cs.Cs(cs.CS_ARCH_ARM, cs.CS_MODE_THUMB | cs.CS_MODE_MCLASS)
        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.arm_const.UC_ARM_REG_PC

        known_regs = [i[len('UC_ARM_REG_'):] for i in dir(uc.arm_const) if '_REG' in i]
        self.reg_map = {r.lower(): getattr(uc.arm_const, 'UC_ARM_REG_'+r) for r in known_regs}

        self.stubbed_functions = local_vars
        self.setup(sca_mode)

        self.reset_stack()
        # Force mapping of those addresses so that
        # exception returns can be caught in the base
        # block hook rather than a code fetch hook
        self.map_space(0xfffffff0, 0xffffffff)

        self.emu.hook_add(uc.UC_HOOK_INTR, self.intr_hook) 
开发者ID:Ledger-Donjon,项目名称:rainbow,代码行数:26,代码来源:cortexm.py

示例5: _set_mode_by_val

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def _set_mode_by_val(self, val):
        new_mode = Operators.ITEBV(
            self.address_bit_size, (val & 0x1) == 0x1, cs.CS_MODE_THUMB, cs.CS_MODE_ARM
        )

        if issymbolic(new_mode):
            from ..state import Concretize

            def set_concrete_mode(state, value):
                state.cpu.mode = value

            raise Concretize(
                "Concretizing ARMv7 mode", expression=new_mode, setstate=set_concrete_mode
            )

        self.mode = new_mode 
开发者ID:trailofbits,项目名称:manticore,代码行数:18,代码来源:arm.py

示例6: _ks_assemble

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def _ks_assemble(asm: str, mode=CS_MODE_ARM) -> bytes:
    """Assemble the given string using Keystone using the specified CPU mode."""
    # Explicitly uses late importing so that Keystone will only be imported if this is called.
    # This lets us avoid requiring installation of Keystone for running tests.
    global ks, ks_thumb
    from keystone import Ks, KS_ARCH_ARM, KS_MODE_ARM, KS_MODE_THUMB

    if ks is None:
        ks = Ks(KS_ARCH_ARM, KS_MODE_ARM)
    if ks_thumb is None:
        ks_thumb = Ks(KS_ARCH_ARM, KS_MODE_THUMB)

    if CS_MODE_ARM == mode:
        ords = ks.asm(asm)[0]
    elif CS_MODE_THUMB == mode:
        ords = ks_thumb.asm(asm)[0]
    else:
        raise Exception(f"bad processor mode for assembly: {mode}")
    if not ords:
        raise Exception(f"bad assembly: {asm}")
    return binascii.hexlify(bytearray(ords)) 
开发者ID:trailofbits,项目名称:manticore,代码行数:23,代码来源:test_armv7unicorn.py

示例7: _ks_assemble

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def _ks_assemble(asm: str, mode=CS_MODE_ARM) -> bytes:
    """Assemble the given string using Keystone using the specified CPU mode."""
    # Explicitly uses late importing so that Keystone will only be imported if this is called.
    # This lets us avoid requiring installation of Keystone for running tests.
    global ks, ks_thumb
    from keystone import Ks, KS_ARCH_ARM, KS_MODE_ARM, KS_MODE_THUMB

    if ks is None:
        ks = Ks(KS_ARCH_ARM, KS_MODE_ARM)
    if ks_thumb is None:
        ks_thumb = Ks(KS_ARCH_ARM, KS_MODE_THUMB)

    if CS_MODE_ARM == mode:
        ords = ks.asm(asm)[0]

    elif CS_MODE_THUMB == mode:
        ords = ks_thumb.asm(asm)[0]
    else:
        raise Exception(f"bad processor mode for assembly: {mode}")
    if not ords:
        raise Exception(f"bad assembly: {asm}")
    return binascii.hexlify(bytearray(ords)) 
开发者ID:trailofbits,项目名称:manticore,代码行数:24,代码来源:test_armv7cpu.py

示例8: test_blx_reg_sym

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def test_blx_reg_sym(self):
        dest = self.cpu.memory.constraints.new_bitvec(32, "dest")
        self.cpu.memory.constraints.add(dest >= 0x1000)
        self.cpu.memory.constraints.add(dest <= 0x1001)
        self.cpu.R1 = dest

        # First, make sure we raise when the mode is symbolic and ambiguous
        with self.assertRaises(Concretize) as cm:
            self.cpu.execute()

        # Then, make sure we have the correct expression
        e = cm.exception
        all_modes = solver.get_all_values(self.cpu.memory.constraints, e.expression)
        self.assertIn(CS_MODE_THUMB, all_modes)
        self.assertIn(CS_MODE_ARM, all_modes)

        # Assuming we're in ARM mode, ensure the callback toggles correctly.
        self.assertEqual(self.cpu.mode, CS_MODE_ARM)
        # The setstate callback expects a State as its first argument; since we
        # don't have a state, the unit test itself is an okay approximation, since
        # the cpu lives in self.cpu
        e.setstate(self, CS_MODE_THUMB)
        self.assertEqual(self.cpu.mode, CS_MODE_THUMB) 
开发者ID:trailofbits,项目名称:manticore,代码行数:25,代码来源:test_armv7cpu.py

示例9: _import_dependencies

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def _import_dependencies(self):

        # Load the Capstone bindings.
        global capstone
        if capstone is None:
            import capstone

        # Load the constants for the requested architecture.
        self.__constants = {
            win32.ARCH_I386:
                (capstone.CS_ARCH_X86,   capstone.CS_MODE_32),
            win32.ARCH_AMD64:
                (capstone.CS_ARCH_X86,   capstone.CS_MODE_64),
            win32.ARCH_THUMB:
                (capstone.CS_ARCH_ARM,   capstone.CS_MODE_THUMB),
            win32.ARCH_ARM:
                (capstone.CS_ARCH_ARM,   capstone.CS_MODE_ARM),
            win32.ARCH_ARM64:
                (capstone.CS_ARCH_ARM64, capstone.CS_MODE_ARM),
        }

        # Test for the bug in early versions of Capstone.
        # If found, warn the user about it.
        try:
            self.__bug = not isinstance(
                capstone.cs_disasm_quick(
                    capstone.CS_ARCH_X86, capstone.CS_MODE_32, "\x90", 1)[0],
                capstone.capstone.CsInsn)
        except AttributeError:
            self.__bug = False
        if self.__bug:
            warnings.warn(
                "This version of the Capstone bindings is unstable,"
                " please upgrade to a newer one!",
                RuntimeWarning, stacklevel=4) 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:37,代码来源:disasm.py

示例10: __init__

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def __init__(self):
        TranslationContext.__init__(self)

        self.registers = {
            capstone.arm.ARM_REG_R0:    r('r0', 32),
            capstone.arm.ARM_REG_R1:    r('r1', 32),
            capstone.arm.ARM_REG_R2:    r('r2', 32),
            capstone.arm.ARM_REG_R3:    r('r3', 32),
            capstone.arm.ARM_REG_R4:    r('r4', 32),
            capstone.arm.ARM_REG_R5:    r('r5', 32),
            capstone.arm.ARM_REG_R6:    r('r6', 32),
            capstone.arm.ARM_REG_R7:    r('r7', 32),
            capstone.arm.ARM_REG_R8:    r('r8', 32),
            capstone.arm.ARM_REG_R9:    r('r9', 32),
            capstone.arm.ARM_REG_R10:   r('r10', 32),
            capstone.arm.ARM_REG_R11:   r('r11', 32),
            capstone.arm.ARM_REG_R13:   r('sp', 32),
            capstone.arm.ARM_REG_R14:   r('lr', 32),
            capstone.arm.ARM_REG_R15:   r('pc', 32),
        }

        self.word_size = 32
        self.thumb = True
        self.stack_ptr = self.registers[capstone.arm.ARM_REG_R13]
        self.link_reg = self.registers[capstone.arm.ARM_REG_R14]
        self.program_ctr = self.registers[capstone.arm.ARM_REG_R15]
        self.disassembler = capstone.Cs(capstone.CS_ARCH_ARM, capstone.CS_MODE_THUMB)
        self.disassembler.detail = True 
开发者ID:c01db33f,项目名称:reil,代码行数:30,代码来源:translator.py

示例11: mode

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def mode(self, new_mode):
        assert new_mode in (cs.CS_MODE_ARM, cs.CS_MODE_THUMB)

        if self._mode != new_mode:
            logger.debug(f'swapping into {"ARM" if new_mode == cs.CS_MODE_ARM else "THUMB"} mode')

        self._mode = new_mode
        self.disasm.disasm.mode = new_mode 
开发者ID:trailofbits,项目名称:manticore,代码行数:10,代码来源:arm.py

示例12: _swap_mode

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def _swap_mode(self):
        """Toggle between ARM and Thumb mode"""
        assert self.mode in (cs.CS_MODE_ARM, cs.CS_MODE_THUMB)
        if self.mode == cs.CS_MODE_ARM:
            self.mode = cs.CS_MODE_THUMB
        else:
            self.mode = cs.CS_MODE_ARM

    # Flags that are the result of arithmetic instructions. Unconditionally
    # set, but conditionally committed.
    #
    # Register file has the actual CPU flags 
开发者ID:trailofbits,项目名称:manticore,代码行数:14,代码来源:arm.py

示例13: BL

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def BL(cpu, label):
        next_instr_addr = cpu.regfile.read("PC")
        if cpu.mode == cs.CS_MODE_THUMB:
            cpu.regfile.write("LR", next_instr_addr + 1)
        else:
            cpu.regfile.write("LR", next_instr_addr)
        cpu.regfile.write("PC", label.read()) 
开发者ID:trailofbits,项目名称:manticore,代码行数:9,代码来源:arm.py

示例14: test_thumb_mode_emulation

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def test_thumb_mode_emulation(self):
        asm = "add r0, r1, r2"
        self._setupCpu(asm, mode=CS_MODE_THUMB)
        self.rf.write("R0", 0)
        self.rf.write("R1", 0x1234)
        self.rf.write("R2", 0x5678)
        emu = emulate_next(self.cpu)
        self.assertEqual(self.rf.read("R0"), 0x1234 + 0x5678)
        self.assertEqual(emu._emu.query(UC_QUERY_MODE), UC_MODE_THUMB) 
开发者ID:trailofbits,项目名称:manticore,代码行数:11,代码来源:test_armv7unicorn.py

示例15: itest_thumb

# 需要导入模块: import capstone [as 别名]
# 或者: from capstone import CS_MODE_THUMB [as 别名]
def itest_thumb(asm):
    def instr_dec(assertions_func):
        @wraps(assertions_func)
        def wrapper(self):
            self._setupCpu(asm, mode=CS_MODE_THUMB)
            self.cpu.execute()
            assertions_func(self)

        return wrapper

    return instr_dec 
开发者ID:trailofbits,项目名称:manticore,代码行数:13,代码来源:test_armv7cpu.py


注:本文中的capstone.CS_MODE_THUMB属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。