ELFファイル ltrace が与えられた。
strings --radix=x コマンドで文字列データを確認したところ、
-0x40(%rbp) に scanf 関数でデータを読み込んだ後、それを strcmp 関数で -0x70(%rbp) のデータと比較し、一致しなければ「Incorrect」を出力することがわかった。
そこで、バイナリを書き換え、一致しなかった時に -0x70(%rbp) の値を出力させることにした。
具体的には、アドレス142dにある 48 8d 3d f6 0b 00 00 (lea 0xbf6(%rip),%rdi) を、48 8d 7d 90 90 90 90 (lea -0x70(%rbp),%rdi; nop; nop; nop) に書き換えた。
書き換えたバイナリを
An ELF file ltrace was given.
I disassembled the file via objdump in strings --radix=x command.
As a result, I found it reads data to -0x40(%rbp) via the function scanf, compares the data with data in -0x70(%rbp) using the function strcmp, and prints "Incorrect" if they differs.
Seeing this, I decided to modify the binary to have it print data in -0x70(%rbp) on mismatch.
To achieve this, I changed 48 8d 3d f6 0b 00 00 (lea 0xbf6(%rip),%rdi) at the address 142d to 48 8d 7d 90 90 90 90 (lea -0x70(%rbp),%rdi; nop; nop; nop).
I obtained the flag my uploading the modified binary to