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


Python r2pipe.open方法代码示例

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


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

示例1: cache

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def cache(filename):
    """
    A simple decorator to cache results to disk.
    """

    def decorator(func):
        """Note: it is the function that is finally returned"""
        def cached_function(*args):
            """Note: needed to access the returned value"""
            try:
                return pickle.load(open(filename, "r"))
            except IOError:
                value = func(*args)
                pickle.dump(value, open(filename, "w"))
                return value
        return cached_function

    return decorator 
开发者ID:guedou,项目名称:flashre,代码行数:20,代码来源:utils.py

示例2: get_r2pipe

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def get_r2pipe(filename, offset, options=None):
    """
    Get a r2pipe handle ready to analyse a flashair binary.
    """

    # Set the miasm architecture
    os.putenv("R2M2_ARCH", "mepl")

    # Use the r2m2 architecture
    default_options = ["-a", "r2m2"]

    # Map the binary at a given location
    default_options += ["-m", hex(offset)]

    # Decrease r2 verbosity
    default_options += ["-e", "bin.verbose=false"]

    # Add user specified options
    if isinstance(options, list):
        default_options += options

    return r2pipe.open(filename, default_options) 
开发者ID:guedou,项目名称:flashre,代码行数:24,代码来源:utils.py

示例3: run_analysis

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def run_analysis(self):
        """Main analysis method.

        :returns: Dictionary containing analysis results.
        """
        log.info('Static Analysis started.')

        # start radare2
        self._r2 = r2pipe.open(self._file.path, ['-2'])
        self._r2.cmd('aaa')

        # binary info
        self._r2_info()

        # strings
        self._load_strings()

        self._r2.quit()
        log.info('Static Analysis finished.')

        return self._output 
开发者ID:danieluhricek,项目名称:LiSa,代码行数:23,代码来源:static_analysis.py

示例4: get_function_information

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def get_function_information(file_name):
    func_list = []

    r2_ins = r2pipe.open(file_name, flags=["-2"])
    '''
    Commands = ['aa', 'afr', '& aap', '& aac', '& aar', '& aaE',
            '& aaf', '& aas', '& aae', '& aav', '&&', 'afva', 'afta']
    
    for command in tqdm(Commands, desc="Analysis Running"):
        r2_ins.cmd(command)
    '''

    r2_ins.cmd('aaa')
    try:
        func_list = r2_ins.cmdj('aflj')
    except:
        func_list = []
    r2_ins.quit()
    return func_list 
开发者ID:ChrisTheCoolHut,项目名称:Firmware_Slap,代码行数:21,代码来源:function_handler.py

示例5: carve

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def carve(file_path, offset, size, magic=None):
    r2 = r2pipe.open(file_path, ['-z'])
    if magic:
        magic_bytes = hexlify(bytes(magic, 'ascii'))
        print('[+] Checking for magic: %s - %x' % (magic, int(magic_bytes, 16)))
        header = r2.cmd("p8 %x @ %s" % (len(magic), offset))
        if bytes(header, 'ascii') != magic_bytes:
            print("[+] No magic found, exiting...")
            exit()
        else:
            print("[+] Magic found, carving...")

    r2.cmd("s %s" % (offset))
    r2.cmd('wtf %s.%s %s' % (file_path, offset, size))
    print("[+] Carving to %s.%s" % (file_path, offset))
    return '%s.%s' % (file_path, offset) 
开发者ID:countercept,项目名称:radare2-scripts,代码行数:18,代码来源:r2_bin_carver.py

示例6: main

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def main():
    parser = argparse.ArgumentParser(description='Carve binaries from MiniDumps.')
    parser.add_argument('dmp', help='The MiniDump file to carve from')
    parser.add_argument('offset', help='Offset to carve from')
    parser.add_argument('size', help='Size of binary to carve')
    parser.add_argument('-b', type=str, help='Magic bytes to check for, e.g. MZ')
    parser.add_argument('-p', '--patch', action='store_true', help='Patch carved PE files')
    args = parser.parse_args()

    # FIXME: Won't redirect r2pipe, will have to 2>/dev/null for now!
    f = open(os.devnull, 'w')
    sys.stderr = f

    output_file = carve(args.dmp, args.offset, args.size, args.b)

    if args.patch:
        patch(output_file) 
开发者ID:countercept,项目名称:radare2-scripts,代码行数:19,代码来源:r2_bin_carver.py

示例7: __init__

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def __init__(self, name):
        self.name = name

        self.r2 = r2pipe.open()

        bininfo = self.r2.cmdj("ij")["bin"]
        self.arch = bininfo["arch"]
        self.bits = bininfo["bits"]
        self.regs = self.r2.cmdj("drlj")
        self.switch_flagspace(self.name)

        self.sections = self.get_sections()
        imports = self.get_imports()
        self.imports = {}
        for imp in imports:
            self.imports[imp["plt"]] = imp["name"]
        exports = self.get_exports()
        self.exports = {}
        for exp in exports:
            self.exports[exp["name"]] = exp["vaddr"] 
