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


Python archinfo.arch_from_id方法代码示例

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


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

示例1: get

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def get(self, name, arch):
        """
        Get an implementation of the given function specialized for the given arch, or a stub procedure if none exists.

        :param name:    The name of the function as a string
        :param arch:    The architecure to use, as either a string or an archinfo.Arch instance
        :return:        A SimProcedure instance representing the function as found in the library
        """
        if type(arch) is str:
            arch = archinfo.arch_from_id(arch)
        if name in self.procedures:
            proc = copy.deepcopy(self.procedures[name])
            self._apply_metadata(proc, arch)
            return proc
        else:
            return self.get_stub(name, arch) 
开发者ID:angr,项目名称:angr,代码行数:18,代码来源:__init__.py

示例2: test_arm_noop_blocks

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def test_arm_noop_blocks():
    arch = archinfo.arch_from_id("ARMEL")

    # andeq r0, r0, r0
    b = b"\x00\x00\x00\x00\x00\x00\x00\x00"
    p = angr.load_shellcode(b, arch, load_address=0x400000)
    block = p.factory.block(0x400000, opt_level=1, cross_insn_opt=False)
    assert CFGBase._is_noop_block(arch, block) is True
    block = p.factory.block(0x400000, opt_level=1, cross_insn_opt=True)
    assert CFGBase._is_noop_block(arch, block) is True

    # mov r0, r0
    b = b"\x00\x00\xa0\xe1"
    p = angr.load_shellcode(b, arch, load_address=0x400000)
    block = p.factory.block(0x400000, opt_level=1, cross_insn_opt=False)
    assert CFGBase._is_noop_block(arch, block) is True
    block = p.factory.block(0x400000, opt_level=1, cross_insn_opt=True)
    assert CFGBase._is_noop_block(arch, block) is True 
开发者ID:angr,项目名称:angr,代码行数:20,代码来源:test_noop_blocks.py

示例3: _detect_arch_ident

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def _detect_arch_ident(self):
        """
        Determines the binary's architecture by inspecting cputype and cpusubtype.
        :return: archinfo.arch_from_id-compatible ident string
        """
        # determine architecture by major CPU type
        try:
            arch_lookup = {
            # contains all supported architectures. Note that apple deviates from standard ABI, see Apple docs
                0x100000c: "aarch64",
                0xc: "arm",
                0x7: "x86",
                0x1000007: "x64",
            }
            return arch_lookup[self.cputype]  # subtype currently not needed
        except KeyError:
            return None 
开发者ID:angr,项目名称:cle,代码行数:19,代码来源:macho.py

示例4: convert_arch

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def convert_arch(arch):
    """
    Convert an arch ID or an archinfo.Arch instance to an archinfo.Arch instance.
    """
    if isinstance(arch, str):
        the_arch = archinfo.arch_from_id(arch)
    else:
        the_arch = arch
    return the_arch 
开发者ID:angr,项目名称:rex,代码行数:11,代码来源:utils.py

示例5: set_default_cc

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def set_default_cc(self, arch_name, cc_cls):
        """
        Set the default calling convention used for this library under a given architecture

        :param arch_name:   The string name of the architecture, i.e. the ``.name`` field from archinfo.
        :parm cc_cls:       The SimCC class (not an instance!) to use
        """
        arch_name = archinfo.arch_from_id(arch_name).name
        self.default_ccs[arch_name] = cc_cls 
开发者ID:angr,项目名称:angr,代码行数:11,代码来源:__init__.py

示例6: _canonicalize

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def _canonicalize(self, number, arch, abi_list):
        if type(arch) is str:
            arch = archinfo.arch_from_id(arch)
        if type(number) is str:
            return number, arch, None
        for abi in abi_list:
            mapping = self.syscall_number_mapping[abi]
            if number in mapping:
                return mapping[number], arch, abi
        return 'sys_%d' % number, arch, None 
开发者ID:angr,项目名称:angr,代码行数:12,代码来源:__init__.py

示例7: load_shellcode

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def load_shellcode(shellcode, arch, start_offset=0, load_address=0, thumb=False, **kwargs):
    """
    Load a new project based on a snippet of assembly or bytecode.

    :param shellcode:       The data to load, as either a bytestring of instructions or a string of assembly text
    :param arch:            The name of the arch to use, or an archinfo class
    :param start_offset:    The offset into the data to start analysis (default 0)
    :param load_address:    The address to place the data in memory (default 0)
    :param thumb:           Whether this is ARM Thumb shellcode
    """
    if not isinstance(arch, archinfo.Arch):
        arch = archinfo.arch_from_id(arch)
    if type(shellcode) is str:
        shellcode = arch.asm(shellcode, load_address, thumb=thumb)
    if thumb:
        start_offset |= 1

    return Project(
            BytesIO(shellcode),
            main_opts={
                'backend': 'blob',
                'arch': arch,
                'entry_point': start_offset,
                'base_addr': load_address,
            },
        **kwargs
        ) 
