Shell prevents CC attacks

Source: Internet
Author: User

The following methods to prevent CC attacks are mainly used to filter access logs and seal the IP address into the firewall. Place the script in cron once every 10 minutes. You can also modify the script as needed, because I use lighttp as a web server, it reads lighttp access logs. This script is also applicable to apache servers:
#! /Bin/bash
/Www/MTCC/solution_ip.sh
/Usr/bin/tail-1000/var/log/lighttpd/access. log | grep-v 127.0.0.1 | awk {print $1} | awk $1 {++ S [$1]} END {for (a in S) print, S [a]} | sort-k 2-n-r | awk $2> 10 {print $1}>/www/MTCC/block_ip.txt
/Www/MTCC/block_ip.sh
#! /Bin/bash
For blockIp in 'cat/www/MTCC/block_ip.txt'
Do
Echo "Blocking... $ blockIp"
/Sbin/iptables-I IPTABLES 4-s $ blockIp-j REJECT
Done
# Iptables-a input-s $1-j REJECT
#! /Bin/bash
/Usr/bin/tail-1000/var/log/lighttpd/access. log | grep-v 127.0.0.1 | awk {print $1} | awk $1 {++ S [$1]} END {for (a in S) print, S [a]} | sort-k 2-n-r | awk $2> 10 {print $1, $2}
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.