开发者ID:kamou,项目名称:pimp,代码行数:22,代码来源:pimp.py

示例8: __init__

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def __init__(self, filename, anal, debug=False, force_replace=False, write=False):
        self.debug = debug
        self.force = force_replace
        flags = []
        if write:
            flags.append("-w")
        print("[INFO] Opening file with r2")
        self.r2 = r2pipe.open(filename, flags)
        info = json.loads(self.r2.cmd("ij").replace("\\", "\\\\"))
        if "bin" not in info.keys():
            raise Exception("[ERROR] File type not supported")
        if not info["bin"]["bits"] in constants.supported_bits or \
           not info["bin"]["arch"] in constants.supported_archs:
            raise Exception("[ERROR] Architecture not supported")
        self.arch = info["bin"]["arch"]
        self.bits = info["bin"]["bits"]
        if anal:
            print("[INFO] Analyzing functions with r2")
            self.r2.cmd("aaa") 
开发者ID:a0rtega,项目名称:metame,代码行数:21,代码来源:r2parser.py

示例9: main

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def main():
    import os
    for i, filename in enumerate(os.listdir("occult_dist")):
        if i % 8 != int(sys.argv[1]):
            continue
        solution_file = "%s.solution" % filename
        if os.path.exists(solution_file):
            continue
        print(i, filename)
        try:
            sol = solve(filename)
        except ValueError:
            print("oops failed on %s" % filename)
            continue
        # data = sol.encode("base64")
        with open(solution_file, "wb") as f:
            f.write(sol)
        #print("Send this:" + data)
        #sock.send(data + "\n") 
开发者ID:angr,项目名称:angr-doc,代码行数:21,代码来源:occult.py

示例10: main

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def main():
    print(solve("df8737d9d5aee3cee6320e7313414458fdfb10552a8e6c8ea45753102ba4509a"))
    return
    import os
    for i, filename in enumerate(os.listdir("bc9cd8ff91a55ecee73caf85c3d55e45")):
        if i % 8 != int(sys.argv[1]):
            continue
        solution_file = "%s.solution" % filename
        if os.path.exists(solution_file):
            continue
        print(i, filename)
        try:
            sol = solve(filename)
            if not sol:
                continue
        except ValueError:
            print("oops failed on %s" % filename)
            continue
        # data = sol.encode("base64")
        with open(solution_file, "wb") as f:
            f.write(sol)
        #print("Send this:" + data)
        #sock.send(data + "\n") 
开发者ID:angr,项目名称:angr-doc,代码行数:25,代码来源:solve_chicken.py

示例11: get_base_addr

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def get_base_addr(file_name):
    r2_ins = r2pipe.open(file_name, flags=["-2"])
    return r2_ins.cmdj('ij')['bin']['baddr'] 
开发者ID:ChrisTheCoolHut,项目名称:Firmware_Slap,代码行数:5,代码来源:function_handler.py

示例12: open_file

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def open_file(self, filename):
        self.r2_obj = r2pipe.open(filename)
        return self.r2_obj 
开发者ID:invictus1306,项目名称:beebug,代码行数:5,代码来源:r2.py

示例13: __init__

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def __init__(self, path, cache_path):
        self.exe_path = path
        self.__r2p = r2pipe.open(path)
        self.__cache_file = os.path.join(cache_path, os.path.basename(path)+'.cache')
        self.__data = {}
        self.__need_save_cache = False
        self.__cached = self.__check_cache()
        self.__analyzed = False
        if not self.__cached:
            self.analyze() 
开发者ID:cylance,项目名称:winapi-deobfuscation,代码行数:12,代码来源:radare.py

示例14: __init__

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def __init__(self):
        # open empty, we'll open files later
        self.r2 = r2pipe.open('--')
        self.opcodeAddrs = [] 
开发者ID:sapir,项目名称:sonare,代码行数:6,代码来源:main.py

示例15: open

# 需要导入模块: import r2pipe [as 别名]
# 或者: from r2pipe import open [as 别名]
def open(self, path):
        # not using 'oc' command because it resets r2's -q flag, don't know what
        # else.

        # close all
        self.cmd('o--')

        # then open the new file
        # TODO: escaping?
        self.cmd('o {}', path)

        self.analyze()
        self.opcodeAddrs = self._getOpcodeAddrs()
        self.symbolFlags = SortedListWithKey(self.getFlags('symbols'),
            key=lambda f: f['offset']) 
开发者ID:sapir,项目名称:sonare,代码行数:17,代码来源:main.py


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