Da das Crackme auch auf crackmes.de ist (ich bin dort als DeepBlue angemeldet), habe ich mal eine genaue Solution auf englisch geschrieben.
Sie muss nur noch von einem Moderator dort reviewed werden.
http://crackmes.de/users/dolphvs/dolphvs_first_c_crackme/
Aber ich poste sie hier schonmal:
EDIT: Der text an den Codestellen ist etwas unübersichtlich formatiert. Guckt in den Anhang. Das ist der text as TXT.
+++ATH0s aka DeepBlues First Solution
==========================
Target: DolphVS first C++ Crackme
Tools: OllyDbg (Shadow), Brain, Beer
-----------------------------------------
-----------------------------------------
Screw PEiD, We load pwd.exe directly with OllyDbg.
First we look for Text-Strings which could be interesting.
We see "Yeah Right!" and "Access Denied".
We make a doubleclick on "Yeah Right!" and see whats going on there.
004014C4 |. /7A 02 JPE SHORT pwd.004014C8
004014C6 |. |74 02 JE SHORT pwd.004014CA <<<< We could patch this line to a JMP, and we're done.
004014C8 |> \EB 26 JMP SHORT pwd.004014F0
004014CA |> C74424 04 680>MOV DWORD PTR SS:[ESP+4],pwd.00440068 ; ASCII "Yeah, right!" <<<< Here we are
2 Lines over it, we see an Jump if Equal. We could patch it to a JMP.
And we are done.
But lets try it the other way.
Scroll a bit up to the Line where "Please enter your ID:" is being moved.
We make here a Breakpoint with F2.
004013F7 |. C74424 04 1A0>MOV DWORD PTR SS:[ESP+4],pwd.0044001A ; ASCII "Please enter your ID: " <<<< Breakpoint here.
004013FF |. C70424 C03344>MOV DWORD PTR SS:[ESP],pwd.004433C0
00401406 |. E8 8DAD0300 CALL pwd.0043C198
0040140B |. 8D45 F0 LEA EAX,[LOCAL.4]
0040140E |. 894424 04 MOV DWORD PTR SS:[ESP+4],EAX
00401412 |. C70424 603444>MOV DWORD PTR SS:[ESP],pwd.00443460
00401419 |. E8 D2680200 CALL pwd.00427CF0 <<<<< Step to this point
Lets run it with F9.
Now we step with F8 over the first call, to the second call where the user is supposed to type in the ID.
Sure, we could have made a Breakpoint directly there. But we could have missed something
Now we type in an ID into the Crackme....Hm lets try 1337 !
Enter.
We're popping back to Ollydbg.
And we see some Floating Operations.
0040141E |. DD45 F0 FLD QWORD PTR SS:[EBP-10] <<<<< Here we are now.
00401421 |. DD05 98004400 FLD QWORD PTR DS:[440098]
00401427 |. DAE9 FUCOMPP
00401429 |. DFE0 FSTSW AX
0040142B |. 9E SAHF
0040142C |. 73 02 JNB SHORT pwd.00401430 <<<<<< Step tho this point.
0040142E |. EB 29 JMP SHORT pwd.00401459
00401430 |> C74424 04 310>MOV DWORD PTR SS:[ESP+4],pwd.00440031 ; ASCII "ID not long enough!"
We step one time with F7 and see our ID loaded in ST0.
We step another time with F7 and see 6.000.. loaded into ST0. (Our ID is now in ST1)
We step further to JNB.
Now we realise what is done. If the 6 is not below (higher) then our ID, it jumps and loads the string, that our ID is not
long enough. But that has nothing to do with the length of the ID, DolphVS. Has it ?
But our ID is 1337, we have nothing to fear. We see that the Jump is not taken.
Behind the JNB, is a JMP which will always be taken.
We jump and now we're here:
00401459 |> \C74424 04 480>MOV DWORD PTR SS:[ESP+4],pwd.00440048 ; ASCII "Please enter the correct Code: "
00401461 |. C70424 C03344>MOV DWORD PTR SS:[ESP],pwd.004433C0
00401468 |. E8 2BAD0300 CALL pwd.0043C198
0040146D |. 8D45 F8 LEA EAX,[LOCAL.2]
00401470 |. 894424 04 MOV DWORD PTR SS:[ESP+4],EAX ; pwd.00440100
00401474 |. C70424 603444>MOV DWORD PTR SS:[ESP],pwd.00443460
0040147B |. E8 70680200 CALL pwd.00427CF0 <<<<<< Step to this line with F8
00401480 |. C74424 04 68A>MOV DWORD PTR SS:[ESP+4],pwd.0043AF68
00401488 |. C70424 C03344>MOV DWORD PTR SS:[ESP],pwd.004433C0
0040148F |. E8 5C8C0200 CALL pwd.0042A0F0
We step over the calls with F8. At the second call we have to enter our code.
We try 12345, coz its 1337

