攻防世界web进阶_Web_php_unserialize

攻防世界web进阶_Web_php_unserialize

解题思路

打开之后是一段代码审计

class Demo {
private $file = 'index.php';
public function __construct($file) {
$this->file = $file;//构造函数 把里面的参数变成传进来的参数
}
function __destruct() {
echo @highlight_file($this->file, true);
}
function __wakeup() { //如果反序列化会执行
if ($this->file != 'index.php') {
//the secret is in the fl4g.php//告诉我们flag在fl4g.php中
$this->file = 'index.php';
}
}
}
if (isset($_GET['var'])) { //get传参
$var = base64_decode($_GET['var']);//进行base64解码
if (preg_match('/[oc]:\d+:/i', $var)) { //如果解码后的东西匹配到o或c开头+:+任意数字(一位或多位)不区分大小写就stop hacking
die('stop hacking!');
} else { //否则反序列化
@unserialize($var);
}
} else {
highlight_file("index.php");
}
?>

解题过程

写代码得到类序列化的字符串并进行base64加密

你可能感兴趣的:(php)