def main(argv=None): # New user interactive session (with extra bells and whistles). user_session = session.InteractiveSession() user_session.session_list.append(user_session) # Alow all special plugins to run. user_session.privileged = True def global_arg_cb(global_flags, _): if global_flags.version: print("This is Rekall Version %s (%s)" % ( constants.VERSION, constants.CODENAME)) print(rekall.get_versions()) sys.exit(0) with user_session.GetRenderer().start(): plugin_cls, flags = args.parse_args( argv=argv, global_arg_cb=global_arg_cb, user_session=user_session) # Install any quotas the user requested. user_session = quotas.wrap_session(user_session) try: # Run the plugin with plugin specific args. user_session.RunPlugin(plugin_cls, **config.RemoveGlobalOptions(flags)) except Exception as e: logging.fatal("%s. Try --debug for more information." % e) if getattr(flags, "debug", None): pdb.post_mortem(sys.exc_info()[2]) raise finally: user_session.Flush()
def main(argv=None): # New user interactive session (with extra bells and whistles). user_session = session.InteractiveSession() user_session.session_list.append(user_session) text_renderer = text.TextRenderer(session=user_session) with text_renderer.start(): plugin_cls, flags = args.parse_args(argv=argv, user_session=user_session) # Determine if an external script needs to be run first. if getattr(flags, "run", None): # Export the session object to the external script. user_session.locals["session"] = user_session exec open(flags.run) in user_session.locals try: # Run the plugin with plugin specific args. user_session.RunPlugin(plugin_cls, **config.RemoveGlobalOptions(flags)) except Exception as e: logging.fatal("%s. Try --debug for more information." % e) if getattr(flags, "debug", None): pdb.post_mortem(sys.exc_info()[2]) raise finally: user_session.Flush()
def main(argv=None): # New user interactive session (with extra bells and whistles). user_session = session.InteractiveSession() user_session.session_list.append(user_session) text_renderer = text.TextRenderer(session=user_session) with text_renderer.start(): plugin_cls, flags = args.parse_args(argv=argv, user_session=user_session) # Determine if an external script needs to be run first. if getattr(flags, "run", None): # Export the session object to the external script. user_session.locals["session"] = user_session exec open(flags.run) in user_session.locals try: # Run the plugin with plugin specific args. user_session.RunPlugin(plugin_cls, **config.RemoveGlobalOptions(flags)) except Exception as e: if getattr(flags, "debug", None): pdb.post_mortem(sys.exc_info()[2]) else: logging.error("%s. Try --debug for more information." % e) # Exit with an error. sys.exit(-1) # Right before we exit we check if we need to save the current session. if user_session.state.session_filename and ( user_session.state.dirty or user_session.state.cache.dirty): user_session.SaveToFile(user_session.state.session_filename)
def main(argv=None): # New user interactive session (with extra bells and whistles). user_session = session.InteractiveSession() plugin_cls, flags = args.parse_args(argv=argv, user_session=user_session) # Determine if an external script needs to be run first. if getattr(flags, "run", None): # Export the session object to the external script. user_session._locals["session"] = user_session exec open(flags.run) in user_session._locals try: # Run the plugin with plugin specific args. user_session.RunPlugin(plugin_cls, **config.RemoveGlobalOptions( vars(flags))) except Exception as e: if getattr(flags, "debug", None): pdb.post_mortem(sys.exc_info()[2]) else: logging.error("%s. Try --debug for more information." % e) # Right before we exit we check if we need to save the current session. if user_session.state.session_filename and ( user_session.state.dirty or user_session.state.cache.dirty): user_session.SaveToFile(user_session.state.session_filename)
def main(argv=None): # IPython notebook launches the IPython kernel by re-spawning the main # binary with its own command line args. This hack traps this and diverts # execution to IPython itself. if len(sys.argv) > 2 and sys.argv[1] == "-c": to_run = sys.argv[2] if ".kernelapp" in to_run: exec(to_run) return # New user interactive session (with extra bells and whistles). user_session = session.InteractiveSession() flags = args.parse_args(argv=argv, user_session=user_session) # Determine if an external script needs to be run first. if getattr(flags, "run", None): # Export the session object to the external script. user_session._locals["session"] = user_session exec open(flags.run) in user_session._locals # Run a module and do not drop into the shell. if getattr(flags, "module", None): # Run the module try: # Explicitly disable our handling of the pager since we are not # running in interactive mode. user_session.RunPlugin(flags.module, flags=flags) except Exception as e: if getattr(flags, "debug", None): pdb.post_mortem(sys.exc_info()[2]) else: logging.error("%s. Try --debug for more information." % e) else: # Interactive session, turn off object access logging since in # interactive mode, the user may use arbitrary object members. os.environ.pop(obj.ProfileLog.ENVIRONMENT_VAR, None) user_session.mode = "Interactive" # Try to launch the session using something. if user_session.state.ipython_engine == "notebook": ipython_support.NotebookSupport(user_session) else: _ = (IPython012Support(user_session) or NativePythonSupport(user_session)) # Right before we exit we check if we need to save the current session. if user_session.state.session_filename and ( user_session.state.dirty or user_session.state.cache.dirty): user_session.SaveToFile(user_session.state.session_filename)
def main(argv=None): # IPython notebook launches the IPython kernel by re-spawning the main # binary with its own command line args. This hack traps this and diverts # execution to IPython itself. if len(sys.argv) > 2 and sys.argv[1] == "-c": to_run = sys.argv[2] if ".kernelapp" in to_run: exec(to_run) return # New user interactive session (with extra bells and whistles). user_session = session.InteractiveSession() flags = args.parse_args(argv=argv, user_session=user_session) # Determine if an external script needs to be run first. if getattr(flags, "run", None): exec open(flags.run) in user_session._locals # Run a module and do not drop into the shell. if getattr(flags, "module", None): # Run the module try: # Explicitly disable our handling of the pager since we are not # running in interactive mode. user_session.RunPlugin(flags.module, flags=flags) except Exception as e: if getattr(flags, "debug", None): pdb.post_mortem(sys.exc_info()[2]) else: logging.error("%s. Try --debug for more information." % e) else: # Interactive session, turn off object access logging since in # interactive mode, the user may use arbitrary object members. os.environ.pop(obj.ProfileLog.ENVIRONMENT_VAR, None) user_session.mode = "Interactive" # Try to launch the session using something. if user_session.state.ipython_engine == "notebook": ipython_support.NotebookSupport(user_session) else: _ = (IPython012Support(user_session) or NativePythonSupport(user_session)) # Right before we exit we check if we need to save the current session. if user_session.state.session_filename and ( user_session.state.dirty or user_session.state.cache.dirty): user_session.SaveToFile(user_session.state.session_filename)
def main(argv=None): # New user interactive session (with extra bells and whistles). user_session = session.InteractiveSession() user_session.session_list.append(user_session) text_renderer = text.TextRenderer(session=user_session) with text_renderer.start(): plugin_cls, flags = args.parse_args(argv=argv, user_session=user_session) try: # Run the plugin with plugin specific args. user_session.RunPlugin(plugin_cls, **config.RemoveGlobalOptions(flags)) except Exception as e: logging.fatal("%s. Try --debug for more information." % e) if getattr(flags, "debug", None): pdb.post_mortem(sys.exc_info()[2]) raise finally: user_session.Flush()