PHP를 사용하여 인증 코드를 해독하는 방법은 단 하나뿐입니다. 즉, 인증 코드에 나타나는 문자의 서명을 수집한 다음 인증 코드에서 문자를 분리하는 방법을 찾는 것입니다. 어떤 종류의 인공지능은 당연히 PHP가 할 수 없는 일이기 때문에 인증코드에 나타나는 문자의 서명을 모두 수집하고 인증코드에 있는 문자를 분리하는 방법만 찾는다면 크랙할 수 있습니다. 크래킹 방지 아이디어는 주로 중국어와 같은 문자를 더 많이 사용하고 글꼴과 변형을 더 많이 사용하여 동일한 문자에 여러 기능 코드가 있거나 고정된 기능 코드가 없도록 이 두 단계를 중심으로 진행됩니다. 문자 분리 난이도를 높입니다. 인증 코드에 나타나는 문자의 위치, 크기 및 간격은 고정된 역할을 할 수 있어야 합니다. 다음은 특정 웹사이트의 인증코드를 예로 들어 위의 두 단계를 통해 인증코드를 크랙하는 방법을 설명합니다. 참고: 코드의 일부는 phper "Baba"에서 제공됩니다. 특별히 감사드립니다!
- /* 첫 번째로 많은 요소가 배경색이고 두 번째로 많은 요소가 문자 색상, 즉 각 문자가 서로 다른 색상을 사용하거나 배경색이 너무 단조롭지 않은 경우 문자 색상을 어떻게 분리할 수 있습니까? */
- 함수 getMostRepeated($array){
- $count = array_count_values($array);
- arsort($count);
- $keys = array_keys($count);
- return $keys[1];
- }
- /* 인증 코드 이미지를 읽고 픽셀 RGB를 2차원 배열로 읽은 다음 유효한 문자를 분리합니다*/
- function fixImg($url ){
- $img = imagecreatefrompng($url);
- $with = Imagesx($img);
- $height = imagey($img);
- $middle = $height / 2;
- $colors = array();
- for ($i = 0; $i < $with; $i) {
- $color = imagecolorat($img, $i , $middle);//가운데 선의 픽셀 색상을 읽으면 중간 선이 확실히 문자로 잘립니다. . .
- $colors[] = $color;
- }
- $mainColor = getMostRepeated($colors);//문자 색상 분리
- $pic = array();
- for ($x = 0; $x < $with; $x) {
- $flag = true;
- for ($y = 0; $y < $height; $y) {
- $currentColor = imagecolorat($img, $x, $y);
- $pos = 0;//원본 이미지는 문자 구분을 쉽게 하기 위해 이탤릭체로 되어 있으며, 따라서 이탤릭체는 쓸모가 없습니다. . .
- if($y < 16){
- $pos = 0;
- }elseif($y >= 16 && $y <= 20){
- $pos = 1;
- $pic[$y][0] = 0;
- }elseif($y >= 21 && $y <= 26){
- $pos = 2;
- $pic[$ y][0] = $pic[$y][1] = 0;
- }else{
- $pos = 3;
- $pic[$y][0] = $pic[$y ][1] = $pic[$y][2] = 0;
- }
- // 간섭 픽셀의 색상과 문자의 색상이 전혀 다르기 때문에 문자 색상을 쉽게 구분할 수 있으며, 문자 픽셀은 1로 설정되어 있으므로 간섭 픽셀의 색상은 문자의 색상과 적어도 부분적으로 동일해야 합니다!
- if ($currentColor !== $mainColor) {
- $pic[$y][$x $pos] = 0;
- }else{
- $pic[$y][$x $pos] = 1;
- $flag = false;
- }
- }
- }
- return $pic;
- }
- // 전설적인 기능 코드
- $char = array(
- 'A'=>'0000000000001000000000000000010110000000000000001111100000000000000011101 0000 0000000001111100000000000000111110000000000010111001100 0000000011111000011000000000111010000110000000111100000000110 00000 011111000000011111111000110000000000011111101 1000000000000011111110000000000000001111110000000000000001 11111100000000 000000001111111000000000000000001110000000000000000000110',
- 'B'=>'111111111111111111111011111111111 1111111110111111 1111111111110110000000110000000110110000000 11000000011011000000011011000000111000000011011100001 111100000011011111111001 10001111001111111000111111100001110100001111111100000000000000111101000',
- 'C' =>'0000010111100000000000000111111111111100000001111111111111000000111010000111111000011100000000000011100011000 00000 00000011000110000000000000011101100000000000000011101100000000000000001101110000000000000000110110000000000000000110110 000 0000000000001101100000000000000110110000000000000011000011 00000000000001100011000000000000011000',
- 'D'=>'111 1111 111111111111011111111111111111111011111111111111111110110000000000000000110110000000000000000110110000000000000000110 11 0000000000000001101100000000000000011011000000000000000110 1100000000000000001101110000000000000011100110000000000000111 0 001111000000000011110000111100000000111100000011111111111110000000111111111100000000000111111110000000',
- 'E'=> ;' 111111111111111111101111111111111111111101111111111111111111011000000011000000011011000000011000000011011000000011000 00001 10110000000110000000110110000000110000000110110000000110 00000011011000000011000000011011000000000000000011000000000000 000110',
- 'F'=>'11111111111111111110111111111111111111011111111111111111101100000001100000000001100000001 100000000001100 0000011000000000011000000011000000000011000000000011000000011000000000011000000000110000000000000000000',
- 'G'=>'00 000101111000000000000001111111111100000001111111111110000001110100001111110000111100000000000000000000011000110000000000 000011101100000000000000111011000000 00000000000110110000000000000000110110000000000000001101100000000000000001101100000000 000000011011000000000111111110011 0000000011111100011000000001111111100',
- 'H'=>'1111111 111111111111101111111111111 11111011111111111111111100000000000000000001100000000000000000001100000000000000 000001100000000000000000011000000000000000 0000110000000000000000000011000000000000000000110000000000000000000011000000000011111111111111110111111111111111 11 1011111111111111111110',
- '나'=>'1111111111111111111011 111111111111111111011111111111111111110',
- 'J'=>'1111111111111111111111111111 11111111111111110',
- 'K'=>'11111111111111111110111111111111111111011111111111111111110000000000110000000000000 000001110000000000000000110110000000000000011110011100000000 00011110001111000000000111100000111100000001110000000001110000 011100000000000111000111000000000000011100110000000000000001110100000000000000000110000000000000000000010',
- 'L'=>' 1111111111111111111101111111111111111111101111111111111111111100000000000000000001100000000000000000001100000000000000000 00110000000000000000000110000000000000000000110000000000000000000110000000000000000011000000000000000000110000000000000 00000110 ',
- 'M'='11111111111111111110111111111111111111110111111000000000000000111111100000000000000000111111110000000000000000000000000 00000111111000000000000000011111111000000000000000011111000 0000000000000111111000000000000000001111000000000000000111111 0000000000001011100000000000000111110000000000001111110100000 000000011111000000000000001110000000000000000011111111111111 1111011111111111111111110111111111111111111110',
- 'N'=>'11111111111111111110111111111111111111101111100000000000 0000001111100000000000000000011110000000000000000000111000000 00000000000001111000000000000000000111100000000000000000001110 0000000000000000001110000000000000000011111000000000000000000111110000000000000000011110000000000000000001111011111111 11111111110111111111111111111110', > 10000000000000110001100000000000000111011000000000000000110 110000000000000000110110 00000000000000011011000000000000000011 0110000000000000000110111000000000000000110011000000000000011100011110000000000111100 001111000000001111000000111111111111 1110000000011111111110000000000011111110000000',
- 'P'=> ;'1111111111111111111111 11110111111111111111 111101100000000110000000001100000000110000000001100000000110000000001100000001110000000001100000001110 0000000011110000111 00000000000111111110000000000001111111000000000000000111110000000000000' ,
- 'Q'=>'000001011110000000000000011111111111100000000111111111111110000001110100001111111000011100000000000011100011000000 0000000011000100000000000000011101100000000000000001101100000 00000000000110110000000000000000110110000000000000000110110000 000000000000110111000000000000000111011000000000000011111011110000000000111101001111000000001111001000111111111111100000 0000111111111000000000000111111110000000',
- 'R'=>'11111 111111111111110111111111111111111101111111111111111110110 0000001100000000001100000001100000000001100000001100000000001100000001100000000001100000011111000000001110010111011110000 001111111110011111100000111111100001111000000111011000000011 110000000000000000001110000000000000000001110000000000000000 00010',
- 'S'=>'00011100000000000100000111111000000000110 0011111111000000001100011000111100000000110110000011110000000 1101100000011100000001101100000011100000001101100000001110000001101100000000111000111001110000000111111111000110000000011 11111000000000000001111100000',
- 'T'=>'1100000000000000000000110000000000000000001100000000000000000011000000000000 00000011000000000000000000011000000000000000000011000000000000000000011111111111111111110111111111111111111110111111111 111111111101100000000000000000011000000000000000000011000000 00000000000001100000000000000000001100000000000000000001100000 00000000000000110000000000000000000',
- 'T'=>'11000000000000000000011000000000000000000011000000000000000000011000000000000000000011000000000000000000011 0000000000000000000111111111111111111101111111111111111111011111111111111111110110000000000000000000110000000000000000 000110000000000000000000110000000000000000000110000000000000000000110000000000000000000110000000000000000000',//vt左边会被侵·掉一列
- 'U'=>'11111111111111111000011111111111111110000111111111111111111100000000000000000001100000 0000000000000011100000000000000000001100000000000000000001100000000000000000001100000000000000000001100000000000000000001 1000000000000000000110000000000000000011110011111111111111111100011111111111111000000',
- 'V'=>'11110000000000000000 0111111000000000000000111111110000000000000000011111100000000000000000111111000000000000000001111111100000000000000011111 11000000000000000001111110000000000000000011110000000000000001111110000000000010111101000000000000111111000000000000101111 1000000000000111111000000000000001110100000000000000111100000000000000000',/ /少读一列
- 'W'=>'11111100000000000000011111111100000000000011111111100000000000000001111111111100000000000011111111100000000000011111 11110000000000000001111111100000000000000001111100000000000000111111000000000111111100100000001111111110000000001111111 0000000000000111111000000000000000111111000000000000000111111 111110000000000000000111111111100000000000111111111100000000 0000001111111110000000000000000111110000000000000011111110000000001111111001000000011111111100000000001111111000000000000 111110100000000000000',
- 'X'=>'0000000000000000000101100 0000000000000011011110000000000001110011111100000000011100000 11110000000011000000000111110000011000000000000111110110000000000000111111100000000000000001111000000000000000001111100000 0000000011110011110000000000111100011111100000001111000000111 1000000111000000000011110001110000000000000111011000000000000 001110100000000000000000010',
- 'Y'=>'110000000000000000000111100000000000000000111111000000000000000001111000000000 00000000001111100000000000000000011111000000000000000011111111111110000000000111111111100000000011111111111100000000111 0000000000000000111100000000000000011110000000000000000111000 00000000000000111000000000000000001100000000000000000001000000 00000000000000',
- 'Z'= >'0000000000000000001101100000000000000111101100000000000011111101100000000000111111101100000000001111001101100000000111 1000011011000000011110000011011000001111100000011011000111110000000011011001111100000000011011011110000000000011011111000 0000000000110111100000000000000110111000000000000000110',
- '0'=>'00000101111010000000000011111111111111000000111111 1101111110000011100000000000011100011000000000000001100110000 00000000000111011000000000000000011011000000000000000011011000 000000000000011011100000000000001110001111100000000011110000111111111011111100000001111111111110000000000011111110000000 ',
- '1'=>'00110000000000000011000110000000000000011001100000000000000011001100000000000000011001111111111111111110 01111111111111111110111111111111111111110000000000000000001 100000000000000000011000000000000000000011000000000000000000 110',
- '2'=>'000000000000000000110001100000000000111110011000000000000111110011000000000001101110110000000000011000 1101100000000001110001101100000000011100001101100000000111000001101110000001110000001101111000011110000001100111111111000 00000110001111111000000000110000111110000000000110',
- '3'=>'011000000000000001100010000000000000001100110000000110000000110110000000110000000110110000000110000000110110000000 1100000001101100000011100000001101110000110110000011101111111110110000111000111111100011111111000011101000011111110000000 00000000111101000',
- '4'=>'00000000000011000000000000000001111000000000000000011111000000000000000110011000000000000 1111000110000000000011110000110000000000111100000110000000001110000000110000000011100000000110000000111111111111111111101 1111111111111111110111111111111111111110000000000000110000000000000000000110000000000000000000110000000',
- '5'=>'1 11111110000000011001111111100000000111011000001100000000011 01100000110000000001101100000110000000001101100000110000000001 101100000011000000001101100000011100000011101100000011100001111001100000001111111110011000000001111111100011000000000111 1100000',
- '6'=>'0000010111101110000000000111111111111100000011111111111111100000111010010100001110001100000110000 0001100011000001000000001110110000011000000000110110000011000 00000011011000001100000000011011000001110000000011011000001111 0000011100111000001111111111100011000000111111111000000000000001111000000',
- '7'=>'11000000000000000000011000000000000000001011000000000000011111011000000000001111111011000000000000000111100110 0000000111110000001100000011111000000001100000111010000000001 100011110000000000011011110000000000000111110000000000000000 111100000000000000000111000000000000000000',
- '8'=>'0000 000000000111100000001110000001111110000011111100111111110001 11111111111000011000110001111111000001110110000011100000000110 11000001111000000011011000000111000000011011000000111100000011 01110010111110000001101111111001110001110001111111000111111 110000111010000111111100000000000000111100000',
- '9'=>'0 00011111100000000000001111111100000011000011111111000000110 00111000001110000001101110000000111000001101100000000011000001 1011000000000110000011011000000000110000011011000000000110000 110011100000001100001110001111100011100111100000111111111111 11000000111111111111000000000000111111110000000',
- );
-
- $ arr = fixImg("https://xxxxxxxxxx");// 哦,这里隐去某社区域name 및 验证码地址,为了支持https,你적php环境要开启openssl
- for($i = 0;$ 나는 < 10;$i )
- unset($arr[$i]);// 前10行是空白
- $y = 0;// 采用从上到下 ,从左到右顺序读特征码,从第0行开始(实际是第10行)
- $len = 31;// 多读一行,JQ超过20行,且J后면几行了上个字符的位置
- $ code = array();// 분할 출력형 문자 유형
- $str = '';
- while($y < count($arr[10])){
- $flag = true;// 전체0是空白竖线
- $line = '';
- for($i = 10;$i < $len;$i ){
- if($arr[$ i][$y])
- $flag = false;
- $line .= $arr[$i][$y];
- }
- $isw = false;
- $isy = false;
- // 对vw적 특성
- if($str === $char['V'] || $str === $char['W']){
- $ 플래그 = true;
- $isw = true;
- }elseif($str === $char['Y'] || $str === $char['A']){
- $ isy = true;
- $flag = true;
- }
- if($flag){
- if(strlen($str) > 21)
- $code[] = $str;
- $str = '';
- }else{
- $str .= $line;
- }
- if($isw){
- $str = '00' .substr($line,2,strlen($line));
- if($str === '000000000000000000000')
- $str = '';
- $isw = false;
- }
- if($isy){
- $str = $line;
- if($str === '000000000000000000000')
- $str = '';
- $isy = false;
- }
- $y ;
-
- }
-
- // 输出字符
- foreach($code as $v){
- $match = false;
- foreach ($char를 $key로 사용 => $v2){
- if($v === $v2){
- echo $key;
- $match = true;
- }
- }
- if(!$match)
- echo '?';// 没匹配到的字符输出问号
- }
-
复代码
|