php编写的简单社区灌水程序及Fiddler使用说明

前段时间,为了测试做的网站的稳定性和安全性。简单的写了一个灌水的程序。建议结合Fiddler使用。

Fiddler下载地址:

http://dlsw.baidu.com/sw-search-sp/soft/47/10963/fiddler4setup.1415771658.exe

Fiddler使用说明:

1:正确安装之后,windows8以上系统会出现弹窗,请无视。


2:Fiddler介绍



3:使用说明,raw就是报头,可以直接被服务器端接收,通过复制之后构造新的raw,便可以构造新的http请求



4:构造新的http请求



php代码


具体的使用以及问题,请看注释。不再赘述,有些需要登陆才能发送消息,可能会无法使用。

<?php
header("Content-type:text/html;charset=utf-8");
include  'water.class.php';
//设置需要传递的cookie值
$cookie = array(
	'thinkphp_show_page_trace' => '0|0',
	'PHPSESSID' => 'oq7o6a9hkaj6upoqhkm34lu5k5',
	);
//使用的方式
$method ='post';
//灌水的内容,注意和表单内容对应
$data = array('id'=>'1','content' =>'content');
$data = http_build_query($data);
//接收数据的url
$url = '';
//执行的次数
$executions = 1;
//合并参数
$conf = array(
	'cookie' => $cookie,
	'method' => $method,
	'data' => $data,
	'url' => $url,
	'executions' => $executions
	);
$robot = new water($conf);
?>
<span style="font-family: Arial, Helvetica, sans-serif;"><?php</span>
header("Content-type:text/html;charset=utf-8");

/**
* @param  请求相关参数
* @author gglinux
* @date   2014-11-9 
* @contact gglinux@163.com
*/
class water 
{
	public $executions = 100;				//执行的次数,int 默认为100次
	public $method = 'post';				//使用post/get方法类型,默认为post
	public $data = '';						//传递的数据,默认为空
	public $url = '';						//接收的url,默认为空
	public $http;							//构造的报头
	public $cookie = array();				//设置的cookie数组,cookie名和cookie的值


	/**
	 * 设置参数
	 */
	public function water($params)
	{
		foreach ($params as $key => $value) {
			$this->$key = $value;
		}
		$this->http_header();
		$this->execute();
	}

	/**
	 * 构造发送的HTTP报头
	 */
	public function http_header($value='')
	{
		$this->http = array(
			'method' => $this->method, 
			'header' => '',
			'content' => $this->data
			);
		$this->http['header'] = "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\nContent-Length:".strlen($this->data)."\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36\r\nCookie: ";
		foreach ($this->cookie as $key => $value) {
			$this->http['header']=$this->http['header'].$key.'='.$value.'; ';
		}
		//去掉最后一个分号和空格
		$this->http['header'] = substr($this->http['header'],0,-2);
		$this->http['header'] =$this->http['header']."\r\n";
		//去掉post中url的最后一个‘/’的部分
		 if(strripos ( $this->url,  '/' )){
		 	$referer = substr($this->url, 0,strripos($this->url, '/'));
		 }else{
		 	$referer=$this->url;
		 }
		$this->http['header'] = $this->http['header'].'Referer:'.$referer."\r\n";
	}
	/**
	 * 开始执行灌水
	 */
	public function execute($value='')
	{
		for ($i=0; $i < $this->executions; $i++) {
			$context = @stream_context_create($this->http);
			$html = @file_get_contents($this->url,false,$context);
			var_dump($html);
		}
		
	}
}
?>


 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值