您的位置:首页 > 运维架构 > 网站架构

php破解验证码(某知名网站)

2014-06-30 20:50 369 查看
php破解验证码(某知名网站)

验证码图片:


<?php
require __DIR__ .'/include/picToStr.class.php';
$tezheng = include __DIR__ .'/include/code.php';

//cookie文件
$array['file']   = __DIR__ .'/picturecode.gif';
$array['validate']  = parse_validate($array, $tezheng);
print_r($array['validate']);
 
/**
 * 解析验证码
 */
function parse_validate($array, $tezheng) 
{
    //解析图片
    $tostr = new toStr($array['file']);
    $tostr->getHec();
    $horData = $tostr->magHorData();
    $ndatas  = $tostr->magVerData($horData);
	//echo $tostr->jz();	//查看横向像素图

	

    //取得解析后的验证码颜色值
    $new  =  formartData($ndatas);
	//echo $tostr->drawWH($ndatas);		//查看纵向像素图
	
    $code = '';
    
    //根据颜色值循环识别验证码图片上的字符
    foreach ($new as  $v) {
        $code .= discern($v, $tezheng);
    }
    //@unlink($array['file']);

    return $code;
}
/**
 * 识别一个字符
 */
function discern($numStr, $tezheng)
{   
     foreach ($tezheng as $k => $v){
        similar_text($numStr, $k, $pre);
        if ($pre>95){
            return $v;
        }
     }
}

/**
 * 格式化数据
 */
function formartData($data)
{
    $array = array();
    $i = 0;
    $str = '';
    foreach ($data as $k => $v) {
        if (!in_array(1,$v)) {
            $array[$i] = $str;
            $str       = '';
            $i++;
            continue;
        } else {
            foreach($v as $vv) {
                $str .= $vv;
            }
        }
    }
    return $array;
}


源代码下载:http://download.csdn.net/detail/e421083458/7576865
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: