1

红明谷CTF 2021 write_shell_0x81-0x8F

 2 years ago
source link: https://sakurahack-y.github.io/2022/02/12/%E7%BA%A2%E6%98%8E%E8%B0%B7CTF-2021-write-shell-0x81-0x8F/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

红明谷CTF 2021 write_shell_0x81-0x8F

这道题属于比较简单的,让我们来看一下源码

当我们在后缀加上?action=pwd 就可以得到路径

再换成upload就可以写文件

?action=upload&date=xxx

这道题考察的就是shell的写入,但是它过滤了不少关键词

其中过滤了php这个关键词,但是这个可以进行绕过

PHP中有两种短标签,<??>和<?=?>。其中,<??>相当于对<?php>的替换。而<?=?>则是相当于<? echo>
大部分文章说短标签需要在php.ini中设置short_open_tag为on才能开启短标签(默认是开启的,但似乎又默认注释,所以还是等于没开启)。但实际上在PHP5.4以后,无论short_open_tag是否开启,<?=?>这种写法总是适用的,<??>这种写法则需要short_open_tag开启才行。

PHP中,反引号可以起到命令执行的效果

空格可以用url编码绕过%09

由这个我们就可以构造出payload

?action=upload&data=<?=%09`whoami`?>

成功执行了命令

直接获取根目录所有文件信息,访问文件,获得flag


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK