/ctf-security:crypto-rsa-attacksfrom ctf-security
Exploit RSA vulnerabilities in CTF challenges including factorization attacks (factordb lookup, Fermat factorization, Pollard rho), Wiener's attack on small private exponents, small public exponent attacks (low e, Hastad broadcast), common modulus attacks, padding oracle attacks, multi-prime RSA, Franklin-Reiter related message attacks, and Coppersmith methods. Use when analyzing RSA encryption challenges, working with public keys (n, e, d, p, q, c parameters), attacking weak RSA implementations, recovering plaintexts from RSA ciphertexts, exploiting mathematical relationships in RSA systems, or factoring composite numbers. Includes RsaCtfTool automation, factordb integration, SageMath implementations for Wiener and lattice attacks, complete working Python scripts for all major RSA attack categories, and practical CTF examples from ASIS, CSAW, PlaidCTF, Google CTF, and other major competitions.
Ships in ctf-security. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Comprehensive techniques for exploiting RSA implementations in CTF challenges. RSA is the most common public-key cryptosystem in CTFs (40%+ of crypto challenges), typically exploiting mathematical weaknesses or implementation flaws.
Use this skill when you encounter:
.pem, .der format)n, e, d, p, q, c, mStep 1: Check factordb.com for n → If factored, compute d and decrypt ✓
Step 2: Run RsaCtfTool → Automates 30+ attacks in minutes
Step 3: Manual attack selection:
├─ Small n (< 1024 bits)? → Trial division, Pollard's rho
├─ e = 3 or e = 5? → Low exponent attack / Hastad broadcast
├─ e > n^0.5? → Wiener's attack (small d)
├─ Multiple (n, e, c) pairs?
│ ├─ Same n, different e → Common modulus attack
│ ├─ Same e, different n → Hastad broadcast / common prime
│ └─ Related messages → Franklin-Reiter attack
└─ Padding present? → Padding oracle / Bleichenbacher attack
# Install
git clone https://github.com/RsaCtfTool/RsaCtfTool.git && cd RsaCtfTool
pip3 install -r requirements.txt
# Basic usage
python3 RsaCtfTool.py --publickey pubkey.pem --uncipherfile flag.enc
python3 RsaCtfTool.py -n <n> -e <e> --uncipher <c>
python3 RsaCtfTool.py -n <n> -e <e> --attack wiener,fermat,factordb
# Always check factordb.com first for any RSA challenge
# Visit: http://factordb.com/index.php?query=<your_n>
# Or use API (see scripts/rsa_factorization.py)
# For Wiener's attack, Coppersmith, lattice reduction
sage wiener_attack.sage
# n is already factored in factordb
# Most common beginner RSA challenge
# See scripts/rsa_factorization.py for API usage
# If m^e < n, just take eth root
from gmpy2 import iroot
m, exact = iroot(c, 3)
if exact:
flag = long_to_bytes(int(m))
# See scripts/small_exponent_attack.py
# When d < (1/3) * n^0.25
# Use continued fractions of e/n
# See scripts/wiener_attack.sage
# Same message, same n, different e1, e2
# Use Extended Euclidean Algorithm
# See scripts/common_modulus_attack.py
# Extract and analyze parameters
n = ... # Modulus
e = ... # Public exponent
c = ... # Ciphertext
print(f"n bit length: {n.bit_length()}") # Typical: 1024, 2048, 4096
print(f"e value: {e}") # Common: 3, 65537
# Red flags
if e <= 5: print("⚠️ Low exponent attack possible")
if e > n: print("⚠️ Unusual - check for typos")
if n.bit_length() < 512: print("⚠️ Small n - try factorization")
# Try automated attacks first (70% success rate on CTF challenges)
python3 RsaCtfTool.py -n <n> -e <e> --uncipher <c>
# Check factordb (often the intended solution)
curl "http://factordb.com/api?query=<n>"
If automation fails, use decision tree → Select appropriate attack → Implement using provided scripts
from Crypto.Util.number import long_to_bytes
# After computing private key d
m = pow(c, d, n)
flag = long_to_bytes(m)
print(flag.decode())
# Handle encoding issues
# - Strip null bytes: flag.strip(b'\\x00')
# - Try different encodings: .decode('utf-8'), .decode('latin-1')
| Attack | Conditions | Complexity | Typical Success Rate |
|---|---|---|---|
| Factordb lookup | Any n | O(1) | Very High (60%) |
| Trial division | n < 2^64 | O(√n) | High |
| Fermat | |p-q| small | O(|p-q|) | Very High |
| Pollard rho | General | O(n^0.25) | Medium |
| Wiener | d < n^0.25 | O(log n) | Very High |
| Low exp (e=3) | m^e < n | O(1) | Very High |
| Hastad | e ciphertexts | O(e) | Very High |
| Common modulus | gcd(e1,e2)=1 | O(log e) | Very High |
# ❌ Wrong (slow and may overflow in other languages)
c = (m ** e) % n
# ✅ Correct
c = pow(m, e, n) # Built-in modular exponentiation
# ✅ Correct
phi = (p - 1) * (q - 1) # For two primes
# ❌ Common mistake
phi = (p * q) - 1 # This is wrong!
# Always check factordb.com FIRST
# Many CTF challenges use pre-factored "interesting" numbers
# This is often the intended solution path
# After decryption, flag might need additional decoding
m = pow(c, d, n)
flag = long_to_bytes(m)
# Try these if flag looks wrong:
# 1. Strip padding: flag.strip(b'\\x00')
# 2. Different encoding: flag.hex(), base64.b64decode(flag)
# 3. Further decryption: might be double-encrypted
#!/usr/bin/env python3
from Crypto.Util.number import long_to_bytes, inverse
from math import gcd
# Challenge parameters
n = ...
e = ...
c = ...
# Method 1: If you have p and q
def solve_with_factors(e, p, q, c):
n = p * q
phi = (p - 1) * (q - 1)
d = inverse(e, phi)
m = pow(c, d, n)
return long_to_bytes(m)
# Method 2: If you factored n
p, q = factor_n(n) # Use scripts/rsa_factorization.py
flag = solve_with_factors(e, p, q, c)
print(flag.decode())
Remember: In CTF RSA challenges, you're not breaking RSA itself - you're exploiting poor parameter choices, implementation mistakes, or mathematical relationships.
Success Strategy:
Quick Navigation:
What SKILL.md sets; muted values are Claude Code's defaults
7 skills in this plugin
/crypto-classical-ciphersSolve classical cipher CTF challenges including Caesar cipher, ROT-N, Vigenère cipher with Autokey variant, substitution ciphers (monoalphabetic and polyalphabetic), transposition ciphers (rail-fence, columnar), Playfair cipher, and other historical encryption methods. Use when analyzing text-only ciphertext, challenges mentioning historical or classical ciphers, frequency analysis opportunities, or when ciphertext contains only letters without numbers. Includes automated solvers for Caesar/ROT-N with all 26 shifts, Vigenère key recovery using Kasiski examination and index of coincidence, frequency analysis for substitution ciphers, dcode.fr and CyberChef integration, complete statistical analysis tools, and English/Italian language frequency tables for OliCyber.IT challenges. Beginner-friendly entry point to CTF cryptography./crypto-general-methodologyComprehensive methodology for solving CTF cryptography challenges including workflow guidance, cipher identification, reconnaissance techniques, tool selection strategy, and challenge categorization. Use when approaching any crypto CTF challenge, need to identify unknown ciphers or encodings, select appropriate tools (dcode.fr, factordb, CyberChef, SageMath, RsaCtfTool), develop attack strategies, or understand crypto challenge patterns. Covers classical ciphers, RSA, AES, block ciphers, PRNG, hash functions, zero-knowledge proofs, encoding detection, and cross-category exploitation techniques. Includes decision trees, cheatsheets for SageMath and PyCryptodome, and systematic approaches for reconnaissance and cryptanalysis.Other plugins' skills for the same job
npx claudepluginhub giofornari/skills --plugin ctf-security