【buuctf】rsarsa writeup
思路: RSA 算法
题目:

压缩包内容:
Math is cool! Use the RSA algorithm to decode the secret message, c, p, q, and e are parameters for the RSA algorithm.
p = 9648423029010515676590551740010426534945737639235739800643989352039852507298491399561035009163427050370107570733633350911691280297777160200625281665378483
q = 11874843837980297032092405848653656852760910154543380907650040190704283358909208578251063047732443992230647903887510065547947313543299303261986053486569407
e = 65537
c = 83208298995174604174773590298203639360540024871256126892889661345742403314929861939100492666605647316646576486526217457006376842280869728581726746401583705899941768214138742259689334840735633553053887641847651173776251820293087212885670180367406807406765923638973161375817392737747832762751690104423869019034
Use RSA to find the secret message
具体步骤:
Step1:
RSA 算法核心流程
RSA 解密的关键步骤包括:
计算模数 n=p×q
计算欧拉函数 ϕ(n)=(p−1)(q−1)
求解私钥指数 d≡e^−1modϕ(n)
解密计算 m≡cdmodn
将十进制明文 m 转换为目标格式(如 ASCII 字符串或数字序列)。
Step2:
# RSA解密
p = 9648423029010515676590551740010426534945737639235739800643989352039852507298491399561035009163427050370107570733633350911691280297777160200625281665378483
q = 11874843837980297032092405848653656852760910154543380907650040190704283358909208578251063047732443992230647903887510065547947313543299303261986053486569407
e = 65537
c = 83208298995174604174773590298203639360540024871256126892889661345742403314929861939100492666605647316646576486526217457006376842280869728581726746401583705899941768214138742259689334840735633553053887641847651173776251820293087212885670180367406807406765923638973161375817392737747832762751690104423869019034
# 计算 模数n 和 欧拉函数ϕ(n)
n = p * q
ϕn = (p - 1) * (q - 1)
# 计算私钥d,满足(d*e) mod ϕ(n)=1
d = pow(e, -1, ϕn)
# 解密得到明文m ,满足m=c^d mod n
m = pow(c, d, n)
# 转换为字符串并生成Flag
secret_message = str(m)
flag = f"flag{{{secret_message}}}"
print("解密后的Flag为:", flag)
结果: flag{5577446633554466577768879988}

被折叠的 条评论
为什么被折叠?



