题目链接
https://buuoj.cn/challenges#rsa
题解(略)
百度有很多博客可以参考。
用010editor打开pub.key文件查看公钥
直接挂两个工具链接:
由公钥文件得到n,e
然后要将模数n改成10进制的,脚本如下
hex = "C0332C5C64AE47182F6C1C876D42336910545A58F7EEFEFC0BCAAF5AF341CCDD"
print(int(hex,16))
python的问题
然后写脚本,很诡异,我的Python2安装了rsa,也安装了pycrypto,也安装了Crypto,在site-packages文件夹下都有,但跑脚本就是报错。而gmpy2我也只有Python2安装了,随后我发现Python3的rsa可以用,于是写了俩脚本,分开跑。
Python2的:
import gmpy2
p = 285960468890451637935629440372639283459
q = 304008741604601924494328155975272418463
n = 86934482296048119190666062003494800588905656017203025617216654058378322103517
e = 65537
phin= (p-1)*(q-1)
d = gmpy2.invert(e,phin)
print(d)
将得到的d代入下面Python3的代码里:
import rsa
p = 285960468890451637935629440372639283459
q = 304008741604601924494328155975272418463
n = 86934482296048119190666062003494800588905656017203025617216654058378322103517
e = 65537
d= int("81176168860169991027846870170527607562179635470395365333547868786951080991441")
key = rsa.PrivateKey(n,e,int(d),p,q)
c = open('d:\我不做人啦\今天你做题了吗\output\flag.enc','rb')
c = c.read()
print(rsa.decrypt(c,key))