當前位置: 首頁>>代碼示例>>Python>>正文


Python capstone.x86方法代碼示例

本文整理匯總了Python中capstone.x86方法的典型用法代碼示例。如果您正苦於以下問題:Python capstone.x86方法的具體用法?Python capstone.x86怎麽用?Python capstone.x86使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在capstone的用法示例。


在下文中一共展示了capstone.x86方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: branchAddress

# 需要導入模塊: import capstone [as 別名]
# 或者: from capstone import x86 [as 別名]
def branchAddress(self):
        raise "not implemented"

# represents x86 asm line 
開發者ID:mtivadar,項目名稱:qiew,代碼行數:6,代碼來源:DisasmViewMode.py

示例2: referencedString

# 需要導入模塊: import capstone [as 別名]
# 或者: from capstone import x86 [as 別名]
def referencedString(self):

        # get referenced string
        if self._refString != None:
            return self._refString

        asm = self._asm

        self._refString = ''

        # PUSH <imm>
        if asm.id == capstone.x86.X86_INS_PUSH:
            if len(asm.operands) == 1:
                o = asm.operands[0]

                if o.type == capstone.x86.X86_OP_IMM:
                    value = o.imm
                    self._refString = self._plugin.stringFromVA(value)

        # [RIP + <imm>]
        if len(asm.operands) > 1:
            o = asm.operands[1]

            if o.type == capstone.x86.X86_OP_MEM:
                if o.mem.base == capstone.x86.X86_REG_RIP:
                    x =  asm.address + asm.size + o.mem.disp
                    self._refString = self._plugin.stringFromVA(x)

        return self._refString 
開發者ID:mtivadar,項目名稱:qiew,代碼行數:31,代碼來源:DisasmViewMode.py

示例3: symbol

# 需要導入模塊: import capstone [as 別名]
# 或者: from capstone import x86 [as 別名]
def symbol(self):
            
        # get symbol from plugin (for API calls for eg.)
        if self._symbol != None:
            return self._symbol

        # get symbol
        if self.ingroup([capstone.x86.X86_GRP_CALL]):
            value = None
            asm = self._asm

            for o in asm.operands:
                if o.type == capstone.x86.X86_OP_IMM:
                    value = o.imm

                if o.type == capstone.x86.X86_OP_MEM:
                    # todo: should we consider other reg relative ??
                    if o.mem.base == capstone.x86.X86_REG_RIP:
                        value = o.mem.disp + asm.size + asm.address

                    # mainly 32bit
                    if o.mem.base == capstone.x86.X86_REG_INVALID:
                        value = o.mem.disp

            if value:
                sym = self._plugin.disasmSymbol(value)

                if sym:
                    self._symbol = sym

        return self._symbol 
開發者ID:mtivadar,項目名稱:qiew,代碼行數:33,代碼來源:DisasmViewMode.py

示例4: isBranch

# 需要導入模塊: import capstone [as 別名]
# 或者: from capstone import x86 [as 別名]
def isBranch(self):
        return self.ingroup([capstone.x86.X86_GRP_JUMP, capstone.x86.X86_GRP_CALL]) 
開發者ID:mtivadar,項目名稱:qiew,代碼行數:4,代碼來源:DisasmViewMode.py

示例5: fill_reg_map

# 需要導入模塊: import capstone [as 別名]
# 或者: from capstone import x86 [as 別名]
def fill_reg_map():
    # TODO: Support more architectures
    for attr in dir(capstone.x86):
        if attr.startswith('X86_REG_'):
            reg_name = attr[8:]
            reg_offset = getattr(capstone.x86, attr)
            CAPSTONE_REG_MAP['X86'][reg_offset] = reg_name.lower()

    for attr in dir(capstone.x86):
        if attr.startswith('X86_REG_'):
            reg_name = attr[8:]
            reg_offset = getattr(capstone.x86, attr)
            CAPSTONE_REG_MAP['AMD64'][reg_offset] = reg_name.lower() 
開發者ID:angr,項目名稱:angr,代碼行數:15,代碼來源:reassembler.py

示例6: _checkCode

# 需要導入模塊: import capstone [as 別名]
# 或者: from capstone import x86 [as 別名]
def _checkCode(self, rawCode):
        md = capstone.Cs(capstone.CS_ARCH_X86, capstone.CS_MODE_16)
        md.detail = True

        checkJmp = True
        for i in md.disasm(rawCode, 0):
            # Check for JUMPs and CALLs before the first PUSH/RET.
            if checkJmp and len(i.groups) > 0:
                # Group check if available
                if hasattr(capstone.x86, 'X86_GRP_CALL') and hasattr(capstone.x86, 'X86_GRP_RET'):
                    if capstone.x86.X86_GRP_CALL in i.groups or capstone.x86.X86_GRP_JUMP in i.groups:
                        self._suspiciousBehaviour.append('JMP or CALL before relocation')
                        checkJmp = False
                    elif capstone.x86.X86_GRP_RET in i.groups:
                        # Stop search after the first PUSH/RET
                        checkJmp = False
                # Manual check in case capstone version doesn't support CALL and RET groups
                else:
                    if i.mnemonic[0] == 'j' or i.mnemonic == 'call':
                        self._suspiciousBehaviour.append('JMP or CALL before relocation')
                        checkJmp = False
                    elif i.mnemonic[:3] == 'ret':
                        # Stop search after the first PUSH/RET
                        checkJmp = False

            # Check for unknown interrupt
            if i.mnemonic == 'int' and i.bytes[1] not in (0x10, 0x13, 0x18, 0x1a):
                self._suspiciousBehaviour.append('Unknown Interrupt : {0:#x}'.format(i.bytes[1])) 
開發者ID:ANSSI-FR,項目名稱:bootcode_parser,代碼行數:30,代碼來源:bootcode_parser.py


注:本文中的capstone.x86方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。