def unflatGraph(flat_graph): graph = DiGraph() nodes, edges = flat_graph for node in nodes: graph.add_node(node) for nodeA, nodeB in edges: graph.add_edge(nodeA, nodeB) return graph
def miasm_graph_from_binja(func): G = DiGraph() for src in func.basic_blocks: for dst in [edge.target for edge in src.outgoing_edges]: G.add_edge(bbid(src), bbid(dst)) return G
def as_graph(self): """Generates a Digraph of dependencies""" graph = DiGraph() for node_a, node_b in self.links: if not node_b: graph.add_node(node_a) else: graph.add_edge(node_a, node_b) for parent, sons in viewitems(self.pending): for son in sons: graph.add_edge(parent, son) return graph
def gen_block_data_flow_graph(lifter, ircfg, ad, block_flow_cb): for irblock in viewvalues(ircfg.blocks): print(irblock) deadrm(ircfg) irblock_0 = None for irblock in viewvalues(ircfg.blocks): loc_key = irblock.loc_key offset = ircfg.loc_db.get_location_offset(loc_key) if offset == ad: irblock_0 = irblock break assert irblock_0 is not None flow_graph = DiGraph() flow_graph.node2str = node2str irb_in_nodes = {} irb_out_nodes = {} for label in ircfg.blocks: irb_in_nodes[label] = {} irb_out_nodes[label] = {} for label, irblock in viewitems(ircfg.blocks): block_flow_cb(lifter, ircfg, flow_graph, irblock, irb_in_nodes[label], irb_out_nodes[label]) for label in ircfg.blocks: print(label) print('IN', [str(x) for x in irb_in_nodes[label]]) print('OUT', [str(x) for x in irb_out_nodes[label]]) print('*' * 20, 'interblock', '*' * 20) inter_block_flow(lifter, ircfg, flow_graph, irblock_0.loc_key, irb_in_nodes, irb_out_nodes) # from graph_qt import graph_qt # graph_qt(flow_graph) open('data.dot', 'w').write(flow_graph.dot())