开发者ID:angr,项目名称:angr,代码行数:29,代码来源:project.py

示例8: test_amd64_noop_blocks

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def test_amd64_noop_blocks():

    # nop
    arch = archinfo.arch_from_id("amd64")
    b = b"\x90\x90\x90\x90\x90\x90\x90\x90"
    p = angr.load_shellcode(b, arch, load_address=0x400000)
    block = p.factory.block(0x400000, opt_level=1, cross_insn_opt=False)
    assert CFGBase._is_noop_block(arch, block) is True
    block = p.factory.block(0x400000, opt_level=1, cross_insn_opt=True)
    assert CFGBase._is_noop_block(arch, block) is True 
开发者ID:angr,项目名称:angr,代码行数:12,代码来源:test_noop_blocks.py

示例9: test_fauxware

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def test_fauxware():

    amd64 = archinfo.arch_from_id('amd64')

    args = {
        'i386': [
            ('authenticate', SimCCCdecl(
                archinfo.arch_from_id('i386'),
                args=[SimStackArg(4, 4), SimStackArg(8, 4)], sp_delta=4, ret_val=SimRegArg('eax', 4),
                )
             ),
        ],
        'x86_64': [
            ('authenticate', SimCCSystemVAMD64(
                amd64,
                args=[SimRegArg('rdi', 8), SimRegArg('rsi', 8)],
                sp_delta=8,
                ret_val=SimRegArg('rax', 8),
                )
             ),
        ],
    }

    for arch, lst in args.items():
        yield run_fauxware, arch, lst


# def test_cgc(): 
开发者ID:angr,项目名称:angr,代码行数:30,代码来源:test_calling_convention_analysis.py

示例10: extract_arch

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def extract_arch(reader):
        arch_str = reader['e_machine']
        if 'ARM' in arch_str:
            # Check the ARM attributes, if they exist
            arm_attrs = ELF._extract_arm_attrs(reader)
            if arm_attrs and 'TAG_CPU_NAME' in arm_attrs:
                if arm_attrs['TAG_CPU_NAME'].endswith("-M") \
                    or 'Cortex-M' in arm_attrs['TAG_CPU_NAME']:
                    return archinfo.ArchARMCortexM('Iend_LE')
            if reader.header.e_flags & 0x200:
                return archinfo.ArchARMEL('Iend_LE' if reader.little_endian else 'Iend_BE')
            elif reader.header.e_flags & 0x400:
                return archinfo.ArchARMHF('Iend_LE' if reader.little_endian else 'Iend_BE')

        return archinfo.arch_from_id(arch_str, 'le' if reader.little_endian else 'be', reader.elfclass) 
开发者ID:angr,项目名称:cle,代码行数:17,代码来源:elf.py

示例11: __init__

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def __init__(self, *args, **kwargs):
        if Xbe is None:
            raise CLEError("Run `pip install pyxbe==0.0.2` to support loading XBE files")
        super().__init__(*args, **kwargs)
        self.set_arch(archinfo.arch_from_id('x86'))

        self.os = 'xbox'
        if self.binary is None:
            self._xbe = Xbe(data=self._binary_stream.read())
        else:
            self._xbe = Xbe.from_file(self.binary)
        self._entry = self._xbe.entry_addr
        self._image_vmem = bytearray(self._xbe.header.image_size)
        self._min_addr = self._xbe.header.base_addr
        self._max_addr = self._xbe.header.base_addr + self._xbe.header.image_size

        # Add header
        self._add_xbe_section(
            0,
            self._xbe.header.image_header_size,
            self._xbe.header.base_addr,
            self._xbe.header.image_header_size,
            self._xbe.header_data)

        # Add each section
        for _, sec in self._xbe.sections.items():
            self._add_xbe_section(
                sec.header.raw_addr,
                sec.header.raw_size,
                sec.header.virtual_addr,
                sec.header.virtual_size,
                sec.data,
                sec)

        self.memory.add_backer(0, bytes(self._image_vmem))
        self.mapped_base = self.linked_base = self._xbe.header.base_addr 
开发者ID:angr,项目名称:cle,代码行数:38,代码来源:xbe.py

