1

Is there any easy way to get a function call graph of a binary program using IDApython then convert it to a networkx graph other than going through every function and constructing the call-graph ourselves?

Basically i want to have a call graph that i can tell which nodes are library calls and which are locals, and not including functions that are called by libraries ( so i dont go deep into nested library functions calling each other)

i tried gen_simple_call_chart() but there are two big problems :

  1. there is no difference between library nodes and local nodes in the generated DOT file (no color or anything)

  2. CHART_IGNORE_LIB_FROM doesnt work, i dont want to include nodes that are called by library calls :(

For example all the nodes are black no matter library or local :

"205" [ label = "sub_40AF20", pencolor = black ];
"206" [ label = "ShellExecuteW", pencolor = black ];
  • Did you try sark? It's built on top of networkx and idapython. – sudhackar Sep 12 at 8:23
1

You can generate graphs in the DOT format by calling gen_flow_graph() with the CHART_GEN_DOT flag.

The DOT file can then be imported into networkx using the from_pydot() function.

| improve this answer | |
  • Thanks for answer! (although for function call graph it seems to be gen_simple_call_chart), but there are two big problems : 1. there is no difference between library nodes and local nodes in the generated DOT file (no color or anything), 2. CHART_IGNORE_LIB_FROM doesnt work, i dont want to include nodes that are called by library calls :( – OneAndOnly Sep 11 at 15:33
  • i edited to question to include part of the .dot file, as you can see all the nodes are black and it also includes nodes that are even called by libraries even tho i used CHART_IGNORE_LIB_FROM, i tried CHART_IGNORE_LIB_TO as well just to check but no luck. – OneAndOnly Sep 11 at 15:39
  • I’ve answered the question as originally asked (get networkx graph from IDA). The graph being different from what you need is another issue. I suggest you contacting Hex-Rays support to confirm if issues you found are a bug and/or get a fix. – Igor Skochinsky Sep 15 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.