def call_extraction(file_info, extracthex, reset, annotate):
    try:
        (path, filename, deps) = file_info
    except UF.CHBError as e:
        print(str(e.wrap()))
        exit(1)

    if not UF.check_executable(path, filename):
        try:
            extract(path, filename, deps, extracthex, annotate)
        except subprocess.CalledProcessError as args:
            print(args.output)
            print(args)
            return

    if reset:
        chdir = UF.get_ch_dir(path, filename)
        if os.path.isdir(chdir):
            print('Removing ' + chdir)
            shutil.rmtree(chdir)
        if not UF.unpack_tar_file(path, filename):
            print('*' * 80)
            print('Error in unpacking tar.gz file with executable content')
            print('*' * 80)
            exit(1)
def call_disassembly(file_info, xml, reducech):
    (path, filename, deps) = file_info
    am = AM.AnalysisManager(path, filename, deps=deps)

    try:
        am.disassemble(save_xml=xml)
        if reducech:
            chdir = UF.get_ch_dir(path, filename)
            if os.path.isdir(chdir):
                print('Removing ' + chdir)
                shutil.rmtree(chdir)
    except subprocess.CalledProcessError as args:
        print(args.output)
        print(args)
Exemple #3
0
    args = parse()

    try:
        (path, filename,
         deps) = UF.get_path_filename_deps('x86-pe', args.filename)
        if not UF.check_executable(path, filename):
            extract(path, filename, deps, args.extracthex)
    except UF.CHBError as e:
        print(str(e.wrap()))
        exit(1)

    UF.check_analyzer()
    am = AM.AnalysisManager(path, filename, deps=deps)

    if args.reset:
        chdir = UF.get_ch_dir(path, filename)
        if os.path.isdir(chdir):
            print('Removing ' + chdir)
            shutil.rmtree(chdir)
        if not UF.unpack_tar_file(path, filename):
            print('*' * 80)
            print('Error in unpacking tar.gz file with executable content')
            print('*' * 80)
            exit(1)

    try:
        am.analyze(iterations=args.iterations,
                   save_asm=args.asm,
                   verbose=args.verbose)
    except subprocess.CalledProcessError as e:
        print(e.output)