示例12: check_compatibility

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def check_compatibility(cls, spec, obj):
        if hasattr(spec, 'read') and hasattr(spec, 'seek'):
            pe = pefile.PE(data=spec.read(), fast_load=True)
        else:
            pe = pefile.PE(spec, fast_load=True)

        arch = archinfo.arch_from_id(pefile.MACHINE_TYPE[pe.FILE_HEADER.Machine])
        return arch == obj.arch

    #
    # Public methods
    # 
开发者ID:angr,项目名称:cle,代码行数:14,代码来源:pe.py

示例13: __init__

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def __init__(self, *args, offset=0, **kwargs):
        """
        Loader backend for BF programs
        :param path: The file path
        :param offset: Skip this many bytes from the beginning of the file.
        """
        super(BPF, self).__init__(*args,
                                  arch=arch_from_id("bpf"),
                                  offset=offset,
                                  entry_point=0,
                                  **kwargs)
        self.os = "bpf" 
开发者ID:angr,项目名称:angr-platforms,代码行数:14,代码来源:load_bpf.py

示例14: __init__

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def __init__(self, *args, offset=0, **kwargs):
        """
        Loader backend for BF programs
        :param path: The file path
        :param offset: Skip this many bytes from the beginning of the file.
        """
        super(BF, self).__init__(*args,
                arch=arch_from_id("bf"),
                offset=offset,
                entry_point=0,
                **kwargs)
        self.os = "bf" 
开发者ID:angr,项目名称:angr-platforms,代码行数:14,代码来源:load_bf.py

示例15: test_no_cross_insn_boundary_opt_amd64

# 需要导入模块: import archinfo [as 别名]
# 或者: from archinfo import arch_from_id [as 别名]
def test_no_cross_insn_boundary_opt_amd64():

    # 0x4020f8:       sub     rsp, 8
    # 0x4020fc:       mov     rax, qword ptr [rip + 0x221ef5]
    # 0x402103:       test    rax, rax
    # 0x402106:       je      0x40210d

    b = binascii.unhexlify("4883ec08488b05f51e22004885c07405")
    p = angr.load_shellcode(b, 'amd64', load_address=0x4020f8)

    # No optimization
    block = p.factory.block(0x4020f8, size=len(b), opt_level=0)
    assert len(block.vex.statements) == 32
    # Full level-1 optimization
    block = p.factory.block(0x4020f8, size=len(b), opt_level=1, cross_insn_opt=True)
    assert len(block.vex.statements) == 20
    # Level-1 optimization within each instruction
    block = p.factory.block(0x4020f8, size=len(b), opt_level=1, cross_insn_opt=False)
    stmts = block.vex.statements
    assert len(stmts) == 25
    # 12 | ------ IMark(0x402103, 3, 0) ------
    assert isinstance(stmts[12], pyvex.IRStmt.IMark)
    assert stmts[12].addr == 0x402103
    # 13 | t6 = GET:I64(rax)
    assert isinstance(stmts[13], pyvex.IRStmt.WrTmp)
    assert isinstance(stmts[13].data, pyvex.IRExpr.Get)
    assert stmts[13].data.offset == archinfo.arch_from_id('amd64').registers['rax'][0]
    # 14 | PUT(cc_op) = 0x0000000000000014
    assert isinstance(stmts[14], pyvex.IRStmt.Put)
    assert stmts[14].offset == archinfo.arch_from_id('amd64').registers['cc_op'][0]
    assert isinstance(stmts[14].data, pyvex.IRExpr.Const)
    assert stmts[14].data.con.value == 0x14
    # 15 | PUT(cc_dep1) = t6
    assert isinstance(stmts[15], pyvex.IRStmt.Put)
    assert stmts[15].offset == archinfo.arch_from_id('amd64').registers['cc_dep1'][0]
    # 16 | PUT(cc_dep2) = 0x0000000000000000
    assert isinstance(stmts[16], pyvex.IRStmt.Put)
    assert stmts[16].offset == archinfo.arch_from_id('amd64').registers['cc_dep2'][0]
    assert isinstance(stmts[16].data, pyvex.IRExpr.Const)
    assert stmts[16].data.con.value == 0
    # 17 | PUT(rip) = 0x0000000000402106
    assert isinstance(stmts[17], pyvex.IRStmt.Put)
    assert stmts[17].offset == archinfo.arch_from_id('amd64').registers['rip'][0]
    assert isinstance(stmts[17].data, pyvex.IRExpr.Const)
    assert stmts[17].data.con.value == 0x402106
    # 18 | ------ IMark(0x402106, 2, 0) ------
    assert isinstance(stmts[18], pyvex.IRStmt.IMark)
    assert stmts[18].addr == 0x402106 
开发者ID:angr,项目名称:angr,代码行数:50,代码来源:test_lifter.py


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