from Crypto.Util.number import getPrime, bytes_to_long from random import randint import os
FLAG = os.getenv("FLAG").encode() flag1 = FLAG[:15] flag2 = FLAG[15:]
defcrypto1(): p = getPrime(1024) q = getPrime(1024) n = p * q e = 0x10001 x1=randint(0,2**11) y1=randint(0,2**114) x2=randint(0,2**11) y2=randint(0,2**514) hint1=x1*p+y1*q-0x114 hint2=x2*p+y2*q-0x514 c = pow(bytes_to_long(flag1), e, n) print(n) print(c) print(hint1) print(hint2)
defcrypto2(): p = getPrime(1024) q = getPrime(1024) n = p * q e = 0x10001 hint = pow(514*p - 114*q, n - p - q, n) c = pow(bytes_to_long(flag2),e,n) print(n) print(c) print(hint) print("==================================================================") crypto1() print("==================================================================") crypto2() print("==================================================================")
from math import gcd from Crypto.Util.number import * from random import randint from gmpy2 import * from sympy import *
n = 22796989847232584966116294915487109667692399388548208723824857982269426577982533576667163788314199914687535479276346304658350161735113960289104183979696133935415188646776595832215264284722670512770470554707499665153015544069122010065312260439523387858828112487588782099366982294819534417816132401540924904685838957357082330263936694480312350765218239631128311090691899678268513832773081674712659582989336522253361666051011711097920229566557894746540797857900051034731211399362219119533279077307321152458275097560958390957855672781889148144546092193220955239367648666685933810680029234780530383892271357380347995689819 c = 15500809819319696897791338730286899435906011157735748702026575236634076515328980326637207906866268251263940032374975549532185373801022208633640902685377742436930240946081698336042744872766305141702335101808659166638891554974804218420085991738631192662946632425072758982757961934234177973937887628455694588363841837871998858416793380376295499615937813361845507842420460604374447588420143950916761217801763530142272886581350320327182880966932325842751695199453666465100905939351955675042151795182275210958628456634676533901872731200863590971292987298842878421590175171242300414874391295079990929796678060214548392771598 hint1 = 1862211078370543480091335720566337979011214317229942783369303684474721435299886066692282340190601528246995538659713203028079171433051686409953814711803715745539615281056845096130150993388823222740835326508143943663312349159730974161720380360041429884293446791041760189634575810871753491959675639372269149003297678963406284496813354856152984421 hint2 = 451978013031216919732462259517336504381883668982999130384688266648583382806895812105588238968591030312940794462780134987725615664473829801678775053631652958914540268442422509110068911621519971159869478916942393510556788177367803958733251858842353604843493765854908537521426219930292526661256016570010664974221111594991806536179924000671962879710797054864049721795259156390686073225308097020589215361235483029040693704919028018150806601949682138526865044809662092 h1 = hint1 + 0x114 h2 = hint2 + 0x514 e = 0x10001 # flag1 = pow(c,d,n) # a = [i for i in range(0,2 ** 11) ] # for a1 in a: # for a2 in a: # if gcd(a2 * h1 - a1 * h2,n) != 1: # print(gcd(a2 * h1 - a1 * h2,n))
p = 150556757501089377335436861597668532759167063418149451873892673041441574746484480172770281695029395204024492543703641890608225475429941688457272867924226947004930880375197608715370559553857293816362519349893628875986030179953298651731386899559083522042580464565731414626985004100382424686783522608921806319081 q = n // p print(q) d = mod_inverse(e,(p-1)*(q-1)) print(long_to_bytes(pow(c,d,n)))
import gmpy2 from Crypto.Util.number import * from sympy import * import numpy
e = 0x10001 n = 24035750183831967945862792163318687711636752271371090849587486052996743335317925707644158466361992088680284764537863907870483800987927045977262379436707935507352930731625828010232148531698069195679206414771560405690866206801521560068223111553181555589657902912351690944653598852969643576557244361774811847786620528125766038976290871157015582419666377724077626852783161544588108892151231349381914349567742343809860879779842598253145859022455636285730609230213893482168129936443755613145793453450265841379651392614504305926698789993597967575449464830551464752887958111479014119364003208540559602831610061068580024304819 c = 19934689766676402834945257825359386260778644093931507561829377556171227917476487950297033854166232075447889855506414923788944066873230395572730425922321820345287653931899872053996044824782950906993111807754923238617369022881802203840405204432268446924041095481162467048547431813579298444860037069073330808101615311961018893636588389609087080788546193553692725702289368182831547430390563914513490366135018553210142200762531317435146556932342500456400144935440074460440245575109860904136544180958572452150042290099122096819070557715615930816198575927509264695516100566470057658853949332163685198579685526667964321845739 hint = 18567032867512285860307419488165768578686620568031343693371467586033464180932929719298233554289159514429056422062355183818429533169961696923649809870818260456617136078495827646887535954139551435058217919572553957538876498055301171484653056802489660140508839376495703495298792704494360514709918221629239667571477378551204563319518122929355306964308922342824945446469956403936864310867999869021233291094379139359357336767219934171235565098713539397213682169115587641501816149888627310047627322248269203989245666081524212042527661700223870861838643701360684940245909880865049035523276592323505026950707591320306175476700 t = inverse(hint,n) p,q = symbols('p q')
res=solve([514*p-114*q-t,p*q-n],[p,q]) print(res) p = res[1][0] p = int (p) q = n//p print(p,q) d = inverse(e,(p-1)*(q-1)) m = pow(c,d,n) print(long_to_bytes(m))
import os from Crypto.Util.number import * defgiaogiao(hex_string): base_num = 0x6c62272e07bb014262b821756295c58d x = 0x0000000001000000000000000000013b MOD = 2**128 for i in hex_string: base_num = (base_num * x) & (MOD - 1) base_num ^= i return base_num
giao=201431453607244229943761366749810895688
print("1geiwoligiaogiao") hex_string = int(input(),16) s = long_to_bytes(hex_string)
print(s)
if giaogiao(s) == giao: print(os.getenv('FLAG')) else: print("error")