Авторские статьи Декодирование капчи

Discussion in 'Статьи' started by 4nob1oz, 27 Feb 2008.

  1. vvs777

    vvs777 Elder - Старейшина

    Joined:
    16 Nov 2004
    Messages:
    394
    Likes Received:
    213
    Reputations:
    4
    Ммать, это как?
    принцип "тыкни мышкой туда где у болонки нос иначе мышка вонять будет"?
     
  2. Dr. Livesey

    Dr. Livesey New Member

    Joined:
    21 Dec 2007
    Messages:
    0
    Likes Received:
    0
    Reputations:
    0
    отпишитесь в пм пожалуйста кто умеет писать распознавалки несложных капчей (ну или сделать на базе gocr или еще чего-то такого).

    платно, разумеется.
     
  3. Johan

    Johan New Member

    Joined:
    25 Nov 2007
    Messages:
    7
    Likes Received:
    0
    Reputations:
    0
    Автору спасибо, на основе его и Nomer'овского кода решил свои маленькие проблемы с одним надоедливым сервисом. :)

    Распознает капчу из букв и цифр типа [​IMG]

    PHP:
    <?

    //coded by rikki

    function pwntcha($image) {

    define("LETTERS" "...##.....####...##..##.##....####....####....############....####....####....########..##...##.##....####...##.######..##...##.##....####....####...##.######....#####..##...####.....###......##......##......##......##.....#.##...##..#####.######..##...##.##....####....####....####....####....####....####...##.######..#######.##......##......##......######..##......##......##......##......#######.##########......##......##......######..##......##......##......##......##........#####..##...####......##......##......##...#####....####....##.##...##..#####.##....####....####....####....############....####....####....####....####....##################################################################################...####......##......##......##......##......##......##..#...##..##.##....###...##....####...##.##..##..##.##...####....####....##.##...##..##..##...##.##....####......##......##......##......##......##......##......##......##......#######.##....#####..#############.##.####.##.####.##.####....####....####....####....####....#####...######..######..####.##.####.##.####..######...#####...#####....##................................................................................#######.##....####....####....#########.##......##......##......##......##........####...##..##.##....####....####....####....####.##.####..####.##..##...####.########.##....####....####....#########.#####...##..##..##...##.##....####....##.######.##....####......##.......######.......##......##......####....##.######.########...##......##......##......##......##......##......##......##......##...##....####....####....####....####....####....####....####....##.##..##...####..##....####....####....##.##..##..##..##..##..##...####....####.....##......##...##....####....####....####....####.##.####.##.####.##.#############..#####....####....####....##.##..##...####.....##......##.....####...##..##.##....####....####....####....##.##..##...####.....##......##......##......##......##......##...#######......##......##.....##.....##.....##.....##.....##......##......#######...####...##..##.##....##......##.....##.....##.....##.....##.....##.....########.#####..##...##.......##.....##....###.......##.......##......####...##..#####.......##.....###....####...##.##..##..##.##...##.########.....##......##......##.#######.##......##......##.###..###..##.......##......####....##.##..##...####....####...##..##.##....#.##......##.###..###..##.##....####....##.##..##...####..########......##......##.....##.....##.....##.....##.....##.....##......##........####...##..##.##....##.##..##...####...##..##.##....####....##.##..##...####....####...##..##.##....####....##.##..###..###.##......##.#....##.##..##...####..
    "
    );

    define("CSE"rand(1,10)>5?65:97); //randomly define CASE of captcha value at runtime.  Don't wanna leave a pattern.



    $tempname tempnam("./""cap");

    $temp fopen($tempname"w");
    fwrite($temp$image);
    fclose($temp);

    $src imagecreatefromjpeg($tempname);
    $im imagecreatetruecolor(5310);
    imagecopy($im$src005115310);
    $bl imagecreatetruecolor(810);

    $txtNum '';

    for(
    $n 0$n<48$n += 9) {

    imagecopy($bl$im00$n0810);
    $txtNum .= charcode($bl);

    }

    unlink($tempname);
    return 
    $txtNum;

    }

    function 
    charcode($cell) {

    $white imagecolorallocate($cell255255255); //$cell must be truecolor, otherwise OOL
    $black imagecolorallocate($cell000);       //-/- applies :P

    $linear='';

    for(
    $j=0;$j<10;$j++)
    {

           for(
    $i=0;$i<8;$i++)
            {
      
    $color=imageColorAt($cell,$i,$j);
      list(
    $r,$g,$b) = array_values(imageColorsForIndex($cell,$color));
      if(
    $r>40 && $g>40 && $b>40)
      {
            
    imagesetpixel($cell,$i,$j,$white);  //what we do here is we map the image pixel by pixel onto a string
            
    $linear .= '.';//echo ".";                     //with binary values of # == "I am a pixel that's part of a letter" and . == "I am useless and irrelevant"
      
    } else {
            
    imagesetpixel($cell,$i,$j,$black);
            
    $linear .= '#';//echo "#";
      
    }
            }
    //echo "\n\r";
    }

    $char strpos(LETTERS$linear);

    if (
    $char 2075)  {return(chr(CSE $char/80));}
    else {return(
    chr(50 + ($char/80)-26 ));}



    }

    ?>
     
    #23 Johan, 17 Apr 2008
    Last edited: 17 Apr 2008