← Back to Writeups
CUSTOMEasyCrypto

baby modulus — Small RSA

XESXOR9/2/20261 min read
#crypto#custom#easy#rsa_small_modulus_factorizatio

baby modulus — Small RSA

Platform: CUSTOM | Category: Crypto | Type: Challenge | Difficulty: Easy | OS: N/A | **Author: XESXOR Techniques: rsa_small_modulus_factorization

Summary

Walkthrough of the CUSTOM Crypto baby modulus — Small RSA. Task: RSA with small 128-bit modulus. Solution: Factor n via factordb.com and compute private key d to decrypt.

Description

RSA with small 128-bit modulus.

  • n = 127515183131859395739078505442605447613
  • e = 31337
  • c = 33403920388615840326926465556447601348

Analysis

The modulus n is only 128 bits — easily factorizable via factordb.com or yafu.

Solution

python
#!/usr/bin/env python3
from Crypto.Util.number import long_to_bytes

n = 127515183131859395739078505442605447613
e = 31337
c = 33403920388615840326926465556447601348

# Factorization via factordb.com:
p = 11192001222936284809
q = 11393421122090001557
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

assert p * q == n

# Calculate phi(n) and d
phi = (p - 1) * (q - 1)
d = pow(e, -1, phi)

# Decrypt
m = pow(c, d, n)
flag = long_to_bytes(m)
print(flag.decode())
# Output: spbctf{REDACTED}

‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Key Takeaways / Lessons

  • Mastering rsa_small_modulus_factorization was key to this challenge.
  • Always check for common misconfigurations and verify assumptions.

Crafted by XESXOR Research • 2026-03-08 • CUSTOM • baby modulus — Small RSA • Difficulty: Easy