2015-12-02 18:59:02 +00:00
|
|
|
from pprint import pprint
|
|
|
|
|
|
|
|
import click
|
|
|
|
|
2016-02-16 19:49:10 +00:00
|
|
|
from mitmproxy 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()
|