Add option to write all REPL prints to a logfile (#100)

This commit is contained in:
r-e-l-z
2017-01-08 19:27:03 +02:00
committed by Ole André Vadla Ravnås
parent 3ddd672791
commit 593bba3ab8
+10 -1
View File
@@ -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():