1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
| import random import math import gmpy2 def find(e,p): root = [] while len(root) < e: a = random.randint(2, p - 1) res = pow(a, (p - 1) // e, p) if res not in root: root.append(res) return root
def AMM(residue,e,p): t = 0 s = p - 1 while s % e == 0: t += 1 s = s // e
d=gmpy2.invert(e,s)
if t==1: return pow(residue,d,p)
noresidue = random.randint(1, p) while pow(noresidue, (p - 1) // e, p) == 1: noresidue = random.randint(1, p) a=pow( noresidue , ( e ** ( t-1 )) * s, p ) b=pow( residue , e * d - 1, p ) c=pow( noresidue , s , p ) h=1 for i in range(1,t): d=pow( b , e** ( t-1-i ) , p ) if d==1: j=0 else: j=-math.log(d,a) b=pow( pow ( c , e , p ) , j , p ) * b % p h=pow( c , j , p ) * h % p c=pow( c , e , p ) return pow( residue , d , p ) * h % p
ppp = [9971877305101532548667657113915432686374600625802767915440064066247538969690929504779569308758806158316830036732847609558927989368198515992358962884845999, 9686779713749996013370168873387336643810360139391110278373359707982679675197866831353082822950439414021110597331749608836927764104519058819809287999191277, 11738824822038281341750095913199075446517552586485188261315252543625912278840584386174541563838459902823978442587021089252281373649445095529570370997140353, 8385622786171806844076175753935694055996440456538617120122854340325548660120153189193604171523482203780916677672818268556891995843000386665967836853148101] eee = [3949210634899972905354615323966329995013354120760848313001868527895893105358656676275468825581, 3352586350227882729695194848291019666469497650929882112900986499971706693129836865558906119017, 2538382896284047546927213869533310553533512722671755934207012576147843086855632406951937438613, 5811018619884267813495708620058955656757034290452722071543724890613376672936415477627562597173]
P1 = 2081 P11 = 1897746580922620329339075119637832770309156232946106829890374112395912112137749484034343501 P2 = 2539 P22 = 1320435742508027857304133457381260207353090843217755853840483064187359863383157489389092603 P3 = 2347 P33 = 1081543628582892009768731942706992140406268735693121403582024957881484059163030424777135679 P4 = 3413 P44 = 1702613132107901498240758458851144347130686870920809279678794283801165154683977579146663521
c = 6584399172697878406122485312269951595848044260489518691299790064128553815820157618343563425157360368851091584911872688623840890520680003501265955854989154 from Crypto.Util.number import * from tqdm import trange ''' c3p4 = pow(c,inverse(P44,ppp[3]-1),ppp[3]) residue = c3p4 e = P4 p = ppp[3] if (p-1)%e==0: mp = AMM(residue, e, p) print("AMM得到的一个根为:",mp) root_list = find(e, p) x = [] for i in trange(len(root_list)): a = mp * root_list[i] % p c2p3 = pow(a,inverse(P33,ppp[2]-1),ppp[2]) c2 = AMM(c2p3, P3, ppp[2]) if (pow(c2,P3,ppp[2])==c2p3): print(a) print(c2) c3 = 4403127215991220229839479518626504962747838285000783938364166412189873143071927478130236190245800549981892987436496348978180866427941150139979562736363530 #true c2 = 11013121863966087348599526053432434321521660893224099328233004475795113083375809385374456345571929502899231166270940852158446728578150994694451298386121238
e = P3 p = ppp[2] mp = c2 root_list = find(e, p) x = [] for i in trange(len(root_list)): a = mp * root_list[i] % p c1p2 = pow(a,inverse(P22,ppp[1]-1),ppp[1]) c1 = AMM(c1p2, P2, ppp[1]) if (pow(c1,P2,ppp[1])==c1p2): print(a) print(c1) '''
''' c1 = [657718726193142880409478453865967528589049196611201298310324188907002939673063004623634772735929171329130925507780030419274465030722598754181569263565843,7209213777090215712662315449230898089623512156749704528486342515384704389258282489994460586038365630048371961190718039354171692411636459384266264420975544,6496454603448450214223576711611405791781352875371008652916500049180198336778260056262327542983348776586493014494467727618355966658810981808565264687907666]
e = P2 p = ppp[1] root_list = find(e, p) for i in range(len(c1)):
mp = c1[i] x = [] for i in trange(len(root_list)): a = mp * root_list[i] % p c0p1 = pow(a,inverse(P11,ppp[0]-1),ppp[0]) c0 = AMM(c0p1, P1, ppp[0]) if (pow(c0,P1,ppp[0])==c0p1): print(a) print((c0)) ''' c0 = [6637290926112650825502453850562363097250378147996414291904068872099093027934962654492895894832751641657317021544428508372597884351254314410853527604755353,9848283492214689508524254071452966592901064150580060548350703376544493971865196137864529044168418598884545206890086095268411015142766841725917214313875490,8868967640126082718320026287539555911382933263008160047816934165250385349691348057955820364462739532787268817879310362470278443268444773185123672522450441] e = P1 p = ppp[0] root_list = find(e, p) for i in range(len(c0)): mp = c0[i] x = [] for i in trange(len(root_list)): a = mp * root_list[i] % p if b'flag' in long_to_bytes(a): print(long_to_bytes(a))
|