Skip to content

Instantly share code, notes, and snippets.

@2ndkauboy
Created May 21, 2014 12:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2ndkauboy/fd82459a248f8689dceb to your computer and use it in GitHub Desktop.
Save 2ndkauboy/fd82459a248f8689dceb to your computer and use it in GitHub Desktop.
This is a simple bash script, that scans text files for typical infections and sends an email to the user. Just setup a cron and run it every couple of hour. And don't worry, even scanning thousand of text files will only take some seconds.
#!/bin/bash
grep '#[0-9a-fA-F]\{6\}#' -r -H -lc /var/www/ --include=*.{html,js,css,php,tpl,sh,py,java,class} | # Only get found issues
/usr/bin/mail -E -s 'INFECTED FILES FOUND on example.com' mail@example.com # Send EMail
grep '/\*[0-9a-fA-F]\{6\}\*/' -r -H -lc /var/www/ --include=*.{html,js,css,php,tpl,sh,py,java,class} | # Only get found issues
/usr/bin/mail -E -s 'INFECTED FILES FOUND on example.com' mail@example.com # Send EMail
grep 'e=w\["eval"\]' -r -H -lc /var/www/ --include=*.{html,js,css,php,tpl,sh,py,java,class} | # Only get found issues
/usr/bin/mail -E -s 'INFECTED FILES FOUND on example.com' mail@example.com # Send EMail
grep '<!--/[0-9a-fA-F]\{6\}-->' -r -H -lc /var/www/ --include=*.{html,js,css,php,tpl,sh,py,java,class} | # Only get found issues
/usr/bin/mail -E -s 'INFECTED FILES FOUND on example.com' mail@example.com # Send EMail
grep 'r=eval' -r -H -lc /var/www/ --include=*.{html,js,css,php,tpl,sh,py,java,class} | # Only get found issues
/usr/bin/mail -E -s 'INFECTED FILES FOUND on example.com' mail@example.com # Send EMail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment