This crackme is a little special as there's no hint about the protection. Filemon and Regmon don't show anything suspicious, there are no hidden resources either. So we should have a look at the listing - but the program is packed with UPX and can't be unpacked by the packer. We do it by hand - and that's the fun part!
We find the jump to the OEP after the popad command:
415F7F: jmp 401000
We make a fulldump with Procdump (Options - Rebuild IT), fix the OEP --> the program runs! But there are no Imports available in the Listing. Even though its not really necessary, i rebuild the IT by hand.
We find the IMAGE_IMPORT_DESCRIPTOR at Offset 15208h at the end of the resource section. Thats the one used by the packer, it shows only a few APIs. Scrolling through the listing we find the real IT with a lot of APIs at offset 12807h and what looks like the FIRST_THUNK at offset E8FCh. I copied the IMAGE_IMPORT_DESCRIPTOR to offset E800h (start of section "text", RVA 10000h) - that's where it should be!
I had to fix the pointer at offset 280h to point to the new location of IMAGE_IMPORT_DESCRIPTOR:
This is the WindowProcedure of the main window which handles the messages. This can be veryfied when looking at RegisterClassExA (address 4014AD). The flag is being set to one at address 40130A - see X-Ref in IDA:
00401308 7E 13 jle short loc_40131D
0040130A C6 05 14 B1 40 00+ mov ds:byte_40B114, 1 ; set flag to 1
00401311 C7 05 18 B1 40 00+ mov ds:dword_40B118, 5
0040131B EB 12 jmp short loc_40132F
In order to get to this location, the program has to take the jump at address 4011D7. But which message is being used? We have a look at the code and win.h:
Well, we have to trace this a couple of times before it becomes clear:
o----->-----o
|
|
Y
|
|
o-----<-----o
We have to click four times the left mouse button i.e. describing the corners of a rectangle. The distance between two points must be greater than 10 pixel, whereas the difference in the other axis must be within +/- 9 pixel.