Skip to content

Instantly share code, notes, and snippets.

@AwwalQuan
AwwalQuan / rsa_key_extractor.py
Last active December 10, 2020 14:19
A script to find the common factor between two related RSA public keys and regenerate the unknown private keys
from Crypto.PublicKey import RSA
import gmpy
#Switch to python2 in the code doesn't work on python3. Simple change the input to raw_input
n1 = long(input("Insert first pub key (n1): "))
n2 = long(input("Insert second pub key (n2): "))
#Replicate the values of n1 and n2 before carrying out GCD operation
num1=long(n1)
num2=long(n2)