mitmproxy/test/helper_tools/inspect_dumpfile.py

35 lines
704 B
Python
Raw Normal View History

2021-06-24 14:13:56 +00:00
#!/usr/bin/env python3
2015-12-02 18:59:02 +00:00
from pprint import pprint
import click
2021-06-24 14:13:56 +00:00
from mitmproxy.io import tnetstring
2015-12-02 18:59:02 +00:00
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)
2016-01-27 09:12:18 +00:00
2015-12-02 18:59:02 +00:00
@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()