从52破解论坛某软件中提取API信息,进行PHP版本创作
接口已失效!
测试地址:点我
<?php
class captcha_recognition{
/*
验证码识别(百度OCR) demo ---从52破解某软件中提取信息
PHP版本创作:刘锦 (老司机)
制作时间:2017年10月8日 15:09
*/
/*传入参数 图片地址 , 请求图片用的httpheader(格式为array('X-FORWARDED-FOR:'.$ip, 'CLIENT-IP:'.$ip,'COOKIE:'.$cookie_str))*/
public function get_rec($image_url,$headerArr){
$image=$this->http($image_url,$headerArr,"");
$image_name=md5($image);
$fp2=fopen($image_name, "w");
fwrite($fp2,$image);
fclose($fp2);
$output=md5($image).".jpg";
$image=imagecreatefromgif($image_name);
imagejpeg($image,$output);
imagedestroy($image);
unlink($image_name);
$image_name=$output;
$imginfo= getimagesize($image_name);
preg_match("/^(image\/)?([^\/]+)/i",$imginfo['mime'],$matches);
$image_base64=urlencode(base64_encode(file_get_contents($image_name)));
$image_ext=$matches[2];
$api_url="https://cloud.baidu.com/aidemo";
$data="type=webimage&image=data%3Aimage%2F".$image_ext."%3Bbase64%2C".$image_base64;
$rec_headerArr=array("User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4","Content-Type: application/x-www-form-urlencoded");
$res=$this->http($api_url,$rec_headerArr,$data);
$res=json_decode($res,true);
$res=$res['data']['words_result'][0]['words'];
unlink($image_name);
return str_replace(" ","",$res);
}
private function http($url,$headerArr,$PostData){
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headerArr);
curl_setopt($curl, CURLOPT_URL, $url);
if(!empty($PostData)){
curl_setopt($curl, CURLOPT_POSTFIELDS, $PostData);
}
$res = curl_exec($curl);
curl_close($curl);
return $res;
}
}
$cookie_str="ASP.NET_SessionId=25lxbh45tdwskkuhssqf5qmz";
$ip2id= round(rand(600000, 2530000) / 10000);
$ip3id= round(rand(600000, 2530000) / 10000);
$ip4id= round(rand(600000, 2530000) / 10000);
$arr_1 = array("110","121","199","126","218","228","62","65","202","204","146","203","204","205","206","207","222","221","216","59","209","210","66","212","211","62","63","64","212","213","120","211","110","120","166","126","218","228","62","65","202","204","146","86","76","59","61","60","222","221","216","59","60","132","66","212","211","62","63","64","53","46");
$randarr= mt_rand(0,count($arr_1)-1);
$ip1id = $arr_1[$randarr];
$ip=$ip1id.".".$ip2id.".".$ip3id.".".$ip4id;
$headerArr = array('X-FORWARDED-FOR:'.$ip, 'CLIENT-IP:'.$ip,'COOKIE:'.$cookie_str);
$a=new captcha_recognition();
echo $a->get_rec("http://61.142.33.204/CheckCode.aspx",$headerArr);
发表评论: