miasm
Reverse engineering framework
|
Public Member Functions | |
def | __init__ (self) |
def | __repr__ (self) |
def | nodes (self) |
def | edges (self) |
def | merge (self, graph) |
def | __add__ (self, graph) |
def | copy (self) |
def | __eq__ (self, graph) |
def | __ne__ (self, other) |
def | add_node (self, node) |
def | del_node (self, node) |
def | add_edge (self, src, dst) |
def | add_uniq_edge (self, src, dst) |
def | del_edge (self, src, dst) |
def | discard_edge (self, src, dst) |
def | predecessors_iter (self, node) |
def | predecessors (self, node) |
def | successors_iter (self, node) |
def | successors (self, node) |
def | leaves_iter (self) |
def | leaves (self) |
def | heads_iter (self) |
def | heads (self) |
def | find_path (self, src, dst, cycles_count=0, done=None) |
def | find_path_from_src (self, src, dst, cycles_count=0, done=None) |
def | nodeid (self, node) |
def | node2lines (self, node) |
def | node_attr (self, node) |
def | edge_attr (self, src, dst) |
def | dot (self) |
def | predecessors_stop_node_iter (self, node, head) |
def | reachable_sons (self, head) |
def | reachable_parents (self, leaf) |
def | reachable_parents_stop_node (self, leaf, head) |
def | compute_dominators (self, head) |
def | compute_postdominators (self, leaf) |
def | compute_dominator_tree (self, head) |
def | walk_dominators (self, node, dominators) |
def | walk_postdominators (self, node, postdominators) |
def | compute_immediate_dominators (self, head) |
def | compute_immediate_postdominators (self, tail) |
def | compute_dominance_frontier (self, head) |
def | walk_breadth_first_forward (self, head) |
def | walk_depth_first_forward (self, head) |
def | walk_breadth_first_backward (self, head) |
def | walk_depth_first_backward (self, head) |
def | has_loop (self) |
def | compute_natural_loops (self, head) |
def | compute_back_edges (self, head) |
def | compute_strongly_connected_components (self) |
def | compute_weakly_connected_components (self) |
def | replace_node (self, node, new_node) |
Static Public Attributes | |
DotCellDescription | |
Implementation of directed graph
def miasm.core.graph.DiGraph.__init__ | ( | self | ) |
def miasm.core.graph.DiGraph.__add__ | ( | self, | |
graph | |||
) |
Wrapper on `.merge`
Reimplemented in miasm.core.graph.MatchGraph.
def miasm.core.graph.DiGraph.__eq__ | ( | self, | |
graph | |||
) |
def miasm.core.graph.DiGraph.__ne__ | ( | self, | |
other | |||
) |
def miasm.core.graph.DiGraph.__repr__ | ( | self | ) |
Reimplemented in miasm.core.asmblock.AsmCFG.
def miasm.core.graph.DiGraph.add_edge | ( | self, | |
src, | |||
dst | |||
) |
def miasm.core.graph.DiGraph.add_node | ( | self, | |
node | |||
) |
Add the node @node to the graph. If the node was already present, return False. Otherwise, return True
Reimplemented in miasm.core.asmblock.AsmCFG.
def miasm.core.graph.DiGraph.add_uniq_edge | ( | self, | |
src, | |||
dst | |||
) |
Add an edge from @src to @dst if it doesn't already exist
def miasm.core.graph.DiGraph.compute_back_edges | ( | self, | |
head | |||
) |
Computes all back edges from a node to a dominator in the graph. :param head: head of graph :return: yield a back edge
def miasm.core.graph.DiGraph.compute_dominance_frontier | ( | self, | |
head | |||
) |
Compute the dominance frontier of the graph Source: Cooper, Keith D., Timothy J. Harvey, and Ken Kennedy. "A simple, fast dominance algorithm." Software Practice & Experience 4 (2001), p. 9
def miasm.core.graph.DiGraph.compute_dominator_tree | ( | self, | |
head | |||
) |
Computes the dominator tree of a graph :param head: head of graph :return: DiGraph
def miasm.core.graph.DiGraph.compute_dominators | ( | self, | |
head | |||
) |
Compute the dominators of the graph
def miasm.core.graph.DiGraph.compute_immediate_dominators | ( | self, | |
head | |||
) |
Compute the immediate dominators of the graph
def miasm.core.graph.DiGraph.compute_immediate_postdominators | ( | self, | |
tail | |||
) |
Compute the immediate postdominators of the graph
def miasm.core.graph.DiGraph.compute_natural_loops | ( | self, | |
head | |||
) |
Computes all natural loops in the graph. Source: Aho, Alfred V., Lam, Monica S., Sethi, R. and Jeffrey Ullman. "Compilers: Principles, Techniques, & Tools, Second Edition" Pearson/Addison Wesley (2007), Chapter 9.6.6 :param head: head of the graph :return: yield a tuple of the form (back edge, loop body)
def miasm.core.graph.DiGraph.compute_postdominators | ( | self, | |
leaf | |||
) |
Compute the postdominators of the graph
def miasm.core.graph.DiGraph.compute_strongly_connected_components | ( | self | ) |
Partitions the graph into strongly connected components. Iterative implementation of Gabow's path-based SCC algorithm. Source: Gabow, Harold N. "Path-based depth-first search for strong and biconnected components." Information Processing Letters 74.3 (2000), pp. 109--110 The iterative implementation is inspired by Mark Dickinson's code: http://code.activestate.com/recipes/ 578507-strongly-connected-components-of-a-directed-graph/ :return: yield a strongly connected component
def miasm.core.graph.DiGraph.compute_weakly_connected_components | ( | self | ) |
Return the weakly connected components
def miasm.core.graph.DiGraph.copy | ( | self | ) |
Copy the current graph instance
Reimplemented in miasm.core.asmblock.AsmCFG.
def miasm.core.graph.DiGraph.del_edge | ( | self, | |
src, | |||
dst | |||
) |
Reimplemented in miasm.core.asmblock.AsmCFG, and miasm.analysis.data_flow.DiGraphDefUse.
def miasm.core.graph.DiGraph.del_node | ( | self, | |
node | |||
) |
Delete the @node of the graph; Also delete every edge to/from this @node
def miasm.core.graph.DiGraph.discard_edge | ( | self, | |
src, | |||
dst | |||
) |
Remove edge between @src and @dst if it exits
def miasm.core.graph.DiGraph.dot | ( | self | ) |
Render dot graph with HTML
def miasm.core.graph.DiGraph.edge_attr | ( | self, | |
src, | |||
dst | |||
) |
Return a dictionary of attributes for the edge between @src and @dst @src: the source node of the edge @dst: the destination node of the edge
Reimplemented in miasm.ir.ir.IRCFG, miasm.core.asmblock.AsmCFG, and miasm.analysis.data_flow.DiGraphDefUse.
def miasm.core.graph.DiGraph.edges | ( | self | ) |
def miasm.core.graph.DiGraph.find_path | ( | self, | |
src, | |||
dst, | |||
cycles_count = 0 , |
|||
done = None |
|||
) |
Searches for paths from @src to @dst @src: loc_key of basic block from which it should start @dst: loc_key of basic block where it should stop @cycles_count: maximum number of times a basic block can be processed @done: dictionary of already processed loc_keys, it's value is number of times it was processed @out: list of paths from @src to @dst
def miasm.core.graph.DiGraph.find_path_from_src | ( | self, | |
src, | |||
dst, | |||
cycles_count = 0 , |
|||
done = None |
|||
) |
This function does the same as function find_path. But it searches the paths from src to dst, not vice versa like find_path. This approach might be more efficient in some cases. @src: loc_key of basic block from which it should start @dst: loc_key of basic block where it should stop @cycles_count: maximum number of times a basic block can be processed @done: dictionary of already processed loc_keys, it's value is number of times it was processed @out: list of paths from @src to @dst
def miasm.core.graph.DiGraph.has_loop | ( | self | ) |
Return True if the graph contains at least a cycle
def miasm.core.graph.DiGraph.heads | ( | self | ) |
def miasm.core.graph.DiGraph.heads_iter | ( | self | ) |
def miasm.core.graph.DiGraph.leaves | ( | self | ) |
def miasm.core.graph.DiGraph.leaves_iter | ( | self | ) |
def miasm.core.graph.DiGraph.merge | ( | self, | |
graph | |||
) |
Merge the current graph with @graph @graph: DiGraph instance
Reimplemented in miasm.core.asmblock.AsmCFG.
def miasm.core.graph.DiGraph.node2lines | ( | self, | |
node | |||
) |
Returns an iterator on cells of the dot @node. A DotCellDescription or a list of DotCellDescription are accepted @node: a node of the graph
Reimplemented in miasm.ir.ir.IRCFG, miasm.core.asmblock.AsmCFG, miasm.analysis.data_flow.DiGraphLiveness, and miasm.analysis.data_flow.DiGraphDefUse.
def miasm.core.graph.DiGraph.node_attr | ( | self, | |
node | |||
) |
Returns a dictionary of the @node's attributes @node: a node of the graph
Reimplemented in miasm.ir.ir.IRCFG, and miasm.core.asmblock.AsmCFG.
def miasm.core.graph.DiGraph.nodeid | ( | self, | |
node | |||
) |
Returns uniq id for a @node @node: a node of the graph
def miasm.core.graph.DiGraph.nodes | ( | self | ) |
def miasm.core.graph.DiGraph.predecessors | ( | self, | |
node | |||
) |
def miasm.core.graph.DiGraph.predecessors_iter | ( | self, | |
node | |||
) |
def miasm.core.graph.DiGraph.predecessors_stop_node_iter | ( | self, | |
node, | |||
head | |||
) |
def miasm.core.graph.DiGraph.reachable_parents | ( | self, | |
leaf | |||
) |
Compute all parents of node @leaf. Each parent is an immediate predecessor of an arbitrary, already yielded parent of @leaf
def miasm.core.graph.DiGraph.reachable_parents_stop_node | ( | self, | |
leaf, | |||
head | |||
) |
Compute all parents of node @leaf. Each parent is an immediate predecessor of an arbitrary, already yielded parent of @leaf. Do not compute reachables past @head node
def miasm.core.graph.DiGraph.reachable_sons | ( | self, | |
head | |||
) |
Compute all nodes reachable from node @head. Each son is an immediate successor of an arbitrary, already yielded son of @head
def miasm.core.graph.DiGraph.replace_node | ( | self, | |
node, | |||
new_node | |||
) |
Replace @node by @new_node
def miasm.core.graph.DiGraph.successors | ( | self, | |
node | |||
) |
def miasm.core.graph.DiGraph.successors_iter | ( | self, | |
node | |||
) |
def miasm.core.graph.DiGraph.walk_breadth_first_backward | ( | self, | |
head | |||
) |
Performs a breadth first search on the reversed graph from @head
def miasm.core.graph.DiGraph.walk_breadth_first_forward | ( | self, | |
head | |||
) |
Performs a breadth first search on the graph from @head
def miasm.core.graph.DiGraph.walk_depth_first_backward | ( | self, | |
head | |||
) |
Performs a depth first search on the reversed graph from @head
def miasm.core.graph.DiGraph.walk_depth_first_forward | ( | self, | |
head | |||
) |
Performs a depth first search on the graph from @head
def miasm.core.graph.DiGraph.walk_dominators | ( | self, | |
node, | |||
dominators | |||
) |
Return an iterator of the ordered list of @node's dominators The function doesn't return the self reference in dominators. @node: The start node @dominators: The dictionary containing at least node's dominators
def miasm.core.graph.DiGraph.walk_postdominators | ( | self, | |
node, | |||
postdominators | |||
) |
Return an iterator of the ordered list of @node's postdominators The function doesn't return the self reference in postdominators. @node: The start node @postdominators: The dictionary containing at least node's postdominators
|
static |