Created
December 16, 2018 02:45
-
-
Save ducnhse130201/4cd495f2ecd989d59b38511fc1682a3d to your computer and use it in GitHub Desktop.
matesS3R2(CryptoX_solve.sage)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sage.all import * | |
from Crypto.Util.number import * | |
#Common Modulus attack | |
def common_modulus_attack(c1,c2,e1,e2,n): | |
print '-----------------------------------Starting Common modulus attack ...----------------------------' | |
g,a,b = xgcd(e1,e2) | |
print a,b | |
c1 = pow(c1,a,n) | |
c2 = pow(c2,b,n) | |
m = int(c1*c2) | |
m = pow(m,1/g) | |
print 'Found plaintext: ' | |
print long_to_bytes(m) | |
n = 16551607791513310143367718420160496017716438900159843171951158812834625404025819000006450794387195406345952438600612732574009790172009017187068132583686325525604998698900736192681010644918133643334867213766651610742025315226553357161124371160165728228238808856850234798660237966304139110197982306465482087141 | |
e1 = 65537 | |
e2 = 65539 | |
c1 = 1129577506068504469345887363147787486017374614115334845659793955402788290276839150314266230618914458454490822134129029320196215857189604704858201914703171395094716563126451957806227382204438629408146257354346918995020514101912710194471044390206478595928893069122774855951576832331537914647316369902972676419 | |
c2 = 2312267001662149847216610383002454962845172172590149633659040319002856658500558236678068991511310275065117853509318224378486528518801367253730813242027077527555556802869225370500266724893566221191787616000347525781413708804332132838890466815970966346122371108786541601825960204632255691107425283995717582890 | |
common_modulus_attack(c1,c2,e1,e2,n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment