RsaCtfTool
RSA multi attacks tool : uncipher data from weak public key and try to recover private key Automatic selection of best attack for the given public key
Attacks :
- Weak public key factorization
- Wiener's attack
- Hastad's attack (Small public exponent attack)
- Small q (q < 100,000)
- Common factor between ciphertext and modulus attack
- Fermat's factorisation for close p and q
- Gimmicky Primes method
- Past CTF Primes method
- Self-Initializing Quadratic Sieve (SIQS) using Yafu (https://github.com/DarkenCode/yafu.git)
- Common factor attacks across multiple keys
- Small fractions method when p/q is close to a small fraction
- Boneh Durfee Method when the private exponent d is too small compared to the modulus (i.e d < n^0.292)
- Elliptic Curve Method
- Pollards p-1 for relatively smooth numbers
- Mersenne primes factorization
- Factordb
- Londahl
- Noveltyprimes
- Partial q
- Primefac
- Qicheng
- Same n, huge e
- binary polynomial factoring
- Euler method
- Pollard Rho
Usage
usage: RsaCtfTool.py [-h] [--publickey PUBLICKEY] [--timeout TIMEOUT]
[--createpub] [--dumpkey] [--ext]
[--uncipherfile UNCIPHERFILE] [--uncipher UNCIPHER]
[--verbosity {CRITICAL,ERROR,WARNING,DEBUG,INFO}]
[--private] [--ecmdigits ECMDIGITS] [-n N] [-p P] [-q Q]
[-e E] [--key KEY]
[--attack {mersenne_primes,pollard_p_1,smallfraction,smallq,boneh_durfee,noveltyprimes,ecm,factordb,wiener,siqs,pastctfprimes,partial_q,comfact_cn,hastads,fermat,nullattack,commonfactors,same_n_huge_e,binary_polinomial_factoring,euler,pollard_rho,all}]
Mode 1 : Attack RSA (specify --publickey or n and e)
- publickey : public rsa key to crack. You can import multiple public keys with wildcards.
- uncipher : cipher message to decrypt
- private : display private rsa key if recovered
Mode 2 : Create a Public Key File Given n and e (specify --createpub)
- n : modulus
- e : public exponent
Mode 3 : Dump the public and/or private numbers (optionally including CRT parameters in extended mode) from a PEM/DER format public or private key (specify --dumpkey)
- key : the public or private key in PEM or DER format
Uncipher file
./RsaCtfTool.py --publickey ./key.pub --uncipherfile ./ciphered\_file
Print private key
./RsaCtfTool.py --publickey ./key.pub --private
Attempt to break multiple public keys with common factor attacks or individually- use quotes around wildcards to stop bash expansion
./RsaCtfTool.py --publickey "*.pub" --private
Generate a public key
./RsaCtfTool.py --createpub -n 7828374823761928712873129873981723...12837182 -e 65537
Dump the parameters from a key
./RsaCtfTool.py --dumpkey --key ./key.pub
Factor with ECM when you know the approximate length in digits of a prime
./RsaCtfTool.py --publickey key.pub --ecmdigits 25 --verbose --private
For more examples, look at test.sh file
Requirements
- GMPY2
- SymPy
- PyCrypto
- Requests
- Libnum
- SageMath : optional but advisable
- Sage binaries
Ubuntu 18.04 and Kali specific Instructions
git clone https://github.com/Ganapati/RsaCtfTool.git
sudo apt-get install libgmp3-dev libmpc-dev
pip3 install -r "requirements.txt"
python3 RsaCtfTool.py
MacOS-specific Instructions
If pip3 install -r "requirements.txt" fails to install requirements accessible within environment, the following command may work.
easy_install `cat requirements.txt`
Todo
- Brainstorm moar attack types !
Metadata
Release files for rsactftool 1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rsactftool-1.1.tar.gz | 1.7 MB | Without provenance | Details for rsactftool-1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rsactftool-1.1-py3-none-any.whl | Python 3 | none | any | Details for rsactftool-1.1-py3-none-any.whl |
Total release size: 3.5 MB
Release files / rsactftool-1.1.tar.gz
| Download URL | rsactftool-1.1.tar.gz |
|---|---|
| Size | 1.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be1d753b413b0e9cb2dac61ebe3bba9969bfd675ecab948ce09846d2763adc4d
|
|
BLAKE2b-256 checksum How to use checksums |
01405894774c4eb2820d166428d4464be07b4414ced205c5e9492588b91a671a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.2 CPython/3.8.6 Darwin/19.6.0
|
Release files / rsactftool-1.1-py3-none-any.whl
| Download URL | rsactftool-1.1-py3-none-any.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1ace1789f2007f4a93915a4dae321b9591367b12135f529e33cd92de95d41052
|
|
BLAKE2b-256 checksum How to use checksums |
7706bf197551b4b5261c931c13ad0bceb93bd11217595e863caa811953748a20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.2 CPython/3.8.6 Darwin/19.6.0
|
Security for rsactftool 1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.