9,515
社区成员
发帖
与我相关
我的任务
分享
# gen_fcg.py
# -*- coding: utf-8 -*-
# python 2
import pickle
import idaapi
import logging
import sys
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s - %(message)s')
def gen(out_name):
text_addr = ScreenEA()
fcg = dict()
for callee_addr in Functions():
callee_name = GetFunctionName(callee_addr)
for caller_addr in CodeRefsTo(callee_addr, 0):
caller_name = GetFunctionName(caller_addr)
logging.info(callee_name + '-' + caller_name)
fcg[caller_name] = fcg.get(caller_name, set())
fcg[caller_name].add(callee_name)
pickle.dump(fcg, open(out_name, 'w'))
print fcg
if __name__ == '__main__':
logging.info('sys.argv' + str(sys.argv))
idaapi.autoWait()
logging.info('start analyse...')
gen('D:\\Lab\\data_win\\fcg\\fcg.pkl')
idc.Exit(0)
%IDAQ_PATH% -L./analysis.log -c -A -S./gen_cfg.py ./CRACKME.EXE