>백엔드 개발 >PHP 튜토리얼 >크래킹 및 크래킹 방지 인증 코드에 대한 아이디어

크래킹 및 크래킹 방지 인증 코드에 대한 아이디어

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


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.