TCPサーバの接続情報が与えられた。
また、ELFファイル OilSpill と、ファイル Dockerfile が与えられた。
OilSpill をstrings --radix=x コマンドで文字列の位置に対応する文字列を求めたところ、以下の処理をしていることがわかった。
puts 関数のアドレスprintf 関数のアドレスfgets 関数でデータを読み込む先のスタック上のアドレスtemp 関数のアドレスfgets 関数で文字列を読み込む。printf 関数の第1引数に渡す。
Information to connect to a TCP server was given.
An ELF file OilSpill and a file Dockerfile were also given.
I disassembled OilSpill using objdump from strings --radix-x command.
As a result, I found it doing this:
putsprintffgets called latertempfgets.printf.I entered this string and examined the output:
を入力し、出力を調べると、入力した文字列は8番目以降のデータに反映されることがわかった。
また、出力された puts 関数および printf 関数のアドレスを libc6_2.27-3ubuntu1.5_amd64 のみがヒットした。
これらに基づき、printf関数とデータの読み込み先のアドレスを受け取り、入力するべきデータを出力する以下のプログラムを作成した。
As a result, I found that the string entered is used as the 8th data and data after that.
Also, I put the printed addresses of puts and printf to libc6_2.27-3ubuntu1.5_amd64 was presented as a result.
Based on these, I created this program that takes addresses of printf and where to read the data, and outputs data to enter.
このプログラムにより作成したデータを入力すると、書式 %n により以下の動作をする。
__stack_chk_fail として呼び出す関数のアドレスを、main 関数のアドレスに書き換える。printf として呼び出す関数のアドレスを、system 関数のアドレスに書き換える。__stack_chk_fail を呼び出させる。
作成したデータを
ここで /bin/sh と入力することで、シェルを起動することができる。
起動したシェルで ls -al コマンドを実行することで、ファイル flag.txt があることがわかった。
cat flag.txt コマンドを実行すると、flagが得られた。
When the data created via this program is entered, thanks to the format specifier %n, the behavior will be:
__stack_chk_fail to one of the function main.printf to one of the function system.__stack_chk_fail.
After sending the data via "Send File" on
We can launch the shell by entering /bin/sh here.
I found that a file flag.txt exists via ls -al command on the shell.
I obtained the flag via cat flag.txt command.