www.Hacking-Romania.com
Hacking, gaby hacker team, programe hack, radmin hack, hi5 hack, hack the west, hacking romania, hacking stuff, hacking tools, 1 hack, 1st hacks, 2 hack, 2 hacks, 3 hack, 3 hacks, 3000 hack, 3004 hack, 4 hack, 4 hacks, 55 hack, 6 hack, 6 hacks, 7 hack, 7 hacks, 9 hack, 9dragons hack, a hack, adventure quest hack, aim hack, alz hack, and hacks, best hack, blue hack, bots hack, bots hacks, buy hack, cabal online hack, chaos hacks, cheat engine hack, cheat hack, cheats and hacks, cheats hacks, city hack, club hack, combo hack, conquer hacks, conquer online hack, conquer online hacks, conquer speed hack, conquiztador hack, counter strike 1.6 hack, damage hack, de hack, download hack, download hack for, dragonfable hack, dragonfable hacks, drakkarious hack, exp hack, flyff hack, free hack, free hacks, game hack, game hacks, garena exp hack, gladiatus hack, gm hack, gold hack, gunz hack, hack, hack 5, hack a pc, hack a site, hack a website, hack blog, hack conquer, hack counter strike, hack crack, hack cs, hack cs 1.6, hack dvd, hack email, hack forum, hack hunter, hack id, hack info, hack it, hack mess, hack muonline, hack net, hack password, hack passwords, hack pc, hack pdf, hack programs, hack site, hack sites, hack soft, hack software, hack team, hack the game, hack this, hack website, hack windows xp, hack world, hack xp, hacked, hacking, hacking game, hacking programs, hacking software, hacking tutorials, hacks, how hack, how to hack, icon hack, last chaos hack, last chaos hacks, life hack, lineage 2 hack, lineage 2 hacks, linux hack, lvl hack, maplestory hacks, mobile hack, multi hack 3.0, mybrute hack, naruto arena hack, naruto arena hacks, one hit kill hack, online hacks, perfect world hacks, pool hack, programe hack, resolution hack, resource hack, roll hack, royal hack, silkroad hack, source hack, speed hack, speed hacks, super hack, the west hack, warrock hack, warrock hacks, web hack, xpango hack, lockerz forum
Lista Forumurilor Pe Tematici
www.Hacking-Romania.com | Reguli | Inregistrare | Login

POZE WWW.HACKING-ROMANIA.COM

Nu sunteti logat.
Nou pe simpatie:
Lore33 pe Simpatie.ro
Femeie
19 ani
Prahova
cauta Barbat
30 - 65 ani
www.Hacking-Romania.com / Hacking T00ls / Cum sa spargem un captcha simplu  
Autor
Mesaj Pagini: 1
harry2115
Moderator

Inregistrat: acum 16 ani
Postari: 385
In acest tutorial vom invata sa spargem acest tip de captcha. In ce consta el ?
- culoarea backgroundului este random
- culoarea cifrelor este mereu aceeasi
- pozitia cifrelor difera pe X
- pozitia cifrelor ramane neschimbata pe Y
Ce inseamna sa "spargem un captcha" ? Practic, trebuie sa afisam in format text cifrele din fiecare imagine (evident, sunt random). Sa vedem in continuare codul .php care genereaza imaginile:
Cod:

<?php
header('Content-type: image/png');
$img = imagecreate(239, 25);

$r = rand(1, 255);
$g = rand(1, 255);
$b = rand(1, 255);
$l1 = rand(0, 4);
$l2 = rand(0, 4);
$l3 = rand(0, 4);
$l4 = rand(0, 4);
$l5 = rand(0, 4);
$poz1 = rand(0, 48);
$poz2 = $poz1 + rand(9, 48);
$poz3 = $poz2 + rand(9, 48);
$poz4 = $poz3 + rand(9, 48);
$poz5 = $poz4 + rand(9, 48);

$background = imagecolorallocate($img, $r, $g, $b);
$culoare = imagecolorallocate($img, 100, 100, 100);

imagechar($img, 7, $poz1, 6, $l1, $culoare);
imagechar($img, 7, $poz2, 6, $l2, $culoare);
imagechar($img, 7, $poz3, 6, $l3, $culoare);
imagechar($img, 7, $poz4, 6, $l4, $culoare);
imagechar($img, 7, $poz5, 6, $l5, $culoare);

