Gencoding/raw-feature-extractor/preprocessing_ida.py

35 lines
934 B
Python
Raw Normal View History

import idc
from func import *
from raw_graphs import *
from idc import *
import os
import argparse
2023-12-02 21:53:57 +08:00
def parse_command():
2023-12-02 21:53:57 +08:00
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument("--path", type=str, help="The directory where to store the generated .ida file")
args = parser.parse_args()
return args
2023-12-02 21:53:57 +08:00
if __name__ == '__main__':
# def main_op(store_file_path):
2023-12-02 21:53:57 +08:00
args = parse_command()
# path = os.path.join("../")
2023-12-02 21:53:57 +08:00
path = idc.ARGV[2]
print os.getcwd()
2023-12-02 21:53:57 +08:00
analysis_flags = idc.GetShortPrm(idc.INF_START_AF)
analysis_flags &= ~idc.AF_IMMOFF
# turn off "automatically make offset" heuristic
idc.SetShortPrm(idc.INF_START_AF, analysis_flags)
idaapi.autoWait()
cfgs = get_func_cfgs_c(FirstSeg())
binary_name = idc.GetInputFile() + '.ida'
fullpath = os.path.join(path, binary_name)
pickle.dump(cfgs, open(fullpath, 'w'))
idc.Exit(0)