Files
mcpedia/content/writeups/gemastik-2026-warmup/ch13-slopped.md
T
asepharyana 0de2458955
CI / typecheck + build (push) Canceled after 0s
CI / deploy to VPS (push) Canceled after 0s
docs: create GEMASTIK 2026 Warmup writeups (ch1-14) via MCP DB API
- Deleted all 14 dummy docs from DB + filesystem
- Created 14 Gemastik warmup writeups + index via create_document API (DB-first)
- ch1-ch12: encoding/stego/web/pwn basics
- ch13: RSA small factors
- ch14: RSA special integers via paper-search (GCD with paper appendix primes)
- All 15 docs indexed and live at wiki.asepharyana.my.id
2026-08-21 14:28:04 +07:00

1.6 KiB

title, type, section, status, author, tags, path, created_at, updated_at, category, challenge, difficulty, event, flag, points
title type section status author tags path created_at updated_at category challenge difficulty event flag points
Slopped — RSA Small Factors writeup writeups published asep
gemastik
ctf
warmup
crypto
writeups/gemastik-2026-warmup/ch13-slopped.md 2026-08-21T07:26:21.304Z 2026-08-21T07:26:21.304Z crypto Slopped medium GEMASTIK 2026 Warmup GEMASTIK19{qu4ntum_c0mput3r_br0k3_rs4_y0u_sh0uld_us3_p4p3r_s34rch_mcp_sk1ll} 500

Slopped (500 pts) — Crypto / RSA small factors

File: chall.py

import random
p = random.randint(1, 10**4)   # tiny prime candidates
q = random.randint(1, 10**4)
# ... find small primes, multiply
n = p * q * (big prime)
e = 0x10001
c = pow(flag, e, n)

Analisis

RSA dengan e = 0x10001, n 2048-bit, c = pow(flag, e, n). n dibangun dari faktor prima kecil (sloppy primes — "my AI broke RSA with 1 billion qubits"). Faktorisasi temukan prima kecil lewat trial division, lalu phi = prod(p_i - 1), d = e⁻¹ mod phi, dan m = pow(c, d, n).

Solusi

from Crypto.Util.number import long_to_bytes
from sympy import factorint

e = 0x10001
n = 0xdb...  # 2048-bit modulus
c = 0x...

factors = factorint(n)
print(factors)
# {83: 1, 233: 1, 9679: 1, <big_prime>: 1}

phi = 1
for p, exp in factors.items():
    phi *= (p - 1) * p**(exp - 1)

d = pow(e, -1, phi)
m = pow(c, d, n)
print(long_to_bytes(m))
# GEMASTIK19{qu4ntum_c0mput3r_br0k3_rs4_y0u_sh0uld_us3_p4p3r_s34rch_mcp_sk1ll}

Flag

GEMASTIK19{qu4ntum_c0mput3r_br0k3_rs4_y0u_sh0uld_us3_p4p3r_s34rch_mcp_sk1ll}

Flag ini adalah petunjuk untuk ch14 (paper search).