防止恶意扫描 用PortSentry保护Linux服务器

发表于:2011-6-10 10:00

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:抚琴煮酒    来源:51Testing软件测试网采编

分享:

  ◆ portsentry-sudp,UDP的秘密扫描检测模式;

  ◆ portsentry-atcp,TCP的高级秘密扫描检测模式;

  ◆ portsentry-audp,UDP的高级秘密扫描检测模式。

  一般情况下,建议使用秘密扫描检测模式或高级秘密扫描检测模式。

  使用高级秘密扫描检测模式(Advanced Stealth Scan Detection Mode),PortSentry会自动检查服务器上正在运行的端口, 然后把这些端口从配置文件中移去, 只监控其它的端口。这样会加快对端口扫描的反应速度,并且只占用很少的CPU时间,这种模式非常智能,我比较喜欢用

  启动PortSentry的命令如下:

#/usr/psionic/portsentry/portsentry -atcp

  可以把启动命令加到“/etc/rc.d/rc.local”脚本文件中,果想让它和其它后台进程一样可以随时启动、停止并查看进程状态, 可以去这样当重新启动计算机的时候PortSentry就会自动运行。

  四、测试

  我们在192.168.1.102上启动PortSentry后,先暂时清掉portsentry.ignore里的文件,然后在另一台192.168.1.104的机器上启动扫描命令nmap -sS 192.168.1.102。稍等片刻,就会发现/etc/hosts.deny里会出现ALL:192.168.1.104的字样,证明此软件配置都是生效的。

  为了证明其有效性,我拿自己的线上的一台LVS机器布署了portsentry1.2,查看日志发现

[root@localhost portsentry_beta]# tail /var/log/messages
Jun 6 13:11:07 localhost portsentry[2555]: attackalert: TCP SYN/Normal scan from host: adsl-65-9-251-89.mia.bellsouth.net/65.9.251.89 to TCP port: 80
Jun 6 13:11:07 localhost portsentry[2555]: attackalert: Host 65.9.251.89 has been blocked via wrappers with string: "ALL: 65.9.251.89"
Jun 6 13:11:07 localhost portsentry[2555]: attackalert: TCP SYN/Normal scan from host: adsl-65-9-251-89.mia.bellsouth.net/65.9.251.89 to TCP port: 80
Jun 6 13:11:07 localhost portsentry[2555]: attackalert: Host: adsl-65-9-251-89.mia.bellsouth.net/65.9.251.89 is already blocked Ignoring
Jun 6 13:11:08 localhost portsentry[2555]: attackalert: TCP SYN/Normal scan from host: adsl-65-9-251-89.mia.bellsouth.net/65.9.251.89 to TCP port: 80
Jun 6 13:11:08 localhost portsentry[2555]: attackalert: Host: adsl-65-9-251-89.mia.bellsouth.net/65.9.251.89 is already blocked Ignoring
Jun 6 13:19:57 localhost portsentry[2555]: attackalert: TCP SYN/Normal scan from host: ns38534.ovh.net/91.121.14.153 to TCP port: 80
Jun 6 13:19:57 localhost portsentry[2555]: attackalert: Host 91.121.14.153 has been blocked via wrappers with string: "ALL: 91.121.14.153"
Jun 6 13:35:44 localhost portsentry[2555]: attackalert: TCP SYN/Normal scan from host: 61.156.31.43/61.156.31.43 to TCP port: 80
Jun 6 13:35:44 localhost portsentry[2555]: attackalert: Host 61.156.31.43 has been blocked via wrappers with string: "ALL: 61.156.31.43"

  检查了下/etc/hosts.deny,发现如下恶意IP:

ALL: 113.57.224.3
ALL: 124.238.249.246
ALL: 65.9.251.89
ALL: 91.121.14.153
ALL: 61.156.31.43

  感觉现在的无聊人士也是非常多的,一天到晚开着扫描器在公网上,难道欲捕肉鸡乎?

44/4<1234
重磅发布,2022软件测试行业现状调查报告~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2023
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号