본문 바로가기
Server&OS/Linux

[보안] 자동공격 봇 막기.2

by 백룡화검 2010. 4. 24.

mod_evasive ???.
(? ? ?? emerge ?濡 ??)
?, Rewrite ,
php.ini auto_prepend_file

<?php

if(!($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1' && $_SERVER['HTTP_USER_AGENT'] == 'Shockwave Flash')) {
    if($_SERVER['SERVER_PROTOCOL'] != 'HTTP/1.1' || !isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
        if(count($_POST) != 0) {
            $fp = fopen('/home/mysite/postdata.txt', 'a');
            fwrite($fp, $_SERVER['REMOTE_ADDR']."\n");
            fwrite($fp, print_r($_POST, true));
            fwrite($fp, print_r($_GET, true));
            fwrite($fp, print_r($_SERVER, true));
            fwrite($fp, "---\n");
            fclose($fp);
            exit;
        }
        if(!preg_match('/BlackBerry|Daum|EMPAS\.ROBOT|Gigabot|Googlebot|NaverBot|Snapbot|Speedy\|SurveyBot|Twiceler|Yahoo|Yeti|MFeedBot|msnbot|webcollage|yoofind|xMind|BrightCrawler|NimbleCrawler|StackRambler|SurveyBot|ia_archiver/', $_SERVER['HTTP_USER_AGENT'])) {
            $fp = fopen('/home/mysite/agents.txt', 'a');
            fwrite($fp, $_SERVER['HTTP_USER_AGENT']."\n");
            fclose($fp);
            header('Content-Type: text/html; charset=utf-8');
            echo '? ? ? ?? ? ??.';
            exit;
        }
    }
}


? ?? Rewrite ?? ? ?.
HTTP/1.0 POST ?° ? ???.

HTTP/1.1 HTTP_ACCEPT_ENCODING ? ?? ?,
http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=56751&sca=&sfl=wr_name%7C%7Csubject&stx=%BC%DB%C8%BF%C1%F8&sop=and&page=2
? , ? ??.
, ? HTTP_ACCEPT_ENCODING ,
? ´? ?? ??.

-------
÷ð HTTP/1.1 μ, ??.

-------

 

o : PHPSCHOOL