Git Product home page Git Product logo

rsactftool's Introduction

RsaCtfTool

Test lint_python CodeQL GitHub issues

GitHub forks GitHub stars GitHub license GitHub contributors

This tool is an utility designed to decrypt data from weak public keys and attempt to recover the corresponding private key. Also this tool offers a comprehensive range of attack options, enabling users to apply various strategies to crack the encryption. The RSA security, at its core, relies on the complexity of the integer factorization problem. This project serves as a valuable resource by combining multiple integer factorization algorithms, effectively enhancing the overall decryption capabilities. Please note that this tool is primarily intended for educational purposes. It is essential to manage your expectations, as not every key can be broken within a reasonable timeframe. The complexity of the encryption algorithm may present significant challenges. It is essential to highlight that the tool, exclusively supports the RSA textbook semiprime composite modulus rather than composite multiprimes. This constraint is embedded upstream in the pycrypto library (see TODO). While this limitation exists, the tool still offers a powerful set of features for attacking RSA keys with semiprime composite modulus.

For an advanced integer factorization tool please use msieve, yafu, or cado-nfs.

This tool is meant for educational purposes. For those participating in CTFs, please do the following first:

  • Learn the basics of RSA math and understand number theory, modular arithmetic, integer factorization and the fundamental theorem of arithmetic.
  • Read the code in this repository to understand what it does and how it works and suggest improvements by sending pull requests.
  • Avoid copy-pasting and running the tool without understanding the underlying math, as knowing the math is more valuable than knowing how to run the tool.

We hope this tool enhances your understanding of RSA encryption and serves as a valuable resource for exploring the intricacies of integer factorization. Use it responsibly and within the bounds of applicable laws and regulations.

Attacks provided:

Usage

usage: RsaCtfTool.py [-h] [--publickey PUBLICKEY] [--output OUTPUT] [--timeout TIMEOUT] [--createpub] [--dumpkey] [--ext] [--decryptfile DECRYPTFILE] [--decrypt DECRYPT]
                     [--verbosity {CRITICAL,ERROR,WARNING,DEBUG,INFO}] [--private] [--tests] [--ecmdigits ECMDIGITS] [-n N] [-p P] [-q Q] [-e E] [--key KEY]
                     [--password PASSWORD] [--show-factors SHOW_FACTORS]
                     [--attack {SQUFOF,XYXZ,binary_polinomial_factoring,brent,comfact_cn,cube_root,ecm,ecm2,factordb,fermat_numbers_gcd,fibonacci_gcd,highandlowbitsequal,mersenne_pm1_gcd,mersenne_primes,neca,nonRSA,noveltyprimes,pastctfprimes,pisano_period,pollard_p_1,primorial_pm1_gcd,qicheng,roca,siqs,small_crt_exp,smallfraction,smallq,system_primes_gcd,wolframalpha,wiener,boneh_durfee,euler,pollard_rho,williams_pp1,partial_q,partial_d,londahl,z3_solver,dixon,lehmer,fermat,hart,common_factors,common_modulus,same_n_huge_e,hastads,lattice,lehman,carmichael,qs,classical_shor,all} [{SQUFOF,XYXZ,binary_polinomial_factoring,brent,comfact_cn,cube_root,ecm,ecm2,factordb,fermat_numbers_gcd,fibonacci_gcd,highandlowbitsequal,mersenne_pm1_gcd,mersenne_primes,neca,nonRSA,noveltyprimes,pastctfprimes,pisano_period,pollard_p_1,primorial_pm1_gcd,qicheng,roca,siqs,small_crt_exp,smallfraction,smallq,system_primes_gcd,wolframalpha,wiener,boneh_durfee,euler,pollard_rho,williams_pp1,partial_q,partial_d,londahl,z3_solver,dixon,lehmer,fermat,hart,common_factors,common_modulus,same_n_huge_e,hastads,lattice,lehman,carmichael,qs,classical_shor,factorial_pm1_gcd,lucas_gcd,all} ...]]
                     [--sendtofdb] [--isconspicuous] [--isroca] [--convert_idrsa_pub] [--check_publickey] [--partial]

Mode 1 : Attack RSA (specify --publickey or n and e)

  • publickey : public rsa key to crack. You can import multiple public keys with wildcards.
  • decrypt : 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

Decrypt file

./RsaCtfTool.py --publickey ./key.pub --decryptfile ./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

Optionally send the results back to factordb

./RsaCtfTool.py --publickey "*.pub" --private --sendtofdb

Generate a public key

./RsaCtfTool.py --createpub -n 7828374823761928712873129873981723...12837182 -e 65537

Dump the parameters from a key

./RsaCtfTool.py --dumpkey --key ./key.pub

Check a given private key for conspicuousness

./RsaCtfTool.py --key examples/conspicuous.priv --isconspicuous

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 the test.sh file

Attack private keys with partial bits of Q known

./RsaCtfTool.py --attack partial_q --key examples/masked.pem

Attack private keys with partial bits of D known

./RsaCtfTool.py --attack partial_d --key examples/partial_d.pem

