看了WP才知道,pem文件是公钥文件,里面包含了加密过程的e和大素数n,而flag.enc文件则是该加密过程得到的密文。
首先,用kali中自带的openssl工具对pem文件中的e和n进行提取
可知,e=65537,
Modules(十六进制)=C2636AE5C3D8E43FFB97AB09028F1AAC6C0BF6CD3D70EBCA281BFFE97FBE30DD
转为十进制得Modules(十进制)=87924348264132406875276140514499937145050893665602592992418171647042491658461
找个在线工具http://www.factordb.com/分解一下,得到两个大素数分别为p=275127860351348928173285174381581152299
q=319576316814478949870590164193048041239
通过p,q,e,我们就可以得到私钥d,然后直接上脚本用python中的rsa的包得到flag:
import gmpy2
import rsa
p = 275127860351348928173285174381581152299
q = 319576316814478949870590164193048041239
N = 87924348264132406875276140514499937145050893665602592992418171647042491658461
e = 65537
d = int(gmpy2.invert(e,(p-1)*(q-1)))
privatekey = rsa.PrivateKey(N,e,d,p,q)
s = open("flag.enc","rb")
print(rsa.decrypt(s.read(),privatekey).decode())
标签:87924348264132406875276140514499937145050893665602592992418171647042491658461,攻防 From: https://www.cnblogs.com/Athena-ydy/p/17360233.html