home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / +Sandman / EditPlus122.txt < prev    next >
Text File  |  2000-05-25  |  16KB  |  367 lines

  1.   
  2.   EditPlus is a text/HTML editor. I have cracked the version 1.20 and 1.21. The 
  3. protection of version 1.22 is slightly changed.I will explain how to make a
  4. key generator for v1.22.
  5.  
  6.   URL: http://www.editplus.com
  7.  
  8.   The author is very clever. He checks your registration code at completely
  9. different places.The first check is done before it exits,while the second check 
  10. is done when it is lanuched.
  11.   Just use "bpx GetWindowTextA" as your breakpoint after you enter your fake
  12. serial.Set a BPR on any occurence of your fake serial in the memory.Finally you
  13. will find that your fake serial is moved to the buffer at 004EA878 if the length
  14. of it is 0x11. This is a global byte array(from DS:004EA878 to DS:004EA888).
  15.   Let's denote this array with 
  16.       char serial[0x11]="12345678-87654321"; /* my fake serial */
  17.  
  18.   First it will check serial[4]:
  19.  
  20. :00420F6B 8B1590A84E00            mov edx, dword ptr [004EA890]
  21. :00420F71 0FBE02                  movsx eax, byte ptr [edx] ;First char of name
  22. :00420F74 8D440010                lea eax, dword ptr [eax+eax+10]
  23. :00420F78 99                      cdq
  24. :00420F79 33C2                    xor eax, edx
  25. :00420F7B 2BC2                    sub eax, edx
  26. :00420F7D 83E00F                  and eax, 0000000F
  27. :00420F80 33C2                    xor eax, edx
  28. :00420F82 2BC2                    sub eax, edx
  29. :00420F84 83F80A                  cmp eax, 0000000A
  30. :00420F87 A348A84E00              mov dword ptr [004EA848], eax
  31. :00420F8C 7D04                    jge 00420F92
  32. :00420F8E 0430                    add al, 30
  33. :00420F90 EB02                    jmp 00420F94
  34. :00420F92 0437                    add al, 37
  35. :00420F94 3A057CA84E00            cmp al, byte ptr [004EA87C]  ;check serial[4]
  36. :00420F9A 740A                    je 00420FA6
  37. :00420F9C C705101D4E0000000000    mov dword ptr [004E1D10], 00000000 ;bad flag
  38.  
  39.   From the above code,we know how it calculates the correct serial[4].
  40.   Then it will check my fake serial[5]:
  41.  
  42. :004588C3 A1101D4E00              mov eax, dword ptr [004E1D10];Is bad flag set?
  43. :004588C8 85C0                    test eax, eax
  44. :004588CA 7444                    je 00458910           ; jump if bad guy 
  45. :004588CC A190A84E00              mov eax, dword ptr [004EA890]
  46. :004588D1 8B0D94A84E00            mov ecx, dword ptr [004EA894]
  47. :004588D7 0FBE4401FF              movsx eax, byte ptr [ecx+eax-01];The last char
  48.                                                                   ;of name
  49. :004588DC 83C007                  add eax, 00000007
  50. :004588DF 8D0480                  lea eax, dword ptr [eax+4*eax]
  51. :004588E2 99                      cdq
  52. :004588E3 33C2                    xor eax, edx
  53. :004588E5 2BC2                    sub eax, edx
  54. :004588E7 83E00F                  and eax, 0000000F
  55. :004588EA 33C2                    xor eax, edx
  56. :004588EC 2BC2                    sub eax, edx
  57. :004588EE 83F80A                  cmp eax, 0000000A
  58. :004588F1 A34CA84E00              mov dword ptr [004EA84C], eax
  59. :004588F6 7D04                    jge 004588FC
  60. :004588F8 0430                    add al, 30
  61. :004588FA EB02                    jmp 004588FE
  62. :004588FC 0437                    add al, 37
  63. :004588FE 3A057DA84E00            cmp al, byte ptr [004EA87D] ;check serial[5]
  64. :00458904 740A                    je 00458910
  65. :00458906 C705101D4E0000000000    mov dword ptr [004E1D10], 00000000;bad flag
  66.  
  67.   It will continue to check serial[6]:
  68.  
  69. :0045CE60 0FBE3C30                movsx edi, byte ptr [eax+esi];get a char from
  70.                                                                ;my name
  71. :0045CE64 03CF                    add ecx, edi                 ;add it
  72. :0045CE66 40                      inc eax
  73. :0045CE67 3BC2                    cmp eax, edx
  74. :0045CE69 890D50A84E00            mov dword ptr [004EA850], ecx
  75. :0045CE6F 7CEF                    jl 0045CE60                  ; continue loop
  76.  
  77. :0045CE71 8D4106                  lea eax, dword ptr [ecx+06]
  78. :0045CE74 8D0440                  lea eax, dword ptr [eax+2*eax]
  79. :0045CE77 99                      cdq
  80. :0045CE78 33C2                    xor eax, edx
  81. :0045CE7A 2BC2                    sub eax, edx
  82. :0045CE7C 83E00F                  and eax, 0000000F
  83. :0045CE7F 33C2                    xor eax, edx
  84. :0045CE81 2BC2                    sub eax, edx
  85. :0045CE83 83F80A                  cmp eax, 0000000A
  86. :0045CE86 A350A84E00              mov dword ptr [004EA850], eax
  87. :0045CE8B 7D04                    jge 0045CE91
  88. :0045CE8D 0430                    add al, 30
  89. :0045CE8F EB02                    jmp 0045CE93
  90. :0045CE91 0437                    add al, 37
  91. :0045CE93 3A057EA84E00            cmp al, byte ptr [004EA87E];check serial[6]
  92. :0045CE99 740A                    je 0045CEA5
  93. :0045CE9B C705101D4E0000000000    mov dword ptr [004E1D10], 00000000 ;bad flag
  94.  
  95.   It continus to check serial[14]:
  96.  
  97. :0045E61E A1101D4E00              mov eax, dword ptr [004E1D10]
  98. :0045E623 85C0                    test eax, eax
  99. :0045E625 7449                    je 0045E670
  100. :0045E627 8B0D90A84E00            mov ecx, dword ptr [004EA890]
  101. :0045E62D 8B1594A84E00            mov edx, dword ptr [004EA894]
  102. :0045E633 0FBE4C0AFF              movsx ecx, byte ptr [edx+ecx-01]
  103. :0045E638 8BC1                    mov eax, ecx
  104. :0045E63A C1E003                  shl eax, 03
  105. :0045E63D 2BC1                    sub eax, ecx
  106. :0045E63F 83E805                  sub eax, 00000005
  107. :0045E642 99                      cdq
  108. :0045E643 33C2                    xor eax, edx
  109. :0045E645 2BC2                    sub eax, edx
  110. :0045E647 83E00F                  and eax, 0000000F
  111. :0045E64A 33C2                    xor eax, edx
  112. :0045E64C 2BC2                    sub eax, edx
  113. :0045E64E 83F80A                  cmp eax, 0000000A
  114. :0045E651 A36CA84E00              mov dword ptr [004EA86C], eax
  115. :0045E656 7D04                    jge 0045E65C
  116. :0045E658 0430                    add al, 30
  117. :0045E65A EB02                    jmp 0045E65E
  118. :0045E65C 0437                    add al, 37
  119. :0045E65E 3A0586A84E00            cmp al, byte ptr [004EA886];check serial[14]
  120. :0045E664 740A                    je 0045E670
  121. :0045E666 C705101D4E0000000000    mov dword ptr [004E1D10], 00000000
  122.  
  123.   Then it will check the length of my fake serial:
  124.  
  125. :004502E0 A1101D4E00              mov eax, dword ptr [004E1D10];Is bad flag set?
  126. :004502E5 85C0                    test eax, eax
  127. :004502E7 741A                    je 00450303       ;jump if bad guy
  128. :004502E9 6878A84E00              push 004EA878
  129.  
  130. * Reference To: KERNEL32.lstrlenA, Ord:02A1h
  131.                                   |
  132. :004502EE FF156CB24B00            Call dword ptr [004BB26C]
  133. :004502F4 83F811                  cmp eax, 00000011   ;check the length
  134. :004502F7 740A                    je 00450303
  135. :004502F9 C705101D4E0000000000    mov dword ptr [004E1D10], 00000000 ;bad flag
  136.  
  137.   After this,it exits. If you think that you have passed all the checks,you
  138. are wrong ! Use SoftICE symbol loader to load the program,type 
  139. "bpr 004EA878 004EA888 rw" to set a breakpoint.(Of course you can use other
  140. breakpoints such as BPX RegQueryValueExA etc.But mine is the best.How do I know
  141. this ? Because I have cracked its older version! )
  142.   Press F5 to proceed,you can see your fake serial is read from windows
  143. registry,and finally is moved to the buffer at DS:004EA878.
  144.  
  145.   First it will check serial[0]:
  146.  
  147. :00458934 A1101D4E00              mov eax, dword ptr [004E1D10];Is bad flag set?
  148. :00458939 85C0                    test eax, eax
  149. :0045893B 743D                    je 0045897A                  ;jump if bad guy
  150. :0045893D 8B0D90A84E00            mov ecx, dword ptr [004EA890]
  151. :00458943 0FBE01                  movsx eax, byte ptr [ecx];First char of name
  152. :00458946 83C005                  add eax, 00000005
  153. :00458949 8D0440                  lea eax, dword ptr [eax+2*eax]
  154. :0045894C 99                      cdq
  155. :0045894D 33C2                    xor eax, edx
  156. :0045894F 2BC2                    sub eax, edx
  157. :00458951 83E00F                  and eax, 0000000F
  158. :00458954 33C2                    xor eax, edx
  159. :00458956 2BC2                    sub eax, edx
  160. :00458958 83F80A                  cmp eax, 0000000A
  161. :0045895B A338A84E00              mov dword ptr [004EA838], eax
  162. :00458960 7D04                    jge 00458966
  163. :00458962 0430                    add al, 30
  164. :00458964 EB02                    jmp 00458968
  165. :00458966 0437                    add al, 37
  166. :00458968 3A0578A84E00            cmp al, byte ptr [004EA878]; check serial[0]
  167. :0045896E 740A                    je 0045897A
  168. :00458970 C705101D4E0000000000    mov dword ptr [004E1D10], 00000000;bad flag
  169.  
  170.   It will then check serial[1]:
  171.  
  172. :0045055F A1101D4E00              mov eax, dword ptr [004E1D10];Is bad flag set?
  173. :00450564 85C0                    test eax, eax
  174. :00450566 7445                    je 004505AD
  175. :00450568 8B0D90A84E00            mov ecx, dword ptr [004EA890]
  176. :0045056E 8B1594A84E00            mov edx, dword ptr [004EA894]
  177. :00450574 0FBE440AFF              movsx eax, byte ptr [edx+ecx-01];The last char
  178. :00450579 83C002                  add eax, 00000002
  179. :0045057C 8D04C0                  lea eax, dword ptr [eax+8*eax]
  180. :0045057F 99                      cdq
  181. :00450580 33C2                    xor eax, edx
  182. :00450582 2BC2                    sub eax, edx
  183. :00450584 83E00F                  and eax, 0000000F
  184. :00450587 33C2                    xor eax, edx
  185. :00450589 2BC2                    sub eax, edx
  186. :0045058B 83F80A                  cmp eax, 0000000A
  187. :0045058E A33CA84E00              mov dword ptr [004EA83C], eax
  188. :00450593 7D04                    jge 00450599
  189. :00450595 0430                    add al, 30
  190. :00450597 EB02                    jmp 0045059B
  191. :00450599 0437                    add al, 37
  192. :0045059B 3A0579A84E00            cmp al, byte ptr [004EA879]; check serial[1]
  193. :004505A1 740A                    je 004505AD
  194. :004505A3 C705101D4E0000000000    mov dword ptr [004E1D10], 00000000;bad flag
  195.  
  196.   Then it will check serial[2]:
  197.  
  198. :0045CA4E 0FBE3C30                movsx edi, byte ptr [eax+esi];get a char
  199. :0045CA52 03CF                    add ecx, edi
  200. :0045CA54 40                      inc eax
  201. :0045CA55 3BC2                    cmp eax, edx
  202. :0045CA57 890D40A84E00            mov dword ptr [004EA840], ecx
  203. :0045CA5D 7CEF                    jl 0045CA4E                  ;loop
  204.  
  205. :0045CA5F 8D4108                  lea eax, dword ptr [ecx+08]
  206. :0045CA62 8D0440                  lea eax, dword ptr [eax+2*eax]
  207. :0045CA65 D1E0                    shl eax, 1
  208. :0045CA67 99                      cdq
  209. :0045CA68 33C2                    xor eax, edx
  210. :0045CA6A 2BC2                    sub eax, edx
  211. :0045CA6C 83E00F                  and eax, 0000000F
  212. :0045CA6F 33C2                    xor eax, edx
  213. :0045CA71 2BC2                    sub eax, edx
  214. :0045CA73 83F80A                  cmp eax, 0000000A
  215. :0045CA76 A340A84E00              mov dword ptr [004EA840], eax
  216. :0045CA7B 7D04                    jge 0045CA81
  217. :0045CA7D 0430                    add al, 30
  218. :0045CA7F EB02                    jmp 0045CA83
  219. :0045CA81 0437                    add al, 37
  220. :0045CA83 3A057AA84E00            cmp al, byte ptr [004EA87A] ;check serial[2]
  221. :0045CA89 740A                    je 0045CA95
  222. :0045CA8B C705101D4E0000000000    mov dword ptr [004E1D10], 00000000;bad flag
  223.  
  224.    It will continue to check serial[9]:
  225.  
  226. :00449C8F A1101D4E00              mov eax, dword ptr [004E1D10]
  227. :00449C94 85C0                    test eax, eax
  228. :00449C96 743A                    je 00449CD2           ;jump if bad guy
  229. :00449C98 A190A84E00              mov eax, dword ptr [004EA890]
  230. :00449C9D 0FBE08                  movsx ecx, byte ptr [eax] ;First char of name
  231. :00449CA0 8D440907                lea eax, dword ptr [ecx+ecx+07]
  232. :00449CA4 99                      cdq
  233. :00449CA5 33C2                    xor eax, edx
  234. :00449CA7 2BC2                    sub eax, edx
  235. :00449CA9 83E00F                  and eax, 0000000F
  236. :00449CAC 33C2                    xor eax, edx
  237. :00449CAE 2BC2                    sub eax, edx
  238. :00449CB0 83F80A                  cmp eax, 0000000A
  239. :00449CB3 A358A84E00              mov dword ptr [004EA858], eax
  240. :00449CB8 7D04                    jge 00449CBE
  241. :00449CBA 0430                    add al, 30
  242. :00449CBC EB02                    jmp 00449CC0
  243. :00449CBE 0437                    add al, 37
  244. :00449CC0 3A0581A84E00            cmp al, byte ptr [004EA881] ; check serial[9]
  245. :00449CC6 740A                    je 00449CD2
  246. :00449CC8 C705101D4E0000000000    mov dword ptr [004E1D10], 00000000
  247.  
  248.   Finally it checks serial[8]:
  249.  
  250. :00449F09 391D101D4E00            cmp dword ptr [004E1D10], ebx
  251. :00449F0F 7429                    je 00449F3A
  252. :00449F11 803D80A84E002D          cmp byte ptr [004EA880], 2D ;Is it '-' ?
  253. :00449F18 7411                    je 00449F2B
  254. :00449F1A 891D101D4E00            mov dword ptr [004E1D10], ebx ;set a bad flag
  255.  
  256.   So many redundant instructions !
  257.   The other chars of my fake serial are not exactly checked.
  258.  
  259.   We can write a key generator for it now.
  260.   Here is the partial source code(compiled with VC++):
  261.  
  262.                   char UserName[80];
  263.                   char RegCode[]="00000000-00000000";
  264.           long tmp[17]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};
  265.           char LastChar;
  266.           long sum;
  267.  
  268.                   GetDlgItemText(hDlg,IDC_USERNAME,UserName,sizeof(UserName));
  269.                   if(UserName[0]=='\0')
  270.                   {  SetDlgItemText(hDlg,IDC_REGCODE,"");
  271.                       return FALSE;
  272.                   }
  273.  
  274.                   _asm 
  275.           {
  276.                     push eax
  277.             push ecx
  278.             push edx
  279.             push esi
  280.             push edi
  281.             mov   esi,offset (UserName[0])
  282.                 xor   eax,eax
  283.                 add_it: movsx ecx,byte ptr [esi]
  284.             test  ecx,ecx
  285.             jz    end_loop
  286.             add   eax,ecx
  287.             inc   esi
  288.             jmp   add_it
  289.               end_loop: mov   [sum],eax
  290.  
  291.             dec   esi
  292.             mov   al,[esi]
  293.             mov   [LastChar],al
  294.                         movsx eax, byte ptr (UserName[0])
  295.                 lea   eax, dword ptr [eax+eax+0x10]
  296.             mov   [tmp+16],eax
  297.  
  298.                         movsx eax, byte ptr [LastChar]
  299.                         add   eax, 00000007
  300.                         lea   eax, dword ptr [eax+4*eax]
  301.             mov   [tmp+20],eax
  302.  
  303.             mov   ecx,[sum]
  304.                         lea   eax, dword ptr [ecx+6]
  305.                         lea   eax, dword ptr [eax+2*eax]
  306.             mov   [tmp+24],eax
  307.  
  308.                         movsx ecx, byte ptr [LastChar]
  309.                         mov   eax, ecx
  310.                         shl   eax, 3
  311.                         sub   eax, ecx
  312.                         sub   eax, 5
  313.             mov   [tmp+56],eax
  314.  
  315.                         movsx eax, byte ptr (UserName[0])
  316.                         add   eax, 5
  317.                         lea   eax, dword ptr [eax+2*eax]
  318.             mov   [tmp],eax
  319.  
  320.             movsx eax, byte ptr [LastChar]
  321.                         add   eax, 2
  322.                         lea   eax, dword ptr [eax+8*eax]
  323.             mov   [tmp+4],eax
  324.  
  325.             mov   ecx,[sum]
  326.                         lea   eax, dword ptr [ecx+8]
  327.                         lea   eax, dword ptr [eax+2*eax]
  328.                         shl   eax, 1
  329.             mov   [tmp+8],eax
  330.  
  331.                         movsx ecx, byte ptr (UserName[0])
  332.                         lea   eax, dword ptr [ecx+ecx+7]
  333.                         mov   [tmp+36],eax
  334.  
  335.                          mov esi,offset (tmp[0])
  336.              mov edi,offset (RegCode[0])
  337.              xor ecx,ecx
  338.                make_key: mov eax,[esi]  
  339.                          cdq          
  340.                          xor eax, edx
  341.                          sub eax, edx
  342.                          and eax, 0x0000000F
  343.                          xor eax, edx
  344.                          sub eax, edx
  345.                          cmp eax, 0x0000000A
  346.                          jge IsHexDigit
  347.                          add al, 0x30
  348.                          jmp continue_it
  349.             IsHexDigit:  add al, 0x37
  350.            continue_it:     mov [edi],al
  351.              add esi,4
  352.              inc edi
  353.              inc ecx
  354.              cmp ecx,16
  355.              jle make_key
  356.                          
  357.                          pop  edi
  358.              pop  esi
  359.              pop  edx
  360.              pop  ecx
  361.              pop  eax
  362.           } 
  363.           RegCode[8]='-';
  364.               SetDlgItemText(hDlg,IDC_REGCODE,RegCode);
  365.  
  366. That's all. Thank you.
  367.