# 1. 填入题目给出的数据 y = 198522960435841482189432265177909868426431703074708363449219028697324701510160286719731988116839697036160581630187160949885168801231636762705713983033164840216512010109089390010468198557792366011939222563881564708155342114969230636341034212421633874868858789397938243061335664034978831542864101231007091988193863118052712382091154270467198016237288512835005671248249864343182623298497353279333896185090300689372993251851698985725825619040354352099701531339567909888327001736937441117830890673409609636796619930226667955511073115983145641056494143455805357766933615911269415380543240132925744315363193308341329870002528062545716167903459438493154302274735882612908825416096548207130441684370171413794313131775960498691561791175984389699661776179746486882233034632979256741127422204726199986374102650551713456275685579171314911783130052174900534533297618292233601037654694611306838303066884626125878765611689352475739052132349596965687310082111652949904102268706219733830038063864703811394198182986558883397487207721093367621647038297033723455527107418011037322197091733780060565430632034276705456268207898108856563488519654411483838153783153351440293627133844440601677480833571012370843618968387929873540183054860492446381685034534436 b = 174037789483961573123221843591212086149338262121485604600830887974881925500571571986993457692950300053374733237615433793104052491813933671943903946487842930332507742237430616633825365722075237337670353892075697891908329460336348924680104502864021820883975695834115061923434753902679746280494899854826747016131 c = 33472511251772997775575923606329341691183359500908766818057589728522254242596438955590397842265158831677351198820346034459567637818737702918129437591421137895764213815168420429024803177742927091662422333575499875132388315943460516679655107714170719351306979285358080183600281172752401859701765071852769889627868633217209348758684870450300228084878260106253395883903968044935866937201968348531962567937222914516096107266208665856669507873113157476771707
# 2. 计算 x # 因为 a*x^2 + b*x + c 相对于 x^4 非常小,所以 x 等于 y 的整数四次方根 # 使用 isqrt 计算平方根的平方根 x = math.isqrt(math.isqrt(y))
# 3. 计算 a # 原始方程: y = x^4 + a*x^2 + b*x + c # 移项: a*x^2 = y - c - b*x - x^4 # 解 a: a = (y - c - b*x - x^4) // x^2 numerator = y - c - b*x - x**4 denominator = x**2
# 验证是否整除(如果整除说明 x 正确) if numerator % denominator == 0: a = numerator // denominator print(f"[+] 成功解出 a: {a}") # 4. 生成 Flag # flag{md5(a)} flag_content = hashlib.md5((str(a)).encode()).hexdigest() flag = f"flag{{{flag_content}}}" print(f"[+] Flag: {flag}") else: print("[-] 解题失败,x 计算可能有误。") flag{01a6eb898468abbd352300a7a072495c}
from pwn import * import re import hashlib import time import base64
context.log_level = 'info' context.timeout = 30
defsolve_pow(prefix): prefix = prefix.lower() start = time.perf_counter() print(f"[*] 计算 PoW, 前缀: {prefix}") for a inrange(256): for b inrange(256): for c inrange(0x20): x = bytes((a, b, c)) if hashlib.sha256(x).hexdigest().startswith(prefix): dur = time.perf_counter() - start print(f"[+] PoW solved in {dur:.2f}s: x={x.hex()}") return x raise RuntimeError("PoW 未找到解")
defxor_bytes(a, b): returnbytes(x ^ y for x, y inzip(a, b))
defextract_multiline_b64(text, anchor): idx = text.find(anchor) if idx == -1: returnNone rest = text[idx + len(anchor):] b64_lines = [] for line in rest.splitlines(): line = line.strip() # 遇到分隔符或空行停止读取 Base64 块 ifnot line or line.startswith('#') or line.startswith('@') or line.startswith('Good job'): break b64_lines.append(line) return''.join(b64_lines)
# Mask: "virtualM" (Offset 0) mask = data[0:8] # Key: Offset 8 # 数据总长 56. Offset 8 到结尾有 48 字节. 足够覆盖 Flag. key = data[8:] flag = "" for i, k inenumerate(key): m = mask[i % 8] dec = k ^ m if dec == 0: break# String terminator flag += chr(dec) print(f"[+] Flag: {flag}")
if __name__ == "__main__": solve() flag{07d3766227718d8094bd@1f2bcd08ca0acccb5a1c}
import zipfile, io, base64, re from pathlib import Path
base_dir = Path(__file__).parent data = (base_dir / "attachment").read_bytes()[::-1]
whileTrue: with zipfile.ZipFile(io.BytesIO(data)) as z: names = z.namelist() s = set(names) other_txts = [n for n in names if n.endswith(".txt") and n != "hint.txt"] if"hint.txt"in s and other_txts: hint = z.read("hint.txt") enc = z.read(other_txts[0]) break flag_name = next(n for n in names if n.startswith("flag")) data = z.read(flag_name)[::-1]
tokens = hint.decode().strip().split() cls_map = { "digits": r"[0-9]", "lowercase": r"[a-z]", "uppercase": r"[A-Z]", "other": r"[^0-9A-Za-z]", } neg_map = { "digits": r"[^0-9]", "lowercase": r"[^a-z]", "uppercase": r"[^A-Z]", "other": r"[0-9A-Za-z]", } parts = [] for tok in tokens: if tok == "I_am_here": parts.append(".") elif tok.startswith("!"): parts.append(neg_map[tok[1:]]) else: parts.append(cls_map[tok]) regex_body = "".join(parts) regex = re.compile(r"(?=(" + regex_body + r"))", re.DOTALL)
enc_text = enc.decode("latin1") L = len(tokens) hits = 0 secret_chars = [] for m in regex.finditer(enc_text): i = m.start(1) secret_chars.append(enc_text[i + 10]) hits += 1