Convert idrsa.pub to pem format

./RsaCtfTool.py --convert_idrsa_pub --publickey $HOME/.ssh/id_rsa.pub

Check if a given key or keys are roca

./RsaCtfTool.py --isroca --publickey "examples/*.pub"

Docker run

docker pull rsactftool/rsactftool
docker run -it --rm -v $PWD:/data rsactftool/rsactftool <arguments>

Virtual environment run

Setup the venv

virtualenv venv
source venv/bin/activate
pip3 install -r requirements.txt

Run

source venv/bin/activate
./RsaCtfTool.py <arguments>

Requirements

  • python3.9
  • GMPY2
  • PyCrypto
  • Requests
  • Libnum
  • SageMath : optional but advisable
  • Sage binaries

Ubuntu 18.04 and Kali specific Instructions

git clone https://github.com/RsaCtfTool/RsaCtfTool.git
sudo apt-get install libgmp3-dev libmpc-dev
cd RsaCtfTool
pip3 install -r "requirements.txt"
./RsaCtfTool.py

Fedora (33 and above) specific Instructions

git clone https://github.com/RsaCtfTool/RsaCtfTool.git
sudo dnf install gcc python3-devel python3-pip python3-wheel gmp-devel mpfr-devel libmpc-devel
cd RsaCtfTool
pip3 install -r "requirements.txt"
./RsaCtfTool.py

If you also want the optional SageMath , you need to do

sudo dnf install sagemath
pip3 install -r "optional-requirements.txt"

MacOS-specific Instructions

If pip3 install -r "requirements.txt" fails to install requirements accessible within the environment, the following command may work.

easy_install `cat requirements.txt`

If you installed gmpy2 with homebrew(brew install gmp), you might have to point clang towards the header files with this command: CFLAGS=-I/opt/homebrew/include LDFLAGS=-L/opt/homebrew/lib pip3 install -r requirements.txt

Optional to factor roca keys upto 512 bits, Install neca:

You can follow the instructions at : https://www.mersenneforum.org/showthread.php?t=23087

TODO (aka. Help wanted !)

  • Implement a test method for each attack.
  • Assign the correct algorithm complexity in Big O notation for each attack.
  • Support multiprime RSA, the project currently supports textbook RSA.
  • Wanted feature: Ransomware decrypter.

Contributing

  • Please read the CONTRIBUTING.md guideline for the bare minimum acceptable PRs.
  • Also please read the CODE_OF_CONDUCT.md, any contribution of any user not honoring it will ignored and the user blocked, good manners are paramount.

Thanks to all our Contributors

šŸ”¼ Back to top

rsactftool's People

Contributors

bpg0x03 avatar calebtree avatar caphosra avatar cclauss avatar daedalus avatar datawearsahood avatar dependabot[bot] avatar enriquesl-git avatar ganapati avatar joohoi avatar killer2op avatar kk-kd avatar kmanc avatar lordkiba avatar marcomeinardi avatar matusso avatar maximmasiutin avatar mendel3 avatar minaminao avatar mohitd404 avatar pedroelbanquero avatar pr0me avatar shraddha761 avatar shresthasurav avatar sjord avatar skaft avatar sourcekris avatar sylvainpelissier avatar toranova avatar yanhuijessica avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rsactftool's Issues

Error

i write this code ./RsaCtfTool.py --publickey ./key.pub --uncipher ./flag.enc

Traceback (most recent call last):
File "./RsaCtfTool.py", line 488, in
attackobj.attack()
File "./RsaCtfTool.py", line 391, in attack
getattr(self, attack.name)()
File "./RsaCtfTool.py", line 369, in Pollard_p_1
self.pub_key.p, self.pub_key.q = pollard_P_1(self.pub_key.n)
TypeError: 'int' object is not iterable

what is the problem???

RSA key format is not supported

raise ValueError("RSA key format is not supported")
ValueError: RSA key format is not supported

Any idea? I copied the files from a CTF and this was the output

Error

Traceback (most recent call last):
File "./RsaCtfTool.py", line 658, in
attackobj.attack()
File "./RsaCtfTool.py", line 478, in attack
getattr(self, attack.name)()
File "./RsaCtfTool.py", line 410, in siqs
if siqsobj.checkyafu() and siqsobj.testyafu():
File "/root/Desktop/ctf/tools/RsaCtfTool/siqs.py", line 39, in testyafu
if b'48670331' in yafutest:
TypeError: 'in ' requires string as left operand, not bytes

publickey
-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIVCe6WrpgUA5ogDr69OKuJSPQ06ICDP
2LbsOZcE6YdET6rixTHqko3sI8Y91us1ZKSsLUerv3NK9Qr8C26IbRcCAwEAAQ==
-----END PUBLIC KEY-----

cube_root.py" line 26 non-hexadecimal number found in fromhex() arg at position 47

Run code below, then got an error.

