1) Identify type of file, change the file permission, and execute
Here we need to use command file "file name" to identify what the file made of
In this example, it is ELF 64-bit
Next, we change the permission of the file to 777 with the command of chmod 777 "file name" which gives full permission for us to do anything with the file
Next, we try to execute the file with command ./"file name"
Here we can see that it prompted us with password:
2) Analyze ELF file using ghidra
Open the file in your ghidra
Scroll down until you find the "password" section.
Here we can see that there is a C code on the right which we can analyze to get our password


3) Code Analysis
Here the important part is this:
__isoc99_scanf("DoYouEven%sCTF", local_28);
and
iVar1 = strcmp(local_28, "_init");
3.1) First Part
__isoc99_scanf("DoYouEven%sCTF", local_28);
in this part the scanf will scan everything up until the %s
the %s means that it will scan right before a whitespace, in this case is a "space"
But, the "DoYouEven" part will not be stored in the variable, only the "%s"
this is due to how the scanf works
the "DoYouEven" act as a verifier, means that the password need to match the "DoYouEven" first.
so that the %s will be stored in the local_28
so the password pattern should be: DoYouEven<something>
and the <something> will be stored in local_28
3.2) Second Part
iVar1 = strcmp(local_28, "_init");
in this syntax, it will compare local_28 with _init, and if the password match,
it will return "correct" or else "please try again"
so from the first part, we know that <something> is stored in local_28
so in order the <something> to be equal to "_init"
We replace <something> with "_init" too
thus the strcmp will campare "_init" and "_init"
and will return == 0 which is correct in the end.
Comments
Post a Comment