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

  1.                         --Unpacking/Softice Tutorial--- 
  2.  
  3. Written by Shany
  4. Email: shanytc@yahoo.com
  5. Date written: 30.4.2001
  6.  
  7. Program Details:
  8. Name: CoDe_InSide CracMe 16
  9. Author: BenGALY
  10.  
  11. Tools Used:
  12. Softice
  13. ProcDump
  14. 32DASM
  15.  
  16. Rank:
  17. easy[ ] medium[X] hard[ ] 
  18.  
  19. ____________________________________________________________________________________________
  20.  
  21.  
  22.                        -About this protection system-
  23.  
  24.          Protection which based on name/serial protection.
  25. _____________________________________________________________________________________________
  26.  
  27.  
  28.                                  The Essay
  29.  
  30. As this is a tutorial for more advanced newbies, I'll go into details about how I go 
  31. about cracking the program. I suggest that you read this tutorial first.
  32. When you have completed the tutorial, leave this tutorial open and follow
  33. the instructions. Re-do it once more after you have completed the step 
  34. by step guide...
  35.  
  36. In this essay, when I write type "d EAX" or similar commands in Softice,
  37. I mean it without the quotes.
  38.  
  39. _____________________________________________________________________________________________
  40.  
  41.                             Lets Crack The Bitch ;)
  42.  
  43. Hello again to my 18's tut..i am very proud of it.
  44. Ok first this CrackMe is very cool..since it combine several protection inside of it.
  45. So let's go to work.
  46. First try on your own to crack it...ok u cant crack it regulary..why??
  47. first we will Dissasmble the crack me...Opps..what do we see??...we see only little stuff dissasmbled, where is all of the asm code gone???...hahaha this is nice, now since it's my first tutorial using ProcDump i can't really explain every thing..i my self didn't knew about how to use procdump in crackme..so i suggest u guy to grasp code_inside's tut13 about unpacking, this will give u a rough idea how it works.
  48. ok...so we will need to use procdump...open the program (procdump)..press the PE editor..chose your crackme, in our case crackme 16 by code_inside ;)
  49. now after openning the program..press the SECTIONS button (under structores editor)..u will see alittle box with offsets and raw numbers, now u can see in the last name (under .rsrc) a blank name (without name) and have a offsets of 0000000 for all raw/virtual/sizes..ok that's mean like a small protection..u avoid us to use 32dasm..right click on mouse (on the blank name) and choose "kill task", haha now click ok, then again ok, and exit program.
  50. now u cab able to dissasmble the crackme using 32dasm....wee we have finished the unpacking part.
  51. now after dissasmblination choose "strn-ref" button, u will see this: "Great !!! now write a KeyGen...", click on that and we will be here:
  52.  
  53.  
  54. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  55. |:0040121D(C)
  56. |
  57. :00401230 33C0                    xor eax, eax                             ; eax = 0
  58. :00401232 8BC2                    mov eax, edx                             ; eax holds edx
  59. :00401234 43                      inc ebx                                  ; ebx + 1
  60. :00401235 4B                      dec ebx                                  ; ebx - 1
  61. :00401236 85DB                    test ebx, ebx                            ; is ebx = ebx?
  62. :00401238 7418                    je 00401252                              ; yes?? jump
  63. :0040123A 55                      push ebp                                 ; no?? save ebp
  64. :0040123B 8BEC                    mov ebp, esp                             ; ebp now holds esp
  65.  
  66. * Possible StringData Ref from Data Obj ->"Great !!! now write a KeyGen..."  ; we are here
  67.                                   |
  68. :0040123D 68BE1E4000              push 00401EBE                               ;call api            
  69.  
  70. ok now that we know where we are it's more easy to find the adress where the right serial is.
  71.  
  72. now scroll up untill here:
  73.  
  74.  
  75. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  76. |:004011CF(C)
  77. |
  78. :004011EF C1C904                  ror ecx, 04                   ; rotate 04 in ecx
  79. :004011F2 0FC9                    bswap ecx                     ; swap bytes in ecx
  80. :004011F4 F7D1                    not ecx                       ; NOT operation on ecx
  81. :004011F6 51                      push ecx                      ; save ecx
  82. :004011F7 33C9                    xor ecx, ecx                  ; if ecx = 0 then:
  83. :004011F9 8B05FC1B4000            mov eax, dword ptr [00401BFC] ; 00401BFC move to eax (name we entered)
  84. :004011FF B9FC1A4000              mov ecx, 00401AFC             ; serial move to ecx
  85. :00401204 81E9FC000000            sub ecx, 000000FC             ; ecx - FC 
  86. :0040120A 8B11                    mov edx, dword ptr [ecx]      ; ecx move to ebx (string??)
  87. :0040120C 8B5904                  mov ebx, dword ptr [ecx+04]   ; ecx+04(string) moves to ebx
  88. :0040120F 85DB                    test ebx, ebx                 ; ebx = ebx??
  89. :00401211 7402                    je 00401215                   ; yes? jump
  90. :00401213 01D3                    add ebx, edx                  ; ebx + edx
  91.  
  92. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  93. |:00401211(C)
  94. |
  95. :00401215 83C108                  add ecx, 00000008             ; ecx + 8
  96. :00401218 8B11                    mov edx, dword ptr [ecx]      ; ecx (4 bytes?) moves to edx
  97. :0040121A 5B                      pop ebx                       ; load ebx from memory
  98. :0040121B 2BC3                    sub eax, ebx                  ; ebx - eax
  99. :0040121D 7411                    je 00401230                   ; jump
  100. :0040121F 33DB                    xor ebx, ebx                  ; ebx = 0
  101. :00401221 8B5904                  mov ebx, dword ptr [ecx+04]   ; ecx+4 (4 bytes?) moves to ebx
  102. :00401224 83C108                  add ecx, 00000008             ; ecx + 8
  103. :00401227 8B11                    mov edx, dword ptr [ecx]      ; ecx (4 bytes?) moves to edx
  104. :00401229 8B59FC                  mov ebx, dword ptr [ecx-04]   ; ecx-04 (4 bytes?) move to ebx
  105. :0040122C 2BD3                    sub edx, ebx                  ; ebx - edx
  106. :0040122E 33DB                    xor ebx, ebx                  ; ebx= 0
  107.  
  108. ok so we got the stuff we wanted right?? yeah..once u look at the code above the crackme began to be very logical.
  109. ok next we need to figure out the algo scheme, so here we go:
  110.  
  111.                                    [ALGO SCHEME]:  
  112.                                    --------------
  113.  
  114. :004011F2 0FC9                    bswap ecx                     ; swap bytes in ecx
  115. :004011F4 F7D1                    not ecx                       ; NOT operation on ecx
  116. :004011F6 51                      push ecx                      ; save ecx
  117. :004011F7 33C9                    xor ecx, ecx                  ; if ecx = 0 then:
  118. :004011F9 8B05FC1B4000            mov eax, dword ptr [00401BFC] ; 00401BFC move to eax (name we entered)
  119. :004011FF B9FC1A4000              mov ecx, 00401AFC             ; serial move to ecx
  120.  
  121.                                  [ALGO EXPLANATION]:
  122.                                  -------------------
  123.                      
  124. so after our serial (fake) is enteres, it is not being compare to a real serial or something, by looking in the code we ca see that first our serial get's a: bswap .
  125. a bswap meaning swaping bytes of our serial.
  126. Example:
  127. our entered serial is: 912E59DC (mostly it will use leters to in sice..u will see that later)
  128. so we will swap the numbers (like a mirror, we actually if u will write those numbers in a paper and look at them in the mirror it will be swaped ;) ).
  129. so swap serial is: DC592E91...go it??..i hope so..;D
  130.  
  131. on to the second operation..after fake serial is now swaped we get a " NOT " operation..(it's like in c/c++ ther is a not operation..)..so how to use he NOT operation in our swaped numbers??
  132. we will do that:
  133. 1.open calculator.exe ( like in any windows OS) ;)
  134. 2.switch to view->sientific mode
  135. 3.chose HEX mode (in te left side)
  136. 4. new we will take ever 2 numbers and make a NOT operation on it
  137. Example:
  138. DC 59 2E 91
  139. type DC in calculator..choose not button it will be calculated to this: FFFFFF23 ignore the FFFFFFF then the calculated number is : 23 ;)
  140. got it?? i hope so
  141.  
  142. now we get in the Sice part:
  143. open the crackme and inset any name/serial, open SoftIce by press ctrl+d..enter a bpx (u can use either hmemcpy or getdlgitemtextA) i will prefer getdlgitemtextA since it's much faster to debug ;), Ctrl+d again..press "CHECK" button..sICE pop-up press f5 to read the seria text field, f12, now trace with f10..(do u remember that we need to trace untill where our serial is generated right??..so the adress was 004011FF)..keep tracing..WHATTT!!!! we jumped to 4012XX (xx mark any adress point)..why??..i will tell u why..when u look at the disasmbled file, look more up to see this code:
  144.  
  145. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  146. |:004011ED(U)
  147. |
  148. :004011CA 0FBE07                  movsx eax, byte ptr [edi]       ; move 1 byte from edi to eax
  149. :004011CD 85C0                    test eax, eax                   ; test eax : ?
  150. :004011CF 741E                    je 004011EF                     ; no test jump
  151. :004011D1 3C30                    cmp al, 30                      ; compare with 0
  152. :004011D3 7CE9                    jl 004011BE                     ; lower then 0? jump out
  153. :004011D5 3C39                    cmp al, 39                      ; compare with 9
  154. :004011D7 7F04                    jg 004011DD                     ; greater then 9? jump
  155. :004011D9 240F                    and al, 0F                      ; compare with 0F
  156. :004011DB EB0A                    jmp 004011E7                    ; jump good boy (algo)
  157.  
  158. what does it mean?? it means that if u enter a serial with less then 0 chars or more then 9 chars then the ouput will always be "Too Bad, please try again !!!"
  159. so..in order ot get to the right road we need to enter 8 chars for the serial to be correct (after finding it of course).
  160.  
  161. so now after entered a 8 chars serial with your name ..we can debug from the start,
  162. bpx getdlgitemtexta->f5->f12->trace with f10..not we wont jump out cuz we entered a 8 chars fpr our name..so keep tracing..u will find your self in a loop of the compares and nonnecery stuff..keep pressing f10 7 more time, at the 8's time u will be at the algo part:
  163.  
  164. xxxx:004011FF mov ecx, 00401AFC   ; <= be on this adress.
  165.  
  166. if u type: d 00401AFC  u will see your name in swaped bytes (ie: YLAGNEB)
  167. and if u will type: ? eax u will see your fake swaped file in sice (be sure to look the the hex code number, since we are talking about a hex code stuff (not operations) and since your fake serial that has been made by the algo will probly use chars as well, so it's in hex mode ;)
  168.  
  169. Example:
  170. i got this when i typed ? eax :
  171. "912E59DC" - 2435733980 - (blah blah)
  172.      ^
  173.      |
  174.  hex number we need to write
  175.  
  176. so let's swap and not and find the right serial for our name.
  177.  
  178. 1.swapping:  912E59DC => DC592E91
  179. 2.using NOT opperation in calculator.exe (hex mode) we get: DC592E91 => 23A6D16E
  180.  
  181. so our correct serial is:
  182. name: bengaly
  183. serial: 23A6D16E
  184.  
  185. Have fun ;D
  186.  
  187.                                   CrackMe cracked ;)
  188. ________________________________________________________________________________________________ 
  189.                                
  190.         
  191.  
  192.                         My thanks and gratitudes goes to:
  193.                    
  194.                       ----CODE_INSIDE----- ;for helping in cracking
  195.                      -----BLAcKgH0sT------ ;for being good friend :)
  196.                        -------FusS------   ;asm / keygenning helper
  197.  
  198.                       All the writers of Cracks tutorials and CrackMes