python3 RsaCtfTool.py -n 47966708183289639962501363163761864399454241691014467172805658518368423135168025285144721028476297179341434450931955275325060173656301959484440112740411109153032840150659 -e 3 --uncipher 10968126341413081941567552025256642365567988931403833266852196599058668508079150528128483441934584299102782386592369069626088211004467782012298322278772376088171342152839
[*] Testing key /tmp/tmp60pindkb.
[*] Performing siqs attack on /tmp/tmp60pindkb.
[!] Yafu SIQS is not working.
[*] Performing comfact_cn attack on /tmp/tmp60pindkb.
[*] Performing cube_root attack on /tmp/tmp60pindkb.
Traceback (most recent call last):
  File "RsaCtfTool.py", line 258, in <module>
    attackobj.attack_single_key(publickey, attacks_list)
  File "/home/kali/Downloads/RsaCtfTool/lib/rsa_attack.py", line 193, in attack_single_key
    self, self.publickey, self.cipher
  File "/home/kali/Downloads/RsaCtfTool/attacks/single_key/cube_root.py", line 26, in attack
    plain.append(bytes.fromhex(m))
ValueError: non-hexadecimal number found in fromhex() arg at position 47


Error with this file "pubkey.pem" (attached) ...

Hi, with this command :

./RsaCtfTool.py --publickey "pubkey.pem" --private

tool fail with error:

[] Testing key challenge/pubkey.pem.
[
] Performing boneh_durfee attack on challenge/pubkey.pem.
[] Performing pastctfprimes attack on challenge/pubkey.pem.
[
] Performing wiener attack on challenge/pubkey.pem.
[] Performing primefac attack on challenge/pubkey.pem.
[
] Performing factordb attack on challenge/pubkey.pem.
Traceback (most recent call last):
File "./RsaCtfTool.py", line 256, in
attackobj.attack_single_key(publickey, attacks_list)
File "/home/user/Working/RsaCtfTool/lib/rsa_attack.py", line 179, in attack_single_key
self, self.publickey, self.cipher
File "/home/user/Working/RsaCtfTool/attacks/single_key/factordb.py", line 56, in attack
q_id = ids[2]
IndexError: list index out of range

How resolve ?

pubkey.zip

How to solve this problem?

[] Testing key pubkey.pem.
[
] Performing primefac attack on pubkey.pem.
Traceback (most recent call last):
File "./RsaCtfTool.py", line 256, in
attackobj.attack_single_key(publickey, attacks_list)
File "/root/Documents/RsaCtfTool/lib/rsa_attack.py", line 179, in attack_single_key
self, self.publickey, self.cipher
File "/root/Documents/RsaCtfTool/attacks/single_key/smallfraction.py", line 18, in attack
["sage", "./sage/smallfraction.sage", str(publickey.n)]
File "/usr/lib/python3.7/subprocess.py", line 411, in check_output
**kwargs).stdout
File "/usr/lib/python3.7/subprocess.py", line 488, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.7/subprocess.py", line 800, in init
restore_signals, start_new_session)
File "/usr/lib/python3.7/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'sage': 'sage'

NotImplementedError: Use module Crypto.Cipher.PKCS1_OAEP instead

$ python3 RsaCtfTool.py --publickey pubkey.txt --uncipher 0123456789

Traceback (most recent call last):
  File "RsaCtfTool.py", line 95, in decrypt
    stderr=DN)
  File "/usr/lib64/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/lib64/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['openssl', 'rsautl', '-decrypt', '-in', '/tmp/tmpe5fwdqga', '-inkey', '/tmp/tmptc9stbjt']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "RsaCtfTool.py", line 724, in <module>
    attackobj.attack()
  File "RsaCtfTool.py", line 536, in attack
    self.unciphered = self.priv_key.decrypt(self.cipher)
  File "RsaCtfTool.py", line 98, in decrypt
    return self.key.decrypt(cipher)
  File "/usr/local/lib64/python3.6/site-packages/Crypto/PublicKey/RSA.py", line 378, in decrypt
    raise NotImplementedError("Use module Crypto.Cipher.PKCS1_OAEP instead")
NotImplementedError: Use module Crypto.Cipher.PKCS1_OAEP instead

I have pycryptodome==3.6.6 installed but I get the same issue also with previews versions.

create pub key

Hi,

