Skip to content

Instantly share code, notes, and snippets.

@ryan-wendel
Created August 15, 2019 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryan-wendel/f0ae7240f9c37cc98acac65f629d5f46 to your computer and use it in GitHub Desktop.
Save ryan-wendel/f0ae7240f9c37cc98acac65f629d5f46 to your computer and use it in GitHub Desktop.
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