Created
October 24, 2021 09:20
-
-
Save aufzayed/c12b9ecf9523b08c3b10a3db697e7850 to your computer and use it in GitHub Desktop.
search for leaked data (tokens, secrets) in JavaScript files and validate them with nuclei token spray
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
# requirements: | |
# gf -> https://github.com/tomnomnom/gf | |
# gf patterns to find leaked tokens and secrets -> https://github.com/emadshanab/Gf-Patterns-Collection | |
# subjs -> https://github.com/lc/subjs | |
# gau -> https://github.com/lc/gau | |
# nuclei -> https://github.com/projectdiscovery/nuclei | |
# hakcheckurl -> https://github.com/hakluke/hakcheckurl | |
# note: before you run the script, edit your gf patterns and remove all grep 'H' and 'n' flag and add the 'h' flag | |
token_spray(){ | |
# create temporary directory | |
echo "[*] Createing a temporary directory" | |
mkdir /tmp/token_spray_test | |
# extract javascript filest links from the website with subjs and donwload them | |
echo "[*] downloading javascript files from http://$1" | |
echo "http://$1" | subjs | xargs wget -q -P /tmp/token_spray_test | |
# search for archived javascript links with gau then check valid links with hakcheckurl then download them | |
echo "[*] searching for archived javascript files and download them" | |
echo "$1" | gau | grep '\.js' | grep -v '\.json' | sort -u | hakcheckurl | grep 200 | cut -d ' ' -f 2 | xargs wget -q -P /tmp/token_spray_test | |
# run gf to search for leaked secrets | |
echo "[*] searching for leaked data in javascript files" | |
touch "/tmp/$1_secrets.txt" | |
for pattern in $( gf -list ); do gf $pattern /tmp/token_spray_test | sort -u | tee -a "/tmp/$1_secrets.txt"; done | |
# run muclei to validate the leaked secrets | |
echo "[*] validating leaked data" | |
nuclei -t ~/nuclei-templates/token-spray -var token="/tmp/$1_secrets.txt" | |
# delete temporary directory | |
rm -rf /tmp/token_spray_test | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment