home *** CD-ROM | disk | FTP | other *** search
/ KeyGen Studio 2002 / KeyGen_Studio_2002.iso / Tutorials / Code Inside / Tut17.txt < prev    next >
Encoding:
Text File  |  2001-09-21  |  14.6 KB  |  321 lines

  1. ************************************************************************************************************************************************************************
  2.                   Crackme #1 bY Sarnaik
  3. ************************************************************************************************************************************************************************
  4.  
  5. Author:        Sarnaik
  6. Protection:    Name / Serial
  7. URL:        
  8. Tools:        SoftICE V4.05
  9.         W32Dasm V8.93
  10.         Hex-Editor
  11.  
  12.  
  13. --->    Intro...
  14.  
  15. Welcome to my next Tutorial !!!
  16. This is a easy CrackMe from Sarnaik but maybe a bit tricky for the Newbie :)
  17. The Algo is very simple but the Compare is a bit harder.
  18. First I'll sniff the Serial and then i'll patch it :)
  19.  
  20.  
  21. --->    Let's Begin...
  22.  
  23. Ok, open up the CrackMe and it asks you for a Name and Serial, fill something in i've used:
  24.  
  25. Name:        CoDe_InSiDe
  26. Serial:        1234567890
  27.  
  28. Then get into SoftICE (CTRL+D) and type "bpx hmemcpy" followed by "enter" , why hmemcpy?
  29. Because it almost always breaks ;)
  30. Then get out of SoftICE (CTRL+D) and press "Check" and SoftICE popups.
  31. Now first type "BC *" to disable the breakpoint and now press (F12) 9 times till you reach
  32. the CrackMe code and you should see this:
  33.  
  34. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  35.  
  36. :00401068 83F800                  cmp eax, 00000000            <--- Compare EAX with 00 (Have we entered a Name?)
  37. :0040106B 0F84A6000000            je 00401117                <--- If equal (No Name entered) we jump and fail, else continue
  38. :00401071 33C0                    xor eax, eax                <--- XOR EAX which is now 00
  39. :00401073 33DB                    xor ebx, ebx                <--- XOR EBX which is now 00
  40. :00401075 33C9                    xor ecx, ecx                <--- XOR ECX which is now 00
  41. :00401077 BF60204000              mov edi, 00402060            <--- EDI now points to our Name
  42.  
  43. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  44. |:00401089(U)
  45. |
  46. :0040107C 8A07                    mov al, byte ptr [edi]        <--- Move first Char in AL
  47. :0040107E 84C0                    test al, al                <--- Test if AL is 00 (Are we at the end of our Name?)
  48. :00401080 7409                    je 0040108B                <--- If so we jump and continue with the Crackme, else continue with the Algo
  49. :00401082 03C8                    add ecx, eax                <--- ADD EAX to ECX
  50. :00401084 C1E008                  shl eax, 08                <--- Shift EAX to the left with 08
  51. :00401087 43                      inc ebx                <--- EBX +1
  52. :00401088 47                      inc edi                <--- EDI +1
  53. :00401089 EBF1                    jmp 0040107C                <--- Repeat loop
  54.  
  55. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  56.  
  57. This is the small Algo :)
  58. It takes the first Char of our Name and checks if it's 00.
  59. If so we jump and continue with the CrackMe, else continue with the Algo.
  60. Then it ADDs EAX to ECX.
  61. Then we get "shl eax, 08" let me show you what this instruction does for my Name (First Char is C=43 hex).
  62.  
  63. EAX    =    00000043
  64.  
  65.     shl eax, 08
  66.  
  67. EAX    =    00004300
  68.  
  69. Then increase EBX with 1    <--- counts the length of our Name
  70. Increase EDI with 1        <--- Points to the next Char
  71. Repeat loop
  72.  
  73. Ok, i think this is not so difficult :) now let's see what's next:
  74.  
  75. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  76.  
  77. :0040108B 0FAFCB                  imul ecx, ebx                <--- Multiply EBX with ECX
  78. :0040108E 81F16E61696B            xor ecx, 6B69616E            <--- XOR ECX with 6B69616E (naik)
  79. :00401094 8BD9                    mov ebx, ecx                <--- Move ECX in EBX
  80. :00401096 53                      push ebx                <--- Save EBX in the Stackdump
  81. :00401097 6A08                    push 00000008                <--- Push 08 = the maximum Chars to be copied from our "Fake" Serial
  82. :00401099 686C204000              push 0040206C                <--- Offset where our "Fake" Serial will be stored
  83.  
  84. * Possible Reference to Dialog: DialogID_0001, CONTROL_ID:006B, ""
  85.                                   |
  86. :0040109E 6A6B                    push 0000006B
  87. :004010A0 FF7508                  push [ebp+08]
  88.  
  89. * Reference To: USER32.GetDlgItemTextA, Ord:0000h
  90.                                   |
  91. :004010A3 E81D010000              Call 004011C5
  92.  
  93. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  94.  
  95. Notice the two instructions on top.
  96. First it Multiplies EBX with ECX (Multiply Length of our Name with the New Value created with the Algo).
  97. And then it XORs ECX with 6B69616E (naik).
  98. And then it get's the "Fake" Serial we entered by using "GetDlgItemTextA" and puts it at offset 0040206C.
  99. Let's see what's next:
  100.  
  101. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  102.  
  103. :004010A8 BF6C204000              mov edi, 0040206C            <--- EDI now points to our "Fake" Serial
  104. :004010AD BB40000000              mov ebx, 00000040            <--- Move 00000040 in EBX
  105. :004010B2 33C9                    xor ecx, ecx                <--- XOR ECX which is now 00
  106.  
  107. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  108. |:004010C4(U)
  109. |
  110. :004010B4 8A07                    mov al, byte ptr [edi]        <--- Move first Char in AL (Are we at the end of our "Fake" Serial?)
  111. :004010B6 84C0                    test al, al                <--- Test if AL is 00
  112. :004010B8 740C                    je 004010C6                <--- If so we jump and continue with the CrackMe, else continue with this "Algo"?
  113. :004010BA 32C3                    xor al, bl                <--- XOR BL with AL
  114. :004010BC 8AC8                    mov cl, al                <--- Move AL in CL
  115. :004010BE C1C108                  rol ecx, 08                <--- Rotate ECX to the left with 08
  116. :004010C1 FEC3                    inc bl                <--- BL +1
  117. :004010C3 47                      inc edi                <--- EDI +1
  118. :004010C4 EBEE                    jmp 004010B4                <--- Repeat loop
  119.  
  120. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  121.  
  122. Another Algo ?
  123. Hehe, this is the tricky part :)
  124. It "Encrypts" the Serial a bit.
  125. So first it takes the first Char of our "Fake" Serial.
  126. Then it XORs BL (00000040) with AL (First Char).
  127. And then it moves AL to CL.
  128. Then we get the instruction "rol ecx, 08" it's almost the same as "shl ecx, 08", let me show you the difference:
  129.  
  130. ECX    =    00000043            ECX    =    00000043    ---
  131.                                            |
  132.     shl ecx, 08                    rol ecx, 08           |-- The Same !!!
  133.                                            |
  134. ECX    =    00004300            ECX    =    00004300    ---
  135.  
  136.  
  137.  
  138. ECX    =    43000000            ECX    =    43000000    ---
  139.                                            |
  140.     shl ecx, 08                    rol ecx, 08           |-- Different !!!
  141.                                            |
  142. ECX    =    00000000            ECX    =    00000043    ---
  143.  
  144.  
  145. Ok, I think you can understand this ;)
  146. Then increase BL with 1        (Our XOR number)
  147. increase EDI with 1        (Points to the next Char)
  148. repeat loop
  149.  
  150. And so on till all "Fake" Serial Chars are done.
  151. After this it Compares our "Magic Value" created with the first Algo, to this new "Fake" Serial.
  152. How are we going to find the "Real" Serial ?
  153. Just reverse the process :)
  154. But there's one thing if you've payed close attention to this "Fake" Serial Algo.
  155. In fact it only uses 4 Chars.
  156. Let me explain...
  157.  
  158. As I mentioned above, there were copied 08 chars from our "Fake" Serial (not including the last Char because that must be 00).
  159. So we have then 7 Chars from our "Fake" Serial for me it was:
  160.  
  161. Entered "Fake" Serial    =    1234567890
  162.  
  163. New "Fake" Serial    =    1234567
  164.  
  165. Then comes the "Fake" Serial Algo and we've seen this "Move AL to CL".
  166. A Register contains "4 Bytes = 4 Chars" (00 00 00 00)
  167. So it takes the last 4 Chars before it reaches the end (00).
  168. I hope this isn't confusing or something :)
  169. Let me show you some Table:
  170.  
  171. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  172.  
  173. Entered Char    Hex    XOR with BL    Result    Move in CL    rol ecx, 08
  174.  
  175. 1        31    40        71    00 00 00 71    00 00 71 00
  176. 2        32    41        73    00 00 71 73    00 71 73 00
  177. 3        33    42        71    00 71 73 71    71 73 71 00
  178. 4        34    43        77    71 73 71 77    73 71 77 71
  179. 5        35    44        71    73 71 77 71    71 77 71 73
  180. 6        36    45        73    71 77 71 73    77 71 73 71
  181. 7        37    46        71    77 71 73 71    71 73 71 77
  182.  
  183. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  184.  
  185. Take some time to have a good look at this :)
  186. So it actually only counts (in my case now) "4567".
  187. which is "Encrypted" in the Register ECX = 73717771.
  188.  
  189. "Man your weird, i see just above 71737177, why now 73717771 ???" ;)
  190.  
  191. Take another look again at the "Fake" Serial Algo, when it has reached the last Char it does "rol ecx, 08" one more time, so that's why :)
  192. So to get the "Real" Serial we need to XOR the values with 40, 41, 42, 43.
  193. Now you may think:
  194.  
  195. "He, i see just above (XOR with BL) 43, 44, 45, 46 ? why now with 40, 41, 42, 43 ?."
  196.  
  197. Hehe, that's because as i said it only takes 4 Chars no matter if their at the beginning or the end (till it reaches 00), otherwise we need to know the first 3 Chars,
  198. but that's not necessary because a Register can only hold 4 Chars :)
  199. I'll hope this explains ;)
  200. Anyway my created "Magic Value" for my Name = E47C645C
  201. But one more problem because of the "rol ecx, 08" we got the new "Fake" Serial = 73717771 which is actually = 6547
  202. Let me show you a Table ones again ;)
  203.  
  204. 73 71 77 71    --->    6547    (XOR with BL)    --->    42 41 40 43
  205.  
  206. 71 73 71 77    --->    7654    (XOR with BL)    --->    43 42 41 40    (It's always in reverse, learn that principle ;)
  207.  
  208. So we need to use this "Magic Value" for my Name = 5CE47C64    (and then XOR with 40 41 42 43 "Reverse" to get Real Serial)
  209.  
  210. Magic Value    5C E4 7C 64
  211. XOR with BL    40 41 42 43
  212.         -----------
  213. Result        1C A5 3E 27
  214.  
  215. Now we have our "Real" Serial so one more time my complete Serial:
  216.  
  217. Name:        CoDe_InSiDe
  218. Serial:        Ñ>'
  219.  
  220. That's it CrackMe Cracked...
  221. I hope it wasn't too confusing i tried my best to explain it very well :)
  222. I think you can Keygen it now ;)
  223. Now the patching part...
  224.  
  225.  
  226. --->    Let's Patch...
  227.  
  228. Stay in SoftICE and examine the following.
  229. remember the spot just above in this file where the "Fake" Serial Algo lies, go there again with SoftICE (if you quited it) and you'll see this after (offset 004010C4):
  230.  
  231. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  232.  
  233. :004010C6 5B                      pop ebx                <--- Pop EBX which is our "Magic Value"
  234. :004010C7 E81E000000              call 004010EA                <--- Call the Compare
  235. :004010CC 85C0                    test eax, eax                <--- Test if EAX is 00 (Bad thing)
  236. :004010CE 7447                    je 00401117                <--- If equal we jump and fail and the program just continue and shows nothing, else continue
  237. :004010D0 6A00                    push 00000000
  238.  
  239. * Possible StringData Ref from Data Obj ->"Good job"
  240.                                   |
  241. :004010D2 6817204000              push 00402017
  242.  
  243. * Possible StringData Ref from Data Obj ->"You cracked this lame crackme "
  244.                                   |
  245. :004010D7 6820204000              push 00402020
  246. :004010DC 6A00                    push 00000000
  247.  
  248. * Reference To: USER32.MessageBoxA, Ord:0000h
  249.                                   |
  250. :004010DE E8EE000000              Call 004011D1
  251.  
  252. * Possible Reference to Dialog: DialogID_0001 
  253.                                   |
  254. :004010E3 B801000000              mov eax, 00000001            <--- Move 01 in EAX
  255. :004010E8 EB2D                    jmp 00401117                <--- Jump to the end
  256.  
  257. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  258.  
  259. Ok, now we can just patch this "je 00401117" or we can check the "CALL 004010EA" we do that :) get in the CALL and you see this:
  260.  
  261. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  262.  
  263. :004010EA 3BD9                    cmp ebx, ecx                <--- Compare "Magic Value" with new "Fake" Serial
  264. :004010EC 7403                    je 004010F1                <--- If equal we jump and move 01 in EAX, else continue and move 00 in EAX
  265. :004010EE 33C0                    xor eax, eax                <--- XOR EAX which is now 00
  266. :004010F0 C3                      ret                    <--- Return to that "test eax, eax"
  267.  
  268. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  269. |:004010EC(C)
  270. |
  271. :004010F1 B001                    mov al, 01                <--- Move 01 in AL
  272. :004010F3 C3                      ret                    <--- Return to that "test eax, eax"
  273.  
  274. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  275.  
  276. Well we can patch this CrackMe in several ways, here are some:
  277.  
  278. 1.    Change "cmp ebx, ecx" ---> "cmp ebx, ebx" or "cmp ecx, ecx"
  279. 2.    Change "je 004010F1"  ---> "jmp 004010F1"
  280. 3.    Change "xor eax, eax" ---> "mov al, 01"
  281. 4.    Or we can change the "je 00401117" into "jmp 004010D0 (EB00)" or "NOP it (9090)" when we're back from this CALL.
  282.  
  283. We're going to do "3" :)
  284. Write down the offset of "xor eax, eax" or keep in mind and close SoftICE (CTRL+D).
  285. Then open the CrackMe in W32Dasm.
  286. Then click on "Goto/Goto Code Location" or simply press "SHIFT + F12" :)
  287. Then enter that offset "004010EE" followed by "enter".
  288. Now check the line below in W32Dasm it says:
  289.  
  290. Line:193 Pg 4 and 5 10 Code Data @:004010EE @Offset 000006EEh in File:crackme1.EXE
  291.  
  292. The only important part for us is "@Offset 000006EEh" write down that offset and open the CrackMe in a Hex-Editor.
  293. Then get to that offset (000006EE) and change this:
  294.  
  295. 33C0    -    xor eax, eax
  296.  
  297. in
  298.  
  299. B001    -    mov al, 01
  300.  
  301. Now don't forget to close W32Dasm otherwise we can't save :)
  302. And save the file (make backup if you want) and run it, now every Serial works :P
  303. Play with all the Patch options if you want it's nice to do ;)
  304. Ok, this is it The End, damn big Tutorial i hope you learned something ;)
  305.  
  306.  
  307. --->    Greetings...
  308.  
  309. Everybody from TrickSoft        (www.TrickSoft.net)
  310. Everybody from Cracking4Newbies        (www.Cracking4Newbies.com)
  311. Everybody from Keygenning4Newbies    (Keygenning4Newbies.cjb.net)
  312. Everybody from ReverseMes        (ReverseMes.cjb.net)
  313. And You...
  314.  
  315.             Don't trust the Outside, trust the InSiDe !!!
  316.  
  317.                       Cya...
  318.  
  319.                     CoDe_InSiDe
  320.  
  321. Email:    code.inside@home.nl