项目作者: skyf0l

项目描述 :
Ctf tool to quickly solve RSA cipher
高级语言: Python
项目地址: git://github.com/skyf0l/RsaSolver.git
创建时间: 2020-07-21T17:41:42Z
项目社区:https://github.com/skyf0l/RsaSolver

开源协议:

下载


RSA Cracker

Build
Crate.io
Docker Image Version
codecov

Powerful RSA cracker for CTFs. Supports RSA, X509, OPENSSH in PEM and DER formats.

RsaCracker provides a simple interface to crack RSA keys and ciphers. With a collection of thousands of attacks, no key can survive against RsaCracker!

Installation

From crates.io:

  1. cargo install rsacracker

Note: To build on windows, you need to use MSYS2. This is required because of the rug dependency. See building-on-windows for more information.

Usage

  1. Powerful RSA cracker for CTFs. Supports RSA, X509, OPENSSH in PEM and DER formats.
  2. Usage: rsacracker [OPTIONS]
  3. Options:
  4. -r, --raw <RAW> Retrieve values from raw file
  5. -c, --cipher <CIPHER> Cipher: the message to uncipher
  6. -f, --cipherfile <CIPHERFILE> Cipher file: the file to uncipher
  7. -o, --outfile <OUTFILE> Write unciphered data to a file. If many unciphered data are found, they will be written to files suffixed with _1, _2, ...
  8. -n <N> Modulus
  9. -e <E> Public exponent. Default: 65537 [default: 65537]
  10. -p <P> Prime number p
  11. -q <Q> Prime number q
  12. -d <D> Private exponent
  13. --phi <PHI> Phi or Euler's totient function of n. (p-1)(q-1)
  14. --dp <DP> dP or dmp1 CRT exponent. (d mod p-1)
  15. --dq <DQ> dQ or dmq1 CRT exponent. (d mod q-1)
  16. --qinv <QINV> qInv or iqmp CRT coefficient. (q^-1 mod p)
  17. --pinv <PINV> pInv or ipmq CRT coefficient. (p^-1 mod q)
  18. --sum-pq <SUM_PQ> The sum of the two primes p and q
  19. --dlog Discrete logarithm attack. When c and e are swapped in the RSA encryption formula. (e^c mod n)
  20. -k, --key <KEY> Public or private key file. (RSA, X509, OPENSSH in PEM and DER formats.)
  21. --password <PASSWORD> Private key password/passphrase if encrypted
  22. --public Print the public key in PEM format
  23. --private Print the private key in PEM format
  24. --addpassword <ADDPASSWORD> Add a password/passphrase to the private key
  25. --showinputs Print all the input parameters
  26. --dump Print the private RSA key variables n, e, p, q and d
  27. --dumpext Print the extended RSA key variables n, e, p, q, d, dP, dQ, pInv and qInv
  28. --factors Print all factors of n
  29. -t, --threads <THREADS> Number of threads to use. Default: number of CPUs [default: 12]
  30. -a, --attack <ATTACK> Specify attacks to run. Default: all. (e.g. --attacks ecm,wiener,sparse)
  31. --exclude <EXCLUDE> Specify attacks to exclude. Default: none. (e.g. --exclude ecm,wiener,sparse)
  32. --list List all available attacks
  33. -h, --help Print help
  34. -V, --version Print version

You can also use a dump as input:

  1. $ rsacracker [OPTIONS] < challenge.txt
  2. [RESULTS]
  3. $ cat challenge.txt | rsacracker [OPTIONS]
  4. [RESULTS]
  5. $ cat challenge.txt
  6. c: 7839407718[...]0577093673
  7. n = 9359619564[...]3745124619
  8. e= 1595235523[...]6275096193

Examples

Uncipher a message from a public key and write it to a file

  1. rsacracker --key public.pem -c 0xdeadbeef -o result.txt

Uncipher a message from n and e

  1. rsacracker -c 0xdeadbeef -n 123...789 -e 65537

Uncipher a message from n, e and other known values

  1. rsacracker -c 0xdeadbeef -n 123...789 -e 65537 --phi 123 --dp 123 --dq 123 --qinv 123 --pinv 123

Uncipher a file from a public key

  1. rsacracker --key public.pem -f secret.txt.enc

Run a specific attack with arguments

  1. rsacracker --attack known_phi -n 123...789 -e 65537 --phi 0xdeadbeef

Generate a private key from a public key

  1. rsacracker --key public.pem --private

Generate a public key from e and n

  1. rsacracker -e 65537 -n 0xdeadbeef --public

Dump private key secrets

  1. rsacracker --key private.pem --dump
  2. $ rsacracker --key private.pem --dumpext

Remove password from a private key

  1. rsacracker --key private.pem --password R54Cr4ck3R --private

Add password to a private key

  1. rsacracker --key private.pem --addpassword R54Cr4ck3R --private

Show all factors of n

  1. rsacracker -n 123...789 --factors

Run discrete logarithm attack: when c and e are swapped in the RSA encryption formula (e^c mod n)

  1. rsacracker --key public.pem -c 0xdeadbeef --dlog

Docker

From dockerhub:

  1. docker pull skyf0l/rsacracker
  2. docker run -it --rm -v $PWD:/data skyf0l/rsacracker [args]

Or build it yourself:

  1. DOCKER_BUILDKIT=1 docker build . --file Dockerfile -t rsacracker
  2. docker run -it --rm -v $PWD:/data rsacracker [args]

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.