Rabu, 07 Mei 2008

[PHP] Defeat Drupal Captcha Question Challenge

Iseng-iseng browsing ke Borneo Cyber, tertarik ama Captcha-nya yang kayak gini:
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

What is the first word in the phrase "uco evot qamubec rafi reg"?

Wah, mo anti-spam kayak gini? Kurang nantang nih! Yang umum kayak pakai GD aja masih bisa di defeat dengan metode OCR.

OK, mari kita melakukan percobaan buat nge-defeat nih Captcha. Oh iya, gak ada maksud ngejelekin tehnik ini, cuman memberi sample bagaimana PHP melakukannya, mungkin kurang secure aja kali ya :D. Berikut ini contoh code scratch kasarnya aja dan simple.

class Defeat
{
 function Keyword($text)
 {
  if(preg_match("/is\ the\ (.+?)\ word/", $text, $hasil))
  {
   return $hasil[1];
  } else {
   return FALSE;
  }
 }

 function SecretWord($text)
 {
  if(preg_match("/phrase\ \"(.+?)\"/", $text, $hasil))
  {
   return $hasil[1];
  } else {
   return FALSE;
  }
 }

 function Destroy($text)
 {
  $off = array('first', 'second', 'third', 'forth', 'fifth');
  $parse = @array_combine(explode(' ', $this->SecretWord($text)), $off);
  $hasil = @array_search($this->Keyword($text), $parse);
  return $hasil;
 }
}

$text = 'What is the fifth word in the phrase "gugukoq fenihux kex pape uqicere"?';
//$text = 'What is the second word in the phrase "gafik ucicam ikamavu eci qucehuv"?';
//$text = 'What is the fifth word in the phrase "merawah kobuna uqopoje ekaxu eyi"?';
//$text = 'What is the first word in the phrase "uco evot qamubec rafi reg"?';

$hack = new Defeat;
$keyword = $hack->Keyword($text);
$secret = $hack->SecretWord($text);
$hacked = $hack->Destroy($text);

Tehnik diatas juga bisa diterapkan untuk Captcha Math Challenge seperti:
10 + 3 =

Semoga berguna dan jangan lupa, DILARANG SPAM!

0 komentar:

Posting Komentar