elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web (Moderador: #!drvy)
| | |-+  captchas
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: 1 [2] Ir Abajo Respuesta Imprimir
Autor Tema: captchas  (Leído 5,116 veces)
EFEX


Desconectado Desconectado

Mensajes: 1.171


"Dinero Facil"


Ver Perfil WWW
Re: captchas
« Respuesta #10 en: 3 Febrero 2012, 12:07 pm »

Version de GIFEncoder que utilizé PHPclasses / Pastie Bin.
Código
  1. <?php
  2. /*
  3. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4. ::
  5. :: GIFEncoder Version 2.0 by László Zsidi, http://gifs.hu
  6. ::
  7. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  8. */
  9. include "GIFEncoder.class.php";
  10.  
  11. class Captcha
  12. {
  13. protected $captcha;
  14. protected $clave;
  15.  
  16. function __construct()
  17. {
  18. $rnd = rand(0, 1000000);
  19. $key = strtoupper(substr(md5( microtime() * $rnd),1,5));
  20. $this->clave = $key;
  21. $this->captcha = imagecreatefromgif('bg.gif');
  22. $posicion_x=15;
  23. for($i = 0;$i<strlen($key);$i++){
  24. $r=rand(0,255);
  25. $g=rand(0,255);
  26. $b=rand(0,255);
  27. $posicion_y=rand(20,40);
  28. $colorText = imagecolorallocate($this->captcha, $r, $g, $b);
  29. imagestring($this->captcha, 30, $posicion_x, $posicion_y, $key[$i], $colorText);
  30. $posicion_x+=25;
  31. }
  32. //Fix con el color de la segunda letra
  33. $white = ImageColorAllocate($this->captcha,0,0,0);
  34. ImageColorTransparent($this->captcha,$white);
  35. }
  36.  
  37. public function imprimir()
  38. {
  39. if (!empty($this->frames) AND !empty($this->framed))
  40. {
  41. $gif = new GIFEncoder($this->frames, $this->framed, 0, 2, 0, 0, 0, 'url');
  42. Header ('Content-type:image/gif');
  43. echo $gif->GetAnimation();
  44. imagedestroy($this->captcha);
  45. }else{
  46. Header('Content-type:image/gif');
  47. imagegif($this->captcha);
  48. }
  49.  
  50. }
  51.  
  52. public function guardar()
  53. {
  54. $_SESSION['CAPTCHA_TEXT'] = $this->clave;
  55. return $this->clave;
  56. }
  57. }
  58.  
  59. class Animacion extends Captcha
  60. {
  61. public $frames;
  62. public $framed;
  63.  
  64. function __construct($aleatorio = 1)
  65. {
  66. parent::__construct();
  67. if ($aleatorio == 1) {
  68. $n = rand(1,3);
  69. $n == 1 ? $this->circulo() : 'no' ;
  70. $n == 2 ? $this->bum() : 'no' ;
  71. $n == 3 ? $this->desliz() : 'no' ;
  72. }
  73. }
  74.  
  75. public function circulo()
  76. {
  77. $circulo_x = 40;
  78. $circulo_y = 0;
  79. $frames_x = 20;
  80. for($b=0;$b<$frames_x;$b++){
  81. $im = imagecreatetruecolor(150, 80);
  82. imagecopy($im, $this->captcha, 0, 0, 0, 0, imagesx($this->captcha), imagesy($this->captcha));
  83. //fix
  84. $white = ImageColorAllocate($im,255,255,255);
  85. ImageFill($im,0,0,$white);
  86. $circulo = imagecolorallocate($im, 0, 0, 0);
  87. imagefilledellipse( $im, $circulo_y, $circulo_x, 30, 30, $circulo );
  88. $fname = 'tmp/'.$b.'.gif';
  89. imagegif($im, $fname);
  90. $this->frames[] = $fname;
  91. $this->framed[] = 1;
  92. $circulo_y+=10;
  93. }
  94. $this->imprimir();
  95. }
  96.  
  97. public function bum()
  98. {
  99. $frames_x = 30;
  100. for($b=0;$b<$frames_x;$b++){
  101. $im = imagecreatetruecolor(150, 80);
  102. imagecopy($im, $this->captcha, 0, 0, 0, 0, imagesx($this->captcha), imagesy($this->captcha));
  103. //fix
  104. $white = ImageColorAllocate($im,255,255,255);
  105. ImageFill($im,0,0,$white);
  106. imagefilledrectangle($im,($b*5),($b*5),10+($b*5),10+($b*5),0);
  107. imagefilledrectangle($im,($b*1),($b*5),10+($b*1),10+($b*5),0);
  108. imagefilledrectangle($im,($b*3)*2,($b*1)+$b,10+($b*3)*2,10+($b*1)+$b,0);
  109. imagefilledrectangle($im,($b*4)*2,($b*2)+$b,10+($b*4)*2,10+($b*2)+$b,0);
  110. $fname = 'tmp/'.$b.'.gif';
  111. imagegif($im, $fname);
  112. $this->frames[] = $fname;
  113. $this->framed[] = 1;
  114. }
  115. $this->imprimir();
  116. }
  117.  
  118. public function desliz()
  119. {
  120. $imgwidth = imagesx($this->captcha);
  121. $imgheight = imagesy($this->captcha);
  122. $frames_x = 30;
  123. for($b=0;$b<$frames_x;$b++){
  124. $im = imagecreatetruecolor(150, 80);
  125. imagecopy($im, $this->captcha, 0, 0, 0, 0, imagesx($this->captcha), imagesy($this->captcha));
  126. //fix
  127. $white = ImageColorAllocate($im,255,255,255);
  128. ImageFill($im,0,0,$white);
  129. imagefilledrectangle($im,($b - 1) * 8 + 8,1,$imgwidth,$imgheight, 0);
  130. $fname = 'tmp/'.$b.'.gif';
  131. imagegif($im, $fname);
  132. $this->frames[] = $fname;
  133. $this->framed[] = 1;
  134. }
  135. $this->imprimir();
  136. }
  137. }
  138.  
  139. // Animacion aleatoria
  140. $showtime = new Animacion();
  141. //$showtime->guardar();
  142.  
  143. // Seleccionar animacion
  144. //$showtime = new Animacion(0);
  145. //$showtime->bum();
  146.  
  147. // Sin animacion
  148. //$showtime = new Captcha();
  149. //$showtime->imprimir();
  150.  
  151. ?>
  152.  


En línea

Páginas: 1 [2] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Captchas: ¿Eres humano?
Noticias
wolfbcn 5 4,750 Último mensaje 12 Marzo 2011, 19:48 pm
por dantemc
Saltarse Captchas
Hacking
apoeti 3 6,264 Último mensaje 3 Junio 2012, 16:19 pm
por int_0x40
Derrotando a los CAPTCHAs
Noticias
wolfbcn 4 3,293 Último mensaje 19 Junio 2012, 03:45 am
por #!drvy
Sistema para llenar Captchas
Programación Visual Basic
yalosabes 3 3,379 Último mensaje 12 Diciembre 2013, 13:35 pm
por noele1995
[SOURCE] Generar captchas para aplicaciones
.NET (C#, VB.NET, ASP)
Eleкtro 2 2,275 Último mensaje 21 Diciembre 2015, 19:38 pm
por Eleкtro
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines