From af3df301adf3c1a0bd9f1772723751e4dfd4411f Mon Sep 17 00:00:00 2001 From: Joey Geralnik Date: Sat, 21 Mar 2015 21:42:15 +0200 Subject: [PATCH 1/3] Fix colorama/readline collision Using autoreset=True in colorama's init function, causes it to wrap stdin. This is problematic because readline also messes with stdin, and causes readline to stop working. The solution is to simply not use autoreset=True, and then (at least on non-windows platforms) stdin will not be wrapped --- src/frida/application.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frida/application.py b/src/frida/application.py index c9fad48..7bc4fb7 100755 --- a/src/frida/application.py +++ b/src/frida/application.py @@ -22,7 +22,7 @@ def await_enter(): class ConsoleApplication(object): def __init__(self, run_until_return=await_enter): - colorama.init(autoreset=True) + colorama.init() parser = OptionParser(usage=self._usage()) parser.add_option("-U", "--usb", help="connect to USB device", From 0154a87b87ec4f43918c2002d5c7b6d6f0cf1fa9 Mon Sep 17 00:00:00 2001 From: Joey Geralnik Date: Sat, 21 Mar 2015 22:16:34 +0200 Subject: [PATCH 2/3] Reset colorama style after use --- src/frida/application.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frida/application.py b/src/frida/application.py index 7bc4fb7..24418b6 100755 --- a/src/frida/application.py +++ b/src/frida/application.py @@ -171,7 +171,7 @@ class ConsoleApplication(object): cursor_position = "\033[A" else: cursor_position = "" - print("%-80s" % (cursor_position + Style.BRIGHT + message,)) + print("%-80s" % (cursor_position + Style.BRIGHT + message + Style.RESET_ALL,)) self._status_updated = True def find_device(type): From e03b5362342bad8bcfaf2e29f15a5283e4b332d5 Mon Sep 17 00:00:00 2001 From: Joey Geralnik Date: Sat, 21 Mar 2015 22:22:31 +0200 Subject: [PATCH 3/3] Reset all colorama styles after use This time I actually grepped instead of just guessing --- src/frida/__init__.py | 8 ++++---- src/frida/repl.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/frida/__init__.py b/src/frida/__init__.py index 603ae12..c52a696 100644 --- a/src/frida/__init__.py +++ b/src/frida/__init__.py @@ -70,15 +70,15 @@ def get_device_manager(): print("") print("***") if str(ex).startswith("No module named "): - print(Back.RED + Fore.WHITE + Style.BRIGHT + "Frida native extension not found") - print(Fore.WHITE + Style.BRIGHT + "Please check your PYTHONPATH.") + print(Back.RED + Fore.WHITE + Style.BRIGHT + "Frida native extension not found" + Style.RESET_ALL) + print(Fore.WHITE + Style.BRIGHT + "Please check your PYTHONPATH." + Style.RESET_ALL) else: - print(Back.RED + Fore.WHITE + Style.BRIGHT + "Failed to load the Frida native extension: %s" % ex) + print(Back.RED + Fore.WHITE + Style.BRIGHT + "Failed to load the Frida native extension: %s" % ex + Style.RESET_ALL) if sys.version_info[0] == 2: current_python_version = "%d.%d" % sys.version_info[:2] else: current_python_version = "%d.x" % sys.version_info[0] - print(Fore.WHITE + Style.BRIGHT + "Please ensure that the extension was compiled for Python " + current_python_version + ".") + print(Fore.WHITE + Style.BRIGHT + "Please ensure that the extension was compiled for Python " + current_python_version + "." + Style.RESET_ALL) print("***") print("") raise ex diff --git a/src/frida/repl.py b/src/frida/repl.py index 562818a..f94746c 100644 --- a/src/frida/repl.py +++ b/src/frida/repl.py @@ -133,7 +133,7 @@ def main(): if stanza['name'] == '+result': output = json.dumps(value, sort_keys=True, indent=4, separators=(",", ": ")) else: - output = Fore.RED + Style.BRIGHT + value + output = Fore.RED + Style.BRIGHT + value + Style.RESET_ALL sys.stdout.write(output + "\n") sys.stdout.flush() self._idle.set()