.
Enter.
Here we go. Now we see how the code is calculated:
00401494 |. DD45 E0 FLD QWORD PTR SS:[EBP-20] <<<< loads a crappy unimportant real number 1,697......
00401497 |. DC4D F0 FMUL QWORD PTR SS:[EBP-10]
0040149A |. DC45 E8 FADD QWORD PTR SS:[EBP-18]
0040149D |. DD5D D8 FSTP QWORD PTR SS:[EBP-28]
004014A0 |. DD05 A0004400 FLD QWORD PTR DS:[4400A0]
004014A6 |. DD5D E0 FSTP QWORD PTR SS:[EBP-20] <<<<< gets 1543 into St0 (everytime, by every ID)
004014A9 |. DD45 F0 FLD QWORD PTR SS:[EBP-10] <<<<< loads our ID from the stack
004014AC |. DC4D E8 FMUL QWORD PTR SS:[EBP-18] <<<<< multiplicates our ID with 12 = 16044
004014AF |. DD45 F0 FLD QWORD PTR SS:[EBP-10] <<<<< loads our ID from the stack
004014B2 |. DC4D E0 FMUL QWORD PTR SS:[EBP-20] <<<<< multiplicates our ID with 1543 = 2062991
004014B5 |. DEC1 FADDP ST(1),ST <<<<< Add both Multiplications = 2079035
004014B7 |. DC45 D8 FADD QWORD PTR SS:[EBP-28] <<<<< Adds 12 to that = 2079047
004014BA |. DD45 F8 FLD QWORD PTR SS:[EBP-8] <<<<< loads the code we typed in : 12345
004014BD |. D9C9 FXCH ST(1) <<<<< exchanges both values in the STs
004014BF |. DAE9 FUCOMPP <<<<< compares our code with the calculated
004014C1 |. DFE0 FSTSW AX <<<<< Exception handling
004014C3 |. 9E SAHF
004014C4 |. 7A 02 JPE SHORT pwd.004014C8 <<<<< Jump on Exception
004014C6 |. 74 02 JE SHORT pwd.004014CA <<<<< Jump if our typed code is the same as the calculated
004014C8 |> EB 26 JMP SHORT pwd.004014F0
004014CA |> C74424 04 680>MOV DWORD PTR SS:[ESP+4],pwd.00440068 ; ASCII "Yeah, right!" <<<< Movs the "Yeah Right!" String
So the Algorithm calculates the Code like this:
1543 * ID + ID * 12 + 12 = Code
1543 * 1337 + 1337 * 12 + 12 = 2079047
Now we can write a keygen (Delphi):
program keygen;
{$APPTYPE CONSOLE}
uses
SysUtils,
Windows;
var
id_str: String;
id,code: Integer;
begin
Writeln('Type in the ID :');
Read(id_str);
id:= StrToInt(id_str);
code:=1543 * id + id * 12 + 12;
Messagebox(0,Pchar('The code for this ID is: ' + IntToStr(code)),'Code',MB_ICONINFORMATION);
end.
Nice, Crackme @ DolphVS
EDIT: Der text an den Codestellen ist etwas unübersichtlich formatiert. Guckt in den Anhang. Das ist der text as TXT.