免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1774 | 回复: 1
打印 上一主题 下一主题

Fail2ban阻止SSH,FTP,mail暴力入侵 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-09-08 10:08 |只看该作者 |倒序浏览

                                                                                相必大家系统日志中无论是ssh还是ftp等总是经常被人猜口令吧?Fail2ban就是由此而生
源码可以在这里下载到:
http://sourceforge.net/project/showfiles.php?group_id=121032&package_id=132537
1.安装在RHEL5上
tar -jxvf
fail2ban-0.8.3.tar.bz2
然后进入目录cd fail2ban-0.8.3/
用root用户执行
./setup.py install
现在config文件已经安装在/etc/fail2ban下面
接下来
cp fail2ban-0.8.3/files/suse-initd /etc/init.d/fail2ban
chmod 755 /etc/init.d/fail2ban
Integrate fail2ban into logrotate:
create file "/etc/logrotate.d/fail2ban":
/var/log/fail2ban.log {
weekly
    rotate 7
   
missingok
   
compress
    postrotate
/usr/bin/fail2ban-client reload 1>/dev/null || true
    endscript
}
注:
The path to your fail2ban-client needs to be adjusted (# whereis fail2ban-client)
# 忽悠 IP范围 如果有二组以上以空白做为间隔 192.168.10.0/24
ignoreip = 127.0.0.1
# 设定 IP 被封锁的时间(秒),如果值为 -1,代表永远封锁
bantime  = 600
# 设定在多少时间内达到 maxretry 的次数就封锁
findtime  = 600
# 允许尝试的次数
maxretry = 3
#分类设置
#针对sshd暴力入侵防护
[ssh-iptables]
enabled  = true
filter   = sshd
action   = iptables[name=SSH, port=ssh, protocol=tcp]
           mail-whois[name=SSH, dest=root]
logpath  = /var/log/secure
# 如果有个别的次数设定就设在这里
maxretry = 5
#针对vsftpd暴力入侵防护
[vsftpd-iptables]
enabled  = true
filter   = vsftpd
action   = iptables[name=VSFTPD, port=ftp, protocol=tcp]
           sendmail-whois[name=VSFTPD, dest=you@mail.com]
logpath  = /var/log/secure
maxretry = 3
bantime  = 1800
建议设置成maxretry为 3 表示3次错误就封锁
2.现在启动fail2ban进行测试用一个IP不断尝试登录ssh
下面是secure的一个小段,修改过的
Did not receive identification string from 192.168.11.2
Invalid user test from 192.168.11.2
Failed password for invalid user test from 192.168.11.2 port 41017 ssh2
Invalid user test from 192.168.11.2
Failed password for invalid user test from 192.168.11.2 port 41096 ssh2
Invalid user test from 192.168.11.2
Failed password for invalid user test from 192.168.11.2 port 41162 ssh2
Invalid user test from 192.168.11.2
Failed password for invalid user test from 192.168.11.2 port 41209 ssh2
Invalid user test from 192.168.11.2
Failed password for invalid user test from 192.168.11.2 port 41267 ssh2
Invalid user test from 192.168.11.2
Failed password for invalid user test from 192.168.11.2 port 41323 ssh2
Invalid user test from 192.168.11.2
Failed password for invalid user test from 192.168.11.2 port 41376 ssh2
Invalid user test from 192.168.11.2
Failed password for invalid user test from 192.168.11.2 port 41433 ssh2
Invalid user test from 192.168.11.2
Failed password for invalid user test from 192.168.11.2 port 41484 ssh2
我们再来看看fail2ban的log
fail2ban.actions: WARNING [ssh-iptables] Ban 192.168.11.2
fail2ban.actions: WARNING [ssh-iptables] Unban 192.168.11.2
已经起到作用了.这只是一小部分应用更详细的可以参照官方网站
http://www.fail2ban.org/
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/30312/showart_1168658.html

论坛徽章:
0
2 [报告]
发表于 2008-09-29 18:30 |只看该作者
不错,收藏
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP