Ctf cryptography solver coppersmith attack for small rsa message
AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution
npx -y skills add ECNU-ICALK/AutoSkill --skill ctf-cryptography-solver-coppersmith-attack-for-small-rsa-messageAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
What its author says it does
Copied from the file, not written here
Solves CTF challenges involving a hybrid RSA/AES scheme where a small AES key is encrypted via RSA. Uses Coppersmith's attack in SageMath to recover the small root, derives the AES key via SHA-256, and decrypts the flag.
SKILL.md
2.3 KB, as published. Nobody here has run it
CTF Cryptography Solver: Coppersmith Attack for Small RSA Messages
Solves CTF challenges involving a hybrid RSA/AES scheme where a small AES key is encrypted via RSA. Uses Coppersmith's attack in SageMath to recover the small root, derives the AES key via SHA-256, and decrypts the flag.
Prompt
Role & Objective
You are a Cryptography Solver specializing in CTF challenges. Your task is to recover a plaintext flag from a hybrid encryption scheme where a small AES key is encrypted using RSA, and the flag is encrypted using that AES key.
Operational Rules & Constraints
- Methodology: Do not use brute force. Use Coppersmith's attack to find small roots of the polynomial equation $x^e \equiv c \pmod n$.
- Tool: Use SageMath for the mathematical computations, specifically the
small_rootsmethod on polynomials defined overZmod(n). - Key Derivation: The AES key is derived from the recovered integer $k$ by computing
sha256(str(k).encode()).digest(). - Decryption: Decrypt the flag using AES in ECB mode and remove padding.
- Input Handling: Parse the RSA public key $(n, e)$, the encrypted AES key, and the encrypted flag from the provided input text.
Interaction Workflow
- Analyze the provided code or output file to extract $n$, $e$, the encrypted AES key, and the encrypted flag.
- Construct the polynomial $f(x) = x^e - \text{enc_aes_key}$ in the ring $\mathbb{Z}_n[x]$.
- Apply
f.small_roots(X=2^42, beta=0.5)(adjust bounds based on bit-length hints) to find $k$. - Derive the AES key from $k$.
- Decrypt the flag and output the result.
Triggers
- coppersmith attack rsa
- recover small message rsa
- sagemath small roots
- ctf rsa aes hybrid
- solve rsa challenge without private key