您的位置:首页 > 其它

web环境之安全小脚本

2018-02-05 14:42 204 查看
1、md5sum -c 可以用来批量校验,方便查看文件是否被篡改
例子:
find /var/log -type f|xargs md5sum > md5list.txt #递归log下的文件的md5值输出重定向到md5list.txt文件中
#使用md5sum校验
[root@test test]# md5sum -c md5list.txt

/var/log/tallylog: OK
/var/log/lastlog: OK
/var/log/wtmp: OK
......
2、使用wc -l来统计文件数量
例子:
[root@test test]# find /var/log -type f |wc -l
241


3、单个目录下禁止执行php文件
#禁止执行php文件
location ~* ^/home/www/test/.*.(php|php5)$ {
deny all;
}


4、监控网站是否异常脚本
#!/bin/sh
#filename is test.sh

#source或. file.sh 重新执行刚修改的初始化文档
[ -f /etc/init.d/functions ]&& . /etc/init.d/functions

# $0:当前文件的名字
usage(){
echo "USAGE:$0 url"
exit 1
}

#初始化变量
RETVAL=0

#函数体
CheckUrl(){

# -T:限制时间10s    -t:限制次数2
wget -T 10 --spider -t 2 $1 &>/dev/null
# $?:记录上一次命令的退出状态
RETVAL=$?
if [ $RETVAL -eq 0 ];then
action "$1 url" /bin/true
else
action "$1 url" /bin/false
fi
return $RETVAL
}
main(){
if [ $# -ne 1 ];then
usage
fi
CheckUrl $1
RETVAL=$?
return $RETVAL
}
# $*:只允许传参数为1
main $*
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  md5sum 校验