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

  1.             Tutorial Number 18
  2.  
  3. Written by Etenal Bliss
  4. Email: Eternal_Bliss@hotmail.com
  5. Website: http://crackmes.cjb.net
  6.          http://surf.to/crackmes
  7. Date written: 2nd Apr 1999
  8.  
  9. Program Details:
  10. Name: Hellforge CrackMe II
  11. Author: LaZaRuS
  12.  
  13. Tools Used:
  14. W32Dasm
  15. SoftIce
  16.  
  17. Cracking Method:
  18. Code sniffing
  19. Routine analysis
  20.  
  21. Viewing Method:
  22. Use Notepad with Word Wrap switched on
  23. Screen Area set to 800 X 600 pixels (Optional)
  24.  
  25. __________________________________________________________________________
  26.  
  27.  
  28.                         About this protection system
  29.  
  30. Protection is based on a serial which is calculated from the Name you enter.
  31. The name you entered must be more than 4 characters.
  32.  
  33. __________________________________________________________________________
  34.  
  35.  
  36.                                The Essay
  37.  
  38. In this essay, when I write type "d edx" or similar commands in Softice,
  39. I mean it without the quotes. 
  40.  
  41. _________________________________________________________________________
  42.  
  43.  
  44.                 W32Dasm
  45.  
  46.  
  47. Disassemble the crackme using W32Dasm. Open the String Data Reference.
  48. **That is the last 2nd icon on the toolbar next to the printer icon.
  49.  
  50. Scroll though the strings found. I can't understand most of them except
  51. for a few.
  52.  
  53. On the last 3 lines, you will see:
  54.  
  55. "Wrong Code"
  56. "Y"
  57. "You did it"
  58.  
  59. Double click on the "You did it" and see where the string is used.
  60.  
  61. You will be brought to somewhere below:
  62.  
  63. :00426970 8B55FC                  mov edx, dword ptr [ebp-04]
  64. :00426973 58                      pop eax
  65. :00426974 E8FBCAFDFF              call 00403474
  66. :00426979 7518                    jne 00426993
  67. :0042697B 6A00                    push 00000000
  68.  
  69. * Possible StringData Ref from Code Obj ->"Congratulations"
  70.                                   |
  71. :0042697D B9F0694200              mov ecx, 004269F0
  72.  
  73. * Possible StringData Ref from Code Obj ->"You did it"    <-- Here is the string
  74.                                   |
  75. :00426982 BA006A4200              mov edx, 00426A00
  76. :00426987 A124864200              mov eax, dword ptr [00428624]
  77. :0042698C E877B2FFFF              call 00421C08
  78. :00426991 EB16                    jmp 004269A9
  79.  
  80. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  81. |:00426979(C)
  82. |
  83. :00426993 6A00                    push 00000000
  84.  
  85. * Possible StringData Ref from Code Obj ->"Sorry"
  86.                                   |
  87. :00426995 B9DC694200              mov ecx, 004269DC
  88.  
  89. * Possible StringData Ref from Code Obj ->"Wrong Code"
  90.                                   |
  91. :0042699A BAE4694200              mov edx, 004269E4
  92.  
  93.  
  94. Look at the codes at :00426974 and :00426979. You will see that there is a
  95. call followed by a conditional jump. A favourite patching point for crackers.
  96. Look at where the jump will bring you to...
  97.  
  98. jne 00426993 means jump  to :00426993 if not equal
  99. and :00426993 is going to show you the "Wrong Code" Message
  100.  
  101. So, newbie crackers can just patch the conditional jump from jne 00426933 to
  102. the following options:
  103. 1) 7518  jne 00426993 to 7418  je 00426993
  104.    (will jump if you enter the correct serial)
  105.  
  106. 2) 7518  jne 00426993 to 9090 NOP NOP
  107.    (will not jump regardless of what you enter)
  108.  
  109. By using one of the patches, you can "Register" the crackme with whatever
  110. serial you want.
  111.  
  112.  
  113. _________________________________________________________________________
  114.  
  115.  
  116.                 Softice
  117.  
  118. But wait... Why be a total newbie when you can improve?
  119.  
  120. Now, looking at the codes
  121.  
  122. :00426970 8B55FC                  mov edx, dword ptr [ebp-04]
  123. :00426973 58                      pop eax
  124. :00426974 E8FBCAFDFF              call 00403474
  125. :00426979 7518                    jne 00426993
  126. :0042697B 6A00                    push 00000000
  127.  
  128.  
  129. Since we know that this call will compare the correct serial with the
  130. serial we entered, we should be able to see what the correct serial is.
  131. (or I won't be writing this tutorial!)
  132.  
  133. Run the crackme, set a general breakpoint to break into the crackme first.
  134. I used hmemcpy. So, type "d hmemcpy".
  135.  
  136. Type in 'Eternal Bliss" for the name and "123456" for the serial.
  137. After you break, F12 a few times until you come to the crackme codes.
  138. **HF CRACKME S1!... will be seen below the code window.
  139.  
  140. You do this about 7 times, then when you come to the crackme codes, you will
  141. see a few instructions, then a ret. This happens a few more times. These codes
  142. are useless for us. So, F12 5 more times.
  143.  
  144. **ret is to return to the code that called this part of the codes.
  145. **So, a total of F12 will do nicely.
  146.  
  147. Disable the hmemcpy breakpoint.
  148. Then, trace a bit using F10 until you come across this.
  149. **F10 is to trace the codes without going into calls.
  150.  
  151. I have commented on the important part and deleted the unimportant part
  152. to save space.
  153.  
  154. :0042689C E86FEDFDFF              call 00405610
  155. :004268A1 83F804                  cmp eax, 00000004
  156. :004268A4 7D1B                    jge 004268C1
  157.  
  158. **See this cmp eax with 00000004? eax contains the length of your username
  159.   So, if it is longer than 4 char, you will jump and continue else
  160.   you will go below to get the "Wrong Code" message.
  161.  
  162. :004268A6 6A00                    push 00000000
  163.  
  164. * Possible StringData Ref from Code Obj ->"Sorry"
  165.                                   |
  166. :004268A8 B9DC694200              mov ecx, 004269DC
  167.  
  168. * Possible StringData Ref from Code Obj ->"Wrong Code"
  169.                                   |
  170. :004268AD BAE4694200              mov edx, 004269E4
  171. :004268B2 A124864200              mov eax, dword ptr [00428624]
  172. :004268B7 E84CB3FFFF              call 00421C08
  173. :004268BC E9E8000000              jmp 004269A9
  174.  
  175. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  176. |:004268A4(C)
  177. |
  178. **You will land here if you enter more than 4 char in your name.
  179.  
  180. :004268C1 8D55FC                  lea edx, dword ptr [ebp-04]
  181. :004268C4 8B83B0010000            mov eax, dword ptr [ebx+000001B0]
  182. :004268CA E881B3FEFF              call 00411C50
  183. :004268CF 8B45FC                  mov eax, dword ptr [ebp-04]
  184. **eax will contain your name -> "Eternal Bliss"
  185.  
  186. :004268D2 0FB600                  movzx eax, byte ptr [eax]
  187. **move the first char into eax -> eax=00000045 ("E")
  188.  
  189. :004268D5 8BF0                    mov esi, eax
  190. **move it to esi -> esi=00000045
  191.  
  192. :004268D7 C1E602                  shl esi, 02
  193. **shl the value with 02 -> esi=00000114
  194.  
  195. :004268DA 8D3476                  lea esi, dword ptr [esi+2*esi]
  196. **value of esi will be (114 + 144*2) which is 33C
  197. **Note, 144 is in HEX
  198. :
  199. :            __________Snip___________
  200. :
  201. :004268EB 8B45F8                  mov eax, dword ptr [ebp-08]
  202. :004268EE 0FB64001                movzx eax, byte ptr [eax+01]
  203. **move the 2nd char into eax -> eax=00000074 ("t")
  204.  
  205. :004268F2 8D0480                  lea eax, dword ptr [eax+4*eax]
  206. **eax will be (74 + 74*4) = 244 (HEX)
  207.  
  208. :004268F5 8D0480                  lea eax, dword ptr [eax+4*eax]
  209. **eax will be (244 + 244*4) = B54
  210.  
  211. :004268F8 03F0                    add esi, eax
  212. **Add B54(eax's value) to 144(esi's value) and esi = E90
  213. :
  214. :            __________Snip___________
  215. :
  216. :0042690B 0FB64002                movzx eax, byte ptr [eax+02]
  217. **move the 3rd char into eax -> eax=00000065 ("e")
  218.  
  219. :0042690F 03C0                    add eax, eax
  220. **eax = (65 + 65) = CA
  221.  
  222. :00426911 03F0                    add esi, eax
  223. **Add CA(eax's value) to E90(esi's value) and esi = F5A
  224. :
  225. :            __________Snip___________
  226. :
  227. :00426924 0FB64003                movzx eax, byte ptr [eax+03]
  228. **move the 4th char into eax -> eax=00000072 ("r")
  229.  
  230. :00426928 6BC00B                  imul eax, 0000000B
  231. **Multiple 72 with B and eax = 4E6
  232.  
  233. :0042692B 03F0                    add esi, eax
  234. **Add 4E6(eax's value) to F5A(esi's value) and esi = 1440
  235. :
  236. :            __________Snip___________
  237. :
  238. :00426938 E8D3ECFDFF              call 00405610
  239. **this call gets the length of your name = D (13 characters for "Eternal Bliss")
  240. **this value is in eax
  241.  
  242. :0042693D 8B1590864200            mov edx, dword ptr [00428690]
  243. **value of edx here is 1440
  244.  
  245. :00426943 0FAF1590864200          imul edx, dword ptr [00428690]
  246. **mulitple 1440 with 1440. edx = 19A1000
  247.  
  248. :0042694A F7EA                    imul edx
  249. **multiple value of eax(D) with value of edx(19A1000)
  250. **eax will contain the result which is 14D2D000
  251. **type "? eax" and see the command window the ascii for 14D2D00
  252.   you will see 349360128
  253.  
  254.  
  255. :0042694C A390864200              mov dword ptr [00428690], eax
  256. **move this value to location 00428690
  257. :
  258. :            __________Snip___________
  259. :
  260. **You have seen the below before. Remember the compare and the jump??
  261. :00426970 8B55FC                  mov edx, dword ptr [ebp-04]
  262. :00426973 58                      pop eax
  263. :00426974 E8FBCAFDFF              call 00403474
  264. :00426979 7518                    jne 00426993
  265. :0042697B 6A00                    push 00000000
  266.  
  267. Ok. After tracing through that lot, F10 to :00426974. Stop there.
  268.  
  269. At :00426970, sometime is moved into edx. See what it is by typing "d edx"
  270. You will see the serial you entered in the data window.
  271.  
  272. At :00426973, something is popped at eax. Type "d eax" to see what is the
  273. value. You will see 349360128 in the data window.
  274.  
  275. Then...it is followed by the compare... So, edx contains the serial we typed.
  276. What would eax be then??
  277.  
  278. It the correct serial, of course!!
  279.  
  280. Then exit Softice using F5. Key in 349360128 for the serial. 
  281. You will get the "You did it" message. 
  282.  
  283.  
  284. CrackMe Cracked!!
  285.  
  286. __________________________________________________________________________
  287.  
  288.  
  289.                              Final Notes
  290.  
  291. This tutorial is dedicated to all the newbies like me.
  292.  
  293. And because I'm a newbie myself, I may have explained certain things wrongly
  294. So, if that is the case, please forgive me. Email me if there is anything 
  295. you are not clear about.
  296.  
  297.  
  298. My thanks and gratitude goes to:-
  299.  
  300. The Sandman
  301. All the writers of Cracks tutorials and CrackMes