道隐于小成,言隐于荣华

实验吧 rsarsa crypto Writeup

该部分为本科期间实验吧题解wp备份。

题目

Math is cool! Use the RSA algorithm to decode the secret message, c, p, q, and e are parameters for the RSA algorithm.
解题链接: http://ctf5.shiyanbar.com/crypto/rsarsa/rsa.txt

思路

打开链接获取得到rsa.txt内容:

p =  9648423029010515676590551740010426534945737639235739800643989352039852507298491399561035009163427050370107570733633350911691280297777160200625281665378483
q =  11874843837980297032092405848653656852760910154543380907650040190704283358909208578251063047732443992230647903887510065547947313543299303261986053486569407
e =  65537
c = 83208298995174604174773590298203639360540024871256126892889661345742403314929861939100492666605647316646576486526217457006376842280869728581726746401583705899941768214138742259689334840735633553053887641847651173776251820293087212885670180367406807406765923638973161375817392737747832762751690104423869019034
# Use RSA to find the secret message

显然这是个很中规中矩的rsa习题,p、q、e、c都挺大的,但是针对rsa大数处理我们可以使用gmpy2这个库。

gmpy2 documention:https://gmpy2.readthedocs.io/en/latest/

以下是计算脚本:

p =  9648423029010515676590551740010426534945737639235739800643989352039852507298491399561035009163427050370107570733633350911691280297777160200625281665378483
q =  11874843837980297032092405848653656852760910154543380907650040190704283358909208578251063047732443992230647903887510065547947313543299303261986053486569407
e =  65537
c =  83208298995174604174773590298203639360540024871256126892889661345742403314929861939100492666605647316646576486526217457006376842280869728581726746401583705899941768214138742259689334840735633553053887641847651173776251820293087212885670180367406807406765923638973161375817392737747832762751690104423869019034
from gmpy2 import *
d=invert(e,(q-1)*(p-1))
n=mul(p,q)
a=powmod(c,d,n)
print(a)
posted @ 2022-05-06 16:15  FrancisQiu  阅读(10)  评论(0)    收藏  举报