Open-source project
RsaCtfTool/RsaCtfTool avatar
RsaCtfTool/RsaCtfTool

RsaCtfTool works through a queue of RSA attacks until one modulus splits

RSA attack tool (mainly for ctf) - retrieve private key from weak public key and/or uncipher data

7,222 stars1,023 forksPythonMIT

At a glance

What is it?
RsaCtfTool takes one public key or a glob of them and runs a fixed queue of non factorization and factorization attacks, so the result depends on the shape of the key rather than on any single algorithm. What the queue covers, where it stops, and which dependencies reach the network are worth knowing before you wait on a run.
Who is it for?
Treat RsaCtfTool as a challenge solver and a quick audit over a directory of public keys, not as a general factoring engine. Anyone holding a textbook semiprime with a hint about its shape gets value from the queue; anyone holding a multiprime modulus or a key that resists every listed method spends CPU to learn nothing.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 3 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • RsaCtfTool/RsaCtfTool7,222 ★ · +83
Star history
Repository2026-09-232026-11-22
RsaCtfTool/RsaCtfTool7.1k7.2k

83 Stars in the last 60 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

One public key flag drives a queue, not a single attack

A single `--publickey` argument starts the work, and it drives a queue rather than one fixed method. Point it at a file and the run keeps going until something yields: `--private` asks for the private key, `--decryptfile ciphertext` asks for plaintext from a file you name. Quote a glob such as `--publickey "*.pub"` and every match becomes a candidate in the same batch. The non factorization branch is the part that pays off most often on challenge keys. It holds Wiener's attack for a small private exponent, Hastad's attack for a small public exponent, Boneh-Durfee for d below n^0.292, a shared modulus carrying an enormous e, a small CRT exponent, partial knowledge of q or d, and lattice reduction. Adding `--attack wiener` pins the run to one of them, which is how you confirm which weakness is actually there instead of guessing from a wall of output.

Textbook semiprime only, so multiprime moduli are out of reach

The scope ceiling is stated plainly: the tool supports RSA textbook semiprime composite modulus and not multiprimes. That one restriction decides which keys you can ever hand it. The second ceiling is time. Not every key can be broken in a reasonable timeframe, which means a queue that comes back empty has only told you that the queue ran. When you need general purpose factorization rather than these shortcuts, the project points you at msieve, yafu, and cado-nfs instead of pretending to be one. Consequence for a reader: check whether the modulus is a two prime product before you wait, because no flag will widen the scope later.

Read the method table as a list of key shapes, not algorithms

The factorization table is best read as a list of key shapes rather than a list of algorithms. Fermat wants p and q close together. Pollard Rho and the Quadratic Sieve are described as general factorization. ECM, Pollard p-1, and Williams p+1 all want smooth numbers. SQUFOF wants square forms, and Dixon wants random squares. ROCA looks for one specific vulnerable key generation pattern, and the GCD attacks go after Mersenne, Primorial, and Fibonacci style values. Common factor attacks need two keys that share a factor, so they need more than one file on disk and they are the one row where a glob of `*.pub` changes the answer. `--ecmdigits 25` sets the digit bound for the ECM run. The consequence: on a key that is neither close prime nor smooth, most rows of that table have no foothold, and the rows that do apply are the ones you have to reason about yourself.

Factordb is an attack route and a live network dependency

Factordb appears in two places, and the second one has consequences. It is listed as an attack route under the online factorization database entry, and `factordb-pycli` sits in the dependency list of both pyproject.toml and requirements.txt next to cryptography, gmpy2, pycryptodome, z3-solver, psutil, requests, urllib3, and tqdm. That makes it a network path inside a tool you may want to run offline, and `--sendtofdb` on a glob pushes results outward to the service. If the keys are yours to publish that is fine; if a key belongs to someone else, or a challenge you are not permitted to submit, the flag publishes it anyway. The test suite marks this route with `@pytest.mark.network` for tests that require Factordb, so `pytest tests/ -m "not slow"` still lets those cases through and you can still hit the network while skipping slow work.

Docker moves your working directory to /data

The container path has a layout that changes how you pass files. The image is `python:3-alpine`, with gmp-dev, mpfr-dev, mpc1-dev, gcc, musl-dev, openssl-dev, libffi-dev, git, g++, make, and cmake installed first, because gmpy2 needs those headers to compile against musl. The build copies the tree into `/app`, runs `pip install -r "requirements.txt"`, then switches the working directory to `/data` and sets the entrypoint to the script path `/app/src/RsaCtfTool/main.py`. Build and run are the documented two steps:

