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. 由于需求特殊性, 如同步客户端的批量数据至云端, 提交至服务器的数据可能是多维数组数据了. 这时需要将此数据以一定的数据 ...
随机推荐
- 使用matlab进行空间拟合
假设有这么一组数据, x=[4 5 6 7 8 4 8 10]'; y=[56 56 56 56 56 60 60 60]';z=[6 6 6 9 6 19 6 6]'; 要求出其平面方程z=C+Ax ...
- Servlet和JSP学习指导与实践(三):JSP助阵
前言: JSP(Java Server Page)虽然作为一门服务端的语言,但它并没有创新新的语言标准.有些人一接触jsp之后发现易学易懂.实际上,jsp的内部原理仍然是基于Servlet,它是Ser ...
- BZOJ 3230: 相似子串
3230: 相似子串 Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 1485 Solved: 361[Submit][Status][Discuss ...
- Jquery跨域访问java接口
Jquery前台代码: <script> $.getJSON("http://跨域URL/Example/text.do?jsonpCallback=?", funct ...
- elastichq 离线安装
plugin install file:///home/hadoop/xxxx.zip 奇怪的是,这样安装成功后访问host:port:9200/_plugin/hq/ 仍然会报错,找不到一些js函数 ...
- Fedora 24 Gnome Boxes 无法ping通网络
安装Fedora 24在试用虚拟机时发现无法ping通外网. 我傻傻地以为是软件问题. 问题描述: 尝试ping程序来测试网络连通性: (我之前也是ping百度,后来在为了少打字百度了一些比较短的域名 ...
- python程序一直在后台运行的解决办法
刚写了个python程序,要一直在后台运行,即使断开ssh进程也在,下面是解决办法: 假如Python程序为test.py 编写shell脚本start.sh #!/bin/bash python t ...
- 二叉树的层序遍历 BFS
二叉树的层序遍历,或者说是宽度优先便利,是经常考察的内容. 问题一:层序遍历二叉树并输出,直接输出结果即可,输出格式为一行. #include <iostream> #include &l ...
- Hadoop概括——学习笔记<一>
之前有幸在MOOC学院抽中小象学院hadoop体验课. 这是小象学院hadoop2.X概述第一章的笔记 第一章主要讲的是hadoop基础知识.老师讲的还是比较全面简单的,起码作为一个非专业码农以及数据 ...
- 用类方法------>快速创建一个autorelease的对象,在封装的类方法内部
在封装的类方法内部,也就是+ (id)personWithName:(NSString *)name andAge:(int)age内部: 创建了一个person对象,并且创建了一个person*类型 ...