DASCTF安恒四月月赛web复现wp

本文详细介绍了DASCTF比赛中关于Ezunserialize和babytricks两道Web安全题目的复现过程。Ezunserialize涉及Joomla的反序列化漏洞,通过构造特定的序列化值并利用read/write方法实现字符串逃逸来获取flag。babytricks则需要理解sprintf格式化字符串非预期解,并通过源码分析找到预期解,最终获取网站后台密码。
摘要由CSDN通过智能技术生成

趁着平台还开放,赶紧复现一下:

  1. Ezunserialize(Joomla 的逃逸)
    参考链接:
    https://xz.aliyun.com/t/6718#toc-2
  2. babytricks
    参考链接:
    https://www.cnblogs.com/test404/p/7821884.html
    https://blog.csdn.net/weixin_41185953/article/details/80485075
    https://www.leavesongs.com/PENETRATION/thinking-about-config-file-arbitrary-write.html
    https://www.anquanke.com/post/id/197745

一、Ezunserialize

这题是Joomla 的逃逸,直接搜就能搜到几乎差不多的题目分析
题目给了源码:

<?php
show_source("index.php");
function write($data) {
   
    return str_replace(chr(0) . '*' . chr(0), '\0\0\0', $data);
}

function read($data) {
   
    return str_replace('\0\0\0', chr(0) . '*' . chr(0), $data);
}

class A{
   
    public $username;
    public $password;
    function __construct($a, $b){
   
        $this->username = $a;
        $this->password = $b;
    }
}

class B{
   
    public $b = 'gqy';
    function __destruct(){
   
        $c = 'a'.$this->b;
        echo $c;
    }
}

class C{
   
    public $c;
    function __toString(){
   
        //flag.php
        echo file_get_contents($this->c);
        return 'nice';
    }
}

$a = new A($_GET['a'],$_GET['b']);
//省略了存储序列化数据的过程,下面是取出来并反序列化的操作
$b = unserialize(read(write(serialize($a))));

咋一看是反序列化,找pop链:
C类存在__toString魔术方法,并通过file_get_contents输出$c的信息,所以可以使$cflag.php
B类存在__destruct魔术方法,析构函数会在到某个对象的所有引用都被删除或者当对象被显式销毁时执行,并且有输出。
A类存在__construct魔术方法,当使用 new 操作符创建一个类的实例时,构造函数将会自动调用。
所以,只要在类B中输出类C,就能调用__toString方法,输出flag.php内容
exp:

<?php
// class A{
   
//     public $username;
//     public $password;
//     function __construct($a, $b){
   
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值