I receive the below error when I try to create a bub key. What I`m doing wrong?
Thanks!

python2.7 ./RsaCtfTool.py --createpub -n 046bd20f8fe764c28f5fe1c4eba69d26e0af42bf1853213d593a5098e075344d6fdc998e9c1e469cad7d799a0891f3bc47ae1f6a1eb6caabd62890a7994f4b6d5f -e 65537
Traceback (most recent call last):
File "./RsaCtfTool.py", line 679, in
args.n = int(args.n)
ValueError: invalid literal for long() with base 10: '046bd20f8fe764c28f5fe1c4eba69d26e0af42bf1853213d593a5098e075344d6fdc998e9c1e469cad7d799a0891f3bc47ae1f6a1eb6caabd62890a7994f4b6d5f'

RsaCtfTool can only be called from it's own folder

RsaCtfTool can only be called from it's own folder, from another PATH it can't find its ressources:

$ python2 ~/CTF/tools/RsaCtfTool/RsaCtfTool.py --publickey pub.key --private                                                                                                                                      
Traceback (most recent call last):
  File "/home/noraj/CTF/tools/RsaCtfTool/RsaCtfTool.py", line 370, in <module>
    attackobj.attack()
  File "/home/noraj/CTF/tools/RsaCtfTool/RsaCtfTool.py", line 261, in attack
    getattr(self, attack.__name__)()
  File "/home/noraj/CTF/tools/RsaCtfTool/RsaCtfTool.py", line 212, in pastctfprimes
    primes = [long(x) for x in open('pastctfprimes.txt','r').readlines() if not x.startswith('#') and not x.startswith('\n')]
IOError: [Errno 2] No such file or directory: 'pastctfprimes.txt'

How to solve a problem ?

C:\Users\HP>C:\Python27\RsaCtfTool\RsaCtfTool.py
Traceback (most recent call last):
File "C:\Python27\RsaCtfTool\RsaCtfTool.py", line 654, in
attackobj = RSAAttack(args)
File "C:\Python27\RsaCtfTool\RsaCtfTool.py", line 103, in init
if '*' in args.publickey or '?' in args.publickey:
TypeError: argument of type 'NoneType' is not iterable

recursion error

I tried to generate private key and get this error at the end:
File "/mnt/hgfs/shf/RsaCtfTool/p_1.py", line 7, in gcd
if b==0:
RuntimeError: maximum recursion depth exceeded in cmp
root@kali:/mnt/hgfs/shf/RsaCtfTool#

Maybe i did something wrong, but i'm sure that my data is correct.
screenshot at 2018-02-22 21-14-33

Can't run script

Hi. I already meet the requirements but I am still unable to run. Is this a bug? Thank you!

pip install -r "requirements.txt"
Requirement already satisfied: PyCrypto in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 1))
Requirement already satisfied: GMPY2 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 2))
Requirement already satisfied: SymPy in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 3))
Requirement already satisfied: requests in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 4))
Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python2.7/dist-packages (from SymPy->-r requirements.txt (line 3))
root@kali:~/RsaCtfTool# ./RsaCtfTool.py 
Traceback (most recent call last):
  File "./RsaCtfTool.py", line 17, in <module>
    import gmpy2
ModuleNotFoundError: No module named 'gmpy2'

I need your help

Hi @Ganapati ,
I was given a public key and a prime.txt file. And I was challenged to decrypt a file.
I guess I need to regenerate the private key from the public key and the prime.txt file. But I do not know how to do it.
You seem to master the subject well. Can you help me ?

error

python RsaCtfTool.py --publickey key.pub --private

Traceback (most recent call last):
  File "RsaCtfTool.py", line 488, in <module>
    attackobj.attack()
  File "RsaCtfTool.py", line 391, in attack
    getattr(self, attack.__name__)()
  File "RsaCtfTool.py", line 369, in Pollard_p_1
    self.pub_key.p, self.pub_key.q = pollard_P_1(self.pub_key.n)
TypeError: 'int' object is not iterable

Make sage calls compatible with virtual envs

I'm using RsaCtfTool in a conda env with sage installed, but the script doesn't detect it.
That's because of how the check is done: subprocess.check_output(['sage', '-v']) and all other subprocess' calls are not executed in the caller's activated conda env (same thing would happen with any other virtual env tool).
Since sage can be called directly from Python, I propose not to use it with subprocess calls anymore but to directly use imports and function calls, that way the code would be cleaner and anyone would be able to use sage without needing to install it globally.
If you agree with the idea, I could make a pull request.
And thank you for providing us with this great tool :)

2048-bit keys cracked with factordb but when I check manually on the site the modulus has not been factored!

Hi.

I almost jumped when I saw my keys were both cracked open.

[*] Multikey mode using keys: Conig1.pubkey, Conig2.pubkey
[*] Performing commonfactors attack.
[*] Performing hastads attack.
[*] Performing same_n_huge_e attack.
Sorry, cracking failed.

[*] Testing key Conig1.pubkey.
Can't load boneh_durfee because sage is not installed
Can't load ecm because sage is not installed
Can't load ecm2 because sage is not installed
Can't load qicheng because sage is not installed
Can't load smallfraction because sage is not installed
[*] Performing comfact_cn attack on Conig1.pubkey.
[*] Performing cube_root attack on Conig1.pubkey.
[*] Performing factordb attack on Conig1.pubkey.

Results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hL
bVYZB29BE78PiiXDNr6mOBCxI2IvE0Dots/lF59/9FT92QB0dP7BznkqGjcz7rD2
pDSt7e44+pzzHilEd3KiSqX2KjtXCPO4MauQqZA5r9jVsxOkyuNQtw9aFa0TLWxI
tUPMyMtL4Tfshi4HPcL+gf3yLOWnl28dYvMVNFD/eWznRIpbtysZdvFRznZyd2Vr
ItK6zRHMrryG/MaNb7TT8IK/GT5gt1ivCwrS3/lfFzhDp83FCddPzCy7t3Ne+9B9
eYF3RKTojYFiPLNMezMf5bL3Z1FNyhIbd2L33qE3ghLO5us6kLE/wEaEG8Z705zq
HdmfU43WwQIBAA==
-----END RSA PRIVATE KEY-----

[*] Testing key Conig2.pubkey.
Can't load boneh_durfee because sage is not installed
Can't load ecm because sage is not installed
Can't load ecm2 because sage is not installed
Can't load qicheng because sage is not installed
Can't load smallfraction because sage is not installed
[*] Performing comfact_cn attack on Conig2.pubkey.
[*] Performing cube_root attack on Conig2.pubkey.
[*] Performing factordb attack on Conig2.pubkey.

Results for Conig2.pubkey:

Private key :
-----BEGIN RSA PRIVATE KEY-----
MIIHKAIBAAKCAQEAvgh4mktnhIw0vX1k7h9yuiB2B97TfqIIzxCmTL6vUDjYdutM
eYDz9wBEjPMvhHUOAHrHCRmCUKC7iMGMToDqmwcd9kQs7QG7iqA0UL2OO1KJ3zTM
r29IFHRJg8fNO1olTILK7aML7qSDG+LDagfXXnw0kLuAe5lYGC0edeDi/pcyEf0S
07Bwu1HO9Aqi6TDXk7vWjyESRNIW76KzdlVdewouFrHainLNQ2no3xJvtwsPmFYJ
aGEm8Yp1MGXI4srCWpY5qjuBoss8ajpEZol3VbNhVeX2PNeRZXG8ppxoMWGG9gkD
y0nzKws5cEXMf1erZiDFrs4WmZxOJH2v0uhw3QIDAQABAoICAC0XcE5qn2xdW8kW
LGQ/+6DbWpzugzZJJRuSwpiMWndFY/x7X0j+dlXcaH+O21yobkTb6u9UNUULK0Cd
IPD8j52sBb+fL6nxKF0qpuLh3r3cVXge4l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B9defDSQu4B7mVgYLR514OL+lzIR/RLTsHC7Uc70CqLpMNeT
u9aPIRJE0hbvorN2VV17Ci4WsdqKcs1DaejfEm+3Cw+YVgloYSbxinUwZcjiysJa
ljmqO4GiyzxqOkRmiXdVs2FV5fY815FlcbymnGgxYYb2CQPLSfMrCzlwRcx/V6tm
IMWuzhaZnE4kfa/S6HDdAoIBAQCBn0ecf3ix6e0Dn+fboWnhWckI305GH4KAs2us
B5mPz+afXyq/6lz/C5i2yB6ObEXLv/PJ2jOQicLBqrvoxHjCnF0soR4/4CGrklF9
DX9aKZfPv7UqqW5yPUvz7rKoHHo6sTB4XfICqwafW9NNnOGkGnbEjpE6PcPgYc5Y
O7i6TimiKYzRBpYuv8O5pROwmldB9yuIX9eVR/TLKqDdQ6dLCQudAV3/eAVZSYHF
v06ifZH6qB0srLAiq/35sEQRppphrfzRiFuJzrV8BBiqFHRo6b2oGP8YSzZrCuTS
hPdxT4P+iPGkleGfZ72bPpEZ/5PzSsFs1jiGOR74Nx9abqClAoIBAQCBn0ecf3ix
6e0Dn+fboWnhWckI305GH4KAs2usB5mPz+afXyq/6lz/C5i2yB6ObEXLv/PJ2jOQ
icLBqrvoxHjCnF0soR4/4CGrklF9DX9aKZfPv7UqqW5yPUvz7rKoHHo6sTB4XfIC
qwafW9NNnOGkGnbEjpE6PcPgYc5YO7i6TimiKYzRBpYuv8O5pROwmldB9yuIX9eV
R/TLKqDdQ6dLCQudAV3/eAVZSYHFv06ifZH6qB0srLAiq/35sEQRppphrfzRiFuJ
zrV8BBiqFHRo6b2oGP8YSzZrCuTShPdxT4P+iPGkleGfZ72bPpEZ/5PzSsFs1jiG
OR74Nx9abqClAgEA
-----END RSA PRIVATE KEY-----```

