apache web server
การโจมตีด้วยวิธีการส่ง HTTP requests จำนวนมากไปยัง web server เป็นการโจมตีแบบ DOS (Denial Of Service) ชนิดหนึ่ง ที่พยายามทำให้ web server ทำงานหนักมากขึ้นเรื่อยๆ จนกระทั่งไม่สามารถให้บริการต่อไปได้ แต่การโจมตีด้วยวิธีการนี้สามารถป้องกันได้โดยง่ายเพียงแค่ติดตั้ง mod_evasive ที่ Apache และ configure ค่าต่างๆเพียงเล็กน้อยก็สามารถป้องกันการโจมตีนี้ได้อย่างได้ผล

การป้องกันการโจมตีของ mod_evasive จะมีอยู่ด้วยกัน 3 วิธี คือ

  1. IP หนึ่งๆ มีการ request ไปยังหน้าเดิมๆ เป็นจำนวนครั้งที่กำหนดในช่วงเวลาที่กำหนด
  2. 1 Client มีการสร้าง request มากกว่าจำนวน request ที่กำหนดในช่วงเวลาที่กำหนด
  3. สร้าง request มากๆในขณะที่ยังติด temporary blacklist

การติดตั้ง mod_evasive บน CentOS

[shell]# yum install mod_evasive[/shell]

mod_evasive จะมีไฟล์ configure อยู่ที่ /etc/httpd/conf.d/mod_evasive.conf และมีค่า default configure ตามตัวอย่างด้านล่าง
[shell]<IfModule mod_evasive20.c>
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
</IfModule> [/shell]

เราสามารถแก้ไขค่าต่างๆให้เหมาะสมกับการใช้งานได้ โดยกำหนดค่าต่างๆตาม parameter ด้านล่างนี้

รายละเอียดเพิ่มเติมสำหรัยการปรับแต่งค่าการป้องกันด้วย mod_evasive

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

DOSPageCount – This is the threshold for the number of requests for the same page (or URI) per page interval. Once the threshold for that interval has been exceeded, the IP address of the client will be added to the blocking list.

DOSSiteCount – This is the threshold for the total number of requests for any object by the same client on the same listener per site interval.

DOSPageInterval – The interval for the page count threshold; defaults to 1 second intervals.

DOSSiteInterval – The interval for the site count threshold; 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).

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.

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.

DOSLogDir – Choose an alternative temp directory, default is /tmp.

DOSWhitelist – You can use whitelists to disable the module for certain ranges of IPs. Wildcards can be used on up to the last 3 octets if necessary. Multiple DOSWhitelist commands may be used in the configuration.

การตรวจสอบการทำงานของ mod_evasive ให้กด F5 หรือ refresh ถี่ๆ ถ้าระบบทำงานถูกต้องจะพบหน้า “403 Forbidden”