Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple shell script to part out requests/responses from a burp history file (with base64 output selected).
#!/bin/bash
print_help() {
echo "Usage: $(basename $0) <burp history file>"
}
INPUT=$1
if [ -z "$INPUT" ]; then
echo "Error: Provide me with a burp history file."
print_help
exit 1
elif [ ! -f "$INPUT" ]; then
echo "Error: Burp history file doesn't exist"
print_help
exit 2
fi
FIRST_TIME="1"
while read -r LINE; do
if [[ $FIRST_TIME -eq 1 ]]; then
FIRST_TIME=0;
if [[ $(echo "$LINE" | grep -c request) -le 0 ]]; then
echo "Error: First line is not a request"
exit 1
fi
fi
if [[ $(echo "$LINE" | grep -c request) -ge 1 ]]; then
FILE_NAME=$(echo "$LINE" | md5sum | awk '{print $1}')
echo "$LINE" | sed -e 's/.*CDATA\[//' -e 's/\]\].*//g' | base64 -d > ${FILE_NAME}_request.txt
elif [[ $(echo "$LINE" | grep -c response) -ge 1 ]]; then
echo "$LINE" | sed -e 's/.*CDATA\[//' -e 's/\]\].*//g' | base64 -d > ${FILE_NAME}_response.txt
else
echo "Error: Neither request nor response present for ${FILE_NAME}"
fi
done < <(grep -e '<request base64' -e '<response base64' "$INPUT")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment