Created
August 23, 2013 06:37
-
-
Save Elemecca/6316178 to your computer and use it in GitHub Desktop.
Splits Burp Proxy saved state files into individual files per request.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import sys | |
from xml.etree.ElementTree import iterparse | |
from datetime import datetime | |
import base64 | |
if len( sys.argv ) != 2: | |
print 'usage: split <filename>\n' | |
sys.exit( 1 ); | |
filename = sys.argv[ 1 ] | |
stream = open( filename, 'r' ) | |
dirname = filename + '_reqs' | |
os.mkdir( dirname ) | |
counter = 0; | |
for event, elem in iterparse( stream ): | |
if 'item' != elem.tag: continue | |
counter += 1 | |
time = datetime.strptime( | |
elem.findtext( 'time' ), | |
'%a %b %d %H:%M:%S %Z %Y' | |
).strftime( '%Y%m%d-%H%M%S' ) | |
name = '%04d-%s' % (counter, time) | |
out = open( dirname + '/' + name, 'w' ) | |
request = elem.find( 'request' ) | |
text = request.text | |
if 'true' == request.get( 'base64' ): | |
text = base64.b64decode( text ) | |
out.write( text ) | |
response = elem.find( 'response' ) | |
if response is not None: | |
text = response.text | |
if 'true' == response.get( 'base64' ): | |
text = base64.b64decode( text ) | |
out.write( '\n\n' ) | |
out.write( text ) | |
out.close() | |
elem.clear() | |
stream.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment