NKCTF2023 Crypto 部分wp

目录

数字人才网络安全CTF Crypto

baby_RSA

ez_polynomial

eZ_Math

eZ_Bl⊕ck

ez_RSA

fake_MT & real_MT

easy_high

complex_matrix

ez_LargeCG

Raven


数字人才网络安全CTF Crypto

只有一个题,简单记录一下

先贴一下主要代码,其中x和p都是512bit

t=30
for i in range(t):
    r = getPrime(512)
    s = getPrime(400)
    c = (r * x + s) % p
    rs.append(r)
    cs.append(c)
    ss.append(s)

enc = pow(x,flag,p)

先求解LWE,在求解DLP问题。

LWE可以看这个Aero CTF 2020 - Magic II

r\times x+b=c\ mod\ p \\ r\times x+k\times p=c-b \\ \left ( \begin{array} {cccccc} r_1 & p & & & \\ r_2 & & p & & \\ \vdots& & & \ddots & \\ r_{30} & & & & p\\ \end{array} \right ) \times \left ( \begin{array} {cccccc} x\\k_1\\k_2\\\vdots\\k_{30} \end{array} \right ) = \left ( \begin{array} {cccccc} c_1-b_1\\c_2-b_2\\c_3-b_3\\\vdots\\c_{30}-b_{30} \end{array} \right )

构造左边的那个矩阵,然后C-B近似为C,求CVP问题得到C-B矩阵

sagemath矩阵乘法好像是反过来的????构造这种

\left (\begin{array} {cccccc} p & \\ &\ddots \\ & & p\\r_1&\cdots &r_{30}\end{array} \right )

求解x的脚本

from Crypto.Util.number import *
p = 6897108443075981744484758716081045417854227543713106404294789655180105457499042179717447342593790180943415014044830872925165163457476209819356694244840079
rs = [12844634549263053228759749264403637022740290008286987401585068952741935277415527678380021212624846722242500708422759563558995936977274580301379494195702461, 12251634003683452916928102291170339939586644029776192301741341674585154859358419625191986830852794085541953563738986709807899575511700135958334229151930861, 7051370666077542197248638013011793824477073777322219545882367881807130066168444134964571398112151848834032654978368255218649720738040945429837692857031957, 9773046862351952930368505593284546267554571295872377323111558071278701231472975791962979256551519533723988556870551885073742407630481198192389750289392107, 8883776497660138308720006912582738672888752344326928153810910221453595077711284302041512529457450211602787210761461172326429880594024187025419873043435877, 12056735137145460036580841038332100311160368843873164649606343042416896898793233249873902218683966283969721460087390120622254758027779960740926123005377571, 8819958747150954554494406068232243249186433676383469322817152210037563032056202909377825740775383087605647374150477096718956454225946093710691864988563109, 12246023449098354751049599873213988024512286270964608502444597112110163392131757813461977030270733012385926751192637938686124570227538910606279104888073013, 11308837998867241929817950595621831002334468993828126438599805989088017326675963100044309448653090403889186401929445861220402556074702741108929442867300279, 9184622887414209361516593101129556569811888214607556630094969763910426953786020755838094184972397480276666170685926425137063559394969166216392939257091541, 12896400069515890897430087815982545671830645201023665112429779640768899091287291452408369445919464144390726200808875066389240126909811239597092893733457339, 11227025698697471809912850435140886785315702278826761054472525227951791647003561270585720797267604996360933395122286757099101227901032364782594523739698877, 8162123490656317490361880020667919072708091053716891870691544217490126444997503404094174246087938828993696335191488583306443577208796794274099282013427247, 13366989889442670291461262313757977600095962057470863475519088648267301129719953368943419562144276679400967122727554764013132918505564677243979978807323041, 9920857455945408588203972193444437533164351309299040911469275059092031755811492460585653948481522995557801781838215407648572999358456612525812067538372579, 7139402473546047825312503780125417567716958846513076797328672521987900978293260385267945187604725349720103672258987935569856239987227455748213833342843243, 13108142660294572752252393081421368493392921884487755391460006730258159004638343897340537616297811742032405724656497443006056456690449881719305597286675631, 13276762958403786077380090195631980415297280849950287990717193547481553124160398455403123819234755237450529090601858784999113026218918277529515287668651121, 12463094640052886550696551772104539361264529587569204472038955376345085195998921095774583176899949596998985033050547755235409943131811058035802010421860899, 11307743131694864808301935844724645695851330736969875190167422024500753079857478680029193758960169072890576310607053767920339034290416580654771095674487943, 10053742503547378455068966704402695956702795408343604912294923217443553169726438945982031485796964462946592530592946335569560364464958066521486506177193131, 9703695763451799125258961776229325510814289358679213305418559381901496449849584244211834872313767844996255556721041007654625153809128987422992102292472533, 8148189465927721940294369879439913703690047528695196368949823197675716174991296513758196009346701553643721225250628151384047219921709201619262393792138023, 9114150910964237818418367840207724528917302406836157928223872622442928604249864486858755737149640683259834299165900696585038569188627682022002709058902291, 12273514376180781903469287345188404399033432117915094289694407562166649079228640510678711431664410226301556172582177240184695103942141430877677144285616059, 8355005721684425514882933910286584148305344580589623112959517428993968438533866906223777778058096962333203237111245328436600994120168924143849685728268811, 8957883838807471492147480816683526636019698464133185237668243268667169800811696770484487123560197988448434475112352005768286417529319182162245840523697001, 12168542584724814356632409768687396920143300559579648963851924568387314914334359305942685551210180448419674060219496395116081866784918059237133414041227833, 12285935007930825571672128346804313607196190465690759870758278705086034778808662886056460827935986285259185071514490942831585313190946386878622608868345563, 7719913817859572377164973343651155934060296607908537845256755472465025202751239980758950094865067751407889569369974011139801401586939119147773466111699913]
cs = [3911325901261770731066343727353093385607196883601022244426857460074338420692610012414571623512152485474248169220030587839849722757773859682519433853455847, 4198555117325325874584019691418573071733167640213933749582347442518997588452211673143722179281773602455507001395983681009769848414007206268682184816168744, 4422173666634983234895098798813962037875417568235708524339826709271381748884936178371767574064794177416615710120223914725873239836121654705208614576413533, 3540260422555697887869627546208164711550015909378340105077652177481959576550678379723450981807556863572610759824660630418670546203733170058626755080797998, 6451498467498935201092514865627931677091078787997097414208430992183264950579022373372254486595458117887305393317663712337699331503725124287017134808484874, 3439629581963524351810430910737336124616316641656190641248434504621774235943514617301857917041111617104850245148746427180069743940612560718213177903427306, 4279468191481832212496939242093486044278976937965085475567008228061184947513156012369586970486543083130565628906296600553024574099481246534878242920637212, 4102135455518061133919027670571325279976222647984452353051395864554309521223498761823084717077102213648612826513661629599971609555235760152049549057234342, 329051927890365028889097463563711966673066795688728876214731188783168691555262156515161429328581094087585127929869064685419149676592073496155898360311360, 1674347209896897571502352451063188834938904430329951752111921115230349947823188121972980025563878887201507629419811736910690965020923751424101521816057970, 4779084317811375050159574994746297486592271247137823471375199626788956576998627181220489952507937768042501203098391966702297812537463211799837921684467541, 5240331815784322792144549873873658636726233093228415489098002982220769676718681132737794994708716389174162820721646744776624413735318240597745363490427584, 2689716894922604875455207695253665212853470308341743040957367957727155614199743562225147359614514189877983156892749669804800163252617480446565479990148021, 449708769594599088851244243076921016853502252396793496349534051273454215985560340288452398756880916680293627457774430655982228613348249480600180821975835, 1584603978331289335352997151059666773277943458357161051278658090420067023680231414255557805410288144092653121568766136372728095300982743309696347031121424, 4874260053151700374809337053763032489184725334196495160358275038586824027920238733886703163018450814805937363825223459277373073591021082276610135118976834, 3524374131362906900545297291947110177298862564718451821839794960169356082042548386553363480921097452902723033854749443288682983558847052843293666815425196, 6544123591499569232021913370293570477776709315008783531720886545784773471486769240711262562401683145937715612435213816372680189321141928790509490282629891, 4873861166228118967099569086478548167127431415017791678812419676791754466935832034870862000658789609084166891933970013849850146718379819943737269970654866, 4100817874436703071716655163972145036104985973164830547825929590871920825981241934633977227547934514142660786061291026657802357404024236287955309372489516, 343238276681348130286495167739162902430650061145485619903964358840996341335935043000395056684771452815629410388891486531126938900311458948803147120186532, 2683710724350412998770392318832434885304538325033159937379489319924346689197445720734209841902612235485016866254994045969716413020197296428323832404151182, 5909464641105704179999104311562416363090166762341644691188169716182958971270396007422581429813172933930581475771306034495224054972725230757675444731953480, 105593489999747649490909471306354863316673821363863362258853043970534652401274789197677558215188249074837829003335733211890211648501689656345824858507373, 4992379366542645691375959247465888889778118153982142100956809440855745659745235576280578316185469306620017845690312554043770651058126536040173113949524396, 6533456398244789907636779407045515567135195474284185379689518387558345997627435421582437390053234675991361808532278264077968540197407743744279106871716267, 5169360398767270275853790242315213671633880428212603766301308853363063092609582572957561138022806887895634140899640025570759919257615537375706008159680239, 203310740924699994885931266978520636166917734618272844754878785050509801614513144739164450834936178065792112797202959106365282699245578309060905297742706, 3143563289239398127009575193211845399079310618985464994769603542400451633289266080869317336163844517539211542909055869608349639432145332113320465388067087, 4016252180207572047405081190649590978593306403200098541033213590567723751195926093369984531729148621419589009515870336049849542537363832071754623330736088]
enc = 1315637864146686255246675143589215932218700984880749264689270214639479160648747323586062096067740047809798944996253169402675772469028914904598116394230426
G=GF(p)
def Babai_closest_vector(M, G, target):
  small = target
  for _ in range(1):
    for i in reversed(range(M.nrows())):
      c = ((small * G[i]) / (G[i] * G[i])).round()
      small -= M[i] * c
  return target - small
