UI

Sark provides some basic utilities and wrappers for IDA’s UI.

NXGraph

A natural extension to creating and analyzing graphs, is plotting them. IDA provides a generic API via the idaapi.GraphViewer interface. As Sark mainly uses NetworkX digraphs, the sark.ui.NXGraph class has been created to provide an easy plotting solution.

>>> viewer = sark.ui.NXGraph(graph, title="My Graph", handler=sark.ui.AddressNodeHandler())
>>> viewer.Show()

The NXGraph constructor takes several arguments:

Argument Desctription
graph the graph to plot
title (opt.) title for the graph
handler (opt.) a default handler for nodes
padding (opt.) visual padding of nodes

After an NXGraph is created, use .Show() to display it.

Node Handlers

To allow different types of node data, NXGraph uses node handlers. Node handlers inherit from sark.ui.BasicNodeHandler and implement the callbacks required for them (all are optional).

Callback Usage
on_get_text returns the text to display for the node
on_click handles a click on the node. Return True to set the cursor on it.
on_double_click same as on_click
on_hint the hint to show
on_bg_color returns the background color for the node
on_frame_color returns the frame (border) color for the node

There are 2 existing handlers you can use.

Handler Info
BasicNodeHandler The most basic handler. Calls str to get node text, and nothing else. This is the default handler for NXGraph.
AddressNodeHandler Assumes all nodes are IDB addresses. For node text, it shows the address’ name if it exists, or a hex address otherwise. On double click, it jumps to the clicked address.