安全-rsarsa(BUUCTF)
Posted 小狐狸FM
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安全-rsarsa(BUUCTF)相关的知识,希望对你有一定的参考价值。
前言
如果安装
gmpy2
的时候报错,可以看下方的文章
一、题目
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
二、WriteUp
目前已知的量是
p、q、e、c
求m
使用gmpy2
来求解d
# coding=utf-8
# 作者:小狐狸FM
import gmpy2
p = int(input("p:"))
q = int(input("q:"))
e = int(input("e:"))
c = int(input("c:"))
n = p*q
fn = (p-1) * (q-1) #欧拉函数
d = int(gmpy2.invert(e,fn))
m = pow(c,d,n)
print("m:",m)
以上是关于安全-rsarsa(BUUCTF)的主要内容,如果未能解决你的问题,请参考以下文章