服务器攻防·禁止穷举邮箱密码 原创2016-11-02景峯Netkiller 本文节选自《Netkiller Linux 手札》 下面是一个脚本你可以放在crontab中运行,每个一定时间运行一次。
服务器攻防·禁止穷举邮箱密码
原创 2016-11-02 景峯 Netkiller
本文节选自《Netkiller Linux 手札》
下面是一个脚本你可以放在crontab中运行,每个一定时间运行一次。
#!/bin/bash######################################### Homepage: http://netkiller.github.io# Author: neo <[email protected]>########################################PIPE=/var/tmp/pipepidfile=/var/tmp/$0.pidBLACKLIST=/var/tmp/black.smtpd.lstWHITELIST=/var/tmp/white.smtpd.lstLOGFILE=/var/log/maillogDAY=5########################################if [ -z "$( egrep "CentOS|7." /etc/centos-release)" ]; then echo 'Only for CentOS 7.x' exitfiif [ -f $BLACKLIST ]; then find $BLACKLIST -type f -mtime +${DAY} -deletefiif [ ! -f ${BLACKLIST} ]; then touch ${BLACKLIST}fiif [ ! -f ${WHITELIST} ]; then touch ${WHITELIST}fifor ipaddr in $(grep "too many errors after AUTH from" ${LOGFILE} | grep -oE "/b([0-9]{1,3}/.){3}[0-9]{1,3}/b" | sort | uniq -c | sort -r -n | head -n 20| awk '{print $2}')do if [ $(grep -c $ipaddr ${WHITELIST}) -gt 0 ]; then continue fi if [ $(grep -c $ipaddr ${BLACKLIST}) -eq 0 ] ; then echo $ipaddr >> ${BLACKLIST} iptables -I INPUT -p tcp --dport 25 -s $ipaddr -j DROP #iptables -I INPUT -s $ipaddr -j DROP fidone
延伸阅读
PostgreSQL·账户表/余额表/消费储蓄表
PostgreSQL·国家地区表的设计
PHP高级编程之守护进程
PHP高级编程之多线程
PHP高级编程之消息队列
网站:http://www.netkiller.cn
公众号:netkiller-ebook
关注作者公众号,每日推送原创文章。如果已有什么建议,请给我留言。