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 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 Content-Length:".strlen($this->data)." User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36 Cookie: "; 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"]." "; //去掉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." "; } /** * 开始执行灌水 */ 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); } } } ?>
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: swoole_server中内存管理机制
- 下一篇: php7变量的内部实现