From 593bba3ab86c05a549af29d8a54f6ac36b1ce87e Mon Sep 17 00:00:00 2001 From: r-e-l-z Date: Sun, 8 Jan 2017 19:27:03 +0200 Subject: [PATCH] Add option to write all REPL prints to a logfile (#100) --- src/frida/application.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/frida/application.py b/src/frida/application.py index 898f3f1..482d262 100644 --- a/src/frida/application.py +++ b/src/frida/application.py @@ -73,6 +73,7 @@ class ConsoleApplication(object): action='store_const', const='remote', dest="device_type", default=None) parser.add_option("-H", "--host", help="connect to remote frida-server on HOST", metavar="HOST", type='string', action='store', dest="host", default=None) + parser.add_option("-o", "--output", help="output to log file", dest="logfile", default=None) if self._needs_target(): def store_target(option, opt_str, target_value, parser, target_type, *args, **kwargs): if target_type == 'file': @@ -119,7 +120,13 @@ class ConsoleApplication(object): self._exit_status = None self._console_state = ConsoleState.EMPTY self._quiet = False - + self._logfile = None; + if options.logfile is not None: + try: + self._logfile = open(options.logfile, 'w') + except Exception as e: + self._update_status('Failed to open logfile "%s"' % options.logfile) + sys.exit(1) if sum(map(lambda v: int(v is not None), (self._device_id, self._device_type, self._host))) > 1: parser.error("Only one of -D, -U, -R, and -H may be specified") @@ -310,6 +317,8 @@ class ConsoleApplication(object): else: color = Fore.RED if level == 'error' else Fore.YELLOW self._print(color + Style.BRIGHT + text + Style.RESET_ALL) + if self._logfile is not None: + self._logfile.write(text + "\n"); def find_device(type): for device in frida.enumerate_devices():