new_project.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:s2e-env 作者: S2E 项目源码 文件源码
def handle(self, *args, **options):
        # Need an absolute path for the target in order to simplify
        # symlink creation.
        target_path = options['target'][0]
        target_path = os.path.realpath(target_path)

        # Check that the target actually exists
        if not os.path.isfile(target_path):
            raise CommandError('Target %s does not exist' % target_path)

        default_magic = Magic()
        magic_checks = [
            (Magic(magic_file=CGC_MAGIC), CGC_REGEX, CGCProjectConfiguration, 'i386'),
            (default_magic, ELF32_REGEX, LinuxProjectConfiguration, 'i386'),
            (default_magic, ELF64_REGEX, LinuxProjectConfiguration, 'x86_64'),
            (default_magic, DLL32_REGEX, WindowsDLLProjectConfiguration, 'i386'),
            (default_magic, DLL64_REGEX, WindowsDLLProjectConfiguration, 'x86_64'),
            (default_magic, PE32_REGEX, WindowsProjectConfiguration, 'i386'),
            (default_magic, PE64_REGEX, WindowsProjectConfiguration, 'x86_64'),
            (default_magic, MSDOS_REGEX, WindowsProjectConfiguration, 'i386')
        ]

        # Check the target program against the valid file types
        for magic_check, regex, proj_config_class, arch in magic_checks:
            magic = magic_check.from_file(target_path)
            matches = regex.match(magic)

            # If we find a match, create that project. The user instructions
            # are returned
            if matches:
                options['target'] = target_path
                options['target_arch'] = arch

                return call_command(Project(proj_config_class), **options)

        # Otherwise no valid file type was found
        raise CommandError('%s is not a valid target for S2E analysis' %
                           target_path)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号