[SWPU 2020]happy
作者:互联网
题目:
('c=', '0x7a7e031f14f6b6c3292d11a41161d2491ce8bcdc67ef1baa9eL') ('e=', '0x872a335') #q + q*p^3 =1285367317452089980789441829580397855321901891350429414413655782431779727560841427444135440068248152908241981758331600586 #qp + q *p^2 = 1109691832903289208389283296592510864729403914873734836011311325874120780079555500202475594
解题:
q+q*p^3=s1 q*p+q*p^2=s2 q*(1+p^3)=s1->q*(1+p)*(p^2-p+1)=s1 q*p*(1+p)=s2 q*(1+p)=gmpy2.gcd(s1,s2) p=s2//gmpy2.gcd(s1,s2) q=gmpy2.gcd(s1,s2)//(1+p)
print("p =",p)
print("q =",q)
#p = 1158310153629932205401500375817
#q = 827089796345539312201480770649
import gmpy2 from Crypto.Util.number import * c = 0x7a7e031f14f6b6c3292d11a41161d2491ce8bcdc67ef1baa9e e = 0x872a335 q = 827089796345539312201480770649 p = 1158310153629932205401500375817 n = p*q d = gmpy2.invert(e,(p-1)*(q-1)) m = pow(c,d,n) print(long_to_bytes(m))
解得:flag{happy_rsa_1}
标签:gmpy2,gcd,1158310153629932205401500375817,s2,s1,2020,print,happy,SWPU 来源: https://www.cnblogs.com/Clair-is-com/p/16469933.html