I've been trying to solve a crackme challenge by examining it's decompiled version by Ghidra.
So I figured the code where the strcmp
is done as shown in the figure below. Now I need to to patch the program to make it print the password if strcmp
fails.
- The password is stored in
local_40
But I don't know how to patch the instruction to print out the value at local_40
Instead of MOV dword ptr [ESP],0x4b1050
what variable in this instruction should be edited? If my understanding is correct then the above instruction is loading the ESP register with the value at 0x4b1050
so how will I get the address of local_40
?
ltrace
for this matter.LEA EAX, [EBP - 0x3c]; MOV dword ptr [ESP], EAX
(notice thatlocal_40
is actuallyEBP - 0x3c
). You'll need to override some instructions before0x40151a
as well, and therefore to point theJNZ
accordingly.