问答
发起
提问
文章
攻防
活动
Toggle navigation
首页
(current)
问答
商城
实战攻防技术
漏洞分析与复现
NEW
活动
摸鱼办
搜索
登录
注册
代码审计-youdiancms最新版getshell漏洞
代码审计-youdiancms最新版getshell漏洞
前言 -- 在近期的授权项目中,遇到了一个目标,使用了youdiancms,需要获取权限,进而进行审计,本次代码审计过程先发现SQL注入漏洞,继续审计发现getshell的漏洞,本文将本次审计过程书写下来,仅作为学习研究,请勿用作非法用途。 0x01 未授权SQL注入 ------------- 首先拿到源码一看,发现该系统是基于THINKPHP3开发的。 在`App/Lib/Action/HomeBaseAction.class.php:16`  cookie可控,然后赋值给了`$this->_fromUser` 跟踪一下`$this->_fromUser`的引用。 在`App/Lib/Action/Home/ChannelAction.class.php:732`  这里将`$this->_fromUser`带入到了`hasVoted`函数中,跟进该函数:  很明显,TP3的where注入。 延时注入payload如下: ```php GET /index.php/Channel/voteAdd HTTP/1.1 Host: localhost Content-Length: 2 Accept: application/json, text/javascript, */*; q=0.01 X-Requested-With: XMLHttpRequest Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9,en;q=0.8 Cookie: youdianfu[0]=exp;youdianfu[1]==(select 1 from(select sleep(3))a) Connection: close ``` 0x02 绕过登录到getshell过程 -------------------- ### 0x0201 流程思路 1. 验证码处可以设置任意session 2. 碰撞md5让AdminGroupID==1(超级管理员) 3. 后台修改模板插入phpcode实现代码执行 ### 0x0x202 任意session设置 在`App/Lib/Action/BaseAction.class.php:223`  这个函数挺有意思的,本来是个生成验证码的操作,但是没想到所有的参数都是用户可以控制的,特别是这个`$verifyName`还可控。跟进`buildImageVerify`看看如何设置的`session`。  红框处设置了session,并且session的键名我们是可控的,但是值不可控,是个md5值。 然后我们去看看管理员的校验函数。在`App/Lib/Action/AdminBaseAction.class.php:7`  起作用的就两个函数,`isLogin`和`checkPurview`。跟进第一个看看:  这个函数很简单,就简单的判断session是否存在,我们可以通过上文的验证码函数来设置。 然后就是checkPurview函数。  这里判断了`AdminGroupID`的值,当等于1的时候就是超级管理员,由于这里是个弱类型比较。所以上文设置session中的md5是可以碰撞的。 编写脚本得到超级管理员的session了,然后登录。  ### 0x0203 后台getshell 后台模板管理,可以修改模板,但是对<?php有检测,如图所示:  我们可以用`<?=?>`来绕过这个检测。 如图所示:  访问首页即可触发:  注:zc.cn为本地127.0.0.1的地址,并非zc.cn的域名
发表于 2021-05-14 16:00:08
阅读 ( 8928 )
分类:
漏洞分析
2 推荐
收藏
0 条评论
请先
登录
后评论
中铁13层打工人
77 篇文章
×
发送私信
请先
登录
后发送私信
×
举报此文章
垃圾广告信息:
广告、推广、测试等内容
违规内容:
色情、暴力、血腥、敏感信息等内容
不友善内容:
人身攻击、挑衅辱骂、恶意行为
其他原因:
请补充说明
举报原因:
×
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!