网站文件是否被篡改脚本(第一版)
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#/bin/bash # Author:byrd # Version:1.0 # Site:note.t4x.org # Contact:root#t4x.org # Check whether a file is unauthorized modification # If the file has been modified, notify the system administrator #yum install vim wget zlib-devel gcc gcc-c++ -y #Definition of variables webmail=root#t4x.org website=/home/wwwroot fingerbackup=/backup/Fingerprint errorlog=/backup/Fingerprint/error.log fingerfile=/backup/Fingerprint/$(date +%F).Fingerprint #Judge the backup directory exists [ ! -d $fingerbackup ] && mkdir -p $fingerbackup #Judge the MD5 exists if [ ! -f $fingerbackup/first.Fingerprint ];then find $website -type f | xargs md5sum > /$fingerbackup/first.Fingerprint fi [ ! -f $fingerfile ] && find $website -type f | xargs md5sum > $fingerfile [ ! -f $errorlog ] && touch $errorlog md5sum -c $fingerfile | grep -i "FAILED" > $errorlog if [ `cat $errorlog | wc -l` -gt 0 ];then #echo `cat $errorlog` mail -s "The file is unauthorized modification" $webmail < $errorlog fi |
说明:此脚本有部分不合理,请期待第二版!
申明:本文由BYRD原创(基于GNU bash, version 4.1.2(1)),未经许可禁止转载!SourceByrd's Weblog-https://note.t4x.org/code/check-unauthorized-modification-first-edition/ SourceByrd's Weblog-https://note.t4x.org/code/check-unauthorized-modification-first-edition/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!