mod_evasive is an evasive maneuvers module for Apache to provide evasiveaction in the event of an HTTP DoS or DDoS attack or brute force attack. Itis also designed to be a detection and network management tool, and can be easily configured to talk to ipchains, firewalls, routers, and etcetera. mod_evasivepresently reports abuses via email and syslog facilities.
Detection is performed by creating an internal dynamic hash table of IPAddresses and URIs, and denying any single IP address from any of the following:
Requesting the same page more than a few times per second
Making more than 50 concurrent requests on the same child per second
Making any requests while temporarily blacklisted (on a blocking list)
This method has worked well in both single-server script attacks as wellas distributed attacks, but just like other evasive tools, is only asuseful to the point of bandwidth and processor consumption (e.g. theamount of bandwidth and processor required to receive/process/respondto invalid requests), which is why it's a good idea to integrate thiswith your firewalls and routers for maximum protection.
This module instantiates for each listener individually, and therefore hasa built-in cleanup mechanism and scaling capabilities. Because of this per-childdesign, legitimate requests are never compromised (even from proxies and NAT addresses)but only scripted attacks. Even a user repeatedly clicking on 'reload' should not be affected unless they doit maliciously. mod_evasive is fully tweakable through the Apache configurationfile, easy to incorporate into your web server, and easy to use.
Apache Evasive Maneuvers Module For Apache 1.3 and 2.0 Copyright (c) Deep Logic, Inc. Version 1.10 [2005.0117]
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
WHAT IS MOD_EVASIVE ?
mod_evasive is an evasive maneuvers module for Apache to provide evasive action in the event of an HTTP DoS or DDoS attack or brute force attack. It is also designed to be a detection tool, and can be easily configured to talk to ipchains, firewalls, routers, and etcetera.
Detection is performed by creating an internal dynamic hash table of IP Addresses and URIs, and denying any single IP address from any of the following:
- Requesting the same page more than a few times per second - Making more than 50 concurrent requests on the same child per second - Making any requests while temporarily blacklisted (on a blocking list)
This method has worked well in both single-server script attacks as well as distributed attacks, but just like other evasive tools, is only as useful to the point of bandwidth and processor consumption (e.g. the amount of bandwidth and processor required to receive/process/respond to invalid requests), which is why it's a good idea to integrate this with your firewalls and routers.
This module instantiates for each listener individually, and therefore has a built-in cleanup mechanism and scaling capabilities. Because of this, legitimate requests are rarely ever compromised, only legitimate attacks. Even a user repeatedly clicking on 'reload' should not be affected unless they do it maliciously.
Three different module sources have been provided:
NOTE: mod_evasiveNSAPI is a port submitted by Reine Persson <firstname.lastname@example.org> and is not officially supported as part of the mod_evasive project.
HOW IT WORKS
A web hit request comes in. The following steps take place:
- The IP address of the requestor is looked up on the temporary blacklist - The IP address of the requestor and the URI are both hashed into a "key". A lookup is performed in the listener's internal hash table to determine if the same host has requested this page more than once within the past 1 second. - The IP address of the requestor is hashed into a "key". A lookup is performed in the listerner's internal hash table to determine if the same host has requested more than 50 objects within the past second (from the same child).
If any of the above are true, a 403 response is sent. This conserves bandwidth and system resources in the event of a DoS attack. Additionally, a system command and/or an email notification can also be triggered to block all the originating addresses of a DDoS attack.
Once a single 403 incident occurs, mod_evasive now blocks the entire IP address for a period of 10 seconds (configurable). If the host requests a page within this period, it is forced to wait even longer. Since this is triggered from requesting the same URL multiple times per second, this again does not affect legitimate users.
The blacklist can/should be configured to talk to your network's firewalls and/or routers to push the attack out to the front lines, but this is not required.
mod_evasive also performs syslog reporting using daemon.alert. Messages will look like this:
Aug 6 17:41:49 elijah mod_evasive: [ID 801097 daemon.alert] Blacklisting address x.x.x.x: possible attack.
WHAT IS THIS TOOL USEFUL FOR?
This tool is *excellent* at fending off request-based DoS attacks or scripted attacks, and brute force attacks. When integrated with firewalls or IP filters, mod_evasive can stand up to even large attacks. Its features will prevent you from wasting bandwidth or having a few thousand CGI scripts running as a result of an attack.
If you do not have an infrastructure capable of fending off any other types of DoS attacks, chances are this tool will only help you to the point of your total bandwidth or server capacity for sending 403's. Without a solid infrastructure and address filtering tool in place, a heavy distributed DoS will most likely still take you offline.
HOW TO INSTALL
APACHE v1.3 -----------
Without DSO Support:
1. Extract this archive into src/modules in the Apache source tree
2. Run ./configure --add-module=src/modules/evasive/mod_evasive.c
3. make, install
4. Restart Apache
With DSO Support, Ensim, or CPanel:
1. $APACHE_ROOT/bin/apxs -iac mod_evasive.c
2. Restart Apache
APACHE v2.0 -----------
1. Extract this archive
2. Run $APACHE_ROOT/bin/apxs -i -a -c mod_evasive20.c
3. The module will be built and installed into $APACHE_ROOT/modules, and loaded into your httpd.conf
Edit obj.conf: In the default object: PathCheck fn=mod_evasive_check
Or an own object <Object name="evasive" ppath="/DoSProtectedArea*"> NameTrans fn=mod_evasive_check </Object>
The hash table size defines the number of top-level nodes for each child's hash table. Increasing this number will provide faster performance by decreasing the number of iterations required to get to the record, but consume more memory for table space. You should increase this if you have a busy web server. The value you specify will automatically be tiered up to the next prime number in the primes list (see mod_evasive.c for a list of primes used).
This is the threshhold for the number of requests for the same page (or URI) per page interval. Once the threshhold for that interval has been exceeded, the IP address of the client will be added to the blocking list.
This is the threshhold for the total number of requests for any object by the same client on the same listener per site interval. Once the threshhold for that interval has been exceeded, the IP address of the client will be added to the blocking list.
The interval for the page count threshhold; defaults to 1 second intervals.
The interval for the site count threshhold; defaults to 1 second intervals.
The blocking period is the amount of time (in seconds) that a client will be blocked for if they are added to the blocking list. During this time, all subsequent requests from the client will result in a 403 (Forbidden) and the timer being reset (e.g. another 10 seconds). Since the timer is reset for every subsequent request, it is not necessary to have a long blocking period; in the event of a DoS attack, this timer will keep getting reset.
If this value is set, an email will be sent to the address specified whenever an IP address becomes blacklisted. A locking mechanism using /tmp prevents continuous emails from being sent.
NOTE: Be sure MAILER is set correctly in mod_evasive.c (or mod_evasive20.c). The default is "/bin/mail -t %s" where %s is used to denote the destination email address set in the configuration. If you are running on linux or some other operating system with a different type of mailer, you'll need to change this.
If this value is set, the system command specified will be executed whenever an IP address becomes blacklisted. This is designed to enable system calls to ip filter or other tools. A locking mechanism using /tmp prevents continuous system calls. Use %s to denote the IP address of the blacklisted IP.
Choose an alternative temp directory
By default "/tmp" will be used for locking mechanism, which opens some security issues if your system is open to shell users.
In the event you have nonprivileged shell users, you'll want to create a directory writable only to the user Apache is running as (usually root), then set this in your httpd.conf.
WHITELISTING IP ADDRESSES
IP addresses of trusted clients can be whitelisted to insure they are never denied. The purpose of whitelisting is to protect software, scripts, local searchbots, or other automated tools from being denied for requesting large amounts of data from the server. Whitelisting should *not* be used to add customer lists or anything of the sort, as this will open the server to abuse. This module is very difficult to trigger without performing some type of malicious attack, and for that reason it is more appropriate to allow the module to decide on its own whether or not an individual customer should be blocked.
To whitelist an address (or range) add an entry to the Apache configuration in the following fashion:
DOSWhitelist 127.0.0.1 DOSWhitelist 127.0.0.*
Wildcards can be used on up to the last 3 octets if necessary. Multiple DOSWhitelist commands may be used in the configuration.
The keep-alive settings for your children should be reasonable enough to keep each child up long enough to resist a DOS attack (or at least part of one). Remember, it is the child processes that maintain their own internal IP address tables, and so when one exits, so does all of the IP information it had. For every child that exits, another 5-10 copies of the page may get through before putting the attacker back into '403 Land'. With this said, you should have a very high MaxRequestsPerChild, but not unlimited as this will prevent cleanup.
You'll want to have a MaxRequestsPerChild set to a non-zero value, as DosEvasive cleans up its internal hashes only on exit. The default MaxRequestsPerChild is usually 10000. This should suffice in only allowing a few requests per 10000 per child through in the event of an attack (although if you use DOSSystemCommand to firewall the IP address, a hole will no longer be open in between child cycles).
Want to make sure it's working? Run test.pl, and view the response codes. It's best to run it several times on the same machine as the web server until you get 403 Forbidden messages. Some larger servers with high child counts may require more of a beating than smaller servers before blacklisting addresses.
Please don't use this script to DoS others without their permission.
- This module appears to conflict with the Microsoft Frontpage Extensions. Frontpage sucks anyway, so if you're using Frontpage I assume you're asking for problems, and not really interested in conserving server resources anyway.
* 2007년 *
1. CentOS 리눅스 구축관리실무 집필
2007년 12월 출판 - 출판사 : (주)수퍼유저코리아 * 2009년 *
2. 김태용의 C++ 기초 입문 :: gcc로 공부하는 C++와 wxWidgets GUI 집필
2009년 03월 출판 - 출판사: (주)수퍼유저코리아
3. 김태용의 리눅스 쉘 스크립트 프로그래밍 입문 집필
2009년 9월 출판 - 출판사: 제이펍 * 2011년 *
4. 김태용의 JSP 웹 프로그래밍 입문
2011년 1월 출판 - 출판사: 제이펍
- 공학/기술인의 위상을 높이고, 공학과 기술중심의 TechNation Korea 건설을 위한 공학정치 실현 - 공학/기술인을 대한민국의 수장으로 만들기 - 1000만 달러 벌기 -> 우수 공학인재 서포팅하기
한국LUG 사이트는 1024 x 768 해상도(운영자 노트북:14")에 최적화 되어 있습니다. : LINUX FANSITE
WWW.LUG.OR.KR Server is made by CentOS Linux, P4 1.8G, Memory 512MB, Main HDD 160GB, Backup HDD 40GB and LAMP, qmail MTA.
CentOS Linux & Mozilla Firefox UTF-8 Base Created.
1998-2021 www.lug.or.kr Directed By Great Dragon, Kim.
LUG 포인트 정책 : [회원가입 : +100점] [로그인(하루한번) : +100점] [글쓰기 : +20점] [코멘트 : +10점] [다운로드 : -200점] [질문 포인트 : 최소 200점]
데스크탑 프로그래밍(gcc, g++, wxGTK[wxWidgets] 등)은 "Fedora"를 사용하고, 서버 운영(WEB, FTP 등)은 "CentOS"를 사용하시길 권장합니다.
도전하는자, 자신을 투자하는자만이 뜻하는바를 이룰 수 있다.
Information should be Exchanged with Interactive, not One Way Direction.
관리자 Be Maker!
인생에서, 100% 순이익을 보장하는건 없다. 1%의 지식을 나눔으로써, 가끔씩 손해볼 필요도 있다.
그대가 가진 1%의 지식만이라도 공공을 위해 포스팅하라. 손해본다는 생각이 앞선다면 그대의 인생은 힘들어질것이다.
자신이 가진 지식의 1%도 투자하지 않고, 오로지 자신의 이익만 탐하는자와는 동지가 되지마라.
만나서 대화하면 모두 좋은 사람들이지만, 유독 인터넷에서만 자신을 밝히지 않고, 좀비로 서식하는 사람들이 많다.
부지불식간[不知不識間], 좀비(하류) 인생이 될지도 모르니, 항상 자신을 경계하도록 하라.
1. CentOS Linux
2. gcc로 공부하는 C++