diff options
| author | Ajax <commial@gmail.com> | 2017-07-05 10:37:52 +0200 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2017-07-05 11:22:42 +0200 |
| commit | 81ba101de2fd128d4fbc99efdac02600d8fcb06f (patch) | |
| tree | 1049b3ec144bc7aaa1b7d439b61f1f25e6954d20 /example/ida/menu.py | |
| parent | 67f5ea5197bec721f706624d40a0687ef246083c (diff) | |
| download | miasm-81ba101de2fd128d4fbc99efdac02600d8fcb06f.tar.gz miasm-81ba101de2fd128d4fbc99efdac02600d8fcb06f.zip | |
IDA: add a Miasm menu with shortcuts to other IDA examples
Diffstat (limited to 'example/ida/menu.py')
| -rw-r--r-- | example/ida/menu.py | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/example/ida/menu.py b/example/ida/menu.py new file mode 100644 index 00000000..b88cc59f --- /dev/null +++ b/example/ida/menu.py @@ -0,0 +1,77 @@ +"""Implements a menu for IDA with: +- Miasm +- Miasm > Symbolic execution (icon 81, F3) +- Miasm > Dependency graph (icon 79, F4) +- Miasm > Graph IR (icon 188, F7) +- Miasm > Graph IR (simplified) (icon 191, F8) +- Miasm > RPYC server (icon 182, F10) +- Miasm > Type propagation (icon 38, F11) +""" + +from symbol_exec import symbolic_exec +from graph_ir import build_graph +try: + from rpyc_ida import serve_threaded +except ImportError: + serve_threaded = None +from depgraph import launch_depgraph +try: + from ctype_propagation import analyse_function +except ImportError: + analyse_function = None + +class Handler(idaapi.action_handler_t): + + def __init__(self, callback): + """Create a Handler calling @callback when activated""" + super(Handler, self).__init__() + self.callback = callback + + def activate(self, ctx): + return self.callback() + + # This action is always available. + def update(self, ctx): + return idaapi.AST_ENABLE_ALWAYS + + def register(self, name, label, shortcut=None, tooltip=None, icon=-1): + action = idaapi.action_desc_t( + name, # The action name. This acts like an ID and must be unique + label, # The action text. + self, # The action handler. + shortcut,# Optional: the action shortcut + tooltip, # Optional: the action tooltip (available in menus/toolbar) + icon, # Optional: the action icon (shows when in menus/toolbars) + ) + idaapi.register_action(action) + self.name = name + return action + + def attach_to_menu(self, menu): + assert hasattr(self, "name") + idaapi.attach_action_to_menu(menu, self.name, idaapi.SETMENU_APP) + +idaapi.create_menu("Miasm", "Miasm") + +handler_symb = Handler(symbolic_exec) +handler_symb.register("miasm:symbexec", "Symbolic exec", shortcut="F3", icon=81) +handler_symb.attach_to_menu("Miasm/Symbolic exec") +handler_depgraph = Handler(launch_depgraph) +handler_depgraph.register("miasm:depgraph", "Dependency graph", shortcut="F4", icon=79) +handler_depgraph.attach_to_menu("Miasm/Dependency graph") +handler_graph = Handler(build_graph) +handler_graph.register("miasm:graphir", "Graph IR", shortcut="F7", icon=188) +handler_graph.attach_to_menu("Miasm/Graph IR") +handler_graph_simp = Handler(lambda: build_graph(simplify=True)) +handler_graph_simp.register("miasm:graphirsimp", + "Graph IR (simplified)", shortcut="F8", icon=191) +handler_graph_simp.attach_to_menu("Miasm/Graph IR (simplified)") +if serve_threaded is not None: + handler_rpyc = Handler(serve_threaded) + handler_rpyc.register("miasm:rpyc", "RPYC server", shortcut="F10", icon=182) + handler_rpyc.attach_to_menu("Miasm/RPYC server") +if analyse_function is not None: + handler_ctype = Handler(analyse_function) + handler_ctype.register("miasm:ctype", "Type propagation", shortcut="F11", + icon=38) + handler_ctype.attach_to_menu("Miasm/Type propagation") |