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. swift 动手写网络请求封装(仿照了一个大神的)不用导入第三方

    新建一个类Network import UIKit //NSURLSession 的使用过程: // //构造 NSURLRequest //确定 URL //确定 HTTP 方法(GET.POST ...

  2. ASP.NET Web API Help Pages using Swagger

    Understanding the various methods of an API can be a challenge for a developer when building a consu ...

  3. css3实践之图片轮播(Transform,Transition和Animation)

    楼主喜欢追求视觉上的享受,虽常以牺牲性能无法兼容为代价却也乐此不疲.本文就通过一个个的demo演示来简单了解下css3下的Transform,Transition和Animation. 本文需要实现效 ...

  4. java并发:同步容器&并发容器

    第一节 同步容器.并发容器 1.简述同步容器与并发容器 在Java并发编程中,经常听到同步容器.并发容器之说,那什么是同步容器与并发容器呢?同步容器可以简单地理解为通过synchronized来实现同 ...

  5. iOS 自定义NavigationBar右侧按钮rightBarButtonItem--button

    //两个按钮的父类view UIView *rightButtonView = [[UIView alloc] initWithFrame:CGRectMake(, , , )]; //历史浏览按钮 ...

  6. Python基础-字符串格式化_百分号方式_format方式

    Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-3101] This ...

  7. ubuntu14.04切换root用户

    打开命令窗口(CTRL+ALT+T),输入:sudo -s -->接着输入管理密码, -->已经切换到root用户

  8. PHP ElasticSearch的使用

    系统是Windows server 2003. ElasticSearch是一个基于Lucene的稳定的.分布式.RESTFul的搜索引擎.其实所谓的RestFul就是它提供URL供你调用(建立索引和 ...

  9. Swift开发小技巧--自定义Log

    Swift中的自定义Log OC中有宏的定义,可以定义自己的Log,但是Swif中没有宏的定义,想要实现类似OC中的自定义Log,必须实现以下操作 1.在AppDelegate.swift文件中定义一 ...

  10. 【POJ 2774】Long Long Message 最长公共子串

    还是模板啊,手残&&打成||查错查了1h+TAT #include<cstdio> #include<cstring> #include<algorith ...