However when I visit the site the status of the modulus is C! (not yet factored)

What is happening?? Is this a bug? I used a tool to generate public keys based on private keys and when I input my two keys, they generated the exact public ones that I cracked!

How is this possible??

All keys used are attached below.

[CONIG keys.zip](https://github.com/Ganapati/RsaCtfTool/files/4500925/CONIG.keys.zip)

Add six to requirements.txt

Add python pip package six to requirements.txt as it is required by primefac

(rsa2) plasticuproject@home:~/Envs/rsa2/RsaCtfTool$ ./RsaCtfTool.py --attack primefac --publickey nick.pub --private --verbose
[*] Performing primefac attack.
[!] Warning: primefac attack module missing
[-] Sorry, cracking failed

After adding:

except ImportError as e:
    print(e)

to lines 296 and 297 of RsaCtfTool.py I got:

(rsa2) plasticuproject@home:~/Envs/rsa2/RsaCtfTool$ ./RsaCtfTool.py --attack primefac --publickey nick.pub --private --verbose
[*] Performing primefac attack.
No module named 'six'
[!] Warning: primefac attack module missing
[-] Sorry, cracking failed

And after running:

pip install six

The script ran without error.

[Discussion] N was a 2048 bit prime

You mentioned at the end of the README.md file.

Saw a CTF where the supplied N was a 2048 bit prime. Detect this and solve using phi = (n - 1) * (n - 1) which seemed to work for that CTF

  1. Can you link me the name of the challenge and the competition name?

  2. What is the principle used in this trick phi = (n - 1) * (n - 1) ? Any technical paper I can read on?

phi(n) = phi(pq) = (p - 1)(q - 1) = pq - p - q + 1 = n - p - q + 1 = n - (p + q) + 1
phi(n) = (n - 1)
phi(nĀ²) = (n - 1)n^(2 - 1) = nĀ² - n

phi(mn) = phi(m)phi(n) if m and n are coprime integers.

  1. Would it be because p - 1 is a multiplication of low prime numbers?

If that is the case, then probably Pollard's p āˆ’ 1 algorithm was used during the CTF you saw.

Error Crypto.PublicKey

Hello,

I keep getting the following error whenever I try to run the script

Traceback (most recent call last):
  File "./RsaCtfTool.py", line 17, in <module>
    from Crypto.PublicKey import RSA
ImportError: No module named Crypto.PublicKey

I've installed all dependencies like asked in the requirements.txt

Thank you,

Wildcard is broken in publickey

Looks like wildcard is broken after this commit.

$ ./RsaCtfTool.py --publickey "*.pub" --private --verbose

Traceback (most recent call last):
  File "./RsaCtfTool.py", line 655, in <module>
    key = open(args.publickey, 'rb').read()
FileNotFoundError: [Errno 2] No such file or directory: '*.pub'

Support "uncipher(file)" with privatekey specified

It would be great, if rsactftool could easily support the decryption of a ciphertext also when you already have the private key generated (and not only the public key).

While this here works:
./RsaCtfTool.py --publickey "pub?.pem" --uncipher 88389551.....

this doesn't:

./RsaCtfTool.py --key priv1.pem --uncipher 883895515...... Traceback (most recent call last): File "./RsaCtfTool.py", line 806, in <module> attackobj = RSAAttack(args) File "./RsaCtfTool.py", line 135, in __init__ if '*' in args.publickey or '?' in args.publickey: TypeError: argument of type 'NoneType' is not iterable
It seems the cmdline parsing logic just assumes a key needs to be attacked but fails to recognize everything's given to actually do something useful.

TypeError when check sageversion (python3)

> python --version
Python 3.6.4

> ./RsaCtfTool.py -n *** -e *** --attack all
Traceback (most recent call last):
  File "./RsaCtfTool.py", line 640, in <module>
    if sageworks():
  File "./RsaCtfTool.py", line 527, in sageworks
    if 'SageMath version' in sageversion:
TypeError: a bytes-like object is required, not 'str'

it seems like subprocess.check_output of python3 returns a bytes, not a str

Floating point exception

Floating point exception when call --uncipherfile mode with previously found key. File to uncipher and pub key found in archive. Any ideas why there are exception ?
test2.zip

Convert from gmpy to gmpy2

gmpy is EoL as of 5 years ago and has since been replaced by gmpy2

gmpy is not compatible with the latest version of Visual C++ for Python causing "pip install gmpy" to fail, resulting in the inability to make use of this tool in a fully updated system.

Build using pip install -r "requirements" fails

HI,

Did a pull on 2 different Kali machines, build fails on both of them.

/RsaCtfTool$ sudo pip install -r "requirements.txt" Requirement already satisfied: PyCrypto in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 1))
Collecting GMPY2 (from -r requirements.txt (line 2))
Using cached gmpy2-2.0.8.zip
Collecting SymPy (from -r requirements.txt (line 3))
Requirement already satisfied: requests in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 4))
Collecting mpmath>=0.19 (from SymPy->-r requirements.txt (line 3))
Building wheels for collected packages: GMPY2
Running setup.py bdist_wheel for GMPY2 ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-RZJhrv/GMPY2/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /tmp/tmpkvSs1Dpip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_ext
building 'gmpy2' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-0ZUWfh/python2.7-2.7.14=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DWITHMPFR -DWITHMPC -I/usr/include/python2.7 -c src/gmpy2.c -o build/temp.linux-x86_64-2.7/src/gmpy2.o
In file included from src/gmpy2.c:426:0:
src/gmpy.h:252:12: fatal error: mpfr.h: No such file or directory

