← Back to Writeups
CUSTOMEasyCrypto

Tooled RSA

XESXOR9/2/20262 min read
#crypto#custom#easy#factordb_lookup#standard_rsa_decrypt

Tooled RSA

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

Summary

Walkthrough of the CUSTOM Crypto Tooled RSA. Task: Standard RSA encryption with n, e, c given. Solution: Check factordb.com for known factorization of n, then perform standard RSA decryption.

Description

Standard RSA encryption. Given n, e, c. Need to decrypt.

Analysis

  • Standard RSA setup with n, e, c
  • The modulus n is already factored in factordb.com
  • Once p and q are known, standard RSA decryption applies
  • Task name "Tooled" hints at using existing tools/databases

Solution

Check factordb.com for known factorization of n. If found, compute d and decrypt.

python
#!/usr/bin/env python3
# RSA decryption with factordb lookup

from factordb.factordb import FactorDB
# pip install factordb-python
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

def decrypt_rsa(n, e, c, p, q):
    """Standard RSA decryption"""
    phi = (p - 1) * (q - 1)
    d = pow(e, -1, phi)
    m = pow(c, d, n)
    return m

# Given parameters
n = ...  # RSA modulus
e = 65537
c = ...  # ciphertext

# Check factordb
f = FactorDB(n)
f.connect()
factors = f.get_factor_list()

if len(factors) == 2:
    p, q = factors
    print(f"Found factors!")
    print(f"p = {p}")
    print(f"q = {q}")
    
    # Decrypt
    m = decrypt_rsa(n, e, c, p, q)
    
    # Convert to bytes
    flag = bytes.fromhex(hex(m)[2:])
    print(f"Flag: {flag.decode()}")
else:
    print(f"Factorization status: {f.get_status()}")
    print(f"Factors: {factors}")
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

# Alternative: use rsatool
# rsatool -f PEM -o key.pem -p <p> -q <q>
# openssl rsautl -decrypt -inkey key.pem -in ciphertext.bin

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

Key Takeaways / Lessons

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

Crafted by XESXOR Research • 2026-03-09 • CUSTOM • Tooled RSA • Difficulty: Easy