def main(debugger=None): voltron.setup_logging('main') # Set up command line arg parser parser = argparse.ArgumentParser() parser.register('action', 'parsers', AliasedSubParsersAction) parser.add_argument('--debug', '-d', action='store_true', help='print debug logging') top_level_sp = parser.add_subparsers(title='subcommands', description='valid subcommands', dest='subcommand') top_level_sp.required = True view_parser = top_level_sp.add_parser('view', help='display a view', aliases=('v')) view_parser.register('action', 'parsers', AliasedSubParsersAction) view_sp = view_parser.add_subparsers(title='views', description='valid view types', help='additional help', dest='view') view_sp.required = True # Set up a subcommand for each view class pm = PluginManager() for plugin in pm.view_plugins: pm.view_plugins[plugin].view_class.configure_subparser(view_sp) if HAS_CONSOLE: Console.configure_subparser(top_level_sp) # Parse args args = parser.parse_args() if args.debug: voltron.config['general']['debug_logging'] = True voltron.setup_logging('main') # Instantiate and run the appropriate module inst = args.func(args, loaded_config=voltron.config) inst.pm = pm try: inst.run() except Exception as e: log.exception("Exception running module {}: {}".format( inst.__class__.__name__, traceback.format_exc())) print( "Encountered an exception while running the view '{}':\n{}".format( inst.__class__.__name__, traceback.format_exc())) except KeyboardInterrupt: suppress_exit_log = True inst.cleanup()
def main(debugger=None): voltron.setup_logging('main') # Set up command line arg parser parser = argparse.ArgumentParser() parser.register('action', 'parsers', AliasedSubParsersAction) parser.add_argument('--debug', '-d', action='store_true', help='print debug logging') parser.add_argument('-o', action='append', help='override config variable', default=[]) top_level_sp = parser.add_subparsers(title='subcommands', description='valid subcommands', dest='subcommand') top_level_sp.required = True view_parser = top_level_sp.add_parser('view', help='display a view', aliases=('v')) view_parser.register('action', 'parsers', AliasedSubParsersAction) view_sp = view_parser.add_subparsers(title='views', description='valid view types', help='additional help', dest='view') view_sp.required = True # Set up a subcommand for each view class pm = PluginManager() for plugin in pm.view_plugins: pm.view_plugins[plugin].view_class.configure_subparser(view_sp) if HAS_CONSOLE: Console.configure_subparser(top_level_sp) # Parse args args = parser.parse_args() if args.debug: voltron.config['general']['debug_logging'] = True voltron.setup_logging('main') voltron.config.update(options=dict((tuple(x.split('=')) for x in args.o))) # Instantiate and run the appropriate module inst = args.func(args, loaded_config=voltron.config) inst.pm = pm try: inst.run() except Exception as e: log.exception("Exception running module {}: {}".format(inst.__class__.__name__, traceback.format_exc())) print("Encountered an exception while running the view '{}':\n{}".format(inst.__class__.__name__, traceback.format_exc())) except KeyboardInterrupt: suppress_exit_log = True inst.cleanup()
def main(debugger=None): # Load config voltron.setup_env() voltron.setup_logging('main') # Set up command line arg parser parser = argparse.ArgumentParser() parser.add_argument('--debug', '-d', action='store_true', help='print debug logging') top_level_sp = parser.add_subparsers(title='subcommands', description='valid subcommands') view_parser = top_level_sp.add_parser('view', help='display a view') view_sp = view_parser.add_subparsers(title='views', description='valid view types', help='additional help') # Set up a subcommand for each view class pm = PluginManager() for plugin in pm.view_plugins: pm.view_plugins[plugin].view_class.configure_subparser(view_sp) if HAS_CONSOLE: Console.configure_subparser(top_level_sp) # Parse args args = parser.parse_args() if args.debug: log.setLevel(logging.DEBUG) # Instantiate and run the appropriate module inst = args.func(args, loaded_config=voltron.config) inst.pm = pm try: inst.run() except Exception as e: log.error("Exception running module {}: {}".format(inst.__class__.__name__, traceback.format_exc())) print("Encountered an exception while running the view '{}':\n{}".format(inst.__class__.__name__, traceback.format_exc())) except KeyboardInterrupt: suppress_exit_log = True inst.cleanup()
import voltron from voltron.core import Server from voltron.plugin import PluginManager try: import lldb in_lldb = True except ImportError: in_lldb = False try: import gdb in_gdb = True except ImportError: in_gdb = False voltron.setup_env() log = voltron.setup_logging('debugger') class VoltronCommand (object): """ Parent class for common methods across all debugger hosts. """ def handle_command(self, command): global log if "status" in command: self.status() elif 'debug' in command: if 'enable' in command: log.setLevel(logging.DEBUG) print("Debug logging enabled") elif 'disable' in command: log.setLevel(logging.INFO)
Install per instructions here: https://github.com/Vector35/binaryninja-api/tree/master/python/examples Documentation here: https://github.com/snare/binja/blob/master/README.md Note: requires the current version of Voltron from GitHub here: https://github.com/snare/voltron """ from binaryninja import * import voltron from threading import Thread from voltron.core import Client from voltron.plugin import api_request log = voltron.setup_logging() client = None last_addrs = [] def sync(view): global client if not client: print("Starting synchronisation with Voltron") def build_requests(): return [ api_request('registers', registers=['pc'], block=True), api_request('breakpoints', block=True), ]
def parent_directory(the_path): return os.path.abspath(os.path.join(the_path, os.pardir)) def add_vdb_to_path(vtrace): sys.path.append(parent_directory(parent_directory( vtrace.__file__))) add_vdb_to_path(vtrace) else: pass import voltron from voltron.plugin import pm from voltron.core import Server log = voltron.setup_logging('debugger') # figure out in which debugger host we are running args = [] try: import lldb host = "lldb" except ImportError: pass try: import gdb host = "gdb" except ImportError: pass try: import pykd