from sage.modules.free_module_integer import IntegerLattice
from random import randint
import sys
from itertools import starmap
from operator import mul
from Crypto.Util.number import *
m = 30
n = 1
A = matrix(ZZ, m + n, m)
for i in range(m):
    A[i, i] = p
for x in range(m):
    A[m , x] = rs[x]
lattice = IntegerLattice(A, lll_reduce=True)
print("LLL done")

gram = lattice.reduced_basis.gram_schmidt()[0]
target = vector(ZZ, cs)
res = Babai_closest_vector(lattice.reduced_basis, gram, target)
print("Closest Vector: {}".format(res))

R = IntegerModRing(p)
M = Matrix(R, rs)
res=vector(R, res)
for i,j in zip(cs,res):
    assert len(bin(i-j))-2==400
x=((res[0])*inverse(rs[0],p)) %p
print('x=',x)

得到x后就是经典离散对数问题

先factor(p-1)看看是否光滑

除了最后一个数很大,其他的都还行,能够轻松求解DLP

题目给了flag长度为38,转成二进制应该在38*8-1=303左右,前面的小素数的乘积为 299 bit。

可以求出大概 flag %2^299的值,然后简单的爆破四位数就好了

factors, exps = zip(*factor(p-1))
primes = [factors[i] ^ exps[i] for i in range(len(factors))]
print(primes)
dlogs = []

for fac in primes[:-1]:
    t = (p-1) // fac
    dlog = discrete_log(G(pow(enc,t,p)), G(pow(x,t,p)))
    dlogs += [dlog]
    print("factor:", fac, "dlog:", dlog)

s=(p-1)//primes[-1]
res=crt(dlogs,primes[:-1])
for i in range(100):
    if long_to_bytes(res+i*s).startswith(b'flag'):
        print(long_to_bytes(res+i*s))
        break

baby_RSA

dP泄露求P,Q,简单写一下推导公式,用了一下费马小定理

\noindent\\ P=m^p \ mod \ pq \\ Q=m^q \ mod \ pq \\ m^p=m+k_1*p\\m^q=m+k_2*q\\ P=m+k_1*p+k*pq=m+k_3*p\\Q=m+k_2*q+k*pq=m+k_4*q\\ P+Q=2*m+k_3*p+k_4*q\\P*Q=m^2+(k_3*p+k_4*q)*m+k_3*k_4*pq\\ m^2+P*Q-m*(P+Q)=k_3*k_4*pq\ %\ n=0

