PHP CURL模拟提交数据 攻击N次方
public function actionCurl(){
$data['DATA']='{"NAME":"c","LEGEND":"c;c","GENDER":"","CITY":0,"BIRTHDAY":"","COMPANY":"","JOB":"","WEBSITE":"","ADDRESS":"","NOTE":"","CONTACTS":[],"IMS":[],"FLAGS":[]}';
$headers=array();
$headers[]='X-Requested-With:XMLHttpRequest';
$headers[]='Cookie:token=3cedf24b188fd7ac57176256a2a14879-b419e6ebb414d661a6e86a30cd633ce5; PHPSESSID=ddfrjb4p8evu3cumgnsveet2o3; _ga=GA1.2.1014541392.1437467254; _gat=1';
$headers[]='Referer:http://www.crm.com/newContact.php';
$headers[]='Content-Type:application/x-www-form-urlencoded; charset=UTF-8';
$headers[]='Content-Length:315';
$headers[]='Host:www.crm.com';
$headers[]='DNT:1';
$headers[]='Pragma:no-cache';
$headers[]='Connection:Keep-Alive';
$headers[]='User-Agent:Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)';
$headers[]='Accept:application/json, text/javascript, */*; q=0.01';
$headers[]='Accept-Encoding:gzip, deflate';
$headers[]='Accept-Language:zh-CN';
for ($i = 0; $i < 10; $i++) {
$res = $this->curls($data, 'http://www.crm.com/handler/handleAddContact.php ', 'POST', $headers);
print_r($res);
}
}
/**
* curl请求
* @author lid
* @param array $data 要请求的array数组
* @param str $url 请求的地址
* @param str $method 大写 POST GET
* @param array $headers 扩展包头信息
* @return string
*/
public static function curls($data, $url, $method = 'POST', $headers = array()) {
$ch = curl_init();
$method_upper = strtoupper($method);
if ($method_upper == 'POST') {
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
} else {
$url = $url . (strpos($url, '?') ? '&' : '?') . (is_array($data) ? http_build_query($data) : $data);
curl_setopt($ch, CURLOPT_URL, $url);
}
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method_upper);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
if ($headers) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
$tmpInfo = curl_exec($ch);
if (curl_errno($ch)) {
exit(curl_error($ch));
}
curl_close($ch);
return $tmpInfo;
}
CURLOPT_POSTFIELDS的这个设置中,亦可以直接发送数组的,但是这样做的后果是严重增加的请求的时间,耗时大约在2秒多,同样的操作用socket方式操作则正常,在毫秒级别。
数组:curl_setopt($ch, CURLOPT_POSTFIELDS, $arrData);
修改为:curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
http_build_query — 生成 URL-encode 之后的请求字符串。
curl 发送XML数据
$xml = ('<xml>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don\'t forget me this weekend!</body>
</note></xml>');
$url = "https://wx.api.zf.com/wxnotify.php ";
$header[] = "Content-type: text/xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
curl_close($ch);

PHP CURL模拟提交数据 攻击N次方的更多相关文章
- curl模拟提交
function curl_post($url, $post){ $options = array( CURLOPT_RETURNTRANSFER =>true, CURLOPT_HEADER ...
- php CURL 模拟 POST 提交数据
<?php function liansuo_post($url,$data){ // 模拟提交数据函数 $curl = curl_init(); // 启动一个CURL会话 curl_seto ...
- php curl模拟post请求提交数据
最近在做校园图书馆图书信息的采集程序,既然是图书馆图书的采集,肯定有提交搜索的页面,无非是post提交,让我想到了curl模拟提交,首先通过firebug进行抓包查询下post提交后的格式如下: tx ...
- 模拟提交API数据Pyqt版
其实这个模拟提交数据之前已经写过篇: Python requests模拟登录 因为现在在做的项目中需要一个debug请求调试API,用PHP的CURL写了一个,又因Pyqt更能直观灵活的显示请求的参数 ...
- 在php中分别使用curl的post提交数据的方法和get获取网页数据的方法
在php中分别使用curl的post提交数据的方法和get获取网页数据的方法整理分享一下额,具体代码如下: (1)使用php curl获取网页数据的方法: $ch=curl_init(); //设置选 ...
- PHP curl 模拟登陆
一个比较好的类: $cookie_file=tempnam("C:/users","tmp");生成以以tmp为前缀的文件. <?php define ( ...
- php封装curl,模拟POST和GET请求HTTPS请求
<?php /** * @title 封装代理请求 * @author victor **/ class ApiRequest { /** * curl提交数据 * @param String ...
- [转]php中 curl模拟post发送json并接收json
本文转自:https://blog.csdn.net/pangchengyong0724/article/details/52103962 本地模拟请求服务器数据,请求数据格式为json,服务器返回数 ...
- php中 curl模拟post发送json并接收json(转)
本地模拟请求服务器数据,请求数据格式为json,服务器返回数据也是json. 由于需求特殊性, 如同步客户端的批量数据至云端, 提交至服务器的数据可能是多维数组数据了. 这时需要将此数据以一定的数据 ...
随机推荐
- 如何完全卸载(Mac&Windows)office 365 ProPlus
Q: 如何完全卸载office 365 ProPlus,如果用户使用之前的office版本没有卸载干净(配置文件中保持了原有的Key)会造成新安装的office 365 ProPlus 或者最新版的o ...
- Message启动菜单个性化制作工具V1.0.3.1最终版
特点及功能 1.可以全新制作Message启动菜单文件!也可以选择修改已存在的菜单文件,制作或预览时会提示以哪个菜单版本为核心启动菜单. 2.支持更换背景图片,也支持图片标准化防止启动时黑屏,在选择背 ...
- EL表达式怎么获取Map的动态key?
缘由 El表达式在调用Map的时候,后台传过来的Map的key不一定是一个固定的值,需要根据另外一个对象的id作为key来put,或者更加复杂的组合id+"string"作为一个k ...
- 收集的在线图片压缩(jpg/png)
http://www.yasuotu.com/ http://www.jpegmini.com/ http://www.tumiaoya.com/ https://tinypng.com/(推荐) h ...
- 【转】C# lock的使用
一.Lock定义 lock 关键字可以用来确保代码块完成运行,而不会被其他线程中断.它可以把一段代码定义为互斥段(critical section),互斥段在一个时刻内只允许一个线程进入执行, ...
- iOS 个人账号 iOS APP Development 灰色不可选
如图,现在的开发者账号是有几个人共用的,已经 生成了一个Development 的证书,我想再申请一个,出现了这样的情况.网上有说的是申请证书个数到了上限,需要删除已经生成的.因为生成的证书其他人需要 ...
- nginx 499 状态码优化
在grafana界面中发现不少499的状态码,在网上了解到出现499的原因大体都是说服务端处理时间过长,客户端主动关闭了连接. 既然原因可能是服务端处理时间太长了,看一下upstream_resp ...
- 网络基础知识之 Ping
========================================假定主机A的IP地址是192.168.1.1,主机B的IP地址是192.168.1.2,都在同一子网内,则当你在主机A上 ...
- mate标签
<meta charset='utf-8'> <!-- 优先使用 IE 最新版本和 Chrome --> <meta http-equiv="X-UA-C ...
- 小白搭建一个网站(DouPHP)
1)安装phpStudy_2014_setup.1413444920.exe 并启动数据库 2)将软件自带的WWW实例替换成我发的这个模板(DouPHP),网上也可以下载. 能找到更好模板的也可以不用 ...