Last active
February 19, 2018 10:22
-
-
Save alexalouit/349b70c839db18e67343 to your computer and use it in GitHub Desktop.
Checks for annoying occurrences in the content of websites & database
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
#!/bin/sh | |
# | |
# cron ex: 0 */6 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/coast-guard-observer.sh >> /root/scripts/cron.log | |
dir="/tmp/" | |
file="/var/www/clients/client*/web*/web" | |
email="" | |
pattern="vicodin|viagra|xanax|valium|silagra|kamagra|propranolol|celexa|albendazole|propecia|ampicillin|amoxil|neurontin|levitra|pharmacy|rolex|casino|cialis " # Need regexp for occurence like cialis (prevent specialist word) | |
# TODO: Add whitelist | |
#whitelist="" | |
# TODO: MySQL Support | |
#dbserver="localhost" | |
#dbuser="coast-guard-observer" | |
#dbpassword="" | |
cd $dir | |
if [ -f ./coast-guard-observer ] | |
then | |
if [ -f ./coast-guard-observer-last ] | |
then | |
rm ./coast-guard-observer-last | |
fi | |
mv ./coast-guard-observer ./coast-guard-observer-last | |
touch ./coast-guard-observer | |
chmod -R 777 ./coast-guard-observer | |
else | |
touch ./coast-guard-observer | |
chmod -R 777 ./coast-guard-observer | |
fi | |
grep -E $pattern -R $file > ./coast-guard-observer | |
if [ -f ./coast-guard-observer-last ] | |
then | |
if diff ./coast-guard-observer ./coast-guard-observer-last >/dev/null ; | |
then | |
rm ./coast-guard-observer | |
else | |
contain=$(diff ./coast-guard-observer ./coast-guard-observer-last) | |
echo -e "Coast Guard Observer possible detection:\n $contain" | mail -s "/!\ Coast Guard Observer possible detection" $email | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment