Script for email notifications when detecting prohibited files

Once, a vulnerability was revealed on one of the file hosting services through which an attacker could upload files to a PHP server and execute it, the vulnerability was fixed and just in case, I wrote a script that would send an email if a PHP file was found in the specified directory:

#!/bin/bash
findphp=`find /home/user/public_html/share/ -type f -iname "*.php"`

if [[ -n $findphp ]];
then
echo "$findphp"
(echo "Subject:DANGER! $findphp"; echo "$findphp";) | sendmail test@ixnfo.com
fi
Did my article help you? How about buying me a cup of coffee as an encouragement? Buy me a coffe.

Leave a comment

Leave a Reply