zip bombでサイトを保護する

古いメソッドはまだ機能します


[更新]ある種の「爆弾」に関する記事を書いたので、特別サービスのリストに載っていますよね?

あなたがウェブサイトをホストしたり、サーバーを管理したことがあるなら、あなたはおそらくあなたの財産で様々な悪いことをしようとしている悪い人たちをよく知っているでしょう。

13歳のときに、SSHアクセスで小さなLinuxボックスを初めてホストしたとき、ログを見て、毎日、私の小さなボックス(実際には、実際、それは壊れたディスプレイを備えた古いThinkPad T21ラップトップであり、ベッドの下で賑やかでした)。 これらのIPをプロバイダーに報告しました。

実際、オープンSSHを備えたLinuxサーバーを使用している場合、毎日何回接続が試行されているかを自分で確認できます。

grep 'authentication failures' /var/log/auth.log


,

Wordpress


, , - Wordpress, , , wp-admin .

, - - .


Nikto

- , . …

?


IDS Fail2ban ZIP- .

— ZIP-?


, ZIP , , , . , .

42.zip, 4,5  (4 500 000 ) 42 . ( ), , , .

ZIP- ?


, - ZIP, GZIP.

10- GZIP, . , .

dd if=/dev/zero bs=1M count=10240 | gzip > 10G.gzip




, 10 . , .

PHP-, .

<?php
//prepare the client to recieve GZIP data. This will not be suspicious
//since most web servers use GZIP by default
header("Content-Encoding: gzip");
header("Content-Length: ".filesize('10G.gzip'));
//Turn off output buffering
if (ob_get_level()) ob_end_clean();
//send the gzipped file to the client
readfile('10G.gzip');

!

:

<?php
$agent = filter_input(INPUT_SERVER, 'HTTP_USER_AGENT');

//check for nikto, sql map or "bad" subfolders which only exist on wordpress
if (strpos($agent, 'nikto') !== false || strpos($agent, 'sqlmap') !== false || startswith($url,'wp-') || startswith($url,'wordpress') || startswith($url,'wp/'))
{
      sendBomb();
      exit();
}

function sendBomb(){
        //prepare the client to recieve GZIP data. This will not be suspicious
        //since most web servers use GZIP by default
        header("Content-Encoding: gzip");
        header("Content-Length: ".filesize('10G.gzip'));
        //Turn off output buffering
        if (ob_get_level()) ob_end_clean();
        //send the gzipped file to the client
        readfile('10G.gzip');
}

function startsWith($a, $b) { 
    return strpos($a, $b) === 0;
}

, , -, , , user-agent.

… , ?


IE 11, IE
Chrome,
Edge, ,
Nikto,
SQLmap,
Safari, , ...
Chrome (Android),

( //, , , )


Chrome

, !

Source: https://habr.com/ru/post/J332580/


All Articles