为了实现注册机才写的教程,为了批量注册一个网站,注册带有验证码,幸好是文本验证码,但是有session验证,于是POST必须携带cookie。代码如下。
<?php
class AutoCurl{
private $curl;
private $strCookie;
public $url;
public $data;
function __construct(){
$this->curl=curl_init();
$this->strCookie='tmp.cookie';
if(!file_exists('tmp.cookie')){
$ckfile = fopen("tmp.cookie", "w") or die("Unable to open file!");
fclose($ckfile);
}
}
function __destruct(){
curl_close($this->curl);
}
function CurlGet(){
curl_setopt($this->curl, CURLOPT_URL, $this->url);
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true) ;
curl_setopt($this->curl, CURLOPT_BINARYTRANSFER, true) ;
//important
curl_setopt($this->curl,CURLOPT_CONNECTTIMEOUT, 5);
//save_cookie
curl_setopt($this->curl,CURLOPT_COOKIEJAR,$this->strCookie);
$output = curl_exec($this->curl) ;
return $output;
}
function CurlPost(){
curl_setopt($this->curl,CURLOPT_POST,1);
//send_cookie
curl_setopt($this->curl,CURLOPT_COOKIEFILE, $this->strCookie);
curl_setopt($this->curl,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->curl,CURLOPT_URL,$this->url);
curl_setopt($this->curl,CURLOPT_POSTFIELDS,$this->data);
$output = curl_exec($this->curl) ;
return $output;
}
}
//实例化一个会话
$newcurl= new AutoCurl();
//第一步GET获取Cookie和验证码
//设置登录填充的Url
$newcurl->url='http://www.jinghong.in/index.php?m=user&mod=reg';
//发送Get
$result=$newcurl->CurlGet();
//获取验证码
if(preg_match('/\<b\>(.*)\<\/b\>/U',$result, $matches)){
$code=$matches[1];
}
//第二步POST提交注册
//设置登录提交的Url
$newcurl->url='http://www.jinghong.in/index.php?m=user&mod=reg&act=ok';
//设置发送POST数据
$newcurl->data=array("name" =>'a'.rand(pow(10,(6-1)), pow(10,6)-1),"sj" => "1".rand(pow(10,(11-1)), pow(10,11)-1),"email" =>rand(pow(10,(5-1)), pow(10,5)-1)."@qq.com","pass" => rand(pow(10,(7-1)), pow(10,7)-1)."qqcom","bzyzm" => $code);
//发送Post
$result=$newcurl->CurlPost();
var_dump($result);
?> PHPDDOS的原理是使用一个主控端批量向被控端(也就是特殊的webshell)发送攻击命令,方式一般是get或者post,达到统一指挥的目的。而被控端一般使用了php中的sock来进行攻击。用过末日DDOS工具应该了解,攻击效果显著。【一】。UDP源...
<!doctype html> <html> <head> <meta charset="utf-8"> <title>demo</title> </head> <bod...
PHP验证码不显示的问题应该是经常的事情,我在这里把2种解决方案都发出来方便大家后期使用.因为是昨天晚上自己写验证码都没有显示,我就直接把之前和李炎恢老师上课写的验证码拿来还是不显示,醉了。首先是第一种方法:1、打开服务器安装目录下的php.ini文件;2、去掉;extension=php_gd.d...
<?php /* *算法学习自百度.只是学习和记录 */ header("Content-type:text/html;charset=utf-8"); //1.设置奖项,id是奖项id,name是中奖名称,v是中奖概率 $arr =&n...
开发com组件可以用c++,vc++,net,我比较熟悉net,演示用dnet(1).创建项目:启动vs2017,新建项目,选择Visual C# ->Windows桌面->类库通用windows(2). 修改Com项目:点击 项目->项目属性,再点击应用程序->程序集信息,...
项目中使用服务来执行webservice,由于对方系统api不稳定,经常导致服务崩溃,只能重启,一个月差不多要重启一次。初期的解决办法是捕获异常,然后continue掉。<?php try { $url = 'http...