PHP を使用して検証コードを解読する方法は 1 つだけあり、それは、検証コードに含まれる文字の署名を収集し、検証コード内の文字を分離する方法を見つけることです。どのような人工知能かというと、明らかに PHP にはできないので、検証コードに含まれる文字の署名をすべて収集し、検証コード内の文字を分離する方法を見つけることができれば、解読することができます。 クラッキング対策のアイデアは主にこれら 2 つのステップを中心に展開し、中国語などのより多くの文字を使用し、より多くのフォントと変形を使用して、同じ文字に複数の特徴コードがあるか、固定の特徴コードが存在しないようにします。文字の分離の難易度が高くなります。検証コード内で不確実な位置、サイズ、間隔で表示される文字が影響を与える可能性があります。 以下では、特定のWebサイトの確認コードを例として、上記の2つの手順で確認コードを解読する方法を説明します。 注: コードの一部は phper "Baba" からのものです。特別に感謝します。
- /* 数値を並べ替えて 2 番目に多い要素を見つけます。最初にある要素は背景色で、2 番目に多い要素は文字の色です。つまり、各文字の場合。全部違う色を使っている、または背景の色が単調ではない 文字の色を分けるにはどうしたらよいでしょうか? */
- function 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 = imagex ($ 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 $pos = 1;
- $pic[$y][0 ] = 0;
- }elseif($y >= 21 && $y $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'=>'00000000000000000001000000000000000000101100000000000000011111000000000000001110100000 0000001111100000000000000111110000000000001011100110000000000111110000110000000001110100000110000000111100000000110000 11110000001100000001111111100011000000000001111111011000000000000011111100000000000000001111111000000000000000011 000000000001111111000000000000000000111000000000000000000110',
- 'B'=>'11111111111111111111011111111111111 111111111111110110000000110000000110110000000110000000110110000000110000000110110000001110000000110111000011 11100000011011 11111110011000111100111111000111111100001110 100000000000000111101000',
- 'C'=>'000001011110 000000000000011111111111100000001111111111100000011101000011111110000111000000000000111000110000000000000011000110000 000000001110110000000000000001110110000000000000000110110000000000000000110110000000000000000011011000000000000000011011 0000000000000110110000000000000001100011000000000000001100011000000000000011000',
- 'D '=>'1111111111111111111101111111 111111111111011111111111111111110110000000000000000110110000000000000000110110000000000000000110110000000000000000110110 0000000000000001101100000000000000001101100000000000000001101 1100000000000000111001100000000000001110001111000000000011100 00111100000000111100000011111111111111000000011111111111100000000000011111110000000',
- 'E'=>'1111111111111111111101 1111111111111111110111111111111111111011000000011000000011 01100000001100000001101100000001100000001101100000001100000001 10110000000110000000110110000000110000000110110000000110000000110110000000000000000110000000000000000000110',
- 'F'=> '111111111111111111011111111111111111101111111111111111111011000000011000000000011000000011000000000011000000011000000 0000110000000110000000000110000000110000000000110000000110000000000110000000110000000000110000000000000000000',
- 'G'=&g t;'00000101111000000000000001111111111110000000111111111111100000011101000011111110000111000000000000111000110000000000 00001100011000000000000011101100000000000000111011000000000 00000001101100000000000000001101100000000000000001101100000000 00000000110110000000000000000110110000000001111111110011000000001111111100011000000001111111100'、
- 'H'=>'1111111111111111111011111111111111111110111111111111111111100000000001100000000000000000001100000000000000000 001100000000000000000011000000000000000000110000000000000000000110000000000000000000110000000000000000001100000000000000 0000011000000000000000000011000000000011111111111111111110111111111111111111011111111111111111110 ',
- 'I'=>'11111 11111111111111011111111111111111110111111111111111111110',
- 'J'=>'11111111111111111111111111111111111111111111111 111111111111110',
- 'K'=>'111111111111111111110111111111111111111101111111111111111111100000000001100000000000000000 0111000000000000000001101100000000000000111100111000000000001111000111100000000011110000011110000000111000000000111000001 1100000000000111000111000000000000011100110000000000000001110100000000000000000110000000000000000000010',
- 'L'=> '111111111111111111101111111111111111111011111111111111111110000000000000000000110000000000000000000110000000000000000 0001100000000000000000001100000000000000000001100000000000000000001100000000000000000001100000000000000000001100000000000 00000000110',
- 'M' =>'111111111111111111110111111111111111111011111100000000000000011111100000000000000000111111110000 00000000000011111 1000000000000000011111100000000000000001111100000000000000001111110000000000000000011110000000000000011 1110000000000 001011100000000000000111110000000000001111101000000000000111000000000000001110000000000000000011111111111 111110111 111111111111111101111111111111111110',
- 'N'=>'11111111110111111111111111111011111000000000000000011111 000000000011110000000000000000001110000000000000000 00111100000000000000000111100000000000000000001110000000000001 1100000000000000000111110000000000000001111100000000000000000111000000000000000000000111101111111111111111111 111111111110',
- 'O'=>'0000010111100000000000000 1111111111000000001111111111100000011101000000111110000 00111000110000000000000110001100000000000000111 01100000000000000001101100000000000000001101100000000000000001 000000001101100000000000000001101110000000000000001100110000000000000111000111100000000000111100001111000000001111000000111 11111111111000000001111111110000000000011111 1110000000',
- 'P'=>'111111111111111111011111111111111111 1110111111111111111101100000000110000000011000 0000001100000000110000 00000110000000011000000011100 00000001111000011100000000000111111110000000000001111111000000000000000111110000000000000',
- 'Q'=>'000001011110000000000000011111111111100000000111111111111100000011101000011111110000111000000000000111000110000 00000000001100010000000000000011101100000000000000011011000 00000000000001101100000000000000001101100000000000000001101100 00000000000000110111000000000000000111011000000000000001111101111000000000011110100111100000000111100100011111111111111000 00000011111111100000000000011111110000000',
- 'R'=>'11111 111111111111110111111111111111111101111111111111111111011 0000000110000000000110000000110000000000110000000110000000000110000000110000000000110000001111100000000111001011101111000 000111111111001111110000011111110000111100000011101100000001 111000000000000000000011100000000000000000111000000000000000 000010',
- 'S'=>'00011100000000000100000111110000000001100 011111111000000001100011000111100000000110110000011110000000 110110000001110000000110110000001110000000110110000000111000000110110000000011100011100111000000011111111000110000000011 1111100000000000001111100000',
- 'T'=>'110000000000000000 001100000000000000000001100000000000000000001100000000000000 000001100000000000000000001100000000000000000001100000000000000000001111111111111111111011111111111111111111011111111111 111111110110000000000000000000110000000000000000000110000000 00000000000011000000000000000000011000000000000000000011000000 0000000000000110000000000000000000',
- 'T '=> '110000000000000000000110000000000000000000110000000000000000000110000000000000000000110000000000000000000110000000000000 0000001111111111111111111011111111111111111110111111111111111111101100000000000000000001100000000000000000001100000000 00000000000110000000000000000000110000000000000000000110000000000000000000110000000000000000000',//vttimet左边会被侵犯一列
- ' U'=>'111111111111111110000111111111111111100001111111111111111110000000000000000000110000000000000000000111000000000 0000000000110000000000000000000110000000000000000000110000000000000000000110000000000000000000110000000000000000001100000 00000000000011110011111111111111111000111111111111111000000',
- 'V'=>'1111000000000000000001111110000000000000001111 11111000000000000000001111110000000000000000111111100000000000000000111111100000000000000011111100000000000000000111111 000000000000000001111000000000000000111110000000000010111101 0000000000001111100000000000010111110000000000001111100000000 0000001110100000000000000111100000000000000000',//少读一列
- 'W'=>' 111111000000000000000111111111000000000000111111111110000000000000000111111111110000000000001111111110000000000000001111111110000000000000000111110000000000000011111110000000001111111001000000011111111100000000011111110000000000000111111000000000000000111111000000000000000111111111110000000000000000111111111110000000000011111111111000000000000001111111110000000000000000111110000000000000011111110000000001111111001000000011111111100000000001111111000000000000111110100000000000000',
- 'X'=>'000000000000000000010110000000000000000110111100000000000011100111111000000000111000001111000000001100000000011110000011000000000000111110110000000000000111111100000000000000001111000000000000000001111100000000000001111001111000000000011110001111110000000111100000011110000001110000000000111100011100000000000001110110000000000000001110100000000000000000010',
- 'Y'=>'110000000000000000000111100000000000000000111111000000000000000001111000000000000000000011111000000000000000000111110000000000000000111111111111110000000000111111111110000000001111111111110000000011100000000000000001111000000000000000111100000000000000001110000000000000000011100000000000000000110000000000000000000100000000000000000000',
- 'Z'=>'000000000000000000110110000000000000011110110000000000001111110110000000000011111110110000000000111100110110000000011110000110110000000111100000110110000011111000000110110001111100000000110110011111000000000110110111100000000000110111110000000000000110111100000000000000110111000000000000000110',
- '0'=>'000001011110100000000000111111111111110000001111111101111110000011100000000000011100011000000000000001100110000000000000001110110000000000000000110110000000000000000110110000000000000000110111000000000000011100011111000000000111100001111111110111111000000011111111111100000000000111111110000000',
- '1 '=>'001100000000000000110001100000000000000110011000000000000000110011000000000000000110011111111111111111110011111111 11111111111011111111111111111110000000000000000000110000000000000000000110000000000000000000110000000000000000000110',
- '2'=>'00000000000000000011000110000000000011110011000011111001100000000000110111011000000000001100011011000 0000000111000110110000000001110000110110000000011100000110111000000111000000110111100001111000000110011111111100000000110 001111111000000000110000111110000000000110'、
- '3'=>'0110000000000000011000100000000000000011001100000001100000001101100000001100000001101100000001100000001101100000 0011000000011011000000111000000011011100001101100000111011111111101100001110001111111000111111110000111010000111111100000 0000000000111101000',
- '4'=>'00000000000011000000000000000 001111000000000000000011111000000000000000110011000000000000 1111000110000000000011110000110000000000111100000110000000001110000000110000000011100000000110000000111111111111111111110 11111111111111111111011111111111111111110000000000000110000000000000000000110000000000000000000110000000',
- '5'=>'1 111111110000000011001111111100000000111011000001100000000011 01100000110000000001101100000110000000001101100000110000000001 1011000000110000000011011000000111000000111011000000111000011110011000000011111111110011000000001111111100011000000000111 1100000',
- '6'=>'000001011110111000000000011111111111110000001111111111111111000001110100101000011100011000001100000 0011000110000010000000011101100000110000000001101100000110000 00000110110000011000000000110110000011100000000110110000011110 000011100111000001111111111100011000000111111111000000000000001111000000',
- '7'=> '11000000000000000000011000000000000000001011000000000000011111011000000000001111110110000000000111111100110000000011111 0000001100000011111000000001100000111010000000001100011110000 00000000110111110000000000000111110000000000000000111100000000 000000000111000000000000000000',
- '8'=>'000000000000011110 00000011100000011111100000111111001111111110001111111111100 0011000110001111110000011101100000111000000001101100000111100 0000011011000000111000000011011000000111100000011011100101111 000000110111111110011100011100011111110001111111100001110100 001111111000000000000000111100000',
- '9'=>'000011111100000 00000000111111110000001100001111111100000011000111000001110 00000110111000000011100000110110000000001100000110110000000001 1000001101100000000011000001101100000000011000011001110000000110000111000111110001110011110000011111111111111110000001111 11111111000000000000111111110000000',
- );
-
- $arr = fixImg("https://xxxxxxxxxx");// 哦、这里ある社の領域名とテストコード地址を去って、https、你のphp環境をサポートするために开启openssl
- for($i = 0;$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']){
- $flag = 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 as $key => $v2){
- if($v === $v2){
- echo $key;
- $match = true;
- }
- }
- if(!$match)
- echo '?';//一致する文字符出问号
- }
-
复制定
|