← Back to Writeups
CUSTOMEasyCrypto

Read Sleep Attack

XESXOR9/10/20261 min read
#crypto#custom#easy#factordb_lookup#standard_rsa_decrypt#linux

Read Sleep Attack

Platform: spbctf | Category: Crypto | Type: Challenge | Difficulty: Easy | OS: Linux | Author: XESXOR | Date: 2026-03-09 | Status: Solved Techniques: factordb_lookup, standard_rsa_decrypt

Summary

Task: RSA with small modulus (~350 bits). Solution: Factor n via factordb.com (p=29), then standard RSA decryption.

Read Sleep Attack — cryptokids20

Description

RSA task with a small modulus. The task name "Read Sleep Attack" is a hint: R.S.A.

Analysis

Key Parameters

  • n — small modulus (~350 bits), easily factorizable
  • e = 65537 — standard public exponent
  • c — ciphertext

Vulnerability

The modulus n is too small and can be factored via online services (factordb.com). After factorization:

  • p = 29 (small prime factor)
  • q = large prime number

Solution

Step 1: Factorizing n

bash
# Check n on factordb.com
# n = p * q, where p = 29

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

Step 2: Standard RSA Decryption

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

# Parameters from the task
n = ...  # small modulus (~350 bits)
e = 65537
c = ...  # ciphertext

# Factorization via factordb
p = 29
q = n // p

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

# Decrypt
m = pow(c, d, n)
flag = long_to_bytes(m)
print(flag.decode())

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