image-20250306195446554

[!Important]

preg_match过滤绕过及RCE重定向截断

0x01

访问靶场,获得源码回显

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date:   2020-09-05 20:49:30
# @Last Modified by:   h1xa
# @Last Modified time: 2020-09-05 21:35:34
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

*/


if(isset($_GET['c'])){
    $c=$_GET['c'];
    if(!preg_match("/\;|cat|flag| /i", $c)){
        system($c." >/dev/null 2>&1");
    }
}else{
    highlight_file(__FILE__);
}

0x02

[!Note]

代码审计,过滤了; cat flag 'Space'

标准输出被重定向

故此处采用&&替代;Tab替代Space常用字符替换)的形式构造payload

0x03

省略目录查看过程,访问flag.php获得flag

image-20250308163031118