[De1CTF 2019]Giftbox

[De1CTF 2019]Giftbox

考点

  • 无参rce

  • chr拼接命令执行

  • open_basedir绕过

wp

给了个shell的界面,usage.md如下

[De1ta Nuclear Missile Controlling System]

login [username] [password]
logout
launch
targeting [code] [position]
destruct

Besides, there are some hidden commands, try to find them!

无论执行什么命令都要先login

执行命令的时候抓包,看到了请求的地址shell.php?a=login admin admin&totp=19541572,提示用户密码错误

使用其他用户登录,提示用户名不存在

应该是有注入,尝试一下发现存在布尔盲注

重放提示totp时间戳错误

F12看一下有没有泄露信息,发现两个js文件,main.js和totp.main.js

在main.js中发现提示,下载下来是pyotp的源码,版本是2.2.7,pip install pyotp==2.2.7安装一下

同样也给了key GAXG24JTMZXGKZBU 以及其他命令

其他可用命令

先看注入,盲注脚本如下

database是giftbox,表是users,字段是id,username,password,得到hint{G1ve_u_hi33en_C0mm3nd-sh0w_hiiintttt_23333}

然后执行sh0w_hiiintttt_23333

得到提示

然后login admin hint{G1ve_u_hi33en_C0mm3nd-sh0w_hiiintttt_23333}成功登录

写个脚本,不用浏览器了

提示Setting target: $1 = "1";,基本可以确定后端是eval("$1='2';")这样

输入如下内容,可以得到phpinfo

重新写个脚本

shell.txt内容如下,读取shell.php

  • 通过chr(ord(strrev(crypt(serialize(array())))))获取/

  • 通过chr(ceil(sinh(cosh(tan(floor(sqrt(floor(phpversion()))))))))获取.

不能使用end等操作数组的函数,只能用chr拼接,并且设置了open_basedir,需要绕过

绕过脚本,这里的chdir数量由chdir一次能否进入根目录决定,这里的目录是/app/,所以一次就行

直接放exp吧

相当于执行如下语句

最后更新于