July 25, 2015

Phát hiện tấn công Ddos hoặc botnet vào website bằng cách xem Raw Access Log trên Cpanel và cách phòng chống.

Vào Một Ngày đẹp trời ,bạn phát hiện website đột ngột chậm như rùa, Hoặc website ngốn bandwith 1 cách nhanh chóng mặt.Có thể website của bạn đang bị tấn công.
Một các đơn giản để phát hiện là bạn vào ngay phần Raw access log trên cpanel download log để kiểm tra.
Nếu Bạn thấy 1IP ( Ddos) hoặc nhiều IP (botnet) request liên tục tới 1 Url (đây là điểm yếu của auto)
VD:
183.80.63.252 – – [13/May/2012:18:19:48 -0700] “GET /@4rum/index.php HTTP/1.1″ 403 301 “-”“Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)”
183.80.63.252 – – [13/May/2012:18:19:48 -0700] “GET /@4rum/index.php HTTP/1.1″ 403 301 “-”“Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)”
183.80.63.252 – – [13/May/2012:18:19:48 -0700] “GET /@4rum/index.php HTTP/1.1″ 403 301 “-”“Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)”
183.80.63.252 – – [13/May/2012:18:19:48 -0700] “GET /@4rum/index.php HTTP/1.1″ 404 297 “-”“Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)”
183.80.63.252 – – [13/May/2012:18:19:48 -0700] “GET /@4rum/index.php HTTP/1.1″ 403 301 “-”“Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)”

Nếu Kẻ tấn công từ 1 IP như trên thì ta thực hiện cấu hình chặn IP bằng file .htaccess như sau:
order allow,deny
deny from 183.80.63.252
allow from all
Nếu bị tấn công liên tiếp vào cùng một vị trí index.php nhưng nhiều IP khác nhau, nếu bạn chỉ sử dụng hàm chặn số lần kết nối trong 1 phút từ 1 IP này, chắc không tính ra được, và nhầm với IP thành viên thực.
– Bạn sẽ chú ý tới các user-agent:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)
OK, rất giống nhau, ta block nó đi thôi.
– Nếu bạn block cả cụm đó, bạn sẽ thấy các máy sử dụng windows 5.1 (XP sp2) và sử dụng IE 6 (MSIE 6.0) sẽ cũng không vô được, vậy bạn không nên block tất nó, bạn hãy quan tâm tới phần riêng của nó, ở đây phần riêng là CLR 1.0.3705
OK, block nó thôi, sử dụng code htaccess:
RewriteCond %{HTTP_USER_AGENT} ^1.0.3705
RewriteRule ^.* – [F,L]
Hoặc
SetEnvIfNoCase User-Agent “1.0.3705” bad_bot
Order Allow,Deny
Allow from all
Deny from env=bad_bot
– Nếu một site nào đó lấy thông tin get nhiều file của bạn từ một trang web, hãy block kết nối trang web đó tới website của bạn:
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://.*1-vài-ký-tự-trong-domain.com [NC]
RewriteRule .* – [F]
Các bước ở trên là các bước cơ bản để hạn chế các cuộc tấn công vào website của bạn.Ngoài các cách trên,bạn có thể sử dụng các mod,plusin,script,để hạn  chế như blockscript (có tính phí).Mong rằng bài viết này sẽ hữu dụng cho các bạn.

Related Posts:

  • Disk Space for MySQL Databases in cPanel Show as 0MB When you upgrade from cPanel 11.24 to 11.25, your users may notice that in cPanel, their MySQL databases show 0MB of disk space used, when they know their databases are much larger. This is due to an option in cPanel that yo… Read More
  • 5 Ways to Get a User’s Disk Usage This may seem pretty simple, but I see a lot of questions about how to get a user’s disk space usage on a cPanel user. I put together a quick list of 5 simple ways for the average admin:  1) Good ole’ cPanel/WHM. You c… Read More
  • How to Clean Log Files Before You Enable Log Rotation Checking disk space usage and removing old log files cPanel & WHM create and maintain log files. These log files allow you to examine errors and other occurrences on the system. After an extended period of time, the sy… Read More
  • How to Delete all logs in a cpanel server - SSH The command below will delete/empty all files in '/path/to/the/logdirectory' directory.for i in $(find /path/to/the/logdirectory -type f); do echo > $i; done You can empty the logs files via SSH as user root using the… Read More
  • 11 Ways to Free Up Disk Space on a cPanel Server I’m sure that most of you have been to the point where one or more of your servers start to fill up as you get more customers. The server’s performing just fine, but there’s one problem…you’re out of disk space! Here are a f… Read More

0 comments:

Post a Comment