imagepng($img);
?>


1) Background - alb, cifre - negru.
Primul pas consta in eliminarea culorilor. Backgroundul imaginii va deveni alb, iar cifrele vor avea culoarea neagra. Sa vedem codul php:
Cod:

$img = imagecreatefrompng("http://site.com/captcha/cap1.png";

$alb = imagecolorallocate($img, 255, 255, 255);
$negru = imagecolorallocate($img, 0, 0, 0);

//Simplificarea imaginii
//Background alb
//Scris de culoare neagra
for ($i=0; $i<239; $i++)
{
   for ($j=0; $j<25; $j++)
   {
      $pixel = imagecolorat($img, $i, $j);
      $rgb = imagecolorsforindex($img, $pixel);
      if ($rgb['red']!=100 && $rgb['green']!=100 && $rgb['blue']!=100)
      {
         imagesetpixel($img, $i, $j, $alb);
      }   
      else
      {
         imagesetpixel($img, $i, $j, $negru);
      }
   }
}
//Finished simplificare

cap1.png reprezinta imaginea care urmeaza sa fie "sparta". Se observa din cod ca cifrele (care au r, g, b = 100) sunt setate la culoarea neagra, iar restul pixelilor la alb. Acum imaginea este alb-negru.

2) Gasire dreptunghiuri cifre.
Cum am spus, cifrele sunt plasate random pe axa oX. Ideea este ca noi trebuie sa impartim imaginea initiala (cea mare/cap1.png) in 5 imagini mai mici, fiecare continand doar o cifra ! Un amanunt foarte important este ca fontul default folosit la functia imagechar() este monospaced (courier din cate stiu), iar orice cifra "scrisa" cu font size=7 poate fi incadrata intr-un dreptunghi de lungime 9.
Deci spre exemplu, ca sa gasesc prima cifra, trebuie sa gasesc primul pixel de culoare neagra (cautarea pornind de la stanga la dreapta) si sa ii retin X'ul. Apoi extrag dreptunghiul de la X pana la X+8. Codul PHP:
Cod:

//Gasire dreptunghi prima cifra
for ($i=0; $i<239; $i++)
{
   for ($j=0; $j<25; $j++)
   {
      $pixel = imagecolorat($img, $i, $j);
      $rgb = imagecolorsforindex($img, $pixel);
      if ($rgb['red']==0 && $rgb['green']==0 && $rgb['blue']==0)
      {
         $istart = $i; $ifinal = $i+8; break 2;
      }
   }
}

//Gasire dreptunghi a 2-a cifra
for ($i=$ifinal+1; $i<239; $i++)
{
   for ($j=0; $j<25; $j++)
   {
      $pixel = imagecolorat($img, $i, $j);
      $rgb = imagecolorsforindex($img, $pixel);
      if ($rgb['red']==0 && $rgb['green']==0 && $rgb['blue']==0)
      {
         $iistart = $i; $iifinal = $i+8; break 2;
      }
   }
}

//Gasire dreptunghi a 3-a cifra
for ($i=$iifinal+1; $i<239; $i++)
{
   for ($j=0; $j<25; $j++)
   {
      $pixel = imagecolorat($img, $i, $j);
      $rgb = imagecolorsforindex($img, $pixel);
      if ($rgb['red']==0 && $rgb['green']==0 && $rgb['blue']==0)
      {
         $iiistart = $i; $iiifinal = $i+8; break 2;
      }
   }
}

//Gasire dreptunghi a 4-a cifra
for ($i=$iiifinal+1; $i<239; $i++)
{
   for ($j=0; $j<25; $j++)
   {
      $pixel = imagecolorat($img, $i, $j);
      $rgb = imagecolorsforindex($img, $pixel);
      if ($rgb['red']==0 && $rgb['green']==0 && $rgb['blue']==0)
      {
         $ivstart = $i; $ivfinal = $i+8; break 2;
      }
   }
}
     
//Gasire dreptunghi a 5-a cifra
for ($i=$ivfinal+1; $i<239; $i++)
{
   for ($j=0; $j<25; $j++)
   {
      $pixel = imagecolorat($img, $i, $j);
      $rgb = imagecolorsforindex($img, $pixel);
      if ($rgb['red']==0 && $rgb['green']==0 && $rgb['blue']==0)
      {
         $vstart = $i; $vfinal = $i+8; break 2;
      }
   }
}
//Finished gasire dreptunghiuri

