catalog

. 漏洞描述
. 漏洞触发条件
. 漏洞影响范围
. 漏洞代码分析
. 防御方法
. 攻防思考

1. 漏洞描述

Relevant Link:
2. 漏洞触发条件
3. 漏洞影响范围
4. 漏洞代码分析

/interface/memebermain.php

function in_center()
{
if ($this->CON['mem_isucenter'])
{
include_once admin_ROOT . 'public/uc_client/client.php';
}
parent::start_pagetemplate();
parent::member_purview();
$lng = (admin_LNG == 'big5') ? $this->CON['is_lancode'] : admin_LNG;
//espcms验证用户信息的都是采用cookie验证uid的,只要可以伪造就可以任意登录
$db_where = "userid=$this->ec_member_username_id AND username='$this->ec_member_username' ";
$db_table1 = db_prefix . 'member AS a';
$db_table2 = db_prefix . 'member_value AS b';
$db_sql = "SELECT * FROM $db_table1 LEFT JOIN $db_table2 ON a.userid = b.userid WHERE a.userid = $this->ec_member_username_id ";
$rsMember = $this->db->fetch_first($db_sql);
$rsMember['userid'] = $this->ec_member_username_id; $rsMember['rankname'] = $this->get_member_purview($rsMember['mcid'], 'rankname');
$userid = intval($rsMember['userid']);
if (empty($userid)) {
exit('user err!');
}
..

继续跟踪一下uid的处理方式
/public/class_connector.php

function member_purview($userrank = false, $url = null, $upurl = false)
{
$this->ec_member_username = $this->fun->eccode($this->fun->accept('ecisp_member_username', 'C'), 'DECODE', db_pscode);
if (!preg_match("/^[^!@~`\'\"#\$\%\^&\*\(\)\+\-\{\}\[\]\|\\/\?\<\>\,\.\:\;]{2,30}$/i", $this->ec_member_username) && !empty($this->ec_member_username)) {
$this->fun->setcookie('ecisp_member_username', false);
$this->fun->setcookie('ecisp_member_info', false);
$linkURL = $this->get_link('memberlogin', array(), admin_LNG);
header('location:' . $linkURL);
exit();
}
//用户名是取了cookie的值可以控制
$user_info = explode('|', $this->fun->eccode($this->fun->accept('ecisp_member_info', 'C'), 'DECODE', db_pscode));
list($ec_member_username_id, $this->ec_member_alias, $ec_member_integral, $ec_member_mcid, $this->ec_member_email, $this->ec_member_lastip, $this->ec_member_ipadd, $this->ec_member_useragent, $this->ec_member_adminclassurl) = $user_info; //黑客利用intvul实现"截断注入"的效果,通过发送一个例如"test4"的账户名,被截断后得到4,黑客利用该特点实现任意用户登录
$this->ec_member_username_id = intval($ec_member_username_id);
$this->ec_member_integral = intval($ec_member_integral);
$this->ec_member_mcid = intval($ec_member_mcid);
if (empty($this->ec_member_username) && empty($this->ec_member_username_id) && md5(admin_AGENT) != $this->ec_member_useragent && md5(admin_ClassURL) != $this->ec_member_adminclassurl) {
$this->condition = ;
if ($url) {
$this->fun->setcookie('ecisp_login_link', $url, );
} elseif ($upurl) {
$nowurl = 'http://' . $_SERVER["HTTP_HOST"] . $this->fun->request_url();
$this->fun->setcookie('ecisp_login_link', $nowurl, );
}
$linkURL = $this->get_link('memberlogin', array(), admin_LNG);
$mlink = $this->memberlink(array(), admin_LNG);
$this->callmessage($this->lng['memberloginerr'], $linkURL, $this->lng['memberlogin'], , $this->lng['member_regbotton'], , $mlink['reg']);
} else {
$this->condition = ;
if ($this->ec_member_mcid < $userrank && $userrank) {
$linkURL = $this->get_link('memberlogin', array(), admin_LNG);
$this->callmessage($this->lng['memberpuverr'], $linkURL, $this->lng['gobackurlbotton']);
}
}
return $this->condition;
}

Relevant Link:

http://www.wooyun.org/bugs/wooyun-2015-0142913 

5. 防御方法

/public/class_connector.php

function member_purview($userrank = false, $url = null, $upurl = false)
{
$this->ec_member_username = $this->fun->eccode($this->fun->accept('ecisp_member_username', 'C'), 'DECODE', db_pscode);
if (!preg_match("/^[^!@~`\'\"#\$\%\^&\*\(\)\+\-\{\}\[\]\|\\/\?\<\>\,\.\:\;]{2,30}$/i", $this->ec_member_username) && !empty($this->ec_member_username)) {
$this->fun->setcookie('ecisp_member_username', false);
$this->fun->setcookie('ecisp_member_info', false);
$linkURL = $this->get_link('memberlogin', array(), admin_LNG);
header('location:' . $linkURL);
exit();
}
//用户名是取了cookie的值可以控制
$user_info = explode('|', $this->fun->eccode($this->fun->accept('ecisp_member_info', 'C'), 'DECODE', db_pscode));
list($ec_member_username_id, $this->ec_member_alias, $ec_member_integral, $ec_member_mcid, $this->ec_member_email, $this->ec_member_lastip, $this->ec_member_ipadd, $this->ec_member_useragent, $this->ec_member_adminclassurl) = $user_info;
/**/
if (is_numeric($ec_member_username_id) == FALSE)
{
die("request error");
}
/**/
//黑客利用intvul实现"截断注入"的效果,通过发送一个例如"test4"的账户名,被截断后得到4,黑客利用该特点实现任意用户登录
$this->ec_member_username_id = intval($ec_member_username_id);
$this->ec_member_integral = intval($ec_member_integral);
$this->ec_member_mcid = intval($ec_member_mcid);
...

6. 攻防思考

Copyright (c) 2015 LittleHann All rights reserved

espcms /public/class_connector.php intval truncation Vul Arbitrary User Login的更多相关文章

  1. ecshop /includes/init.php Arbitrary User Login Vul

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 对用户输入的cookie,判断免登的逻辑中存在漏洞,导致黑客可以直接通过 ...

  2. espcms会员二次开发文件说明——会员,时间格式

    [espcms会员图片字段] 添加字段加入图片类型/webadm/include/inc_formtypelist.php 会员修改页面模型/webadm/templates/member/membe ...

  3. espcms自定义表单邮件字段

    /include/inc_replace_mailtemplates.php中增加一行就可以了. 如:$replacemail['mailform'][] = array(name => '职位 ...

  4. php代码审计10审计会话认证漏洞

    挖掘经验:遇到的比较多的就是出现在cookie验证上面,通常是没有使用session来认证,直接将用户信息保存在cookie中      Session固定攻击:黑客固定住目标用户的session i ...

  5. 关于BigDecimal 和 double 类型保存金钱,以及精度问题,银行家舍入法

    1. BigDecimal 类型数据 的创建,构造函数 有 public BigDecimal(BigInteger intVal, long val, int scale, int prec); p ...

  6. spring beans源码解读之--Bean的注解(annotation)

    随着spring注解的引入,越来越多的开发者开始使用注解,这篇文章将对注解的机制进行串联式的讲解,不求深入透彻,但求串起spring beans注解的珍珠,展示给大家. 1. spring beans ...

  7. Java多线程编程之同步器

    同步器 为每种特定的同步问题提供了解决方案 Semaphore Semaphore[信号标:旗语],通过计数器控制对共享资源的访问. 测试类: package concurrent; import c ...

  8. redis 哈希数据类型简单操作(实现购物车案例)

    这里不累赘如何安装redis和php  redis扩展,主要熟悉调用redis哈希数据类型 简单方法操作如下 1:hSet 2:hGet 4:hDel 5:hGetAll 4:hExists 5:hI ...

  9. 2017swpu-ctf总结

    2017swpu-ctf总结 今年是我第一次出题感受很多,就分析几道我印象最深刻的题吧 你能进入后台吗? 这道题主要是考察php_screw还有md5加密开启true过后的注入 phpscrew加密在 ...

随机推荐

  1. Android -- Adapter

    体系 public interface Adapter----0层(表示继承体系中的层次)  public interface ExpandableListAdapter---(无所谓层次因为没有其他 ...

  2. shell 使用

    echo -e "1\t2\t3" #-e echo -e "\e[1;31m This is red text \e[0m" #color echo -e & ...

  3. iptables规则组成

    一.四张表五条链 组成部分:四张表 + 5条链(Hook point) + 规则 四张表:filter nat mangle raw 五条链:PREROUTING INPUT FORWARD OUTP ...

  4. MD5算法的C语言实现

    1 #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h ...

  5. Javascript 模块化开发上线解决方案

    最近又换部门了,好频繁地说...于是把这段时间搞的小工具们简单整理了一下,作了一个小的总结.这次用一个简单业务demo来向大家介绍一下Javascript模块化开发的方式和自动化合并压缩的一些自己的处 ...

  6. shell note

    1 输出重定向:ll > aaa 将输出内容 添加到aaa文件中 ll >> aaa将输出内容追加到aaa中 ll &>> abc 将输出内容不论正确或错误都保存 ...

  7. LVS+MYCAT+读写分离+MYSQL主备同步部署手册

    LVS+MYCAT+读写分离+MYSQL主备同步部署手册 1          配置MYSQL主备同步…. 2 1.1       测试环境… 2 1.2       配置主数据库… 2 1.2.1  ...

  8. Percona 开始尝试基于Ceph做上层感知的分布式 MySQL 集群,使用 Ceph 提供的快照,备份和 HA 功能来解决分布式数据库的底层存储问题

    本文由 Ceph 中国社区 -QiYu 翻译 英文出处:Using Ceph with MySQL 欢迎加入CCTG Over the last year, the Ceph world drew m ...

  9. [转]Spring3核心技术之事务管理机制

    原文地址:http://chouyi.iteye.com/blog/1675199 Spring对事务的解决办法其实分为2种:编程式实现事务,AOP配置声明式解决方案. http://jinnians ...

  10. 【HDU 1007】Quoit Design

    http://acm.hdu.edu.cn/showproblem.php?pid=1007 最近欧式距离模板题. 用分治大法(分治的函数名用cdq纯属个人习惯_(:з」∠)_) 一开始狂M. 后来判 ...