From 85b553724cb56821cf9cea80983c21c238f1469f Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 2 Dec 2015 19:59:02 +0100 Subject: add tnetstring inspection tool --- test/tools/inspect_dumpfile.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/tools/inspect_dumpfile.py (limited to 'test') diff --git a/test/tools/inspect_dumpfile.py b/test/tools/inspect_dumpfile.py new file mode 100644 index 00000000..8ba42c2a --- /dev/null +++ b/test/tools/inspect_dumpfile.py @@ -0,0 +1,32 @@ +from pprint import pprint + +import click + +from libmproxy import tnetstring + + +def read_tnetstring(input): + # tnetstring throw a ValueError on EOF, which is hard to catch + # because they raise ValueErrors for a couple of other reasons. + # Check for EOF to avoid this. + if not input.read(1): + return None + else: + input.seek(-1, 1) + return tnetstring.load(input) + +@click.command() +@click.argument("input", type=click.File('rb')) +def inspect(input): + """ + pretty-print a dumpfile + """ + while True: + data = read_tnetstring(input) + if not data: + break + pprint(data) + + +if __name__ == "__main__": + inspect() -- cgit v1.2.3