shell 入侵检测与邮件告警

shell 入侵检测与邮件告警

#!/bin/bash
webdir=/var/www/html
cd $webdir#方法1 MD5sum校验
#md5sum /var/www/html/index.html >/opt/webfile.db
md5sum -c --quiet /opt/webfile.db
if [ $? -eq 0 ]; then
echo “web file is ok”
else
echo “”
#mail -s “web file is change!” [email protected]
fi
##方法2 web目录下文件数是否有变动
#find /var/www/html/ -type f >/opt/countfile.db_sec
find /var/www/html/ -type f >/opt/countfile.db
count=diff /opt/countfile.db*|wc -l
if [ $count -gt 0 ]; then
echo “the file_count is changed”
#mail -s “count_err” [email protected]
else
echo “ok”
fi
shell 入侵检测与邮件告警