密钥文件无法使用openssl解出,e=3,n很大,低加密指数攻击
题目给出public.txt与secret.txt:
题目
使用openssL无法解出:n,e;观察public.txt中内容与以前所见到的不一样:
-----BEGIN RSA PUBLIC KEY-----
MIIBCAKCAQEAsKE2J66COeSM8Adt6nrijJZ1HahnRUK2P/9GVIb+bu/gObCWuGdH
N5BcSRUzlux6Ri65r2ITJNdgYA1hFnJQlf1t0BzC8Z6/msn1N6/oQjCBHsF5YGeH
m9s4l6JNI3HcWpmi9JXnRAT4a319EjJG7Sba1Rny1gMvrYsxi2bmqy5LP1NLl2g+
IA1ykv5vttwZhm6rOY8x03aG+vJ/rzOlYFtNHBMk8z+lm8Hwqb0kEmFPqZHuSB4p
EipjtNCS+CNs+/3sMPIH99/n36RtaHlLfkWr8PAEWGOPjbbq95foVBteWvgGJi+K
CTUE7ZmIqMgUYazIStc8yv/aBiN+pIM8WwIBAw==
-----END RSA PUBLIC KEY-----
使用RsaCtfTool即可解出:
python3 RsaCtfTool.py --dumpkey --publickey pubkey.txt
结果
n:22297438048747269084668540548451075863697230316653829979974766264037201288683962161805975218606091995006130774808955539752875140782316727212105999696527131465934655046004790537960872091980166123411315052309079498420607841421247264531922117703195318039364311581700525131351979022710906386748056454542460271638541382899446214550199566437929001010047362849553798762483138636321018729693026538570107613275416663305123403057997135200290324262461965489374460932097451640809963516688449930838072464936715548241448176034327352770246471027737140032671088236665050898710889588790999714069123042393091902555727321368525503937627
e:3
解密脚本如下:
import gmpy2
from Crypto.Util.number import *
i = 0
with open('secret.txt', 'rb') as f:
hex_c = f.read()
c = int.from_bytes(hex_c, byteorder='big')
n = 22297438048747269084668540548451075863697230316653829979974766264037201288683962161805975218606091995006130774808955539752875140782316727212105999696527131465934655046004790537960872091980166123411315052309079498420607841421247264531922117703195318039364311581700525131351979022710906386748056454542460271638541382899446214550199566437929001010047362849553798762483138636321018729693026538570107613275416663305123403057997135200290324262461965489374460932097451640809963516688449930838072464936715548241448176034327352770246471027737140032671088236665050898710889588790999714069123042393091902555727321368525503937627
e = 3
while 1:
if(gmpy2.iroot(c+i*n, e)[1] == 1):
tmp = gmpy2.iroot(c+i*n, 3)[0]
break
i = i+1
print(long_to_bytes(tmp))
题目分享:
链接:https://pan.baidu.com/s/1J_4iTZ0h8buGwl-uwGnY7A
提取码:420r
网友评论