bash
docker build -t rsactftool/rsactftool .
docker run -it --rm -v $PWD:/data rsactftool/rsactftool <arguments>

The consequence is that a relative path such as `key.pub` resolves inside the mounted directory, not inside the directory you launched from, and nothing maps it for you. A top level `Dockerfile_full` and an `optional-requirements.txt` exist if the slim image is not the one you want.

pip install -e . writes two console scripts, only one is shown

Prerequisites are Python 3.9+ and, optionally but recommended, SageMath. The virtual environment route is three commands:

bash
python3 -m venv venv
source venv/bin/activate
pip install -e .

That editable install writes two console scripts, `rsacrack` and `RsaCtfTool`, and both point at `RsaCtfTool.main:main`. Same entry point, two names, while every documented example uses the capitalized one, so building a wrapper around `rsacrack` is a choice you make on purpose. The repository ships `requirements.txt` and `pyproject.toml` with matching dependency lists, and setuptools is told to find packages under `src`. Your first real run is the same shape as the documented examples:

bash
RsaCtfTool --publickey key.pub --private
RsaCtfTool --publickey key.pub --decryptfile ciphertext
RsaCtfTool --dumpkey --key key.pub

`--dumpkey --ext` adds CRT parameters, `--createpub -n 7828374823761928712873... -e 65537` builds a key when you only hold the modulus and exponent, and `--isroca --publickey "examples/*.pub"` checks a whole directory for the ROCA pattern.

SageMath is recommended, shipped as files, and not pip-installable

SageMath is the recommendation you cannot satisfy from the package index. The dependency comment in pyproject.toml says outright that SageMath is not pip-installable and has to be installed separately if needed, yet it stays listed as recommended in the prerequisites, and the package data still ships a `sage/` directory next to `data/`. That mismatch is the trap. A fresh virtual environment has the directory and not the library, so anything routed through SageMath lattice work simply is not present. The pip-installable optional extra is `wolframalpha`, and the CTF specific method list names the Z3 Theorem Prover and Wolfram Alpha as routes in their own right. Because `z3-solver` is a hard dependency while the Wolfram Alpha path is opt in, the two symbolic routes behave differently out of the box.

Version 0.1.0, a Planning classifier, and no release tags

Version metadata is the thing to check before you pin anything. pyproject.toml declares `version = "0.1.0"`, a development status classifier of Planning, and a download URL pointing at the 0.1.0 tarball. The repository has no GitHub releases, so there is no tag history to diff a packaged build against and no changelog entry attached to a build you can name. The last push to the default branch, master, is dated 2026-10-23 and the repository is not archived, which tells you work is landing rather than that any particular packaged copy is stable. The licence is MIT, recorded in LICENSE.txt and pyproject.toml. Practical effect: expect the option surface to move, and install from master rather than from a version number you found in a tutorial.

Editorial conclusion

Treat RsaCtfTool as a challenge solver and a quick audit over a directory of public keys, not as a general factoring engine. Anyone holding a textbook semiprime with a hint about its shape gets value from the queue; anyone holding a multiprime modulus or a key that resists every listed method spends CPU to learn nothing. Before a long run, check the modulus type, pick one attack with --attack to confirm which weakness is present, and decide whether the Factordb network path is acceptable in your environment.

Frequently asked questions

how to use rsactftool

Give it a key file and choose an outcome. `RsaCtfTool --publickey key.pub --private` recovers the private key, `--publickey key.pub --decryptfile ciphertext` produces plaintext, and `--attack wiener` pins the run to one method. Quote a glob such as `--publickey "*.pub"` to sweep a directory, and run `RsaCtfTool --help` for the full option list.

Is it possible to decrypt RSA?

Only when the key carries a weakness one of the attacks exploits. The tool supports RSA textbook semiprime composite modulus and not multiprimes, and it states that not every key can be broken in a reasonable timeframe.

Is RSA encryption still safe?

This project exists because RSA security rests on the difficulty of integer factorization. It combines several factorization algorithms to attack that assumption, and its own scope limit is the tell: RSA textbook semiprime composite modulus only, not multiprimes.

Official sources

  1. Issues
  2. License: MIT
  3. README
  4. RsaCtfTool/RsaCtfTool on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/rsactftool-rsactftool.svg)](https://hysenlabs.com/projects/rsactftool-rsactftool)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/rsactftool-rsactftool.svg)](https://hysenlabs.com/projects/rsactftool-rsactftool)

Was this useful?