全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
123
返回列表 发新帖
楼主: lazyzhu
打印 上一主题 下一主题

自动屏蔽扫描ssh:22的php,并email通知

[复制链接]
21#
发表于 2012-8-10 10:46:13 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
22#
发表于 2012-8-10 10:47:41 | 只看该作者
lazyzhu 发表于 2012-8-10 10:44
什么蜜罐对咩咩最有效...


http://s.taobao.com/search?q=%B7%E4%C3%DB%D1%F2%C4%CC%D4%ED

骚年,来,嗑一块吧...
23#
 楼主| 发表于 2012-8-10 10:52:05 | 只看该作者
Kokgog 发表于 2012-8-10 10:47
http://s.taobao.com/search?q=%B7%E4%C3%DB%D1%F2%C4%CC%D4%ED

骚年,来,嗑一块吧...

咩咩正品?
24#
 楼主| 发表于 2012-8-10 10:40:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
IPXcore老板写的,原文如下:
Not sure if it's limited only to us, but we have a problem with having our customer's VPSes sshscanned for weak passwords.

So I have developed a simple PHP script to parse the output of netstat -n | grep :22, then counts how many IP addresses the remote IP is attempting to connect to, then add iptables rules when it determines an attack is happening. It will only add an iptable rule if a DROP rule for the IP does not exist already.

As we only run OpenVZ, it has only been tested on OpenVZ nodes. I am curious for feedback on if it works for Xen or KVM nodes.

It is being released to the community. You can find it here: http://pastebin.com/kfWaJa9q

Install it by writing it anywhere on your node, (I have mine in /sbin), editing the variables at the top of the script, then adding a crontab entry for root.
This will run it every 5 minutes:

*/5 * * * *  /usr/bin/php /sbin/sshcheck.php

(update to reflect your php binary, and where you put the script)

You will get reports in your email like this:

Hello, this is sshcheck.php running on sapphire.ipxcore.com

Current time: Thu, 09 Aug 12 19:33:49 -0600

Adding iptables DROP rule. Remove it with:
iptables -D FORWARD -s 218.203.165.153 -j DROP

IP 218.203.165.153 is involved in a brute force attack against the
following IPs:

Count: 13
1.2.3.157:22
1.2.3.136:22
1.2.3.108:22
1.2.3.31:22
1.2.3.201:22
1.2.3.32:22
1.2.3.195:22
1.2.3.11:22
1.2.3.32:22
1.2.3.180:22
1.2.3.103:22
1.2.3.108:22
1.2.3.122:22

Tested with PHP 5.1.6 (Centos 5), PHP 5.3.3 (Centos 6), PHP 5.3.3-7+squeeze13 (Debian Squeeze).

Upcoming/to-do/V2.0:
-check that destination IPs are unique
-add method for iptables drop for a specified timeframe only
-proper source code commenting


http://www.lowendtalk.com/discussion/4185/sshcheck.php-blocking-ssh-bruteforce-attempts-against-client-vps-containers
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2026-1-13 09:18 , Processed in 0.138843 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表