ELFファイル chall が与えられた。
chall をentry関数からFUN_001011a9関数を第1引数として__libc_start_main関数を呼び出していた。
FUN_001011a9関数の逆コンパイル結果は、以下のものである。
A ELF file chall was given.
Decompiling chall via entry is calling the function __libc_start_main with the function FUN_001011a9 as the first argument.
This is the result of decompiling of the function FUN_001011a9:
この関数は、scanf関数で文字列をlocal_58に読み込んだ後、local_60を1に初期化し、
local_5cを0から0x39まで1ずつ増やしながら以下の計算を行い、
最終的にlocal_60が0かどうかを判定するものである。
This function firstly reads a string to local_58 via the scanf function.
Then, after initializing local_60 to 1, it performs following calculation with incrementing local_5c from 0 to 0x39.
Finally, it checks if local_60 is zero.
この計算は、配列s__00104020の指定の要素が入力データlocal_58の今見ている要素と一致しているならlocal_60の値を変えず、
そうでなければlocal_60の値を0にする、というものである。
したがって、最終的なlocal_60の値を1にするには、この計算全てについて値を一致させないといけない。
Ghidra上で00105000にあるデータがファイル中の0x4000バイト目(0-origin)に存在したことからオフセットを計算し、 以下のプログラムを用いてflagを求めた。
This calculation keeps the value of local_60 if the specified element of the array s__00104020 equals to current element of the input data local_58,
and sets local_60 to zero otherwise.
This means that all pairs of values checked here should be equal to make the final value of local_60 to be 1.
I calculated the offset from the fact that the data on 00105000 in Ghidra existed from 0x4000-th byte in the file (the first byte is 0th), and obtained the flag via this program: