这次拿到题目后, 最起码还能推测出解题思路了, 不过因为不够成熟, 还是习惯性的去看看其他师傅写的wp.
题目给了个公钥文件public.key
,使用openssl解码得出n(Modules
)与e(Exponent
)
命令:
openssl rsa -pubin -text -modulus -in warmup -in 文件路径
n为16进制数字, 先转为10进制后,
不是很长, 使用yafu或factordb.com分解出p和q
于是, 该有的参数都有了, 就可以开始解密了
(这里用了师傅的脚本)
import gmpy2
import rsa
p = 302825536744096741518546212761194311477
q = 325045504186436346209877301320131277983
n = 98432079271513130981267919056149161631892822707167177858831841699521774310891
e = 65537
d = int(gmpy2.invert(e, (p - 1) * (q - 1)))
private_key = rsa.PrivateKey(n, e, d, p, q)
with open('encrypted.message1', 'rb') as f:
print(rsa.decrypt(f.read(), private_key).decode())
with open('encrypted.message2', 'rb') as f:
print(rsa.decrypt(f.read(), private_key).decode())
with open('encrypted.message3', 'rb') as f:
print(rsa.decrypt(f.read(), private_key).decode())
然后输出三行被拆分的flag(这里就不放了)
gmpy2还有rsa库整起来好麻烦=-=, 还以为conda默认带了
拖了好多天的wp终于填完了, 离flag渐行渐远=.=!!
今天才发现自己把n的生成方法搞成p * q
了, 我好菜(哭哭)
参考链接: