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

  1. Tutorial for Crackme id:9 (tC...)
  2. by Sanhedrin
  3.  
  4. Tools
  5. Wdasm
  6. Softice
  7. PEEK
  8.  
  9. --PART ONE--
  10.  
  11. This crackme requires an unlock code before it allows you to enter your name and serial number.  
  12. First thing to do is to disassemble and look at the binary text with PEEK.  Nothing too 
  13. unusual in the binary text, but something stands out at 004442FF.  The String Data Reference
  14. to "CrackMe [id:9] by tC... ." is in an unusual place for something that is in the about dialog
  15. box.  Furthermore, there is another "CrackMe [id:9] by tC... .Today". Just a clue, but perhaps 
  16. it has something to do with the unlock code.  So, enter an unlock code
  17.  
  18. 12344321
  19.  
  20. go into softice and enter the breakpoint
  21.  
  22. bpx hmemcpy
  23.  
  24. go back to the crackme and enter another number in the unlock code box.
  25.  
  26. Once in softice, disable the breakpoints and press F12 until you end up at:
  27.  
  28. :004442DE 8BD8                    mov ebx, eax
  29. :004442E0 33C0                    xor eax, eax
  30. :004442E2 55                      push ebp
  31. :004442E3 6875434400              push 00444375
  32. :004442E8 64FF30                  push dword ptr fs:[eax]
  33. :004442EB 648920                  mov dword ptr fs:[eax], esp
  34. :004442EE 8D55FC                  lea edx, dword ptr [ebp-04]
  35. :004442F1 8B83C4020000            mov eax, dword ptr [ebx+000002C4]
  36. :004442F7 E898F9FDFF              call 00423C94
  37. :004442FC 8B45FC                  mov eax, dword ptr [ebp-04]<----you will land here
  38.  
  39. * Possible StringData Ref from Code Obj ->"CrackMe [id:9] by tC... ."
  40.                                   |
  41. :004442FF BA88434400              mov edx, 00444388
  42. :00444304 E83BF8FBFF              call 00403B44<---call the compare code routine
  43. :00444309 7507                    jne 00444312<----jump if not the same
  44. :0044430B E8BCFFFFFF              call 004442CC
  45. :00444310 EB4D                    jmp 0044435F
  46.  
  47. //SNIP//
  48.  
  49. * Possible StringData Ref from Code Obj ->"Please enter your name and serial..."
  50.                                   |
  51. :0044434F BAAC434400              mov edx, 004443AC
  52. :00444354 8B83F0020000            mov eax, dword ptr [ebx+000002F0]
  53. :0044435A E8FDF4FFFF              call 0044385C
  54.  
  55. //SNIP//
  56.  
  57. * Possible StringData Ref from Code Obj ->"UnlockCode needed..."
  58.                                   |
  59. :00444405 BA20444400              mov edx, 00444420
  60.  
  61. Interesting place to land!  At 004442FC (call 00403B44) press F8 and you will end up:
  62.  
  63.  
  64. :00403B44 53                      push ebx<---you will land here
  65. :00403B45 56                      push esi
  66. :00403B46 57                      push edi
  67. :00403B47 89C6                    mov esi, eax<---move our 3 to esi
  68. :00403B49 89D7                    mov edi, edx<---move real # to edi
  69. :00403B4B 39D0                    cmp eax, edx<---compare our # to real #
  70. :00403B4D 0F848F000000            je 00403BE2<---jump if the same
  71. :00403B53 85F6                    test esi, esi
  72. :00403B55 7468                    je 00403BBF<---jump if no number is entered
  73. :00403B57 85FF                    test edi, edi
  74. :00403B59 746B                    je 00403BC6
  75. :00403B5B 8B46FC                  mov eax, dword ptr [esi-04]<---count our number of digits
  76. :00403B5E 8B57FC                  mov edx, dword ptr [edi-04]<---count the amount in real #
  77. :00403B61 29D0                    sub eax, edx<---subtract real number from our number
  78. :00403B63 7702                    ja 00403B67<---jump if greater than 0
  79. :00403B65 01C2                    add edx, eax
  80.  
  81. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  82. |:00403B63(C)
  83. |
  84. :00403B67 52                      push edx
  85. :00403B68 C1EA02                  shr edx, 02
  86. :00403B6B 7426                    je 00403B93
  87.  
  88. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  89. |:00403B89(C)
  90. |
  91. :00403B6D 8B0E                    mov ecx, dword ptr [esi]
  92. :00403B6F 8B1F                    mov ebx, dword ptr [edi]
  93. :00403B71 39D9                    cmp ecx, ebx
  94. :00403B73 7558                    jne 00403BCD<---check 1st four numbers jump if not the same
  95. :00403B75 4A                      dec edx
  96. :00403B76 7415                    je 00403B8D
  97. :00403B78 8B4E04                  mov ecx, dword ptr [esi+04]
  98. :00403B7B 8B5F04                  mov ebx, dword ptr [edi+04]
  99. :00403B7E 39D9                    cmp ecx, ebx
  100. :00403B80 754B                    jne 00403BCD<---check 2nd four numbers jump if not the same
  101. :00403B82 83C608                  add esi, 00000008
  102. :00403B85 83C708                  add edi, 00000008
  103. :00403B88 4A                      dec edx
  104. :00403B89 75E2                    jne 00403B6D<---finished all the numbers?  Repeat process if no
  105. :00403B8B EB06                    jmp 00403B93<---jump when finished the first 24 numbers
  106.  
  107. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  108. |:00403B76(C)
  109. |
  110. :00403B8D 83C604                  add esi, 00000004
  111. :00403B90 83C704                  add edi, 00000004
  112.  
  113. * Referenced by a (U)nconditional or (C)onditional Jump at Addresses:
  114. |:00403B6B(C), :00403B8B(U)
  115. |
  116. :00403B93 5A                      pop edx
  117. :00403B94 83E203                  and edx, 00000003
  118. :00403B97 7422                    je 00403BBB
  119. :00403B99 8B0E                    mov ecx, dword ptr [esi]
  120. :00403B9B 8B1F                    mov ebx, dword ptr [edi]
  121. :00403B9D 38D9                    cmp cl, bl<---compare 25th # 
  122. :00403B9F 7541                    jne 00403BE2<---jump if not the same
  123. :00403BA1 4A                      dec edx<---decrease the count on our # by one
  124. :00403BA2 7417                    je 00403BBB<---jump if zero
  125. :00403BA4 38FD                    cmp ch, bh
  126. :00403BA6 753A                    jne 00403BE2
  127. :00403BA8 4A                      dec edx
  128. :00403BA9 7410                    je 00403BBB
  129. :00403BAB 81E30000FF00            and ebx, 00FF0000
  130. :00403BB1 81E10000FF00            and ecx, 00FF0000
  131. :00403BB7 39D9                    cmp ecx, ebx
  132. :00403BB9 7527                    jne 00403BE2
  133.  
  134. //SNIP//
  135.  
  136. * Referenced by a (U)nconditional or (C)onditional Jump at Addresses:
  137. |:00403B4D(C), :00403B9F(C), :00403BA6(C), :00403BB9(C), :00403BBD(U)
  138. |:00403BC4(U), :00403BCB(U), :00403BD0(C), :00403BD4(C), :00403BDE(C)
  139. |
  140. :00403BE2 5F                      pop edi
  141. :00403BE3 5E                      pop esi
  142. :00403BE4 5B                      pop ebx
  143. :00403BE5 C3                      ret<---return
  144.  
  145. Here is where things get a little strange.  We know what the first 24 characters should be, 
  146. and we know that the last character should be a period.  I have to admit that I got lost in 
  147. the code somewhat here, but here is what works.  Either enter another space after the last 
  148. period, or delete the period after you have entered it.  I am not sure if this is a bug, or 
  149. planned for, but it through me for a bit of a loop (tC informs me that it was  an 
  150. intentional annoyance).  So the Unlock Code is:
  151.  
  152. CrackMe [id:9] by tC... . 
  153.                        ^ ^
  154.                        Spaces before and after the last period.
  155.                        
  156.  
  157. --PART TWO--
  158.  
  159.  
  160. Notice that you can enter your name and serial number, and that the Register button is enabled.  
  161. So, enter your name and serial number
  162.  
  163. Sanhedrin
  164. 12344321
  165.  
  166. enter softice and place a breakpoint
  167.  
  168. bpx hmemcpy
  169.  
  170. and press Register
  171.  
  172. Once we have broken into softice, disable the breakpoint press F12 a few times and we will be at:
  173.  
  174. :0044477E 8B55F8                  mov edx, dword ptr [ebp-08]<---we will land here
  175. :00444781 B868684400              mov eax, 00446868
  176.  
  177. Press F10 until
  178.  
  179. //SNIP//
  180.  
  181. :00444848 E813FCFFFF              call 00444460<---first important call - STOP here
  182. :0044484D E81EFEFFFF              call 00444670<---second important call
  183. :00444852 A150684400              mov eax, dword ptr [00446850]
  184. :00444857 3B0554684400            cmp eax, dword ptr [00446854]
  185. :0044485D 7546                    jne 004448A5<---no jump if the calcualtions are not the same
  186.  
  187.  
  188. --FIRST CALL--
  189.  
  190.  
  191. A lot of information in these few lines of code.  I would love to go through each line of 
  192. code and explain everything, but I really only have space to go through the highlights. 
  193. Let's start with 00444848.  Once you are there press F8:
  194.  
  195. :00444460 55                      push ebp<---you will land here
  196. :00444461 8BEC                    mov ebp, esp
  197. :00444463 6A00                    push 00000000
  198. :00444465 53                      push ebx
  199. :00444466 56                      push esi
  200. :00444467 33C0                    xor eax, eax
  201.  
  202. //SNIP//
  203.  
  204. Press F10 until 004444CD.
  205.  
  206. :004444CD 8B55FC                  mov edx, dword ptr [ebp-04]<---stop here
  207.  
  208. At the top of your softice window, you will notice all of the registers EAX=, EBX=, etc., etc..
  209. The lower right hand is SS=.  The addresses may not be the same, but on my computer it says:
  210.  
  211. ss:0068FA90=00BB6194
  212.  
  213. It's the second location that we are interested in.  Type:
  214.  
  215. d 00BB6194 
  216.  
  217. and you will see the first part of your code (for me it was B20E).  Write it down.
  218. Continue pressing F10 until:
  219.  
  220. :00444537 8D45FC                  lea eax, dword ptr [ebp-04]<---stop here
  221.  
  222. Again, on my computer:
  223.  
  224. ss:0068FA90=00BB2DDC
  225.  
  226. Type
  227.  
  228. d 00BB2DDC (for me it was FFFBDC4A)
  229.  
  230. you will see the final section of your code.  Write it down.
  231.  
  232.  
  233. --SECOND CALL--
  234.  
  235.  
  236. Here's where things get complicated.  tC has added a lot of dummy routines to cloud 
  237. exactly which serial number is correct.  All look like they could be serial numbers.  
  238. Again, to make things short, I will go over the code which relates only to obtaining a 
  239. valid serial number.  Let's begin at the second call routine 0044484D.  Once you have 
  240. finishedthe first call, stop at the second call and press F8.  This call brings you
  241. to the magical sequence that ties everything together. Follow the code carefully....
  242.  
  243. :00444848 E813FCFFFF              call 00444460
  244. :0044484D E81EFEFFFF              call 00444670<---stop here, press F8
  245.  
  246.  
  247. :00444670 55                      push ebp<---you will land here
  248. :00444671 8BEC                    mov ebp, esp
  249. :00444673 6A00                    push 00000000
  250. :00444675 6A00                    push 00000000
  251. :00444677 53                      push ebx
  252. :00444678 56                      push esi
  253. :00444679 33C0                    xor eax, eax
  254. :0044467B 55                      push ebp
  255.  
  256. //SNIP//
  257.  
  258. Press F10 until:
  259.  
  260. :00444700 E847FEFFFF              call 0044454C<---stop here, press F8
  261. :00444705 33C0                    xor eax, eax
  262. :00444707 5A                      pop edx
  263. :00444708 59                      pop ecx
  264. :00444709 59                      pop ecx
  265. :0044470A 648910                  mov dword ptr fs:[eax], edx
  266.  
  267. //SNIP//
  268.  
  269. :0044454C 55                      push ebp<---you will land here
  270. :0044454D 8BEC                    mov ebp, esp
  271. :0044454F 6A00                    push 00000000
  272. :00444551 6A00                    push 00000000
  273. :00444553 6A00                    push 00000000
  274.  
  275. Press F10 until:
  276.  
  277. :00444645 8D45F4                  lea eax, dword ptr [ebp-0C]
  278. :00444648 BA03000000              mov edx, 00000003
  279. :0044464D E88AF1FBFF              call 004037DC<---stop here, press F8
  280. :00444652 C3                      ret
  281.  
  282. //SNIP//
  283.  
  284. :004037DC 53                      push ebx<---you will land here
  285. :004037DD 56                      push esi
  286. :004037DE 89C3                    mov ebx, eax
  287. :004037E0 89D6                    mov esi, edx
  288. :004037E2 8B13                    mov edx, dword ptr [ebx]
  289. :004037E4 85D2                    test edx, edx
  290. :004037E6 7419                    je 00403801
  291. :004037E8 C70300000000            mov dword ptr [ebx], 00000000<---stop here
  292.  
  293. Alright, we have found that magic spot in the program that will tie it all together and do
  294. all of the work for us.  Cancel all breakpoints and put a breakpoint:
  295.  
  296. bpx 004037E8
  297.  
  298. Before we look at the whole serial, look at the second address at SS (top right hand of the
  299. register window) and type (for me)
  300.  
  301. d 00BB613C 
  302.  
  303. This will give you the third part of the key code (for me it was 1135).  Press F5, look at the same 
  304. register and type the address(for me it was)
  305.  
  306. d 00BB6128
  307.  
  308. This will give you the second part of the serial (for me it was 46653). BUT WAIT!!!!  Press F5 again,
  309. type in the address
  310.  
  311. d 00BB570C
  312.  
  313. and VOILA, our entire serial waiting patiently for us.  
  314.  
  315.  
  316. B20E-46653-1135-FFFBDC4A
  317.  
  318.  
  319. --FINAL NOTES--
  320.  
  321. There was a lot of code that I had to leave out for brevity's sake.  tC does a lot of neat 
  322. things to try and trick the cracker.  For example, if you watch the initial serial being 
  323. made, you will notice that there is a '65A' after the first part of the code.  At the serial
  324. check routine, it looks for that '65A', and sends you immediately to the bad cracker 
  325. section.  There are some other fun tricks in this one, and I suggest that, rather than just 
  326. following the above code, that you do some exploring.  
  327.  
  328.  
  329. Greets to tC
  330.  
  331. Thanks to all of those coders that make these crackmes, to Pepper for sending me on the 
  332. right path so long ago and of course to Eternal Bliss.
  333.  
  334.  
  335. Sanhedrin
  336. stachi@geocities.com
  337.  
  338.  
  339.  
  340.