Gn taj xirly gf Fxgjuakd, oe igywnd mt tegbs mnrxxlrivywd sngearbsw wakksre. Bs kpimj gf tank, it bx gur bslenmngn th jfdetagur mt ceei yze Ugnled Lystel tx Amxwaca gjmtrtq.
An taj wvegy gf tank nom xmccxjvinz, bw prhugse ts sllbffce hs lhe ytdlopnfg btxas wbyz Meqnuo: Tafl we lmsll ffce wtw logxyzer tsv madj heavj logxyzer. Pj khaeq yivLNUTF{4695vft9-fd68-4684-uj81-u6c1avg6uaft}j yenxwgus ynfanvnsl snuhorm, ffd ag zfdekxlanwnfg og tmr ptwl thty Eexbhg is mt jechsiuek yze lhxl tekwatokd an Nxb Eexbhg, Teqfk, anw Fjizhss. Thx iwtabqk of ljltlxrwnt tww leyy lo yhz.
Qou tww inlyjucmjv to bsxorf yze Pkjkidxsl [of Fjpich] tx thx ftovx nf thx ljeamjkt chsxidxsue al xgon tx at il hwrttnf thty lhekj oile gw an hzlbrxfc of pfj wimm lhe Nsatew Xlatxx snd lzygely lham yze Pkjkidxsl, on ank owg nfitbflivx, nfvimj Bapts lo ifrwdityw adajjenvj oita yzis iqsn; am yze strw tifj, gffxw lo mxiaatx gwtwxjf Jaiff anw tmrsxqnes.
Iqwasx hsll mt lhe tylenmngn oy yze Pkjkidxsl thty lhe kzlhlxxk emiqgymxsl of hzj suursrigjk nop txfekx lhe iwgspxhl of vtepeeqang Xsylagi lo mtpw pethw in t kww mhslhs.
On the first of February, we intend to begin unrestricted submarine warfare. In spite of this, it is our intention to endeavour to keep the United States of America neutral.
In the event of this not succeeding, we propose an alliance on the following basis with Mexico: That we shall make war together and make peace together. We shall givSICTF{4695cab9-fd68-4684-be81-c6c1acb6cafa}e generous financial support, and an understanding on our part that Mexico is to reconquer the lost territory in New Mexico, Texas, and Arizona. The details of settlement are left to you.
You are instructed to inform the President [of Mexico] of the above in the greatest confidence as soon as it is certain that there will be an outbreak of war with the United States and suggest that the President, on his own initiative, invite Japan to immediate adherence with this plan; at the same time, offer to mediate between Japan and ourselves.
Please call to the attention of the President that the ruthless employment of our submarines now offers the prospect of compelling England to make peace in a few months.
from Crypto.Util.number import * from enc import flag
m = bytes_to_long(flag) defgen_keys(bits): while1: p = getPrime(bits) q = sum([p**i for i inrange(7)]) if isPrime(q): r = getPrime(1024) n = p*q*r return p,n p,n = gen_keys(512) e = 65537 c = pow(m,e,n) print(f"n = {n}") print(f"e = {e}") print(f"c = {c}") ''' n = 8361361624563191168612863710516449028280757632934603412143152925186847721821552879338608951120157631182699762833743097837368740526055736516080136520584848113137087581886426335191207688807063024096128001406698217998816782335655663803544853496060418931569545571397849643826584234431049002394772877263603049736723071392989824939202362631409164434715938662038795641314189628730614978217987868150651491343161526447894569241770090377633602058561239329450046036247193745885174295365633411482121644408648089046016960479100220850953009927778950304754339013541019536413880264074456433907671670049288317945540495496615531150916647050158936010095037412334662561046016163777575736952349827380039938526168715655649566952708788485104126900723003264019513888897942175890007711026288941687256962012799264387545892832762304320287592575602683673845399984039272350929803217492617502601005613778976109701842829008365226259492848134417818535629827769342262020775115695472218876430557026471282526042545195944063078523279341459199475911203966762751381334277716236740637021416311325243028569997303341317394525345879188523948991698489667794912052436245063998637376874151553809424581376068719814532246179297851206862505952437301253313660876231136285877214949094995458997630235764635059528016149006613720287102941868517244509854875672887445099733909912598895743707420454623997740143407206090319567531144126090072331 e = 65537 c = 990174418341944658163682355081485155265287928299806085314916265580657672513493698560580484907432207730887132062242640756706695937403268682912083148568866147011247510439837340945334451110125182595397920602074775022416454918954623612449584637584716343806255917090525904201284852578834232447821716829253065610989317909188784426328951520866152936279891872183954439348449359491526360671152193735260099077198986264364568046834399064514350538329990985131052947670063605611113730246128926850242471820709957158609175376867993700411738314237400038584470826914946434498322430741797570259936266226325667814521838420733061335969071245580657187544161772619889518845348639672820212709030227999963744593715194928502606910452777687735614033404646237092067644786266390652682476817862879933305687452549301456541574678459748029511685529779653056108795644495442515066731075232130730326258404497646551885443146629498236191794065050199535063169471112533284663197357635908054343683637354352034115772227442563180462771041527246803861110504563589660801224223152060573760388045791699221007556911597792387829416892037414283131499832672222157450742460666013331962249415807439258417736128976044272555922344342725850924271905056434303543500959556998454661274520986141613977331669376614647269667276594163516040422089616099849315644424644920145900066426839607058422686565517159251903275091124418838917480242517812783383 '''
n = 8361361624563191168612863710516449028280757632934603412143152925186847721821552879338608951120157631182699762833743097837368740526055736516080136520584848113137087581886426335191207688807063024096128001406698217998816782335655663803544853496060418931569545571397849643826584234431049002394772877263603049736723071392989824939202362631409164434715938662038795641314189628730614978217987868150651491343161526447894569241770090377633602058561239329450046036247193745885174295365633411482121644408648089046016960479100220850953009927778950304754339013541019536413880264074456433907671670049288317945540495496615531150916647050158936010095037412334662561046016163777575736952349827380039938526168715655649566952708788485104126900723003264019513888897942175890007711026288941687256962012799264387545892832762304320287592575602683673845399984039272350929803217492617502601005613778976109701842829008365226259492848134417818535629827769342262020775115695472218876430557026471282526042545195944063078523279341459199475911203966762751381334277716236740637021416311325243028569997303341317394525345879188523948991698489667794912052436245063998637376874151553809424581376068719814532246179297851206862505952437301253313660876231136285877214949094995458997630235764635059528016149006613720287102941868517244509854875672887445099733909912598895743707420454623997740143407206090319567531144126090072331 e = 65537 c = 990174418341944658163682355081485155265287928299806085314916265580657672513493698560580484907432207730887132062242640756706695937403268682912083148568866147011247510439837340945334451110125182595397920602074775022416454918954623612449584637584716343806255917090525904201284852578834232447821716829253065610989317909188784426328951520866152936279891872183954439348449359491526360671152193735260099077198986264364568046834399064514350538329990985131052947670063605611113730246128926850242471820709957158609175376867993700411738314237400038584470826914946434498322430741797570259936266226325667814521838420733061335969071245580657187544161772619889518845348639672820212709030227999963744593715194928502606910452777687735614033404646237092067644786266390652682476817862879933305687452549301456541574678459748029511685529779653056108795644495442515066731075232130730326258404497646551885443146629498236191794065050199535063169471112533284663197357635908054343683637354352034115772227442563180462771041527246803861110504563589660801224223152060573760388045791699221007556911597792387829416892037414283131499832672222157450742460666013331962249415807439258417736128976044272555922344342725850924271905056434303543500959556998454661274520986141613977331669376614647269667276594163516040422089616099849315644424644920145900066426839607058422686565517159251903275091124418838917480242517812783383 k = 7
R = Zmod(n)["x"] whileTrue: Q = R.quo(R.random_element(k)) pp = gcd(ZZ(list(Q.random_element() ^ n)[1]), n) if pp != 1: qq = sum([pp**i for i inrange(k)]) rr = n // (pp * qq) assert n == pp * qq * rr break phi = (pp - 1) * (qq - 1) * (rr - 1) d = pow(e, -1, phi) m = pow(c, d, n) print(long_to_bytes(int(m))) # SICTF{d9428fc7-fa3a-4096-8ec9-191c0a4562ff}
easyLattice
task.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
from Crypto.Util.number import * from secret import flag import gmpy2
assertlen(flag) == 47
f = bytes_to_long(flag) p = getPrime(512) g = getPrime(128) h = gmpy2.invert(f, p) * g % p
print('h =', h) print('p =', p)
""" h = 9848463356094730516607732957888686710609147955724620108704251779566910519170690198684628685762596232124613115691882688827918489297122319416081019121038443 p = 11403618200995593428747663693860532026261161211931726381922677499906885834766955987247477478421850280928508004160386000301268285541073474589048412962888947 """
h = 9848463356094730516607732957888686710609147955724620108704251779566910519170690198684628685762596232124613115691882688827918489297122319416081019121038443 p = 11403618200995593428747663693860532026261161211931726381922677499906885834766955987247477478421850280928508004160386000301268285541073474589048412962888947 T = 2^250
from Crypto.Util.number import * from enc import flag
defDecimal_conversion(num): if num == 0: return'0' digits = [] while num: digits.append(str(num % 5)) num //= 5 return''.join(reversed(digits))
m = bytes_to_long(flag) p = getPrime(512) q = getPrime(512) e = 65537 n = p*q c = pow(m,e,n) print(f"leak = {Decimal_conversion(p)[:112]}") print(f"n = {n}") print(f"e = {e}") print(f"c = {c}")
''' leak = 2011133132443111302000224204142244403203442000141102312242343143241244243020003333022112141220422134444214010012 n = 85988668134257353631742597258304937106964673395852009846703777410474172989069717247424903079500594820235304351355706519069516847244761609583338251489134035212061654870087550317540291994559481862615812258493738064606592165529948648774081655902831715928483206013332330998262897765489820121129058926463847702821 e = 65537 c = 64708526479058278743788046708923650158905888858865427385501446781738669889375403360886995849554813207230509920789341593771929287415439407977283018525484281064769128358863513387658744063469874845446480637925790150835186431234289848506337341595817156444941964510251032210939739594241869190746437858135599624562 '''
from Crypto.Util.number import * import gmpy2 from tqdm import *
leak = "2011133132443111302000224204142244403203442000141102312242343143241244243020003333022112141220422134444214010012" n = 85988668134257353631742597258304937106964673395852009846703777410474172989069717247424903079500594820235304351355706519069516847244761609583338251489134035212061654870087550317540291994559481862615812258493738064606592165529948648774081655902831715928483206013332330998262897765489820121129058926463847702821 e = 65537 c = 64708526479058278743788046708923650158905888858865427385501446781738669889375403360886995849554813207230509920789341593771929287415439407977283018525484281064769128358863513387658744063469874845446480637925790150835186431234289848506337341595817156444941964510251032210939739594241869190746437858135599624562
deffive_to_ten(num): temp = 0 i = 109 for j inreversed(num): temp += int(j) * 5**i i += 1 return temp
leak = five_to_ten(leak) gift = leak >> 256
for i in trange(2^8): ph = gift << 8 phigh = ph + i phigh = phigh << 248 R.<x> = PolynomialRing(Zmod(n)) f = phigh + x res = f.small_roots(X=2^248, beta=0.4, epsilon=0.01) if res != []: p = phigh + int(res[0]) q = n // p d = gmpy2.invert(e,(p-1)*(q-1)) m = pow(c,d,n) print(f"i = {i}") print(long_to_bytes(int(m))) break
t = gmpy2.gcd(e1,e2) if t == 1: s,x,y = gmpy2.gcdext(e1,e2) m = (pow(c1,x,n)*pow(c2,y,n))%n print(long_to_bytes(m)) else: s,x,y = gmpy2.gcdext(e1,e2) k = 0 while1: m = gmpy2.iroot((pow(c1,x,n)*pow(c2,y,n)+k*n)%n,t) if m[1]: print(long_to_bytes(m[0])) break else: k += 1 # SICTF{S0_Great_RSA_Have_Y0u_Learned?}
a = ZZ(-I.groebner_basis()[0].univariate_polynomial()(0)) b = ZZ(-I.groebner_basis()[1].univariate_polynomial()(0)) x = ZZ(-I.groebner_basis()[2].univariate_polynomial()(0)) print(f"a = {a}") print(f"b = {b}") print(f"x = {x}")
X = [x] for i inrange(6): x = (a * x + b) % p X.append(x) R.<m> = PolynomialRing(GF(p)) f = X[1] + X[2]*m + X[3]*m^2 + X[4]*m^3 + X[5]*m^4 + X[6]*m^5 - enc_flag res = f.roots() m = res[0][0] flag = long_to_bytes(int(m)) print(flag) # SICTF{Th3s_1s_a_high_l3vel_p0lyn0mial}
''' c = 6027704939934795526809476320408984749353451163184148193613218899917989403800738729505135647560822568147775955030636790796412038749080589962404088890138 n = 2345049742327685796181532105032554795628696111708534285951012187089560814230641663133312117797131139088986342455315166062482479446527815702735474197358418746066993291802284464812612727625991647573889402281825863578807474887341632160586307943897790827019291411639756252138594856687013363652094621849674259604512491449809337670874218320926522274379234396955495643125680407916326561528774056618181536326260093822819468635513422755218190798616168156924793527386350080400722536575372660262573683231490166520738579903818495107264328324326819989553511070207494208500239603511665056894947107356065440333537271115434438827753 e = 1560967245790387854530279132085915310737094193704812456970549221459036227794862560384548159924112528879771688534015861357630951162558357151823378870345945435342412220708167081427844035498174919749839232806280901968067512188264340755833308035745702731211924571583963089915893479992177245815565483658484702813753029786985027579475059989141119719224961817402605977566829967197490932672021566512826377376988752959467389833419735737545201988916590880487156074463948048461415870071893002222885078350961871888123567241990517365430474025391208925638731208820904957752596249597885523540692851123131898267246576902438472358221 '''
from Crypto.Util.number import * from secret import flag, Curve
defhappy(C, P): c, d, p = C u, v = P return (u**2 + v**2 - c**2 * (1 + d * u**2*v**2)) % p == 0
defnew(C, P, Q): c, d, p = C u1, v1 = P u2, v2 = Q assert happy(C, P) and happy(C, Q) u3 = (u1 * v2 + v1 * u2) * inverse(c * (1 + d * u1 * u2 * v1 * v2), p) % p v3 = (v1 * v2 - u1 * u2) * inverse(c * (1 - d * u1 * u2 * v1 * v2), p) % p return (int(u3), int(v3))
defyear(C, P, m): assert happy(C, P) c, d, p = C B = bin(m)[2:] l = len(B) u, v = P PP = (-u, v) O = new(C, P, PP) Q = O if m == 0: return O elif m == 1: return P else: for _ inrange(l-1): P = new(C, P, P) m = m - 2**(l-1) Q, P = P, (u, v) return new(C, Q, year(C, P, m))
c, d, p = Curve
flag = flag.lstrip(b'SICTF{').rstrip(b'}') l = len(flag) l_flag, r_flag = flag[:l // 2], flag[l // 2:]
m1, m2 = bytes_to_long(l_flag), bytes_to_long(r_flag) assert m1 < p and m2 < p
P = (398011447251267732058427934569710020713094, 548950454294712661054528329798266699762662) Q = (139255151342889674616838168412769112246165, 649791718379009629228240558980851356197207)
p = 903968861315877429495243431349919213155709 c = 662698094423288904843781932253259903384619# or p - c d = 540431316779988345188678880301417602675534 a = 1 P.<z> = PolynomialRing(Zmod(p))
# 把扭曲爱德华曲线映射到蒙哥马利曲线 aa = a dd = (d*c^4)%p J = (2*(aa+dd)*inverse(aa-dd,p))%p K = (4*inverse(aa-dd,p))%p A = ((3-J^2)*inverse(3*K^2,p))%p B = ((2*J^3-9*J)*inverse(27*K^3,p))%p
for i in P(z^3+A*z+B).roots(): alpha = int(i[0]) #print(kronecker(3*alpha^2+A,p)) for j in P(z^2-(3*alpha^2+A)).roots(): s = int(j[0]) s = inverse_mod(s, p) if J==alpha*3*s%p: Alpha = alpha S = s # 扭曲爱德华映射到 Weierstrass形式(其中经过蒙哥马利转换) deftwist_to_weier(x,y): v = x*inverse(c,p)%p w = y*inverse(c,p)%p assert (aa*v^2+w^2)%p==(1+dd*v^2*w^2)%p s = (1+w)*inverse_mod(1-w,p)%p t = s*inverse(v,p)%p assert (K*t^2)%p==(s^3+J*s^2+s)%p xW = (3*s+J) * inverse_mod(3*K, p) % p yW = t * inverse_mod(K, p) % p assert yW^2 % p == (xW^3+A*xW+B) % p return (xW,yW) defweier_to_twist(x,y): xM=S*(x-Alpha)%p yM=S*y%p assert (K*yM^2)%p==(xM^3+J*xM^2+xM)%p xe = xM*inverse_mod(yM,p)%p ye = (xM-1)*inverse_mod(xM+1,p)%p assert (aa*xe^2+ye^2)%p==(1+dd*xe^2*ye^2)%p xq = xe*c%p yq = ye*c%p assert (a*xq^2+yq^2)%p==c^2*(1+d*xq^2*yq^2)%p return (xq,yq)
# uncompyle6 version 3.7.4 # Python bytecode 3.8 (3413) # Decompiled from: Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)] # Embedded file name: C:\Users\Administrator\Desktop\233.py # Compiled at: 2024-01-11 17:19:49 # Size of source mod 2**32: 1082 bytes import hashlib k = [['#'] * 10, [ '#', 0, 1, 9] + [0] * 3 + [3, 0, 7], [ '#', 8] + [0] * 8, [ '#', 4] + [0] * 5 + [2, 0, 0], [ '#'] + [0] * 4 + [3] + [0] * 4, [ '#', 5] + [0] * 3 + [6, 0, 0, 2, 0], [ '#', 0, 7] + [0] * 5 + [3, 1], [ '#'] + [0] * 9, [ '#', 0, 0, 8, 0, 9, 0, 7, 0, 0], [ '#'] + [0] * 9] cnt = 0 s = str(int(input(), 16)) try: for x in s: if x notin [str(t) for t inrange(1, 10)]: s[cnt + 43690] = 1 for i inrange(1, len(k)): for j inrange(1, len(k[i])): if k[i][j] == 0: k[i][j] = int(s[cnt]) cnt += 1
else: for i inrange(1, len(k)): for j inrange(1, len(k)): if j notin k[i]: s[cnt + 3735928559] = 0
else: for i inrange(1, len(k)): tmp = []
for j inrange(1, len(k)): tmp.append(k[j][i]) else: for j inrange(1, len(k)): if j notin tmp: s[cnt + 3735928559] = 1 else: for i inrange(1, len(k), int(len(k) ** 0.5)): for j inrange(1, len(k), int(len(k) ** 0.5)): square = [k[x][y] for x inrange(i, i + 3) for y inrange(j, j + 3)] for t inrange(1, len(k)): if t notin tmp: s[cnt + 3735928559] = 2 else: print('SICTF{%s}' % hashlib.md5(s.encode()).hexdigest()) input()
except Exception as e: try: pass finally: e = None del e
# uncompyle6 version 3.7.4 # Python bytecode 3.8 (3413) # Decompiled from: Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)] # Embedded file name: E:\CTF赛题\ez_pyc\233.py # Compiled at: 2024-02-16 09:19:13 # Size of source mod 2**32: 1178 bytes import hashlib k = [['#'] * 10, [ '#', 0, 1, 9] + [0] * 3 + [3, 0, 7], [ '#', 8] + [0] * 8, [ '#', 4] + [0] * 5 + [2, 0, 0], [ '#'] + [0] * 4 + [3] + [0] * 4, [ '#', 5] + [0] * 3 + [6, 0, 0, 2, 0], [ '#', 0, 7] + [0] * 5 + [3, 1], [ '#'] + [0] * 9, [ '#', 0, 0, 8, 0, 9, 0, 7, 0, 0], [ '#'] + [0] * 9] cnt = 0 s = str(int(input(), 16)) try: for x in s: if x notin [str(t) for t inrange(1, 10)]: s[cnt + 43690] = 1 else: for i inrange(1, len(k)): for j inrange(1, len(k[i])): if k[i][j] == 0: k[i][j] = int(s[cnt]) cnt += 1
else: for i inrange(1, len(k)): for j inrange(1, len(k)): if j notin k[i]: s[cnt + 3735928559] = 0
else: for i inrange(1, len(k)): tmp = [] for j inrange(1, len(k)): tmp.append(k[j][i])
else: for j inrange(1, len(k)): if j notin tmp: s[cnt + 3735928559] = 1 else: for i inrange(1, len(k), int(len(k) ** 0.5)): for j inrange(1, len(k), int(len(k) ** 0.5)): square = [k[x][y] for x inrange(i, i + 3) for y inrange(j, j + 3)] for t inrange(1, len(k)): if t notin tmp: s[cnt + 3735928559] = 2
else: m = hashlib.md5(s.encode()).hexdigest() if m == '60b845d09f7b818a1e1e6cd0f4a04d96': print('SICTF{%s}' % m) else: print('试着换一种解嘞qwq') input()
except Exception as e: try: pass finally: e = None del e