home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / KEY.TXT < prev    next >
Encoding:
Text File  |  1999-03-04  |  5.1 KB  |  233 lines

  1. Shadow's tutorial to HF crackme II
  2. ==================================
  3.  
  4.  
  5. Part I - code calculation
  6. =========================
  7.  
  8. Protection routine. use bpx 0042668d2 to test it ... I didn't find
  9. it using softice, but then I found it from wdasm deadlisting..
  10. this crackme is coded using delphy so, it's not so easy to track.
  11.  
  12. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  13. |:004268A4(C)
  14. |
  15. :004268D2 0FB600                  movzx eax, byte ptr [eax]
  16.  
  17. copy 1st character to eax
  18.  
  19. :004268D5 8BF0                    mov esi, eax
  20.  
  21. copy it to esi
  22.  
  23. :004268D7 C1E602                  shl esi, 02
  24.  
  25. shift left 2 bytes
  26.  
  27. :004268DA 8D3476                  lea esi, dword ptr [esi+2*esi]
  28.  
  29. esi = esi+2*esi
  30.  
  31. next 3 lines are not "important"
  32.  
  33. :004268DD 8D55F8                  lea edx, dword ptr [ebp-08]
  34. :004268E0 8B83B0010000            mov eax, dword ptr [ebx+000001B0]
  35. :004268E6 E865B3FEFF              call 00411C50
  36.  
  37. :004268EB 8B45F8                  mov eax, dword ptr [ebp-08]
  38. :004268EE 0FB64001                movzx eax, byte ptr [eax+01]
  39.  
  40. copy next char to eax
  41.  
  42. :004268F2 8D0480                  lea eax, dword ptr [eax+4*eax]
  43.  
  44. eax = eax+4*eax
  45.  
  46. :004268F5 8D0480                  lea eax, dword ptr [eax+4*eax]
  47.  
  48. eax = eax+4*eax
  49.  
  50. :004268F8 03F0                    add esi, eax
  51.  
  52. add it to esi
  53.  
  54. :004268FA 8D55F4                  lea edx, dword ptr [ebp-0C]
  55. :004268FD 8B83B0010000            mov eax, dword ptr [ebx+000001B0]
  56. :00426903 E848B3FEFF              call 00411C50
  57. :00426908 8B45F4                  mov eax, dword ptr [ebp-0C]
  58.  
  59. copy next char to eax
  60.  
  61. :0042690B 0FB64002                movzx eax, byte ptr [eax+02]
  62.  
  63. :0042690F 03C0                    add eax, eax
  64.  
  65. eax = eax+eax
  66.  
  67. :00426911 03F0                    add esi, eax
  68.  
  69. esi = esi+eax
  70.  
  71. :00426913 8D55F0                  lea edx, dword ptr [ebp-10]
  72. :00426916 8B83B0010000            mov eax, dword ptr [ebx+000001B0]
  73. :0042691C E82FB3FEFF              call 00411C50
  74. :00426921 8B45F0                  mov eax, dword ptr [ebp-10]
  75.  
  76. copy next char to eax
  77.  
  78. :00426924 0FB64003                movzx eax, byte ptr [eax+03]
  79.  
  80. signed multiply
  81.  
  82. eax = eax * 0bh
  83.  
  84. :00426928 6BC00B                  imul eax, 0000000B
  85.  
  86. esi = esi+eax
  87.  
  88. :0042692B 03F0                    add esi, eax
  89.  
  90. store esi to memory.
  91.  
  92. :0042692D 893590864200            mov dword ptr [00428690], esi
  93.  
  94. eax = first char of string..
  95.  
  96. :00426933 A194864200              mov eax, dword ptr [00428694]
  97.  
  98. this function calculates lenght of username
  99.  
  100. :00426938 E8D3ECFDFF              call 00405610
  101.  
  102. eax = lenght of username
  103.  
  104. :0042693D 8B1590864200            mov edx, dword ptr [00428690]
  105.  
  106. edx = esi from "memory"
  107.  
  108. :00426943 0FAF1590864200          imul edx, dword ptr [00428690]
  109.  
  110. eax = edx * eax
  111.  
  112. :0042694A F7EA                    imul edx
  113.  
  114. eax = edx * eax
  115.  
  116. :0042694C A390864200              mov dword ptr [00428690], eax
  117.  
  118. store it to memory.
  119.  
  120. now we can code keygenerator to this crackme and generate some keys
  121. to test if we have understand routine.... there is also check if
  122. usernamelen is < 4 chars.. before calculating routine..
  123.  
  124. Part II - keygenerator
  125. ======================
  126.  
  127. #include <string.h>
  128. #include <stdlib.h>
  129. #include <stdio.h>
  130.  
  131. void main(void)
  132. {
  133.         unsigned char user[30];
  134.     unsigned long char1 = 0;
  135.     unsigned long char2 = 0;
  136.     unsigned long char3 = 0;
  137.     unsigned long char4 = 0;
  138.     unsigned long keycode = 0;
  139.     unsigned long temp = 0;
  140.  
  141.         memset(user,0,sizeof(user));
  142.         printf("Keygenerator for HF crackme by Shadow/hf\n");
  143.         printf("Name: ");
  144.         gets(user);
  145.         if(strlen(user) < 5) {
  146.                 printf("Usernamelen must be > 4\n");
  147.                 exit(1);
  148.         }
  149.     // number 1
  150.     char1 = (user[0] << 2) * 2 + (user[0] << 2);
  151.     // number 2
  152.     char2 = (user[1]+4*user[1]);
  153.         char2 = char2+4*char2;
  154.     // number 3
  155.     char3 = user[2]+user[2];
  156.     // number 4
  157.     char4 = user[3] * 0xb;
  158.     keycode = char1 + char2 + char3 + char4;
  159.     temp = keycode * strlen(user);
  160.     temp = keycode * temp;
  161.         printf("Your code is: %lu",temp);
  162. }
  163.  
  164. Part III win32 assembly keygenerator
  165. ====================================
  166.  
  167. I still decided to code this using pure w32 assembler...
  168.  
  169. key.rc
  170. key.asm
  171. makefile
  172. key.def
  173. w32.inc
  174.  
  175. and tasm5 needed to compile it..
  176.  
  177. [in key.asm]
  178.  
  179. ;
  180. ; this prodecure calculates correct key value
  181. ;
  182. Calculate proc pstr1:DWORD
  183.         mov     esi,pstr1
  184.         xor     eax,eax
  185.         mov     number,0
  186.  
  187. ;
  188. ; 1 char
  189. ;
  190.         lodsb
  191.         shl     eax,2
  192.         lea     eax,[eax+2*eax]
  193.         add     number,eax
  194.  
  195. ;
  196. ; 2 char
  197. ;
  198.  
  199.         xor     eax,eax
  200.         lodsb
  201.         lea     eax,[eax+4*eax]
  202.         lea     eax,[eax+4*eax]
  203.         add     number,eax
  204.  
  205. ;
  206. ; 3 char
  207. ;
  208.         xor     eax,eax
  209.         lodsb
  210.         add     eax,eax
  211.         add     number,eax
  212.  
  213. ;
  214. ; 4 char
  215. ;
  216.  
  217.         xor     eax,eax
  218.         lodsb
  219.         imul    eax,eax,0bh
  220.         add     number,eax
  221. ;
  222. ; final stage
  223. ;
  224.         call    lstrlen,pstr1
  225. ; strlen  = eax
  226.  
  227.         mov     edx,number 
  228.         imul    edx,number  
  229.         imul    edx
  230.         ret
  231. Calculate endp
  232.  
  233.