Skip to content
Agentmart
Submit a tool

ctf-crypto-rsa

CTF RSA cryptography attacks.

Skill by Yoraexe

IndexedMIT★ 1
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/yoraexe-ctf-crypto-rsa

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

CTF RSA cryptography attacks. Small exponent cube root, common modulus, Wiener attack, Pollard p-1, Hastad broadcast, Fermat factorization, batch GCD, Manger padding oracle, p=q bypass, gcd(e,phi)>1, signature forgery. Triggers: 'rsa attack', 'rsa ctf', 'crypto rsa', 'wiener attack', 'hastad broadcast', 'small exponent', 'common modulus', 'pollard p-1', 'fermat factorization', 'rsa cipher', 'rsa decryption'.

Use cases: finance

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/ctf-crypto-rsa

What's inside

Skill name
ctf-crypto-rsa
Description
CTF RSA cryptography attacks. Small exponent cube root, common modulus, Wiener attack, Pollard p-1, Hastad broadcast, Fermat factorization, batch GCD, Manger padding oracle, p=q bypass, gcd(e,phi)>1, signature forgery. Triggers: 'rsa attack', 'rsa ctf', 'crypto rsa', 'wiener attack', 'hastad broadcast', 'small exponent', 'common modulus', 'pollard p-1', 'fermat factorization', 'rsa cipher', 'rsa decryption'.
License
MIT
Instructions
353 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# CTF Crypto — RSA Attacks

Complete RSA attack toolkit: cube root, Wiener, Hastad, Pollard, Fermat, batch GCD, Manger oracle, signature forgery.

## Install

```bash
pip install pycryptodome gmpy2 sympy owiener --break-system-packages
# SageMath for Coppersmith:
# apt-get install -y sagemath
```

---

## Phase 1: Small Public Exponent (Cube Root)

```python
import gmpy2

def small_e_attack(c, e):
    """Works when m^e < n (no modular wrap)."""
    m, exact = gmpy2.iroot(c, e)
    if exact:
        return int(m)
    return None

m = small_e_attack(c, e=3)
if m:
    print(bytes.fromhex(hex(m)[2:]))
```

---

## Phase 2: Common Modulus Attack

```python
from math import gcd

def common_modulus_attack(c1, c2, e1, e2, n):
    """Same n, same message, different coprime exponents."""
    def extended_gcd(a, b):
        if a == 0: return b, 0, 1
        g, x, y = extended_gcd(b % a, a)
        return g, y - (b // a) * x, x

    g, a, b = extended_gcd(e1, e2)
    assert g == 1
    if a < 0:
        c1 = pow(c1, -1, n); a = -a
    if b < 0:
        c2 = pow(c2, -1, n); b = -b
    return (pow(c1, a, n) * pow(c2, b, n)) % n

m = common_modulus_attack(c1, c2, e1, e2, n)
print(bytes.fromhex(hex(m)[2:]))
```

---

## Phase 3: Wiener's Attack (Small Private Exponent)

```python
import owiener  # pip install owiener

d = owiener.attack(e, n)
if d:
    m = pow(c, d, n)
    print(bytes.fromhex(hex(m)[2:]))
else:
    print("Wiener failed — d not small enough")

# Manual implementation:
def wiener_attack(e, n):
    def continued_fraction(num, den):
        cf = []
        while den:
            q, r = divmod(num, den)
            cf.append(q)
            num, den = den, r
        return cf

    def convergents(cf):
        h0, h1 = 0, 1
        k0, k1 = 1, 0
        for a in cf:
            h0, h1 = h1, a * h1 + h0
            k0, k1 = k1, a * k1 + k0
            yield h1, k1

    from math import isqrt
    for k, d in convergents(continued_fraction(e, n)):
        if k == 0: continue
        if (e * d - 1) % k != 0: continue
        phi = (e * d - 1) // k
        s = n - phi + 1
        disc = s * s - 4 * n
        if disc < 0: continue
        t = isqrt(disc)
        if t * t == disc:
            return d
    return None
```

---

## Phase 4: Pollard's p-1 Factorization

```python
from math import gcd

def pollard_p1(n, B=100000):
    """Factor n when p-1 is B-smooth."""
    a = 2
    for j in range(2, B + 1):
        a = pow(a, j, n)
        d = gcd(a - 1, n)
        if 1 < d < n:
            return d, n // d
    return None

From Yoraexe/ceobe, MIT.

Signals

Stars
1
Forks
1
Open issues
0
Last commit (this folder)
Jul 17, 2026 (3 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from Yoraexe

Cite this page

ctf-crypto-rsa skill. Agent Mart. https://agentmart.dev/skills/yoraexe-ctf-crypto-rsa (last updated 2026-10-24)