home *** CD-ROM | disk | FTP | other *** search
/ KeyGen Studio 2002 / KeyGen_Studio_2002.iso / Tutorials / CrackMesCbjNet / alf-canyou.txt < prev    next >
Encoding:
Text File  |  2001-09-21  |  4.4 KB  |  148 lines

  1. Santmat's Crackme 5th August 2001
  2. ---------------------------------
  3. Solution by Alf
  4.  
  5. Tools Used: Softice 3.24
  6. Thanks to Santmat for the crackme!!
  7.  
  8. The purpose of this crackme is to make a keygen.
  9. At a first glance this seems simple because the name manipulation is 
  10. very simple but there are two subtle details.The program uses the 
  11. coordinates 
  12. of the mouse cursor ( when you click 'Gain Access!') and the serial of 
  13. your c: drive 
  14. to produce the correct serial number. 
  15.  
  16. The important memory addresses are these:
  17.  
  18. [4030d0] : name entered
  19. [4032d0] : serial entered
  20. [4036d4] : serial_length+ number produced by your windows product 
  21. number
  22. [4036d8] : holds the result from name manipulation
  23. [4036dc] : serial of c: drive
  24. [4030cc] : (x*y)^0x12345 ( x,y mouse coordinates)
  25.  
  26. Note: ^ indicates the xor boolean function
  27.  
  28. The crackme first produces a number out of the name, more or less like 
  29. this:
  30.  
  31. result=0;
  32. while(*name) 
  33.     result=*name++^0x33;
  34.  
  35. Then let x,y be the coordinates of the mouse cursor:
  36. A=result* ((x*y)^0x12345)+ SerialOfC:Drive
  37.  
  38. The x*y^0x12345 is stored in location [4030cc]. At first I thought it 
  39. was 
  40. a constant number but when I placed a breakpoint on it I realised it 
  41. was changing
  42. as the mouse moved. After that it was a piece of cake to figure out the 
  43. x*y formula.
  44.  
  45. There is also a B=(SerialLength+NumberByWindowsSerial)+((x*y)^0x12345) 
  46. but either on purpose or by error it is not used!
  47.  
  48. That is because after some calculations A is stored in EDX and B 
  49. in ECX.
  50. Then A(EDX) is pushed as a parameter to wsprintf and then the function 
  51. is called.
  52. The bad thing is that wsprintf alters the value of ECX and puts in 
  53. there the address
  54. of the current SEH( 'structured exception handler' ). This is always 
  55. 0x64fb80.
  56. Then ECX( which is not B anymore) is pushed as a parameter to another 
  57. wsprintf.
  58.  
  59. Anyway the way the number is produced by the windows serial at [4034d4] 
  60. is the following:
  61.  
  62. Every character is xored with 0x66 and added to 0x64fb00. All these 
  63. results are added
  64. to produce the final result at [4036d4] . Actually the addition to 
  65. 0x64fb00 is not really an addition. The number 0x64fbcc is a leftover in 
  66. ECX from a previous function and is the current SEH ( just like the 
  67. previous case ). The windows serial manipulations take place at CL but ECX 
  68. is not cleared before that and so the rest of ECX gets carried along...
  69.  
  70.  
  71. To wrap up,each wsprintf(...,"%lu",...) just produces a string with the 
  72. number provided in base 10. The correct serial is the concatenation of 
  73. the two strings produced by the wsprintfs.
  74.  
  75. By the way there is a softice check in the dll, called SofticeChecker 
  76. :) 
  77. which sets a flag at [403000]
  78.  
  79. The Keygen
  80. ----------
  81. OK! Now let's make a keygen!
  82.  
  83. The biggest problem to overcome is the mouse coordinates that are not 
  84. constant. 
  85. A windows programmer ( I am NOT one :) could make a keygen that 
  86. automatically updates 
  87. its output according to the current mouse coordinates and name 
  88. specified.  
  89.  
  90. But I'll take another road.
  91. A quick and dirty solution is to drag the program window to the left 
  92. edge of the screen 
  93. so as to be able to press the 'Gain Access' button while the mouse 
  94. cursor is as far left
  95. as possible ( x coordinate=0).
  96.  
  97. This way x*y^0x12345 is always 0x12345 and the uncertainty factor is 
  98. gone...
  99. I know this is not a very 'clean' way but without using windows this is 
  100. the 
  101. only thing I could think of :)
  102.  
  103. Another problem is c: drive's serial. A windows programmer could just 
  104. call 
  105. GetVolumeInformationA ( which is used in the crackme, too) but I will 
  106. just ask
  107. the user for the serial!
  108.  
  109. So a very simple keygen in good-old ANSI/ISO C is the following:
  110.  
  111. #include <stdio.h>
  112.  
  113. int main(void) {
  114.  
  115.     char name[21];
  116.     char serial[10];
  117.     unsigned long serial_num;
  118.     char *p;
  119.     unsigned long result=0;
  120.     /* Because x*y=0 A is initialized as 0x12345
  121.        and B is always 0x64fb80    */
  122.     unsigned long A=0x12345,B=0x064fb80 ;
  123.  
  124.     
  125.     printf("Please enter name(20 chars max): ");
  126.     fgets(name,21,stdin);
  127.  
  128.     do {
  129.         printf("Please enter c: drive serial (without '-' ): ");
  130.         fgets(serial,10,stdin);
  131.     /* Make sure that the serial is acceptable */
  132.     } while (sscanf(serial,"%x",&serial_num)!=1);
  133.  
  134.     p=name;
  135.  
  136.     /* Name Manipulation */
  137.     while (*p && *p!='\n') { result+=*p++^0x33; }
  138.  
  139.     printf("%lu%lu\n",A*result+serial_num,B);
  140.     printf("Before pressing the 'Gain Access!' button make sure your 
  141. cursor is\n"
  142.            "as far left as possible! Move the whole window if you must!");
  143. }
  144.  
  145.  
  146. .::Alf::. 6th August 2001 
  147. email: alf82@freemail.gr  
  148.