from Crypto.Util.number import * from PIL import Image import numpy as np n = 29869349657224745144762606999 p=160216064374859 q=186431677583461 e =65537 phi = (p-1)*(q-1) d = inverse(e,phi) def decry(c): m = pow(c,d,n) return m data = np.load(r"encrypted_image.npy",allow_pickle=True) h = 2065 w = 712 image = Image.new("RGB", (w,h)) for i in range(w): for j in range(h): r = decry(data[i, j, 0]) g = decry(data[i, j, 1]) b = decry(data[i, j, 2]) image.putpixel((i, j), (r, g, b)) image.save("custom_rgb_image.png")
c= 8989289659072309605793417141528767265266446236550650613514493589798432446586991233583435051268377555448062724563967695425657559568596372723980081067589103919296476501677424322525079257328042851349095575718347302884996529329066703597604694781627113384086536158793653551546025090807063130353950841148535682974762381044510423210397947080397718080033363000599995100765708244828566873128882878164321817156170983773105693537799111546309755235573342169431295776881832991533489235535981382958295960435126843833532716436804949502318851112378495533302256759494573250596802016112398817816155228378089079806308296705261876583997 n= 13424018200035368603483071894166480724482952594135293395398366121467209427078817227870501294732149372214083432516059795712917132804111155585926502759533393295089100965059106772393520277313184519450478832376508528256865861027444446718552169503579478134286009893965458507369983396982525906466073384013443851551139147777507283791250268462136554061959016630318688169168797939873600493494258467352326974238472394214986505312411729432927489878418792288365594455065912126527908319239444514857325441614280498882524432151918146061570116187524918358453036228204087993064505391742062288050068745930452767100091519798860487150247 leak= 9192002086528025412361053058922669469031188193149143635074798633855112230489479254740324032262690315813650428270911079121913869290893574897752990491429582640499542165616254566396564016734157323265631446079744216458719690853526969359930225042993006404843355356540487296896949431969541367144841985153231095140361069256753593550199420993461786814074270171257117410848796614931926182811404655619662690700351986753661502438299236428991412206196135090756862851230228396476709412020941670878645924203989895008014836619321109848938770269989596541278600166088022166386213646074764712810133558692545401032391239330088256431881 from Crypto.Util.number import *
m = pow(c,leak-n-1,n) print(long_to_bytes(m))
小蓝鲨的数学题
参考 2020网鼎杯 you raise me up
根据题目条件和提示,我们已知
c=pow(m,flag,p)
利用sagemath解题
1 2 3 4 5 6
m = 5321153468370294351697008906248782883193902636120413346203705810525086437271585682015110123362488732193020749380395419994982400888011862076022065339666193 c = 7383779796712259466884236308066760158536557371789388054326630574611014773044467468610300619865230550443643660647968413988480055366698747395046400909922513 p = 2**512 d=discrete_log(c,mod(m,p)) import libnum print(libnum.n2s(int(d)))
c = 587245179027322480379581200283415189810421958968516831191660631552695197401940961725169763339428980298128692606951200581483431566182271569207988054537414289564013883171160614196522169980339024564884190765084419167938640701193928669 hint = 0.2427542737153618793334900104191212626446625872340179613972610728976081994921862517310186626304527115125924716035632505287111236596234811779375148657365336957626454491865164520834975233144235103885081268955448330597818844340656652982593545877449810282619387305007246499089258519062093814083383071737897364213169497762760797899310673216754376885295598952272100016962368762532805864796748393317534908268379601445004775495237901072144236328105526403608646831124542336002540011176406194984370372589752234640498423911217119220030242197564695880261480071310815379681250975672935544404797155655708441222387631967447088319826137200280810029390387418159394276760100487636516708987579464183208860911063948902432948269805493252899815187044807603000344378890835564906163242023600624338694473573763088471321731611077227112205396909637906507673367598721218000123789690455125909411309668615810240938664264212370815385282488986625554704015828254539339719586211726300858711328516487805251366293457402531199532556110786048074755505680210260049 n = 839799159583571337450826982895478997157381520448790705455708438948150905361244823725400304016136863419723271227616684280477524669207590477657886623628732394537008838314015048569652202355464477680540884654473950183135276735347866051 e = 65537 hint = hint *2 from Crypto.Util.number import * cf = continued_fraction(hint) for i in range(1000): k = cf.numerator(i) x = cf.denominator(i) ifisPrime(x) and x.bit_length()==512: print(k,x) h,p = k,x Ge = Matrix(ZZ,[[1,h],[0,p]]) print(Ge.LLL()) f,g = Ge.LLL()[0] f,g = abs(f),abs(g) print(f,g) q = n //f phi = (f-1)*(q-1) d = inverse(e,phi) print(long_to_bytes(pow(c,d,n)))