{"id":54,"date":"2010-10-29T10:01:00","date_gmt":"2010-10-29T04:31:00","guid":{"rendered":"https:\/\/ajaymreddy.com\/sms-alerts-when-your-website-is-hacked"},"modified":"2013-05-09T07:29:20","modified_gmt":"2013-05-09T01:59:20","slug":"sms-alerts-when-your-website-is-hacked","status":"publish","type":"post","link":"https:\/\/ajaymreddy.com\/sms-alerts-when-your-website-is-hacked\/","title":{"rendered":"SMS alerts when your website is hacked"},"content":{"rendered":"
Yes, I did it without spending any money too.<\/p>\n
\nM abc.txt
D parser.py
?? config\/xya.cfg
<\/pre>\n<\/blockquote>\nBe sure to run it via a cron job or some other automated process at regular intervals. Mine runs every 10 minutes –<\/p>\n
\n*\/10 * * * * \/scripts\/git_watch.sh \/home\/public_html\/website\/ >> \/var\/log\/script_output.log 2>&1
<\/pre>\n<\/blockquote>\nShell script to send email when git repo is changed<\/b> –<\/p>\n
\n
#!\/usr\/bin\/env bash
#--
# Name : git_watch.sh
# Author : Ajay Reddy (modified from ruby version by Jerod Santo)
# Contact : \"moc.ahskanpirt@yaja\".reverse
# Date : 2010 October 29
# About : Check a git repo for changes and email to the provided email
# address. Parameter - directory to check. Schedule with cron.
# Inspired from http:\/\/blog.jerodsanto.net\/2009\/05\/git-informed-when-your-site-is-hacked\/
#--
SEND_TO=\"abc@domain.com\"
FROM=\"watch@domain.com\"
FROM_ALIAS=\"Git watch\"
SUBJECT=\"A repo has changed\"
BODY=\"A repo has changed\"
if [ $# != 1 ]
then
echo \"Usage: #{__FILE__} [path to repo with .git directory]\"
exit
fi
path=$1
cd $path
if [ -d \".git\" ]
then
result=`export PATH=$HOME\/git\/bin:$HOME\/git\/lib\/libexec\/git-core\/:$PATH ; git status --porcelain; `
if [[ ! -n $result ]]
then
exit
else
subject=\"Repo change : `echo $1 | awk -F'\/' '{print $4}'`\"
message+=\"From: $FROM\\n\"
message+=\"To: $SEND_TO\\n\"
message+=\"Subject: $subject\\n\"
message+=\"\\n\"
message+=$result.\"\\n\"
message+=\"Repo: $1\\n\"
message+=\"Checked at: `date`\\r\\n\"
message+=\"Change log: \\n\\n\"
echo -e $message | \/usr\/lib\/sendmail -t
fi
else
echo \"Sorry, no git repository at $path\"
exit
fi
<\/span><\/span><\/span><\/span><\/pre>\n<\/blockquote>\n- Setting up SMS alert –<\/b>Now, I setup the script to send me an email to my gmail address because it is the one I use frequently. Next, I created another email account on Hotmail<\/a> – Hotmail has a free email-to-sms service in India. I got this tip from a blog<\/a>. Voila! Whenever there is a change in the repo, the script on the server sends an email to my Gmail account, this gets forwarded to my Hotmail account and further to my cellphone as an SMS. The SMS has from email address and other stuff, but I still can make some sense out of it as I had removed all the extra info from the git status command.<\/li>\n<\/ol>\n<\/div>\n
Your own SMS alert system for free!<\/p><\/div>\n
<\/div>\nDoes the quote at the start make sense now?<\/div>\n","protected":false},"excerpt":{"rendered":"“The real genius was in the production engineering; the whole thing could be built with standard parts ordered out of Sweet’s Catalogue, with the exception of two three-dimensional cams and one printed circuit.” The Door Into Summer, Robert A. Heinlein No, of course I did not have to use Sweet’s catalog or use 3d cams…<\/span><\/p>\n