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

  1. **************************************************************************************************************************************************************
  2.                     CrackMe 7
  3. **************************************************************************************************************************************************************
  4.  
  5. Author:        Fr1c
  6. Protection:    SoftICE, W32Dasm, Enable Button, Name / Serial and a NAG (Btw, packed with UPX ;)
  7. URL:        http://www.mesa-sys.com/~eternal/e-h/fr1c-crackme7.zip
  8. Tools:        SoftICE v4.05
  9.         W32Dasm v8.93
  10.         ProcDump v1.6.2
  11.         Hex-Editor
  12.  
  13.  
  14. --->    Intro...
  15.  
  16. Welcome to my next Tutorial !!!
  17. First we're going to Manually Unpack it (UPX), as you probably know it can be done with UPX
  18. itself but i don't like that so we're going to do it Manually :)
  19. Then to get rid of the "SoftICE, W32Dasm, Enable Button and the NAG" we're going to find those
  20. places in memory (The places to patch that is ;) with W32Dasm.
  21. And then we're going to do some "Inline Patching" (I think it's called like that ;) so that when
  22. you run the Packed CrackMe it will patch the program itself :) (Jmp OEP -> Jmp Our Code and back)
  23. And then offcourse we're going to crack it :)
  24.  
  25.  
  26. --->    Let's Begin...        *** Manually Unpacking ***
  27.  
  28. Ok, well first we're going to find the OEP of the Packed program to do the "int 3" break :)
  29. So open ProcDump and click on "PE Editor" then select the Packed CrackMe and click "Open".
  30. Notice the Entry Point it's:    00056610
  31. But that's a "Virtual Address" we need to have the "Raw Address" ;)
  32. So click on "Sections" and check in which Section this "Virtual Address" is located in.
  33. It's the second Section called:    UPX1
  34. It's always the same with UPX ;)
  35. So to convert to "Raw Address" we do this:
  36.  
  37. Virtual Address - Raw Address
  38.  
  39. OEP = 00056610 - (00036000 - 00000400)
  40. OEP = 00020A10
  41.  
  42. Close ProcDump and open the Packed CrackMe in your HexEditor, then go to that location "00020A10"
  43. But we're not going to break exactly at the beginning of the Unpacking process because you can
  44. find easily where it jumps to the real OEP :)
  45. So when your at that "Raw Address" press 1 time "Page-Down" and then notice at the end of the
  46. Code something like this:
  47.  
  48. 61E94BC3FEFF
  49.  
  50. Now replace the "E9" with "CC" and save the File and get into SoftICE (CTRL+D).
  51. Then type "bpint 3" and get out of SoftICE (CTRL+D), run the Packed CrackMe and SoftICE should popup :)
  52. now type "BC *" to clear the breakpoint and we're landed right on the Jump to the real OEP :)
  53. So press (F10) 1 time and we're at the OEP write down the "Virtual Address" it's: 00442AE8
  54. Ok, now do the "EBFE" trick and get to ProcDump (If you don't know what the EBFE trick is check
  55. my other Tutorials ;) and right click on the File and select "DUMP (full)" then save the File
  56. to where ever you want and then right click again and select "Kill task".
  57. ok, now in ProcDump click on "PE Editor" and open the Unpacked CrackMe.
  58. Then change the Entry Point to: 00042AE8 (No Image Base ;)
  59. That's it, now you can run and disassemble the CrackMe :)
  60.  
  61.  
  62. --->    Let's Begin...        *** Getting rid of... ***
  63.  
  64. Well if you run the Unpacked CrackMe now you'll get a Message Box saying that it has detected SoftICE :)
  65.  
  66. "SoftICE is DETECTED"
  67.  
  68. Ok, now open up W32Dasm and disassemble the Unpacked CrackMe and then search for that string, Nowhere??? damn ;)
  69. Hmmm... so how are we going to do this :)
  70. Ok, first we'll deal with the SoftICE check so i suggest to open the Unpacked CrackMe in your
  71. HexEditor (Close W32Dasm if you haven't done so) and then search for something like:
  72.  
  73. SoftICE
  74. SICE
  75.  
  76. It'll found the second one :) and so you'll see this:
  77.  
  78. //./SICE
  79.  
  80. Aha, the SoftICE check done with CreateFileA :)
  81. Now get into SoftICE (CTRL+D) and type "bpx CreateFileA" then out of SoftICE (CTRL+D) and open the Unpacked CrackMe.
  82. Now SoftICE breaks fast but the first time isn't the one we need because Windows needs to "Create" the File first :)
  83. So press (F5) to skip this one and SoftICE will break again.
  84. Now press (F12) 1 time and you'll see this:
  85.  
  86. --------------------------------------------------------------------------------------------------------------------------------------------------------------
  87.  
  88. :00442756 83F8FF                  cmp eax, FFFFFFFF            <--- Compare EAX with FFFFFFFF (//./SICE not found?)
  89. :00442759 7417                    je 00442772                <--- If equal jump and skip the SoftICE detected Message Box :), else show it and quit
  90. :0044275B 50                      push eax
  91. :0044275C E8C734FCFF              call 00405C28
  92. :00442761 B828284400              mov eax, 00442828            <--- SoftIce is DETECTED
  93. :00442766 E85DF9FFFF              call 004420C8
  94. :0044276B 6A00                    push 00000000
  95. :0044276D E8FE34FCFF              call 00405C70
  96.  
  97. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  98. |:00442759(C)
  99. |
  100. :00442772 B844284400              mov eax, 00442844            <--- Kill me !! My name is NAG SCREEN!
  101. :00442777 E84CF9FFFF              call 004420C8
  102. :0044277C 33D2                    xor edx, edx
  103. :0044277E 8B83CC020000            mov eax, dword ptr [ebx+000002CC]
  104. :00442784 8B08                    mov ecx, dword ptr [eax]
  105. :00442786 FF5160                  call [ecx+60]
  106. :00442789 5B                      pop ebx
  107. :0044278A C3                      ret
  108.  
  109. --------------------------------------------------------------------------------------------------------------------------------------------------------------
  110.  
  111. So as you can see for the SoftICE check the "je 00442772" decides if we are the Good Boy or the Bad Boy ;)
  112. So we need to make it Jump, and so remember the "Virtual Address" 00442759 for our Inline Patching :)
  113. For now when your on the "je 00442772" type "r fl z" this will set the Z flag and so we jump.
  114. But...
  115. Have you seen where it jumps to?
  116. To our lovely NAG screen :)
  117. Heh, we need to make it jump a little further, and i suggest to let it jump just behind the next Call.
  118. Why?
  119. Notice the String "SoftICE is DETECTED" behind it is a Call the same as with the String "Kill me !! My name is NAG SCREEN!" so it's probably the Message Box
  120. (You can check it out with SoftICE if you want :).
  121. So we need to change the length of the Jump as well.
  122. Now just jump till you get the NAG and press "Ok" and we're back in SoftICE (Remember the Protection "Enable Button" ? ;).
  123. Now trace and go into "call [ecx+60]" and you'll see this:
  124.  
  125. --------------------------------------------------------------------------------------------------------------------------------------------------------------
  126.  
  127. :00423CD4 3A5048                  cmp dl, byte ptr [eax+48]
  128. :00423CD7 7411                    je 00423CEA
  129. :00423CD9 885048                  mov byte ptr [eax+48], dl
  130. :00423CDC 6A00                    push 00000000
  131. :00423CDE 33C9                    xor ecx, ecx
  132. :00423CE0 BA0CB00000              mov edx, 0000B00C
  133. :00423CE5 E8A6100000              call 00424D90
  134.  
  135. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  136. |:00423CD7(C)
  137. |
  138. :00423CEA C3                      ret
  139.  
  140. --------------------------------------------------------------------------------------------------------------------------------------------------------------
  141.  
  142. Hmm.. you see that Compare with DL and [eax+48]? :)
  143. If equal we jump to the ret and nothing changes, else it puts DL in [eax+48] and does all kinds of other stuff :)
  144. This is probably the "Enable Button" check ;P How are we going to find out? Simple...
  145. Just let the "je 00423CEA" jump and we'll see :)
  146. So when your on the "je 00423CEA" type "r fl z" to let it jump and press (CTRL+D) to exit SoftICE.
  147. Now the main program pops up and i see no Button Disabled or something :)
  148. Now quit the CrackMe and do the same but without letting the last "je" (the Enable Button check) jump and now you'll see in the main window that the Button
  149. "Register" is disabled ;)
  150. Hehe, right we got it :)
  151. But now we need to let this program patch itself.
  152.  
  153. (Ok, one other thing, i don't want to explain this to much ;) but like i mentioned above in the File there's also a W32Dasm check.
  154. It uses FindWindowA to locate W32Dasm (If running) you can easily defeat this by changing the next line in W32Dasm or the CrackMe itself :)
  155.  
  156. "URSoft W32Dasm Ver 8.93 Program Disassembler/Debugger" <--- In CrackMe
  157. "URSoft W32Dasm Ver %s Program Disassembler/Debugger"   <--- In W32Dasm
  158.  
  159. Anyway have you noticed something in the Code above (the second above ;) where those 2 Message Boxes are?
  160. It checks for "//./SICE" if equal we get a Message Box and then quit, else we get the NAG and Enable Button" check, and then followed by a:
  161.  
  162. :00442789 5B                      pop ebx
  163. :0044278A C3                      ret
  164.  
  165. So why not change the "je 00442772" to "pop ebx, ret" :)
  166. Then we don't need to patch so much and it's more easy then the other thing we had in mind.
  167. (Well much we can still patch the "je" to a jump and skip all of it but crap, i'm gonna do it this way ;)
  168. So what we're actually going to do is at the Address "00442759" patch the bytes "7417" with "5BC3" :)
  169. Ok, if you want you can delete the Unpacked CrackMe now ;)
  170.  
  171. Now we need to find some space in the Packed CrackMe for our Code.
  172. So open the Packed CrackMe in your HexEditor and go to the OEP (not the real OEP that's not there now ;) and press "Page-Down" 1 time.
  173. You see some little space below the Code, excellent :)
  174. I suggest to put our Code at "Raw Address" 00020BE0 and my Code looks like this (put your Code there in whatever language you want ;) :
  175.  
  176. --------------------------------------------------------------------------------------------------------------------------------------------------------------
  177.  
  178. mov byte ptr [00442759], 5B
  179. mov byte ptr [0044275A], C3
  180. push 00442AE8
  181. ret
  182.  
  183. --------------------------------------------------------------------------------------------------------------------------------------------------------------
  184.  
  185. Ok, why 2 mov's ???
  186. Dunno, i just want it that way ;P
  187. You can also change it in "mov word ptr [00442759], 5BC3" :)
  188. And why the "push 00442AE8, ret" ???
  189. Also dunno, it's just easy to use ;)
  190. So now save the File and run it, it works ;P
  191. Ok phew, now on to the Cracking ;)
  192.  
  193.  
  194. --->    Let's Begin...        *** Getting a valid Name and Serial ***
  195.  
  196. Open the Packed CrackMe and enter any Name and Serial i've used:
  197.  
  198. Name:        CoDe_InSiDe
  199. Serial:        1234567890
  200.  
  201. Now get into SoftICE (CTRL+D) and type "bpx hmemcpy" then out of SoftICE (CTRL+D) and press on the Button "Register" and SoftICE should popup.
  202. Press (F12) 12 times to get into the CrackMe Code and you'll see this:
  203.  
  204. --------------------------------------------------------------------------------------------------------------------------------------------------------------
  205.  
  206. :004428AE 8B45F4                  mov eax, dword ptr [ebp-0C]        <--- EAX now points to our Name
  207. :004428B1 E87E11FCFF              call 00403A34                <--- Get the length of our Name
  208. :004428B6 8BF0                    mov esi, eax                <--- Move EAX in ESI
  209. :004428B8 85F6                    test esi, esi                <--- Test if ESI is 00
  210. :004428BA 7E41                    jle 004428FD                <--- If equal we jump and fail (well almost fail ;), else continue with the loop
  211. :004428BC BF01000000              mov edi, 00000001            <--- Mov 00000001 in EDI
  212.  
  213. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  214. |:004428FB(C)
  215. |
  216. :004428C1 8D55F4                  lea edx, dword ptr [ebp-0C]
  217. :004428C4 8B45FC                  mov eax, dword ptr [ebp-04]
  218. :004428C7 8B80C4020000            mov eax, dword ptr [eax+000002C4]
  219. :004428CD E8CE14FEFF              call 00423DA0
  220. :004428D2 8B45F4                  mov eax, dword ptr [ebp-0C]        <--- Move offset to our Name in EAX
  221. :004428D5 0FB64438FF              movzx eax, byte ptr [eax+edi-01]    <--- Move first Char in EAX
  222. :004428DA 8BD8                    mov ebx, eax                <--- Move EAX in EBX
  223. :004428DC 6BC363                  imul eax, ebx, 00000063        <--- Multiply 00000063 with EBX and put the result in EAX
  224. :004428DF 8BD8                    mov ebx, eax                <--- Mov EAX in EBX
  225. :004428E1 83F306                  xor ebx, 00000006            <--- XOR EBX with 00000006
  226. :004428E4 8D45F0                  lea eax, dword ptr [ebp-10]        <--- Point EAX to some place in Memory
  227. :004428E7 8BD3                    mov edx, ebx                <--- Move EBX in EDX
  228. :004428E9 E86E10FCFF              call 0040395C                <--- Move DL at some place in Memory (EDX contains the data from EBX)
  229. :004428EE 8B55F0                  mov edx, dword ptr [ebp-10]        <--- Move [ebp-10] in EDX
  230. :004428F1 8D45F8                  lea eax, dword ptr [ebp-08]        <--- Point EAX to some place in Memory
  231. :004428F4 E84311FCFF              call 00403A3C                <--- Here it puts the Characters behind each other
  232. :004428F9 47                      inc edi                <--- EDI +1
  233. :004428FA 4E                      dec esi                <--- ESI -1 (Length of our Name)
  234. :004428FB 75C4                    jne 004428C1                <--- If ESI isn't 00 we repeat the loop else continue
  235.  
  236. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  237. |:004428BA(C)
  238. |
  239. :004428FD 8D55F4                  lea edx, dword ptr [ebp-0C]
  240. :00442900 8B45FC                  mov eax, dword ptr [ebp-04]
  241. :00442903 8B80C8020000            mov eax, dword ptr [eax+000002C8]
  242. :00442909 E89214FEFF              call 00423DA0
  243. :0044290E 8B55F4                  mov edx, dword ptr [ebp-0C]        <--- Move offset to our "Fake" Serial in EDX
  244. :00442911 8B45F8                  mov eax, dword ptr [ebp-08]        <--- Move offset to our "Real" Serial in EAX
  245. :00442914 E82B12FCFF              call 00403B44                <--- Compare them
  246. :00442919 750A                    jne 00442925                <--- If not equal we jump and just continue, else we get a Good Message Box :)
  247. :0044291B B864294400              mov eax, 00442964            <--- Good work cracker!
  248. :00442920 E8A3F7FFFF              call 004420C8
  249.  
  250. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  251. |:00442919(C)
  252. |
  253. :00442925 33C0                    xor eax, eax
  254. :00442927 5A                      pop edx
  255. :00442928 59                      pop ecx
  256. :00442929 59                      pop ecx
  257. :0044292A 648910                  mov dword ptr fs:[eax], edx
  258. :0044292D 6852294400              push 00442952
  259.  
  260. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  261. |:00442950(U)
  262. |
  263. :00442932 8D45F0                  lea eax, dword ptr [ebp-10]
  264. :00442935 E87E0EFCFF              call 004037B8
  265. :0044293A 8D45F4                  lea eax, dword ptr [ebp-0C]
  266. :0044293D E8760EFCFF              call 004037B8
  267. :00442942 8D45F8                  lea eax, dword ptr [ebp-08]
  268. :00442945 E86E0EFCFF              call 004037B8
  269. :0044294A C3                      ret
  270.  
  271.  
  272. --------------------------------------------------------------------------------------------------------------------------------------------------------------
  273.  
  274. Ok, very simple and small Algo :)
  275. So it does this for my Name:
  276.  
  277. Name: CoDe_InSiDe
  278. Put first Char in EAX (C = 43)
  279. Move EAX in EBX
  280. Then it Multiplies EBX with 00000063 and puts the result in EAX (result in EAX is now = 000019E9)
  281. Move EAX in EBX
  282. Then it XOR's EBX with 00000006 (EBX = 000019EF)
  283. Move EBX in EDX
  284. Move DL into some place in the Memory
  285. Increase EDI (Point to our next Char)
  286. Decrease ESI (Are we at the end of our Name?)
  287. If not we jump and repeat this loop else we're finished :)
  288.  
  289. So, very simple when your on the instruction "call 00403B44" type "d eax" and you'll see your "Real" Serial :)
  290. In my case it weren't any readable Characters so i had this for my Name:
  291.  
  292. Name:        CoDe_InSiDe
  293. Serial:        hex = EFEB4A09BB3D8C1F9D4A09
  294.  
  295. Ok, that's All...
  296. You can patch this CrackMe by simply NOP the "jne 00442925" but i'll leave that up to you :)
  297.  
  298.                     *** NOTE ***
  299.  
  300. Remember where i said above "If equal we jump and fail (well almost fail ;), else continue with the loop" ? ;)
  301. It was the check if we entered a Name, now the funny thing is if we haven't entered a Name we still go to the Compare stuff.
  302. So then it Compares nothing (00 our Name) with the created Serial (which is also 00 because it hasn't created any Serial from our Name) and so we continue
  303. and get the Good Boy Message :P
  304. Just try it enter nothing as your Name and Serial and your Registered.
  305. Well, a weird thing about this one is that in the Title bar it says "CrackMe 7 by Fr1c - UNREGISTERED" and after we Registered it, it isn't changed ;)
  306. But who cares...
  307.  
  308.  
  309. --->    Outro...
  310.  
  311. And another big Tutorial ;)
  312. You maybe also think now "Hmmm... why have we Unpacked this program it wasn't necessary?" and your right it wasn't :P
  313. But hey i like to Unpack stuff ;) I hope you learned something from this Tutorial...
  314. (Btw, this CrackMe checks for W32Dasm if it's running, with the Inline Patch you can easily fix that ;)
  315.  
  316.  
  317. --->    Greetings...
  318.  
  319.  
  320. To be honest i'm getting a bit sick of these greetings everytime ;P
  321. So i'll just say:
  322.  
  323. Greetings to everyone i know, and to everyone who knows me, and You... ;P
  324.  
  325.  
  326.             Don't trust the Outside, trust the InSiDe !!!
  327.  
  328.                       Cya...
  329.  
  330.                     CoDe_InSiDe
  331.  
  332.  
  333. Email:    code.inside@home.nl