题目:
-----BEGIN PUBLIC KEY-----
MDwwDQYJKoZIhvcNAQEBBQADKwAwKAIhAMAzLFxkrkcYL2wch21CM2kQVFpY9+7+
/AvKr1rzQczdAgMBAAE=
-----END PUBLIC KEY-----
首先,审计题目,我们可知道public key
于是,使用分解公匙的工具具将其分解:
我们可以求出:e:65537
n:86934482296048119190666062003494800588905656017203025617216654058378322103517
于是,分解质因数:可得p和q分别为,.将n分解为p和q
p = 1201147059438530786835365194567
q = 1212112637077862917192191913841
于是,写出解题代码:
import gmpy2
import rsa
p = 1201147059438530786835365194567
q = 1212112637077862917192191913841
n=86934482296048119190666062003494800588905656017203025617216654058378322103517
e=65537
phi=(p-1)*(q-1)
d=gmpy2.invert(e,phi)
key = rsa.PrivateKey(n, e, d, p, q)
print(key)
with open("flag.enc","rb") as f:
print(rsa.decrypt(f.read(), key).decode())
可得出flag