I need to generate call graph for two DLL's and compare it using IDApython and it must be executed automatically in command line.
How to generate and save call graph and immediately open next DLL and generate and save callgraph and then compare?
If you prefer to write something yourself, please remember that comparing 2 binaries is not a trivial task. That said, I will explain how the comparison of the call graphs of 2 binaries works in both gcluster.py and Diaphora:
Another way of comparing call graphs is doing it by traversing both graphs and calculating the differences between 2 graphs (considering that you have some way to determine that a function F in binary A is equal to function F' in binary B, something that is not trivial). I don't recommend you doing so unless solving how to do so is your problem/what you want to do.
My 2 cents.
This is very broad question, which consists from some simpler ones.
How to operate IDA from command line ?
According to this link you can invoke IDA from the command line with
-S switch to run specific script after auto-analysis is complete. You can create shell script to run multiple ida instances from the command line.
How to generate function graph and save it?
#not tested, beware of errors, use on your own risk
# if you find GDL format problematic you can use ODT format
# by replacing idaapi.CHART_GEN_GDL to idaapi.CHART_GEN_ODT
for ea in idautils.Functions():
idc.GenFuncGdl("%s.gdl" % idc.GetFunctionName(ea), idc.GetFunctionName(ea), ea , idc.BADADDR, idaapi.CHART_GEN_GDL)
How to generate the whole call graph ?
It is simple:
idc.GenCallGdl("z:\\callgdl.gdl", "TheTitle", CHART_GEN_GDL)
Note the possibility to use CHART_WINGRAPH and CHART_NOLIBFUNCS as flags.
If you want to use functions from
How to compare call graphs ?
It depends what exactly you are trying to get from the comparison.
Hope it helps.