[HDCTF2019]basic rsa
题目描述:得到的 flag 请包上 flag{} 提交。
解题步骤:打开附件python文件
import gmpy2
from Crypto.Util.number import *
from binascii import a2b_hex, b2a_hex
flag = "*****************"
p = 262248800182277040650192055439906580479
q = 262854994239322828547925595487519915551
e = 65533
n = p * q
c = pow(int(b2a_hex(flag), 16), e, n)
print c
# 27565231154623519221597938803435789010285480123476977081867877272451638645710
题目给出p,q,e,c,c就是#后的数:
27565231154623519221597938803435789010285480123476977081867877272451638645710了,相当于已知p,q,e,c,n,求M即可
exp如下:
import gmpy2
import libnum
p = 262248800182277040650192055439906580479
q = 262854994239322828547925595487519915551
e = 65533
n = p * q
c = 27565231154623519221597938803435789010285480123476977081867877272451638645710
phi = (p - 1) * (q - 1)
d = gmpy2.invert(e, phi)
M = pow(c, d, n)
print libnum.n2s(M)
运行得到结果flag
flag:flag{B4by_Rs4}