Skip to content

Instantly share code, notes, and snippets.

@realtebo
Last active June 21, 2019 12:53
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 realtebo/76033e65c95c49c2d267fefbca19e646 to your computer and use it in GitHub Desktop.
Save realtebo/76033e65c95c49c2d267fefbca19e646 to your computer and use it in GitHub Desktop.
Search corrupted php file and fake icons
#!/bin/bash
EXIT_CODE=0
for cartella in $( ls -l /var/www | grep -e "^d" | awk '{ print $9 }'); do
echo "Scansione /var/www/$cartella ...."
for phpfile in $(find /var/www/$cartella -type f -iname '*.php'); do
if [ -f $phpfile ]; then
grep '@include "\\057' $phpfile > /dev/null
if [ $? -eq 0 ]; then
EXIT_CODE=$((EXIT_CODE+1))
echo
echo "******* $phpfile INFETTO ******"
grep -n '@include "\\057' $phpfile
sed -i 's/.*@include "\\057.*//' $phpfile
echo "******* $phpfile RIPULITO ******"
echo "*******************************"
fi
fi
done;
for icon in $(find /var/www/$cartella -type f -name "*.ico" -exec file {} \; | grep "PHP" | awk -F ":" '{ print $1 }' ); do
echo
echo "***************** FINTA ICONA RILEVATA ********"
echo $icon
if [ -f $icon ]; then
EXIT_CODE=$((EXIT_CODE+1))
rm $icon
echo " --------------- BRASATA ----- "
fi
echo "***********************************************"
done;
done;
exit $EXIT_CODE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment