Here is the Ghidra decompiler output for a crackme problem. Specifically, this one:
Code:
undefined8 entry(undefined8 param_1,char *param_2)
{
int iVar1;
size_t sVar2;
char *pcVar3;
char *pcVar4;
char local_118 [9];
char local_10f;
long local_10;
local_10 = *(long *)___stdinp;
_strcspn("Enter the password...\n",param_2);
_printf(local_118,0x100,*(undefined8 *)_fgets);
pcVar3 = "\n";
sVar2 = _strlen(local_118);
pcVar4 = local_118;
local_118[sVar2] = '\0';
iVar1 = dyld_stub_binder();
if (iVar1 == 10) {
if (local_118[0] == local_10f) {
_strcspn("Correct!\nthe password is: %s\n",local_118);
}
else {
_wrong_password(pcVar4,pcVar3);
}
}
else {
_wrong_password(pcVar4,pcVar3);
}
if (*(long *)___stdinp == local_10) {
return 0;
}
I'm having some trouble understanding the output.
- the printf and strcspn functions seem to be switched?
- the
local_10f
variable is never initialized, and yet is still used to compare to the passcode. - I know from reading the solution, that as long as the first and last characters are the same, and the length is 10, then the passcode will work. How does "dyld_stub_binder" check for length? Where do the first and last characters get compared?
Thanks for any help.