include "mpfr.h"

          ^~~~~~~~

compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1


Failed building wheel for GMPY2
Running setup.py clean for GMPY2
Failed to build GMPY2
Installing collected packages: GMPY2, mpmath, SymPy
Running setup.py install for GMPY2 ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-RZJhrv/GMPY2/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-K2mOfB-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'gmpy2' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-0ZUWfh/python2.7-2.7.14=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DWITHMPFR -DWITHMPC -I/usr/include/python2.7 -c src/gmpy2.c -o build/temp.linux-x86_64-2.7/src/gmpy2.o
In file included from src/gmpy2.c:426:0:
src/gmpy.h:252:12: fatal error: mpfr.h: No such file or directory
# include "mpfr.h"
^~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-RZJhrv/GMPY2/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-K2mOfB-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-RZJhrv/GMPY2/

Hastads failing on multi attack

I have three .pub files, and I'm trying to do a multi-attack using the latest version from GitHub, but it fails in hastads.py.

python3 ./RsaCtfTool.py --publickey "*.pub" --private
[*] Multikey mode using keys: 1.pub, 3.pub, 2.pub
[*] Performing hastads attack.
Traceback (most recent call last):
  File "./RsaCtfTool.py", line 250, in <module>
    found = attackobj.attack_multiple_keys(args.publickey, attacks_list)
  File "/blabla/RsaCtfTool/lib/rsa_attack.py", line 151, in attack_multiple_keys
    self, self.publickey, self.cipher
  File "/blabla/RsaCtfTool/attacks/multi_keys/hastads.py", line 59, in attack
    for _ in cipher:
