diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-12-02 19:59:02 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-12-02 19:59:02 +0100 |
commit | 85b553724cb56821cf9cea80983c21c238f1469f (patch) | |
tree | 0eaae334839bc14d3d9570f1e29f76bd46169103 /test/tools | |
parent | 3963a2191be816ce697d9f666b48c989e30d83ef (diff) | |
download | mitmproxy-85b553724cb56821cf9cea80983c21c238f1469f.tar.gz mitmproxy-85b553724cb56821cf9cea80983c21c238f1469f.tar.bz2 mitmproxy-85b553724cb56821cf9cea80983c21c238f1469f.zip |
add tnetstring inspection tool
Diffstat (limited to 'test/tools')
-rw-r--r-- | test/tools/inspect_dumpfile.py | 32 |
1 files changed, 32 insertions, 0 deletions
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() |