Am gasit ceea ce aveam nevoie (valorile sunt retinute in variabilele $istart, $iistart, $iiistart, $ivstart, $vstart). Acum trebuie sa dam crop la imaginea initiala pentru a extrage exact aceste cifre (pt. asta folosim functia imagecopyresampled -> ):
Cod:

//Impartire in 5 imagini
//Cropuire de la stanga la dreapta
$img1=imagecreate(9, 25);
$img2=imagecreate(9, 25);
$img3=imagecreate(9, 25);
$img4=imagecreate(9, 25);
$img5=imagecreate(9, 25);
imagecopyresampled ($img1, $img, 0, 0, $istart, 0,9, 25, 9, 25);
imagecopyresampled ($img2, $img, 0, 0, $iistart, 0,9, 25, 9, 25);
imagecopyresampled ($img3, $img, 0, 0, $iiistart, 0,9, 25, 9, 25);
imagecopyresampled ($img4, $img, 0, 0, $ivstart, 0,9, 25, 9, 25);
imagecopyresampled ($img5, $img, 0, 0, $vstart, 0,9, 25, 9, 25);
//Finished cropuire de la stanga la dreapta

Din ceea ce se vede mai sus, cifrele sunt salvate in imagini de 9x25. Sa le vedem:


3) Compararea imaginilor.
Acum ca am obtinuit imaginile care contin cifrele (0, 1, 2, 3, 4), le salvam pe server pentru a face comparatii mai tarziu. Ca sa le putem folosi in scriptul php, trebuie sa folosim urmatorul cod:
Cod:

$cif[0] = imagecreatefrompng("cifre/0.png";
$cif[1] = imagecreatefrompng("cifre/1.png";
$cif[2] = imagecreatefrompng("cifre/2.png";
$cif[3] = imagecreatefrompng("cifre/3.png";
$cif[4] = imagecreatefrompng("cifre/4.png";

Ce ne mai ramane de facut ? Sa comparam pixelii lui $img1, $img2, $img3, $img4, $img5 cu fiecare dintre $cif[0], $cif[1], $cif[2], $cif[3], $cif[4], pe rand. Daca $img1 coincide cu $cif[2], atunci cifra corespunzatoare este 2.
Cod:

//Functie comparare imagini
function comparare($imagine12, $cifra12)
{
   $true = 0;
   for ($i=0; $i<239; $i++)
   {
      for ($j=0; $j<25; $j++)
      {
         $pixelx = imagecolorat($imagine12, $i, $j);
         $pixely = imagecolorat($cifra12, $i, $j);
         if ($pixelx != $pixely)
         {
            //Difera un pixel
            $true = 1; break 2;
         }
      }
   }

return $true;
}
//End functie

//Comparari imagini & stuff
//Daca returneaza 0, imaginile sunt identice
//Daca returneaza 1, imaginile sunt diferite
//Si trecem sa comparam cu urmatoarea
for ($x=0; $x<=4; $x++)
{
   $value=comparare($img1, $cif[$x]);
   if ($value==0) { echo $x."\r\n"; break; }
}
for ($x=0; $x<=4; $x++)
{
   $value=comparare($img2, $cif[$x]);
   if ($value==0) { echo $x."\r\n"; break; }
}
for ($x=0; $x<=4; $x++)
{
   $value=comparare($img3, $cif[$x]);
   if ($value==0) { echo $x."\r\n"; break; }
}
for ($x=0; $x<=4; $x++)
{
   $value=comparare($img4, $cif[$x]);
   if ($value==0) { echo $x."\r\n"; break; }
}
for ($x=0; $x<=4; $x++)
{
   $value=comparare($img5, $cif[$x]);
   if ($value==0) { echo $x."\r\n"; break; }
}


Asta e tot. Ati reusit sa spargeti un captcha ! Felicitari


_______________________________________
[img]http://img191.imageshack.us/img191/3862/45256061.jpg[/img]
[img]http://img.userbarz.com/35/6865.jpg[/img]
[color=red]Putina rabdare,putina culoare....
Si ziua-i frumoasa ca ziua cu soare!!!![/color]

pus acum 16 ani
   
Pagini: 1  

Mergi la