TypeError: 'NoneType' object is not iterable

If I manually specify one of the other attack modes, it completes the run. But if I specify 'hastads' it fails with same error.

Display value of q when cracked using smallq attack

Hello,

I recently used RsaCtfTool to uncipher text which was vulnerable to a smallq attack, given n and e.

For the work I'm doing, I need to find the small value of q that was used to uncipher the text. Is it possible the q value could be added to the verbose output?

Thanks!

Factoring fails when primes are not close enough

I am trying to factor

n = 316341779932648675985791704990724089516454422587094833169408333523414739834909517309715699939317715087526517454431375116879351671364301319495659096020992713723208722190937740766450883017917635799026613109992174843186393756297174271962473795425087410844561019652906553118852648659911340204749198564105889477617

but the tool fails for this number (I guess the difference |p-q| is too large). The two primes are

p = 17785999548314642751774703489649490792859797093721105132562728724448911505635166813224212967627398814715202394464187693886191289350137588089220151890768019
q = 17785999548314642751774703489649490792859797093721105132562728724448915173277940491632723963037561789695844144194444626441506989745893161735904252626571243

I found this paper, which seems to improve the Fermat factorization https://hsbp.org/tiki-download_wiki_attachment.php?attId=174

Would you consider adding something like this?

Cheers,
James

import requests

I've messed with this for about 2 hours now. There is no solution. I am convinced this code just does not function but my current problem is with importing requests there is no module named 'requests'

Traceback (most recent call last):
File "./RsaCtfTool.py", line 22, in
import requests
ModuleNotFoundError: No module named 'requests'

I have followed the "installation guide" step by step.. I have attempted to install it myself, I have literally installed ever single python package directly into the RsaCtfTool folder, I have tried basically everything in the world.

Don't Work.

No output of private key

Used the following command:

RsaCtfTool.py --publickey public.key --private

After some minutes (2 or 3), the RsaCtfTool ends, with no output.
No errors, no information, no new files... nothing.

Error in siqs.py

~/Documents/RsaCtfTool >>> ./RsaCtfTool.py --publickey ~/key.pub --private Ā±[ā—][master]
Traceback (most recent call last):
File "./RsaCtfTool.py", line 658, in
attackobj.attack()
File "./RsaCtfTool.py", line 478, in attack
getattr(self, attack.name)()
File "./RsaCtfTool.py", line 410, in siqs
if siqsobj.checkyafu() and siqsobj.testyafu():
File "/home/astro/Documents/RsaCtfTool/siqs.py", line 39, in testyafu
if b'48670331' in yafutest:
TypeError: 'in ' requires string as left operand, not bytes

Consider adding Merssenne Prime trial division

I ran into a CTF today where the modulus was nearly entirely just a run of 1s followed by a runs of zeros. Only a couple bits flipped other than this. I realized it must be a product of two numbers very close to a power of two. Turned out to be the product of two mersenne primes. The modulus was pretty huge because the primes themselves were huge.

You might considering adding a bunch of the mersenne primes to the known primes list for trial division https://primes.utm.edu/mersenne/

Memory Error

python RsaCtfTool.py --uncipher 7022848098469230958320047471938217952907600532361296142412318653611729265921488278588086423574875352[32/43]
765943911598056510802236985767089349939516184644601094223773299727378760601679038576137632949323266192662817259004974274580478619731530125065
95691389361443123047595975834017549312356282859235890330349 --publickey public.key
[!] Warning: primefac attack module missing
Traceback (most recent call last):
  File "RsaCtfTool.py", line 807, in <module>
    attackobj.attack()
  File "RsaCtfTool.py", line 602, in attack
    getattr(self, attack.__name__)()
  File "RsaCtfTool.py", line 424, in londahl
    factors = londahl.close_factor(self.pub_key.n, londahl_b)
  File "/home/bowork/Desktop/RsaCtfTool/londahl.py", line 12, in close_factor
    look_up[z] = i
