Pages

Saturday, January 3, 2015

Remove all phpinfo.php file from document root

Below is the script how to remove phpinfo.php file from document root from webserver.Which is not secure to display on live environment.

#!/bin/bash
#=================Script Starts here========================
#Created by Krunal Patel - Linux Admin
a=$(/bin/find /var/www/ -name phpinfo.php -exec /usr/bin/wc -c {} \; | /usr/bin/wc  -l | /bin/cut -d" " -f1)
/bin/echo "Total ${a} phpinfo.php file detected..."
if [ ${a} -eq 0 ];then
echo "No phpinfo.php files to delete..."
else
/bin/echo "Removing ${a} phpinfo.php located under document root /var/www/:..."
$(/bin/find /var/www/ -name phpinfo.php -exec rm -rf {} \;)
/bin/echo "Removed ${a} phpinfo.php located under document root /var/www/..."
fi
#=================Script Ends here========================

No comments:

Post a Comment

Please give us suggestions.

Shell Script Code