from Crypto.Util.number import *
e=65537
n =  114101396033690088275999670914803472451228154227614098210572767821433470213124900655723605426526569384342101959232900145334500170690603208327913698128445002527020347955300595384752458477749198178791196660625870659540794807018881780680683388008090434114437818447523471527878292741702348454486217652394664664641
N =  1159977299277711167607914893426674454199208605107323826176606074354449015203832606569051328721360397610665453513201486235549374869954501563523028914285006850687275382822302821825953121223999268058107278346499657597050468069712686559045712946025472616754027552629008516489090871415609098178522863027127254404804829735621706042266140637592206366042515190385496909533329383212542170504864473944657824502882014292528444918055958758310544435120502872883857209880723535754528096143707324179005292445100655695427777453144657819474805882956064292780031599790769618615908501966912635232746588639924772530057835864082951499028
dp =  33967356791272818610254738927769774016289590226681637441101504040121743937150259930712897925893431093938385216227201268238374281750681609796883676743311872905933219290266120756315613501614208779063819499785817502677885240656957036398336462000771885589364702443157120609506628895933862241269347200444629283263
c1=0
c2=0
for i in range(1,65538):
    if (dp*e-1)%i == 0:
        if N%(((dp*e-1)//i)+1)==0:
            P=((dp*e-1)//i)+1
            Q=N//(((dp*e-1)//i)+1)
            print(N==P*Q)
            c1=P
            c2=Q

n = 114101396033690088275999670914803472451228154227614098210572767821433470213124900655723605426526569384342101959232900145334500170690603208327913698128445002527020347955300595384752458477749198178791196660625870659540794807018881780680683388008090434114437818447523471527878292741702348454486217652394664664641
c1 = 37269067352457630263351774206178494913957088859822110344334922741582406663357663275001777826744534556652993452577088773275825539553907027527722045884489297259984687894496505265384077983882580247333972954704644517469999916574893996324149548980338301147983367163067556434434982470623587914250041142380667816331
c2 = 31124398373258967647259273958463995255448332282733968391096762136494537693158180734634142626374694999391960402681114664140356232930100613919064790135723294710984789809295862966052914533841176463683069225072916170624016363164528353386087305805869313783193076760778433672011918504199905552973276891160558444988

PR.<m> = PolynomialRing(Zmod(n))
f = m^2-(c1+c2)*m+c1*c2
x0 = f.small_roots(X=2^400)
long_to_bytes(ZZ(x0[0]))

ez_polynomial

多项式RSA,了解一下,其实跟普通RSA解法一样,具体可以看这个文章

P很小,所以分解N,对sagemath来说很简单

注意一下phi=(P^order1-1)*(P^order2-1)

P=40031
N=24096*y^93 + 38785*y^92 + 17489*y^91 + 9067*y^90 + 1034*y^89 + 6534*y^88 + 35818*y^87 + 22046*y^86 + 12887*y^85 + 445*y^84 + 26322*y^83 + 37045*y^82 + 4486*y^81 + 3503*y^80 + 1184*y^79 + 38471*y^78 + 8012*y^77 + 36561*y^76 + 19429*y^75 + 35227*y^74 + 10813*y^73 + 26341*y^72 + 29474*y^71 + 2059*y^70 + 16068*y^69 + 31597*y^68 + 14685*y^67 + 9266*y^66 + 31019*y^65 + 6171*y^64 + 385*y^63 + 28986*y^62 + 9912*y^61 + 10632*y^60 + 33741*y^59 + 12634*y^58 + 21179*y^57 + 35548*y^56 + 17894*y^55 + 7152*y^54 + 9440*y^53 + 4004*y^52 + 2600*y^51 + 12281*y^50 + 22*y^49 + 17314*y^48 + 32694*y^47 + 7693*y^46 + 6567*y^45 + 19897*y^44 + 27329*y^43 + 8799*y^42 + 36348*y^41 + 33963*y^40 + 23730*y^39 + 27685*y^38 + 29037*y^37 + 14622*y^36 + 29608*y^35 + 39588*y^34 + 23294*y^33 + 757*y^32 + 20140*y^31 + 19511*y^30 + 1469*y^29 + 3898*y^28 + 6630*y^27 + 19610*y^26 + 11631*y^25 + 7188*y^24 + 11683*y^23 + 35611*y^22 + 37286*y^21 + 32139*y^20 + 20296*y^19 + 36426*y^18 + 25340*y^17 + 36204*y^16 + 37787*y^15 + 31256*y^14 + 505*y^13 + 27508*y^12 + 20885*y^11 + 32037*y^10 + 31236*y^9 + 7929*y^8 + 27195*y^7 + 28980*y^6 + 11863*y^5 + 16025*y^4 + 16389*y^3 + 570*y^2 + 36547*y + 10451
C=3552*x^92 + 6082*x^91 + 25295*x^90 + 35988*x^89 + 26052*x^88 + 16987*x^87 + 12854*x^86 + 25117*x^85 + 25800*x^84 + 30297*x^83 + 5589*x^82 + 23233*x^81 + 14449*x^80 + 4712*x^79 + 35719*x^78 + 1696*x^77 + 35653*x^76 + 13995*x^75 + 13715*x^74 + 4578*x^73 + 37366*x^72 + 25260*x^71 + 28865*x^70 + 36120*x^69 + 7047*x^68 + 10497*x^67 + 19160*x^66 + 17939*x^65 + 14850*x^64 + 6705*x^63 + 17805*x^62 + 30083*x^61 + 2400*x^60 + 10685*x^59 + 15272*x^58 + 2225*x^57 + 13194*x^56 + 14251*x^55 + 31016*x^54 + 10189*x^53 + 35040*x^52 + 7042*x^51 + 29206*x^50 + 39363*x^49 + 32608*x^48 + 38614*x^47 + 5528*x^46 + 20119*x^45 + 13439*x^44 + 25468*x^43 + 30056*x^42 + 19720*x^41 + 21808*x^40 + 3712*x^39 + 25243*x^38 + 10606*x^37 + 16247*x^36 + 36106*x^35 + 17287*x^34 + 36276*x^33 + 1407*x^32 + 28839*x^31 + 8459*x^30 + 38863*x^29 + 435*x^28 + 913*x^27 + 36619*x^26 + 15572*x^25 + 9363*x^24 + 36837*x^23 + 17925*x^22 + 38567*x^21 + 38709*x^20 + 13582*x^19 + 35038*x^18 + 31121*x^17 + 8933*x^16 + 1666*x^15 + 21940*x^14 + 25585*x^13 + 840*x^12 + 21938*x^11 + 20143*x^10 + 28507*x^9 + 5947*x^8 + 20289*x^7 + 32196*x^6 + 924*x^5 + 370*x^4 + 14849*x^3 + 10780*x^2 + 14035*x + 15327
R.<y> = PolynomialRing(GF(P))
S.<x> = R.quotient(N)
N=R(str(N))
#factor(N)
from Crypto.Util.number import *
phi=(P^40-1)*(P^53-1)
d=inverse(e,phi)

m=S(C)^d
print(m)
for i in m.list():
    print(chr(i),end='')

eZ_Math

前面两个等式就够用了

\noindent\\ 6^{large1}\equiv 9\ mod \ n\\6^{large2} \equiv 4 \ mod \ n \\ 6^{large1+large2} \equiv 36 \ mod \ n \\ 6^{large1+large2-2} \equiv 1 \ mod \ n

Zmod(N)的任何一个元的阶为phi的因数,感觉是群论的子群理论

然后发现6的阶:large1+large2-2的bit位数跟n一样,所以乘以2,3,4这样的小数可能就是phi

这里是乘以2就是phi了,然后常规解密

from Crypto.Util.number import *
e = 0x10001
n = 369520637995317866367336688225182965061898803879373674073832046072914710171302486913303917853881549637806426191970292829598855375370563396182543413674021955181862907847280705741114636854238746612618069619482248639049407507041667720977392421249242597197448360531895206645794505182208390084734779667749657408715621
c = 324131338592233305486487416176106472248153652884280898177125443926549710357763331715045582842045967830200123100144721322509500306940560917086108978796500145618443920020112366546853892387011738997522207752873944151628204886591075864677988865335625452099668804529484866900390927644093597772065285222172136374562043

# d=pow(6, 42762902032363446334121451790132830028099011269558028556333775251728898854654431095595000922138958455510196735338223430882428451914478079186797153527810555787441234842366353864053114538165236037883914332840687123514412294276743506313011532002136735343280737244020115917460801848337792582496228600926958548903290, n)
c1=141997416965295486849546892322458652502850390670128808480582247784728456230996812361056958004801816363393016360646922983916999235770803618904474553309200419301820603229504955218189709387942156848904968053547462302189568831762401075340100029630332409419313772378068180267756675141584884876543484516408660699471038
c2=42762902032363446334121451790132830028099011269558028556333775251728898854654431095595000922138958455510196735338223430882428451914478079186797153527810555787441234842366353864053114538165236037883914332840687123514412294276743506313011532002136735343280737244020115917460801848337792582496228600926958548903290
p1=c1+c2-2
phi=p1*2
d=inverse(e,phi)

print(long_to_bytes(pow(c,d,n)))

eZ_Bl⊕ck

八轮Feistel网络,可以参考一下七轮的这个

\noindent\\L_8=R_0\bigoplus K_1\bigoplus K_2\bigoplus K_4\bigoplus K_5\bigoplus K_7\bigoplus K_8\\ R_8=L_0\bigoplus R_0\bigoplus K_1\bigoplus K_3\bigoplus K_4\bigoplus K_6\bigoplus K_7\\ K_l=L_8\bigoplus R_0\\K_r=R_8\bigoplus L_0\bigoplus R_0\\ M_r=R_0=L_8\bigoplus K_l\\ M_l=L_0=R_8\bigoplus R_0\bigoplus K_r

解题脚本

from Crypto.Util.strxor import strxor as xor
r=b"t\xf7\xaa\xac\x9d\x88\xa4\x8b\x1f+pA\x84\xacHg'\x07{\xcc\x06\xc4i\xdd)\xda\xc9\xad\xa9\xe8\x1fi"
t=b"'{<z}\x91\xda\xc5\xd5S\x8b\xfa\x9f~]J\x0f\xf4\x9a\x1e\xe0\xef\x129N\xe7a\x928+\xe0\xee"
c=b'8\x1f"\x83B4\x86)\xce\xebq3\x06\xa0w\x16U\x04M/w\xa1\x8f;)M\xdd~\x11:\xe3\xb3'

Lt=r[0:16]
Rt=r[16:]

Kr=xor(t[16:],xor(Rt,Lt))
Kl=xor(Rt,t[:16])
Ml=xor(c[:16],Kl)
Mr=xor(xor(Kr,c[16:]),Ml)
print(Mr+Ml)

不知道这有啥问题,但是把-符号给replace了????????

m = flag.strip(b'NKCTF{').strip(b'}').replace(b'-',b'')

ez_RSA

n为四个素数相乘,给了phi和n,攻击方法谷歌搜一下attack phi n就找到了脚本

然后计算出第一段flag为27字节,估算第二段为54字节,即432bit左右,然后small_roots套用第一题,上界设置为2^432左右就可以解出来第二段

from Crypto.Util.number import *
from math import gcd
#from math import isqrt
from random import randrange

from sage.all import is_prime
n = 8836130216343708623415307573630337110573363595188748983290313549413242332143945452914800845282478216810685733227137911630239808895196748125078747600505626165666334675100147790578546682128517668100858766784733351894480181877144793496927464058323582165412552970999921215333509253052644024478417393146000490808639363681195799826541558906527985336104761974023394438549055804234997654701266967731137282297623426318212701157416397999108259257077847307874122736921265599854976855949680133804464839768470200425669609996841568545945133611190979810786943246285103031363790663362165522662820344917056587244701635831061853354597
phi = 8836130216343708623415307573630337110573363595188748983290313549413242332143945452914800845282478216810685733227137911630239808895196748125078747600505622503351461565956106005118029537938273153581675065762015952483687057805462728186901563990429998916382820576211887477098611684072561849314986341226981300596338314989867731725668312057134075244816223120038573374383949718714549930261073576391501671722900294331289082826058292599838631513746370889828026039555245672195833927609280773258978856664434349221972568651378808050580665443131001632395175205804045958846124475183825589672204752895252723130454951830966138888560
c1 = 78327207863361017953496121356221173288422862370301396867341957979087627011991738176024643637029313969241151622985226595093079857523487726626882109114134910056673489916408854152274726721451884257677533593174371742411008169082367666168983943358876017521749198218529804830864940274185360506199116451280975188409
N = 157202814866563156513184271957553223260772141845129283711146204376449001653397810781717934720804041916333174673656579086498762693983380365527400604554663873045166444369504886603233275868192688995284322277504050322927511160583280269073338415758019142878016084536129741435221345599028001581385308324407324725353
c2 = 63355788175487221030596314921407476078592001060627033831694843409637965350474955727383434406640075122932939559532216639739294413008164038257338675094324172634789610307227365830016457714456293397466445820352804725466971828172010276387616894829328491068298742711984800900411277550023220538443014162710037992032
c3 = 9266334096866207047544089419994475379619964393206968260875878305040712629590906330073542575719856965053269812924808810766674072615270535207284077081944428011398767330973702305174973148018082513467080087706443512285098600431136743009829009567065760786940706627087366702015319792328141978938111501345426931078
e=65537

def factorize_multi_prime(N, phi):
    """
    Recovers the prime factors from a modulus if Euler's totient is known.
    This method works for a modulus consisting of any number of primes, but is considerably be slower than factorize.
    More information: Hinek M. J., Low M. K., Teske E., "On Some Attacks on Multi-prime RSA" (Section 3)
    :param N: the modulus
    :param phi: Euler's totient, the order of the multiplicative group modulo N
    :return: a tuple containing the prime factors
    """
    prime_factors = set()
    factors = [N]
    while len(factors) > 0:
        # Element to factorize.
        N = factors[0]

        w = randrange(2, N - 1)
        i = 1
        while phi % (2 ** i) == 0:
            sqrt_1 = pow(w, phi // (2 ** i), N)
            if sqrt_1 > 1 and sqrt_1 != N - 1:
                # We can remove the element to factorize now, because we have a factorization.
                factors = factors[1:]

                p = gcd(N, sqrt_1 + 1)
                q = N // p

                if is_prime(p):
                    prime_factors.add(p)
                elif p > 1:
                    factors.append(p)

                if is_prime(q):
                    prime_factors.add(q)
                elif q > 1:
                    factors.append(q)

                # Continue in the outer loop
                break

            i += 1

    return list(prime_factors)

res=factorize_multi_prime(n,phi)
# print(res)
p,q=min(res),max(res)

d=inverse(e,(p-1)*(q-1))
print(long_to_bytes(ZZ(pow(c1,d,p*q))),end='')
PR.<m> = PolynomialRing(Zmod(N))
f = m^2-(c2+c3)*m+c2*c3
x0 = f.small_roots(X=2^435)
if x0:
    print(long_to_bytes(ZZ(x0[0])))

fake_MT & real_MT

很好奇,这两个不是一样的吗???????

MT19937还是调库和脚本小子吧

用预测和反推随机数这两个库

from extend_mt19937_predictor import ExtendMT19937Predictor
from randcrack import RandCrack

还有extract_number和反推seed可以参考安全客和La佬的文章

from extend_mt19937_predictor import ExtendMT19937Predictor
from randcrack import RandCrack
import gmpy2
from pwn import *
context.log_level='debug'

def s1(randoms):
    rc = RandCrack()
    for i in randoms:
        res=bin(i)[2:].rjust(96,'0')
        rc.submit(int(res[-32:],2))
        rc.submit(int(res[-64:-32],2))
        rc.submit(int(res[-96:-64],2))
    res=rc.predict_getrandbits(96)
    return res
def s2(randoms):
    predictor = ExtendMT19937Predictor()
    for i in randoms[:624]:
        predictor.setrandbits(i, 32)

    _ = [predictor.backtrack_getrandbits(256) for _ in range(78)]
    res=predictor.backtrack_getrandbits(96)
    return res
def s3(seed):
    def _int32(x):
        return int(0xFFFFFFFF & x)
    def init(seed):
        mt = [0] * 624
        mt[0] = seed
        for i in range(1, 624):
            mt[i] = _int32(1812433253 * (mt[i - 1] ^ mt[i - 1] >> 30) + i)
        return mt[-1]
    def invert_right(res,shift):
        tmp = res
        for i in range(32//shift):
            res = tmp^res>>shift
        return _int32(res)

    def recover(last):
        n = 1<<32
        inv = gmpy2.invert(1812433253,n)
        for i in range(623,0,-1):
            last = ((last-i)*inv)%n
            last = invert_right(last,30)
        return last
    return recover(seed)
def s4(num):
    def inverse_left_mask(res, shift, mask, bits=32):
        tmp = res
        for i in range(bits // shift):
            tmp = res ^ tmp << shift & mask
        return tmp
    def inverse_right(res, shift, bits=32):
        tmp = res
        for i in range(bits // shift):
            tmp = res ^ tmp >> shift
        return tmp
    def recover(y):
        y = inverse_right(y,18)
        y = inverse_left_mask(y,15,4022730752)
        y = inverse_left_mask(y,7,2636928640)
        y = inverse_right(y,11)
        return y&0xffffffff
    return recover(num)
p=remote('node2.yuzhian.com.cn',31487)
p.sendline()
for i in range(1,21):
    p.recvuntil(b' '+str(i).encode()+b'\n')
    res=p.recvline()
    # print(res)
    if b'extract number = ' in res:
        r=int(res.replace(b'\n',b'').split(b' = ')[-1].decode())
        p.sendline(str(s4(r)).encode())
        p.recvuntil(b'Good job!\n')
    if b'last number = ' in res:
        r=int(res.replace(b'\n',b'').split(b' = ')[-1].decode())
        p.sendline(str(s3(r)).encode())
        p.recvuntil(b'Good job!\n')
    if b'randoms' in res:
        rr=eval(res.replace(b'L',b'').replace(b'\n',b'').split(b' = ')[-1].decode())
        print(rr)
        if len(bin(rr[0])) > 90:
            print(len(rr))
            p.sendline(str(s1(rr)).encode())
            p.recvuntil(b'Good job!\n')
        else:
            p.sendline(str(s2(rr)).encode())
            p.recvuntil(b'Good job!\n')
p.recvline()

easy_high

泄露低444位,高位不知道泄露多少,但是flag总不会有 1024-444 位吧,只需高位570-444=126位就可以计算出中间的,跟常规的p低位泄露其实差不多

直接上脚本吧

from Crypto.Util.number import *

c= 4881545863615247924697512170011400857004555681758106351259776881249360423774694437921554056529064037535796844084045263140567168171628832384672612945806728465127954937293787045302307135365408938448006548465000663247116917564500525499976139556325841597810084111303039525833367199565266613007333465332710833102978756654324956219855687611590278570749890543277201538208370370097424105751568285050703167350889953331829275262932104042040526209179357770495596739361176548337593674366015027648541293309465113202672923556991818236011769228078267484362980348613669012975963468592763463397575879215173972436831753615524193609612
N= 17192509201635459965397076685948071839556595198733884616568925970608227408244870123644193452116734188924766414178232653941867668088060274364830452998991993756231372252367134508712447410029668020439498980619263308413952840568602285764163331028384281840387206878673090608323292785024372223569438874557728414737773416206032540038861064700108597448191546413236875600906013508022023794395360001242071569785940215873854748631691555516626235191098174739613181230094797844414203694879874212340812119576042962565179579136753839946922829803044355134086779223242080575811804564731938746051591474236147749401914216734714709281349
p0= 149263925308155304734002881595820602641174737629551638146384199378753884153459661375931646716325020758837194837271581361322079811468970876532640273110966545339040194118880506352109559900553776706613338890047890747811129988585025948270181264314668772556874718178868209009192010129918138140332707080927643141811



PR.<x> = PolynomialRing(Zmod(N))
p4=(p0>>898)<<898
p1=int(bin(p0)[-444:],2)
par=p1+p4
mod=pow(2,444)
f=x*mod+par

# f=f.monic()
# f.small_roots(X=2^454,beta=0.4)
res=8996514515788824631645217678983870972689906544773849929777173576310649928527740139864048823998116829780535762155750526515388194925404594

p=par+res*mod
q=ZZ(N)//ZZ(p)
assert p*q==N
d=inverse(65537,(p-1)*(q-1))
long_to_bytes(ZZ(pow(c,d,N)))

complex_matrix

贴一下题目,扩展Wiener攻击

k = 400
p, q = getPrime(741), getPrime(741)
N = p * q
phi = (p-1) * (q-1)
_flag = bytes_to_long(flag)
# p, q = getPrime(1024), getPrime(1024)
d_array = [getPrime(k) for _ in range(4)]
e_array = [inverse(i, phi) for i in d_array]
c = pow(_flag, 65537, N)
print('N=',N)
print('e=',e)

d私钥为400位,N为741*2位

\frac{1}{3} N^{\frac{1}{4}}<d<N^{0.292}

N^0.292>d   第一眼觉得Boneh and Durfee attack可行,试了一下,发现上界为381位,这样跟理论不符,对我这样的脚本小子来说,不知道怎么改只能老实用扩展Wiener攻击了。

老实当脚本小子,往里面套一下e_array和N就行了,还是贴一下github的脚本

from Crypto.Util.number import *
debug = True

isdigit = lambda x: ord('0') <= ord(x) <= ord('9')

def my_permutations(g, n):
    sub = []
    res = []
    def dfs(s, prev):
        if len(s) == n:
            res.append(s[::])
        for i in g:
            if i in s or i < prev:
                continue
            s.append(i)
            dfs(s, max(prev, i))
            s.remove(i)
    dfs(sub, 0)
    return res

class X3NNY(object):
    def __init__(self, exp1, exp2):
        self.exp1 = exp1
        self.exp2 = exp2
    
    def __mul__(self, b):
        return X3NNY(self.exp1 * b.exp1, self.exp2 * b.exp2)

    def __repr__(self):
        return '%s = %s' % (self.exp1.expand().collect_common_factors(), self.exp2)

class X_Complex(object):
    def __init__(self, exp):
        i = 0
        s = '%s' % exp
        while i < len(s):
            if isdigit(s[i]):
                num = 0
                while i < len(s) and isdigit(s[i]):
                    num = num*10 + int(s[i])
                    i += 1
                if i >= len(s):
                    self.b = num
                elif s[i] == '*':
                    self.a = num
                    i += 2
                elif s[i] == '/':
                    i += 1
                    r = 0
                    while i < len(s) and isdigit(s[i]):
                        r = r*10 + int(s[i])
                        i += 1
                    self.b = num/r
            else:
                i += 1
        if not hasattr(self, 'a'):
            self.a = 1
        if not hasattr(self, 'b'):
            self.b = 0

def WW(e, d, k, g, N, s):
    return X3NNY(e*d*g-k*N, g+k*s)
def GG(e1, e2, d1, d2, k1, k2):
    return X3NNY(e1*d1*k2- e2*d2*k1, k2 - k1)

def W(i):
    e = eval("e%d" % i)
    d = eval("d%d" % i)
    k = eval("k%d" % i)
    return WW(e, d, k, g, N, s)

def G(i, j):
    e1 = eval("e%d" % i)
    d1 = eval("d%d" % i)
    k1 = eval("k%d" % i)
    
    e2 = eval("e%d" % j)
    d2 = eval("d%d" % j)
    k2 = eval("k%d" % j)
    
    return GG(e1, e2, d1, d2, k1, k2)

def R(e, sn): # min u max v
    ret = X3NNY(1, 1)
    n = max(e)
    nn = len(e)
    l = set(i for i in range(1, n+1))
    d = ''
    u, v = 0, 0
    for i in e:
        if i == 1:
            ret *= W(1)
            d += 'W(%d)' % i
            nn -= 1
            l.remove(1)
            u += 1
        elif i > min(l) and len(l) >= 2*nn:
            ret *= G(min(l), i)
            nn -= 1
            d += 'G(%d, %d)' % (min(l), i)
            l.remove(min(l))
            l.remove(i)
            v += 1
        else:
            ret *= W(i)
            l.remove(i)
            d += 'W(%d)' % i
            nn -= 1
            u += 1
    if debug:
        print(d)
    return ret, u/2 + (sn - v) * a

def H(n):
    if n == 0:
        return [0]
    if n == 2:
        return [(), (1,), (2,), (1, 2)]
    ret = []
    for i in range(3, n+1):
        ret.append((i,))
        for j in range(1, i):
            for k in my_permutations(range(1, i), j):
                ret.append(tuple(k + [i]))
    return H(2) + ret
    
def CC(exp, n):
    cols = [0 for i in range(1<<n)]
    
    # split exp
    texps = ('%s' % exp.exp1.expand()).strip().split(' - ')
    ops = []
    exps = []
    for i in range(len(texps)):
        if texps[i].find(' + ') != -1:
            tmp = texps[i].split(' + ')
            ops.append(0)
            exps.append(tmp[0])
            for i in range(1, len(tmp)):
                ops.append(1)
                exps.append(tmp[i])
        else:
            ops.append(0)
            exps.append(texps[i])
    if exps[0][0] == '-':
        for i in range(len(exps)):
            ops[i] = 1-ops[i]
        exps[0] = exps[0][1:]
    else:
        ops[0] = 1
    # find e and N
    l = []
    for i in range(len(exps)):
        tmp = 1 if ops[i] else -1
        en = []
        j = 0
        while j < len(exps[i]):
            if exps[i][j] == 'e':
                num = 0
                j += 1
                while isdigit(exps[i][j]):
                    num = num*10 + int(exps[i][j])
                    j += 1
                tmp *= eval('e%d' % num)
                en.append(num)
            elif exps[i][j] == 'N':
                j += 1
                num = 0
                if exps[i][j] == '^':
                    j += 1
                    while isdigit(exps[i][j]):
                        num = num*10 + int(exps[i][j])
                        j += 1
                if num == 0:
                    num = 1
                tmp *= eval('N**%d' % num)
            else:
                j += 1
        if tmp == 1 or tmp == -1:
            l.append((0, ()))
        else:
            l.append((tmp, tuple(sorted(en))))
    
    # construct h
    mp = H(n)
    for val, en in l:
        cols[mp.index(en)] = val
    # print(cols)
    return cols

def stirling(k):
    return factorial(k)/(factorial(k//2)^2)
def calcAlpha(n):
    if n % 2 == 1:
        fz = (2*n + 1) * 2^n - 4*n*stirling(n-1)
        fm = (2*n - 2) * 2^n + 8*n*stirling(n-1)
    else:
        fz = (2*n + 1) * 2^n - (2*n + 1)*stirling(n)
        fm = (2*n - 2) * 2^n + (4*n + 2)*stirling(n)
    return fz/fm


def EWA(n, elist, NN, alpha):
    mp = H(n)
    var('a')
    S = [X_Complex(n*a)]
    cols = [[1 if i == 0 else 0 for i in range(2^n)]]
    for i in mp[1:]:
        eL, s = R(i, n)
        cols.append(CC(eL, n))
        S.append(X_Complex(s))
    
    alphaA,alphaB = 0, 0
    for i in S:
        alphaA = max(i.a, alphaA)
        alphaB = max(i.b, alphaB)
    D = []
    for i in range(len(S)):
        D.append(
            int(NN^((alphaA-S[i].a)*alpha + (alphaB - S[i].b)))
        )
    kw = {'N': NN}
    for i in range(len(elist)):
        kw['e%d' % (i+1)] = elist[i]
    if debug:
        print("The lattice: ")
        print(Matrix(cols).T)
        
        print("The matrix D: ")
        print([N^((alphaA-S[i].a)*alpha + (alphaB - S[i].b)) for i in range(len(S))])

    B = Matrix(ZZ, Matrix(cols).T(**kw)) * diagonal_matrix(ZZ, D)
    L = B.LLL(0.5)
    v = Matrix(ZZ, L[0])
    x = v * B**(-1)
    phi = int(x[0,1]/x[0,0]*elist[0])
    return phi

def attack(NN, elist, alpha):
    for i in range(1, len(elist)+1):
        var("e%d" % i)
        var("d%d" % i)
        var("k%d" % i)
    g, N, s = var('g'), var('N'), var('s')
    phi = EWA(len(elist), elist, NN, alpha)
    return phi

def example(N,e):
    from Crypto.Util.number import long_to_bytes, getPrime, bytes_to_long
    import uuid
    def rsa(e, n):
        m = uuid.uuid4().hex.encode()
        c = pow(bytes_to_long(m), e, n)
        return m.decode(), c
#     p = getPrime(1024)
#     q = getPrime(1024)
    
    # The modulus in RSA
    NN = N
    
    # The exponent in RSA
#     e = 0x10001
#     m, c = rsa(e, NN)
#     print("The plaintext is:", m)
    
    # Theoretical upper bound in paper, but it is much smaller when actual test 
    alpha = calcAlpha(3)
    print("Alpha: ",alpha)
    elist = e
    phi = attack(NN, elist, alpha)
    
    if phi != 0:
        print("Found Phi: ", phi)
        return phi

N=71841248095369087024928175623295380241516644434969868335504061065977014103487197287619667598363486210886674500469383623511906399909335989202774281795855975972913438448899231650449810696539722877903606541112937729384851506921675290984316325565141178015123381439392534417225128922398194700511937668809140024838070124095703585627058463137549632965723304713166804084673075651182998654091113119667582720831809458721072371364839503563819080226784026253
n=N
e=[65128799196671634905309494529154568614228788035735808211836905142007976099865571126946706559109393187772126407982007858423859147772762638898854472065889939549916077695303157760259717113616428849798058080633047516455513870697383339784816006154279428812359241282979297285283850338964993773227397528608557211742425548651971558377656644211835094019462699301650412862894391885325969143805924684662849869947172175608502179438901337558870349697233790535, 58756559706647121529575085912021603170286163639572075337348109911506627489265537716060463072086480156516641723700802217411122982693536541892986623158818442274840863016647800896033363360822503445344748132842451806511693779600370832206455202293028402486647422212959763287987847280322100701242139127654031151565924132562837893975505159702015125483479126108892709063135006366792197127007229210558758401679638300464111782814561428899998471531067163715, 34828685390969672139784723764579499920301439564705391196519314224159563070870933754477650614819514127121146216049444888554338415587165719098661141454627820126445291802801256297252654045398330613075575527685542980264993711077876535643646746742646371967302159565887123638001580042027272379341650995728849759541960087953160211696369079708787543303742132161742979856720539914370868829868891655221361545648778590685232034703220732697083024449894197969, 26717968456600556973167180286909817773394160817933525240720067057464671317174201540556176814203780603153696663101158205367554829261808020426363683474848952397963507069306452835776851274959389849223566030857588019845781623271395012194869024566879791449466064832273531795430185178486425688475688634844530106740480643866537205900809400383304665727460014210405339697947582657505028211149470787536144302545259243549176816653560626044921521516818788487]
c=39297018404565022956251803918747154798377576057123078716166221329195959669756819453426741569480551313085435037629493881038383709458043802420338889323233368852331387845200216275712388921820794980987541224782392553528127093154957890356084331463340193478391679540506421250562554424770350351514435220782124981277580072039637811543914983033300225131364246910828188727043248991987332274929827173923543187017105236008487756190002204169623313222748976369
phi=example(N,e)
d=inverse(65537,ZZ(phi))
long_to_bytes(ZZ(power_mod(c, d, n)))

ez_LargeCG

p1,q1,p2,q2因为光滑数很好分解,都很好求

第一次见四阶LCG反推,以为可以用sagemath求数列通项来反推出来,结果发现数据结果模运算之后,求出来的也不过是一个较为拟合的通项公式。

看别人wp,才知道是构造矩阵的方法,通过矩阵的快速幂来快速实现LCG。

很巧妙呀,一个等式就很看懂了

\begin{pmatrix} 0 & 1 & 0 &0\\ 0 & 0 & 1 & 0\\ a & b & c & d\\ 0 & 0 &0 & 1 \end{pmatrix}\times \begin{pmatrix} s_1\\s_2\\s_3\\1 \end{pmatrix}= \begin{pmatrix} s_2\\s_3\\s_4\\1 \end{pmatrix}

from Crypto.Util.number import *
n1 = 39755206609675677517559022219519767646524455449142889144073217274247893104711318356648198334858966762944109142752432641040037415587397244438634301062818169
n2 = 30725253491966558227957591684441310073288683324213439179377278006583428660031769862224980605664642101191616868994066039054762100886678504154619135365646221
r = 7948275435515074902473978567170931671982245044864706132834233483354166398627204583162848756424199888842910697874390403881343013872330344844971750121043493
s1 = 6085327340671394838391386566774092636784105046872311226269065664501131836034666722102264842236327898770287752026397099940098916322051606027565395747098434
s2 = 1385551782355619987198268805270109182589006873371541520953112424858566073422289235930944613836387546298080386848159955053303343649615385527645536504580787
s3 = 2529291156468264643335767070801583140819639532551726975314270127875306069067016825677707064451364791677536138503947465612206191051563106705150921639560469

q1 = 427721675251610827084310512123962488210068003845592404231631542730839819224381
p1 = 92946439027877993602295703905130336736159270745389239059083263513478865293549

p2=106481130516780473105954611077340189174861459077145246394800660809527032990637
q2=288551157776490110472645044398395422160196115791981535735903775378294599329633

S=vector(GF(r),[s1,s2,s3,1])
T=matrix(GF(r),[[0,1,0,0],[0,0,1,0],[p1,q1,p2,q2],[0,0,0,1]])
res=T^(-6^666)*S
long_to_bytes(ZZ(res[0]-2023))

---------------------------------------------------------------------------------------------------------------------------------补一下这个格

Raven

感觉应该是常见的构造方式,毕竟La佬的格密码文章示例就是这个

三次多项式的系数都是md5加密过来的,即32bytes=>256bit,

这个题就是求这个系数的

 \noindent \\ y=(a_3*x^3+a_2*x^2+a_1*x+a0)^2+e

展开是这样的 

y_i=\begin{pmatrix} a_1& \cdots &a_6 \end{pmatrix}*\begin{pmatrix} x_i^1\\ \vdots \\x_i^6 \end{pmatrix}+a_0+e_i

构造格使得a0+e,a1-a6在格上,对着上面的构造示例就完事了,m=>[a1,..,a6],r=>a+e

\begin{pmatrix} -1&a_1& \cdots &a_6 & -k_1 &\cdots&-k_4 \end{pmatrix}*\begin{pmatrix} 2^{256} &0 & \cdots &0 &y_1 &\cdots & y_4\\&1&\cdots&0&x_1&\cdots&x_4\\ &\vdots &\ddots &\vdots &\vdots &\vdots &\vdots &\vdots\\ &0 &\cdots &1 &x_1^6 &\cdots&x_4^6 \\ & & & & p & & \\ & & & & & \ddots & &\\ & & & & & & p \end{pmatrix}\\\\\\=\begin{pmatrix}-2^{256} &a_1& \cdots &a_6 & a_0+e_0&\cdots&a_0+e_3\end{pmatrix}

exp

p = 1018551160851728231474335384388576586031917743463656622083024684199383855595168341728561337234276243780407755294430553694832049089534855113774546001494743212076463713621965520780122783825100696968959866614846174188401153
pairs = [(615358616404864757405587650175842125441380884418119777842292095751090237848084440177153221092040264723889917863863854377665802549748720692225139890884830475485512763149974948701807492663962748292710803434009673589337265, 84982753624462868217739962129526665082932464631118597651920986288766037499319751354013335054886685186857222944776560264528363811382359242656883760986496856164448940929282013856762706210675691655747370624405968909408102), (528363810186974800127873139379943131424126521611531830591311656948009967709310974894584084912262479395720199930206495204352231804549705720854271566421006481173043064265399467682307971910488405265826107365679757755866812, 496810092723839642457928776423789418365006215801711874210443222720529161066621876103037104247173440072986344011599384793861949574577559989016501090247331146721371126871470611440468688947950954988175225633457347666551944), (68711183101845981499596464753252121346970486988311398916877579778110690480447199642602267233989256728822535174215153145632158860662954277116345331672194812126361911061449082917955000137698138358926301360506687271134873, 995428771589393162202488762223106955302099250561593105620410424291405842350539887383005328242236156038373244928147473800972534658018117705291472213770335998508454938607290279268848513727721410314612261163489156360908800), (61574167546312883246262193556029081771904529137922128124933785599227801608271357738142074310192454183183340219301304405636497744152219785042075198056952749425345561162612590170550454476602892138914473795478531165181812, 618169326093802548516842299173393893046765466917311052414967158839652012130855552015876657514610755108820971877570295328618373296493668146691687291894702228119875561585283226588768969944781923428807766632578060221034862)]
X=[i[0] for i in pairs]
Y=[i[1] for i in pairs]

b=matrix(11,11)
b[0,0]=2^256
for i in range(1,7):
    b[i,i]=1
for i in range(7,11):
    b[0,i]=Y[i-7]
for i in range(1,7):
    for j in range(7,11):
        b[i,j]=X[j-7]^i
for i in range(7,11):
    b[i,i]=p
res=b.LLL()[0]
import gmpy2
from Crypto.Util.number import *
from Crypto.Cipher import AES
a3=gmpy2.iroot(res[6],2)[0]
a2=res[5]//(2*a3)
a1=(res[4]-a2^2)//(2*a3)
a0=res[1]//(2*a1)
print(a0^2)
key=long_to_bytes(a0)
ct = b"|2\xf0v7\x05Y\x89\r]\xe93s\rr)#3\xe9\x90%Z\x9a\xd9\x9ck\xba\xec]q\xb8\xf2'\xc8e~fL\xcf\x93\x00\xd6^s-\xc9\xd6M"
aes=AES.new(key,iv=bytes(range(16)),mode=AES.MODE_CBC)

print(aes.decrypt(c))

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值