MemoryError

I get a Memory Error when trying to crack an RSA ciphertext.

cat public.key
-----BEGIN PUBLIC KEY-----
MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgFwUyakFGGdM3suv1F46d54wIp6L
Huk3va2XRn8tl+WNMyD5A3ONCTivs7LgdtAdXZ8LmfXslCfVlK01zZHzsqzdLGfr
pJ6qVubiBPGWmfPZ0YOs8vbAh0/sibOlvebaHY7wVvKF5l2igmUgJ3VEih/QNAZM
EKBYMHiIPdLXXur1AgMBAAE=
-----END PUBLIC KEY-----

And I used this to create the public key
python RsaCtfTool.py --createpub -n 64661619081566980804190100354926277870654153140456125893362948358616871347387602985767249018081090677122881379260804173643249531756962204727510922839492155437995895841992167230056775155693770862949166788493903028640851926422098808715056724371516182984131462833172570662800858803285852455362173089675686636277 -e 65537

'sage' requirement?

When running some of the attack modes I get a "Can't load (...) because sage is not installed"

F.instance: "Can't load ecm because sage is not installed".

Is there a missing requirement in requirements.txt?

invalid literal for int() with base 10

Getting error

python3 ./RsaCtfTool.py --publickey tmp1 --uncipher tmp5 --verbose
Traceback (most recent call last):
File "./RsaCtfTool.py", line 653, in
args.uncipher = int(args.uncipher)
ValueError: invalid literal for int() with base 10: 'tmp5'

tmp1

MDwwDQYJKoZIhvcNAQEBBQADKwAwKAIhALxHhYGPVMYmx3vzJbPPAEa10NETXrV3
mI9wJizmFJhrAgMBAAE=

tmp5
mTJPrVNiiaHi0Y3QImXNfxVXnWecid0ZVMjFbzeNEUk=

also tried this as uncipher file
bVRKUHJWTmlpYUhpMFkzUUltWE5meFZYbldlY2lkMFpWTWpGYnplTkVVaz0K

need help

Unknown bug with Kali Linux

Hi your tools are great. But recently, I encountered a bug, whereby my teammate can use factordb attack to break one of the RSA, but I am unable to do so with the exact same numbers. We both ran it in auto mode, however his breaks the RSA and mine dosen't. We are using 2 different versions of Kali Linux with mine being the latest and his slightly older. Thanks. I am not too sure if I can provide the test case yet as it may not be ready for release yet.

This is mine:
No LSB modules are available.
Distributor ID: Kali
Description: Kali GNU/Linux Rolling
Release: kali-rolling
Codename: kali-rolling

Error on Pollard_p_1 attack

[*] Performing Pollard_p_1 attack.
Traceback (most recent call last):
File "/home/kali/pentest/tools/RsaCtfTool/RsaCtfTool.py", line 488, in
attackobj.attack()
File "/home/kali/pentest/tools/RsaCtfTool/RsaCtfTool.py", line 391, in attack
getattr(self, attack.name)()
File "/home/kali/pentest/tools/RsaCtfTool/RsaCtfTool.py", line 369, in Pollard_p_1
self.pub_key.p, self.pub_key.q = pollard_P_1(self.pub_key.n)
TypeError: 'int' object is not iterable

Warning: Modulus too large for SIQS attack module

./RsaCtfTool.py --publickey public.key --verbose

[] Performing Pollard_p_1 attack.
[
] Performing hastads attack.
[] Performing factordb attack.
[
] Performing pastctfprimes attack.
[] Loaded 71 primes
[
] Performing noveltyprimes attack.
[] Performing smallq attack.
[
] Performing wiener attack.
[] Performing comfact_cn attack.
[
] Performing fermat attack.
[] Performing siqs attack.
[
] Warning: Modulus too large for SIQS attack module

Update MacOS requirements

Hi,
for MacOS the requirements should be installed with
pip install -r requirements (there is no space in the readme)
and PyCrypto should be changed to pycryptodome in the requirements.txt:

pycryptodome
GMPY2
SymPy
requests
six
cryptography

Find d when n is prime

We encountered a ctf challenge, where n was prime and tried to solve it with RsaCtfTool.

Attached to the issue is our java code, the public key and the secret. Would be cool if you could add this to the tool.

SolveDwhenNisPrime.zip

Can't install gmpy2

Running setup.py install for GMPY2 ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-9nkaidrb/GMPY2/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-4h9b9_t_-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'gmpy2' extension
creating build
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DWITHMPFR -DWITHMPC -I/usr/include/python3.5m -c src/gmpy2.c -o build/temp.linux-x86_64-3.5/src/gmpy2.o
In file included from src/gmpy2.c:426:0:
src/gmpy.h:106:19: fatal error: gmp.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.