Iptables : SSH Brute force attack

written by Mr-San.com on October 18, 2006 in Howto with no comments

สำหรับคนที่ใช้ iptables นะครับ กรณีที่ยังไม่ได้ใช้ความสามารถ ของ recent module ใน iptables การป้องกันในอีกวิธีหนึ่งคือ นับจำนวน connection ในช่วงเวลาหนึ่งและ block ซึ่งก็เป็นวิธีที่ใช้การได้ดีในระดับหนึ่ง
ลองเอาไปใช้ดูนะครับวิธีการมีมากมาย ขึ้นอยู่กับความเหมาะสม และ การนำไปใช้นะครับ แต่ไม่ได้หมายความว่าจะดีที่สุด เราก้ต้องศึกษาหาข้อมูลกันต่อไป

iptables -A INPUT -m tcp -p tcp --dport 22 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m tcp -p tcp -s My.local.Lan.0/24 --dport 22 -j ACCEPT
iptables -A INPUT -m tcp -p tcp -s Trusted.Internet.Machine --dport 22 -j ACCEPT
iptables -A INPUT -m tcp -p tcp --dport 22 -m state --state NEW -m limit --limit 1/min --limit-burst 2 -j ACCEPT
iptables -A INPUT -m tcp -p tcp --dport 22 -j LOG --log-prefix SSHBRUTE
iptables -A INPUT -m tcp -p tcp --dport 22 -j DROP

ความหมายคร่าวๆ
The effect is that the firewall will only admit two (for example) incoming new SSH connections per minute (it will reset the “burst” counter every minute).

อ้างอิงจาก http://lwn.net/Articles/192057/