TCPサーバの接続情報と、ELFファイル deadcode が与えられた。
このファイルをobjdumpで逆アセンブルすると、
main関数内でgets関数を用いて入力を読み込んでいるのが見えた。
また、以下のsystem("/bin/sh")を呼び出すコードがあった。
Information to connect to a TCP server and a ELF file deadcode were given.
Disassembling the file via objdump in gets is used to read some input in the function main.
Also, I found this code that calls system("/bin/sh"):
さらに、gets関数が読み込んだデータは-0x20(%rbp)から読み込まれ、リターンアドレスは%rbpの8バイト先なので、
リターンアドレスはgets関数のデータの読み込み先から0x28バイト先にあることが読み取れた。
これらを踏まえ、
シェルで ls -al コマンドを実行するとファイル flag.txtがあることがわかり、
cat flag.txt コマンドを実行することでflagが得られた。
Moreover, I found that the return address is 0x28 bytes ahead from where the function gets saves data read
because it saves from -0x20(%rbp) and the return address is 8 bytes ahead from %rbp.
Based on these, I succeeded to launch the shell by connecting to the server via
I found that a file flag.txt exists by executing a commnand ls -al in the shell,
and obtained the flag via a command cat flag.txt.