题目如下:
from Crypto.Util.number import *
from flag import *
n1 = 103835296409081751860770535514746586815395898427260334325680313648369132661057840680823295512236948953370895568419721331170834557812541468309298819497267746892814583806423027167382825479157951365823085639078738847647634406841331307035593810712914545347201619004253602692127370265833092082543067153606828049061
n2 = 115383198584677147487556014336448310721853841168758012445634182814180314480501828927160071015197089456042472185850893847370481817325868824076245290735749717384769661698895000176441497242371873981353689607711146852891551491168528799814311992471449640014501858763495472267168224015665906627382490565507927272073
e = 65537
m = bytes_to_long(flag)
c = pow(m, e, n1)
c = pow(c, e, n2)
print("c = %d" % c)
# output
# c = 60406168302768860804211220055708551816238816061772464557956985699400782163597251861675967909246187833328847989530950308053492202064477410641014045601986036822451416365957817685047102703301347664879870026582087365822433436251615243854347490600004857861059245403674349457345319269266645006969222744554974358264
由题目所给的python文件得到了n1,n2,e,c的值,在rsa加密算当中,n=p*q,这里有两个n,也就是说对m进行了两次加密,以根据加密的n去求出d,因为n1,n2的值都比较大,直接去求p和q都不太现实,所以就要看n1和n2有什么共用的素数(假设求出来的是q,类似于求最大公因数?),然后求出p1,p2;再分别求出两次加密的d1,d2,;再将c带入到d2中进行解密,再带入到d1中进行解密就可以求出m。
脚本如下(找的大佬的脚本):
# *******************************
# @author:Kit
# @description:rsa 模不互素
# @time:2023/11/18
import gmpy2
from Crypto.Util.number import *
# output
c = 60406168302768860804211220055708551816238816061772464557956985699400782163597251861675967909246187833328847989530950308053492202064477410641014045601986036822451416365957817685047102703301347664879870026582087365822433436251615243854347490600004857861059245403674349457345319269266645006969222744554974358264
e = 65537
n1 = 103835296409081751860770535514746586815395898427260334325680313648369132661057840680823295512236948953370895568419721331170834557812541468309298819497267746892814583806423027167382825479157951365823085639078738847647634406841331307035593810712914545347201619004253602692127370265833092082543067153606828049061
n2 = 115383198584677147487556014336448310721853841168758012445634182814180314480501828927160071015197089456042472185850893847370481817325868824076245290735749717384769661698895000176441497242371873981353689607711146852891551491168528799814311992471449640014501858763495472267168224015665906627382490565507927272073
q = gmpy2.gcd(n1, n2)
q1 = n1 // q
q2 = n2 // q
d1 = gmpy2.invert(e, (q1 - 1) * (q - 1))
d2 = gmpy2.invert(e, (q2 - 1) * (q - 1))
m1 = pow(c, d2, n2)
m2 = pow(m1, d1, n1)
flag = ''
flag = long_to_bytes(m2)
print(flag)
运行可得flag