import Crypto
import binascii
from Crypto.PublicKey import RSA
from Crypto.Util.number import long_to_bytes,bytes_to_long
import gmpy2
import rsa
r=open('pub.key').read()
pub=RSA.importKey(r)
n=pub.n
e=pub.e
print n
print e
p = 285960468890451637935629440372639283459
q = 304008741604601924494328155975272418463
phi = (p-1)*(q-1)
d= gmpy2.invert(e,phi)
key = rsa.PrivateKey(n, e, int(d), p, q)
with open("flag.enc", "rb") as f:
f = f.read()
print(rsa.decrypt(f, key))
Buuctf RSA 详细题解
最新推荐文章于 2024-02-03 22:37:11 发布