MugoSquero on 5:25 PM 04/23/2024: Seems impossible without patching, because the algorithm includes some checks based on the effective address of a value on the stack. This means it changes every time. I hope I am wrong because it will teach me a lot.
majorsopa on 5:51 PM 04/23/2024: Mugo- correct(ish), however for whatever reason this effective address didn't change between runs on Windows, only compiles. On Linux it changed every run.
I do absolutely think the only practical approach would use patching to bypass the antidebug and derive a password from that, which you can then use on the original binary.
If my observations about effective addresses were incorrect and an artifact of my development environment, then I will remove the crackme. However I do not believe this is the case.
note- patching the binary will change the effective address, so it's not as simple as printf'ing the effective address.
nnxstnt on 11:23 AM 04/24/2024: The answer is clearly runtime dependant. Check out ASLR and how virtual memory works.
Apart from the some anti-debug shenanigans at the start, the algorithm is pretty straigth forward.
majorsopa on 12:42 PM 04/24/2024: it isn't runtime dependent. i have a text file on my pc which gives a correct answer. don't be mad if you can't solve it lol
nnxstnt on 2:23 PM 04/24/2024: Uhh, I patched too much in the anti-debug part, you are correct, my bad
MugoSquero on 4:30 PM 04/24/2024: Every time I hit restart on the original binary in x64dbg, the effective address of the top of the stack changes. What am I missing?
Mirion on 11:41 AM 05/07/2024: int __stdcall getPassword()
{
int v1; // [esp+0h] [ebp-4h] BYREF
v1 = 1986487925;
return (int)&v1;
}
The returned value seems dynamic to me. I don't know how to do next.
cnathansmith on 4:48 AM 05/11/2024: @majorsopa you can calculate the password from just the base address of the main module, which you can obtain via CreateToolhelp32Snapshot without attaching to it or modifying anything.
checksum = ((base + 0x27f18) ^ 0x80000103) * -1
Then the password is the checksum spelled out backwards (LSB first) in binary. (The password will be 32 '1's and '0's)
cnathansmith on 7:31 AM 05/11/2024: @majorsopa Windows ASLR isn't really randomized for the same module during a single boot. If you rename or copy the exe it's layout will change, but if you keep executing it from the same location, it will be mapped the same every time at least until a reboot.
cnathansmith on 6:23 PM 05/13/2024: Also, the exe image stays together. So an address in .text or .data will always be the same offset from the base address, though the base address might be random (-ish.. there's only 12 bits of entropy for a 32-bit ASLR).
The stack and external DLLs could theoretically be mapped anywhere, though that isn't quite true with DLLs because Windows tries to load them to the same address in every process. Kernel32.dll in particular is unofficially guaranteed to be in the same location for every process (Microsoft won't claim so in official documentation, but Windows Internals and other sources they semi-endorse do)
Consequently, if you keep running a program from the same location, it will keep getting the same base address, but renaming it will randomize it again.
goxdevislearningreversing3131 on 5:45 PM 08/24/2024: hello. can you please give me your discord back?