|
|
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
Cách giải quyết:
Cho phép user "Apache" có thể sử dụng iptables - qua sudoers - để chặn các IP DDOS Trong Apache có một mod là mod_evasive. Cài đặt: Quote:
Quote:
Quote:
ví dụ tôi xài Webmin th́ đường dẫn của tôi là /usr/sbin/apxs ... nếu apache 1.3 cũ: Quote:
Edit your httpd.conf (usually located in /usr/local/apache/conf/httpd.conf): Add: <ifmodule mod_evasive20.c> DOSHashTableSize 3097 DOSPageCount 2 DOSSiteCount 50 DOSPageInterval 1 DOSSiteInterval 1 DOSBlockingPeriod 10 DOSEmailNotify admin@domain.be DOSWhitelist 192.16 DOSWhitelist 192.168.1.* DOSSystemCommand "sudo /sbin/iptables -A INPUT -s %s -j DROP" </ifmodule>[/html]Chú ư ḍng in đậm sudo /sbin/iptables -A INPUT -s %s -j DROP tức là nâng quyền user Apache cho phép sử dụng iptables chặn các IP không hợp lệ Trước đó ta phải login vào root và cho phép user này sử dụng iptables bằng cách HTML Code:
vim /etc/sudoers HTML Code:
apache ALL=(ALL) NOPASSWD: /sbin/iptables -A INPUT -s [0-9.]* -j DROP - Request vào cùng 1 trang nhiều hơn 5 lần / 1 giây - Tạo hơn 50 concurrent requests trên cùng một child mỗi giây - Tạo ra các request khác khi đă tạm cho vào blacklisted (on a blocking list) Giải thích: - DOSHashTableSize: is the size of the table of URL and IP combined - DOSPageCount: is the number of same page requests from the same IP during an interval that will cause that IP to be added to the block list. - DOSSiteCount: is the number of pages requested of a site by the same IP during an interval which will cause the IP to be added to the block list. - DOSPageInterval: is the interval that the hash table for IPs and URLs is erased (in seconds) - DOSSiteInterval: is the intervale that the hash table of IPs is erased (in seconds) - DOSBlockingPeriod: is the time the IP is blacked (in seconds) - DOSEmailNotify: can be used to notify by sending an email everytime an IP is blocked - DOSSystemCommand: is the command used to execute a command when an IP is blocked. It can be used to add a block the user from a firewall or router. - DOSWhiteList: can be used to whitelist IPs such as 127.0.0.1 Although mod_dosevasive can be quite effective in some cases, in others it can cause more problems by blocking non-offending IPs. It is suggested you take a look at hardware solution if you Xem một cách khác ở đây Chống DDoS - Các phương pháp - Thành lập công ty, TOP 10 GOOGLE, Server - System - Manager - CentOS, Operation System, SEO, VBB, HACKING and SECURITY - Rao vặt, tuyển dụng, Thiet ke website
__________________
http://hackingart.com/tinh_yeu_va_gi...c_girl_9x.html Last edited by Lovelinux; 07-08-2008 at 08:49 AM. |
|
||||
|
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 4. Restart Apache CONFIGURATION mod_evasive has default options configured, but you may also add the following block to your httpd.conf: APACHE v1.3 ----------- <IfModule mod_evasive.c> DOSHashTableSize 3097 DOSPageCount 2 DOSSiteCount 50 DOSPageInterval 1 DOSSiteInterval 1 DOSBlockingPeriod 10 </IfModule> APACHE v2.0 ----------- <IfModule mod_evasive20.c> DOSHashTableSize 3097 DOSPageCount 2 DOSSiteCount 50 DOSPageInterval 1 DOSSiteInterval 1 DOSBlockingPeriod 10 </IfModule> Optionally you can also add the following directives: DOSEmailNotify you@yourdomain.com DOSSystemCommand "su - someuser -c '/sbin/... %s ...'" DOSLogDir "/var/lock/mod_evasive" You will also need to add this line if you are building with dynamic support: APACHE v1.3 ----------- AddModule mod_evasive.c APACHE v2.0 ----------- LoadModule evasive20_module modules/mod_evasive20.so (This line is already added to your configuration by apxs) DOSHashTableSize ---------------- 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). DOSPageCount ------------ 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. DOSSiteCount ------------ 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. DOSPageInterval --------------- The interval for the page count threshhold; defaults to 1 second intervals. DOSSiteInterval --------------- The interval for the site count threshhold; defaults to 1 second intervals. DOSBlockingPeriod ----------------- 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. DOSEmailNotify -------------- 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. DOSSystemCommand ---------------- 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. DOSLogDir --------- 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. Home 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. TWEAKING APACHE 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). TESTING 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. |
![]() |
| Tags |
| attack, centos, ddos, dos, linux |
| Thread Tools | |
| Display Modes | |
|
|