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

  1.             Tutorial Number 15
  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: 25th Mar 1999
  8.  
  9. Program Details:
  10. Name: VB Crackme 1,2,3
  11. Author: Andrenalin
  12.  
  13. Tools Used:
  14. SmartCheck
  15. SoftIce
  16. Crackers' Tool (available on my website)
  17.  
  18. Cracking Method:
  19. CrackMe 1 & 2 - Code sniffing
  20. CrackMe 3 - Calculation analysis
  21. Code sniffing
  22.  
  23. Viewing Method:
  24. Use Notepad with Word Wrap switched on
  25. Screen Area set to 800 X 600 pixels (Optional)
  26.  
  27. __________________________________________________________________________
  28.  
  29.  
  30.                         About this protection system
  31.  
  32. No disabled function. 
  33. CrackMe 1 and 3 are based on a code, CrackMe 2 is based on Name and Serial.
  34.  
  35. __________________________________________________________________________
  36.  
  37.  
  38.                                  The Essay
  39.  
  40. I've decided to write this tutorial for the 3 CrackMes written by Andrenalin
  41. because I think they are quite easy and I shouldn't waste time writing 3
  42. different tutorials.
  43.  
  44. In this essay, when I write type "d edx" or similar commands in Softice,
  45. I mean it without the quotes. At the same time, I'll not go into the 
  46. settings and how to configure SmartCheck anymore. If this is the first time 
  47. you are reading my tutorials, I suggest you download the first few that 
  48. use SmartCheck.
  49.  
  50. ==========================================================================
  51.  
  52.                 CrackMe 1
  53.  
  54.                 SmartCheck
  55.  
  56. Run the crackme using SmartCheck.
  57. **Make sure that SC is in "Show Errors and Specific Events" mode.
  58.  
  59. Type in 123456 in the textbox and click on OK.
  60.  
  61. You will get an error message with a big red cross. I don't understand what
  62. it says but I know I am not lucky enough to register it with "123456". 8P
  63.  
  64. Now, in SC, You will see Command1_Click. Click on the + sign next to it.
  65. you will only see Text1.Text and MsgBox(). Well, not enough for us.
  66.  
  67. Now, select the line Text1.Text by clicking on it. And then choose
  68. "Show All Events" in SC. Just below the Text1.Text, you will see
  69. __vbaStrCmp(String:"SynTaX2...",String:"123456") returns...
  70.  
  71. Now, click on that line and look in the right window. You will see the full
  72. length of "SynTaX 2..."
  73.  
  74. __vbaStrCmp is the function in VB to compare two strings.
  75.  
  76. So SynTaX 2oo1 is compared to 123456 which we entered. Why would it compare
  77. with what we entered? The only reason is because it is the real code!
  78.  
  79. So, enter SynTaX 2oo1 in the textbox and click on OK. You will get a message
  80. box with titlebar saying that "Successful" and something... CrackMe 2.
  81. I take that we are suppose to crack CrackMe 2 now since CrackMe 1 has been 
  82. cracked. 8)
  83.  
  84. **You can use Softice and bp on __vbastrcomp and you will get the correct 
  85.   answer after a bit of tracing.
  86.  
  87.  
  88. ==========================================================================
  89.  
  90.                 CrackMe 2
  91.  
  92.                 SmartCheck
  93.  
  94. Run the crackme using SmartCheck.
  95. **Make sure that SC is in "Show Errors and Specific Events" mode.
  96.  
  97. Enter "Eternal Bliss" as the Name and "123456" as the Key. 
  98. Click on OK. You will get an error message again.
  99.  
  100. Now look for Command1_Click again. Expand the thread. More stuff this time.
  101. You will see a lot of Mid and Asc.
  102.  
  103. Explanation:
  104. 1) Mid(VARIANT:String:"Eternal ...",long:2, VARIANT:Integer:1)
  105.    is to get the 2nd char from the string "Eternal Bliss"
  106.  
  107. 2) Asc(String:"t") returns Integer:116
  108.    To convert the ascii "t" into decimal notation which is 116
  109.  
  110. After every Asc, you will see
  111. __vbaVarAdd()
  112. this is to add up all the decimal notations of our Name which is
  113. equal to 1256
  114.  
  115. After the last __vbaVarAdd, a few lines below, you will see
  116. __vbaVarMul(VARIANT:Integer:1256, VARIANT:Long:1234567890) returns...
  117.  
  118. This is to multiple the sum of our Name with 1234567890. Answer to 
  119. that is 1550617269840 which is seen a line below __vbaVarMul on
  120. __vbaVarMove
  121.  
  122. The next two lines are
  123. Mid(VARIANT:Double:1.55062e+012, Long:4, Long:1, VARIANT:String"-")
  124. Mid(VARIANT:String:"155-6172..", Long:9, Long:1, VARIANT:String"-")
  125.  
  126. These two lines are to replace the 4th and the 9th char of 1550617269840
  127. so that the result is 155-6172-9840
  128.  
  129. You can now choose "Show All Events" in SC. Click on the last Mid() first.
  130. Few lines later, you will see the function __vbaVarTstEq
  131. This is a function to compare two Variants. In this case:
  132. 155-6172-9840 and our Key we entered.
  133.  
  134. So, Key for "Eternal Bliss" is 155-6172-9840
  135.  
  136. **Note, if you set bp in Softice using __vbaVarTstEq, and trace a bit,
  137.   you will find the correct code as well.
  138.  
  139.  
  140. ==========================================================================
  141.  
  142.                 CrackMe 3
  143.  
  144.                 SmartCheck
  145.  
  146. Time for the last CrackMe. Run it with SC. And enter 123456 and click on OK.
  147. Error message.
  148.  
  149. **You must be in "Show Errors and Specfic Events" mode only.
  150.  
  151. Look for Command1_Click again. Expand the thread.
  152. Things you will see:
  153. Mid()
  154. Asc()
  155. Chr$()
  156.  
  157. This three functions keep repeating for the key we entered. (123456)
  158. EG.
  159. 1) Mid(VARIANT:String"123456", long:1, VARIANT:Integer:1)
  160. 2) Asc(String:"1") returns Integer:49
  161. 3) Chr$(Integer:59)
  162.  
  163. Explanation:
  164. 1) Get 1st char
  165. 2) Convert to decimal notation
  166. 3) Add 10 to the decimal notation and convert the result back to Ascii format.
  167.  
  168. The reason why I know step 3 is because I look at the rest of the Chr$()
  169. The Integer in the Chr$() is always 10 more than the Asc() result.
  170.  
  171. Ok. We know how the Key we entered is being converted. 
  172. But all of a sudden, it comes to an end.
  173.  
  174. Click on the last Chr$() just before the MsgBox and choose
  175. "Show All Events" in SC.
  176.  
  177. 2 lines after it, you will see
  178. __vbaVarMove(VARIANT:String:";<=>?@",.....)...
  179. This is the converted Key we get when we enter 123456.
  180.  
  181. **You can do the conversion I mentioned above using Crackers' Tool
  182.   coded by Borna and I. It can be found on my website.
  183.  
  184. A few more lines down, you will see 
  185. __vbaVarTstEq(VARIANT:String";<=>?@",VARIANT:Const String:"") returns...
  186.  
  187. This is comparing our converted key with a constant string... But the 
  188. constant string is not shown!! Have to use Softice now.
  189.  
  190. _________________________________________________________________________
  191.  
  192.  
  193.                 SoftIce
  194.  
  195. Notice __vbaVarTstEq in SmartCheck? Well, it is one of the common breakpoints
  196. to be used. So, lets use it.
  197.  
  198. Set the breakpoint by typing "bpx __vbaVarTstEq" (same as __vbavartsteq)
  199.  
  200. You will break in Softice after you click on OK.
  201. Before you go on, I would like to say that it is quite a long way to trace 
  202. and I've shorten the listing to show only the important parts as a guide.
  203.  
  204. To trace and go into calls, use F8
  205. In this case, it is tracing into EVERY FIRST CALL after the break.
  206.  
  207. I've commented on certain things in the code.
  208.  
  209. Break due to BPX MSVBVM50!__vbaVarTstEq  (ET=962.85 milliseconds)
  210. MSVBVM50!__vbaVarTstEq
  211. :7B3FB9A2  FF742408            PUSH    DWORD PTR [ESP+08]
  212. :7B3FB9A6  6A00                PUSH    00
  213. :7B3FB9A8  E8E74AFFFF          CALL    7B3F0494
  214. **Go into this call using F8
  215.  
  216. ==========================================================================
  217. :7B3F0494  55                  PUSH    EBP
  218. :7B3F0495  8BEC                MOV     EBP,ESP
  219. :7B3F0497  83EC44              SUB     ESP,44
  220. :7B3F049A  833D64F03F7B00      CMP     DWORD PTR [7B3FF064],00
  221. :            __________Snip___________
  222. :
  223. :7B3F062F  8B550C              MOV     EDX,[EBP+0C]
  224. :7B3F0632  FF7308              PUSH    DWORD PTR [EBX+08]
  225. :7B3F0635  FF7208              PUSH    DWORD PTR [EDX+08]
  226. :7B3F0638  FF7508              PUSH    DWORD PTR [EBP+08]
  227. :7B3F063B  E8BC3FF0FF          CALL    7B2F45FC
  228. **Go into this call using F8
  229.  
  230. ==========================================================================
  231. :7B2F45FC  66837C240400        CMP     WORD PTR [ESP+04],00
  232. :7B2F4602  B800000000          MOV     EAX,00000000
  233. :7B2F4607  0F85D9F20500        JNZ     7B3538E6                  (NO JUMP)
  234. :7B2F460D  FF74240C            PUSH    DWORD PTR [ESP+0C]
  235. :7B2F4611  FF74240C            PUSH    DWORD PTR [ESP+0C]
  236. :7B2F4615  50                  PUSH    EAX
  237. :7B2F4616  E848EFFFFF          CALL    MSVBVM50!__vbaStrComp
  238. **Go into this call using F8
  239.  
  240. ==========================================================================
  241. MSVBVM50!__vbaStrComp
  242. :7B2F3564  8BEC                MOV     EBP,ESP
  243. :7B2F3566  53                  PUSH    EBX
  244. :7B2F3567  56                  PUSH    ESI
  245. :7B2F3568  57                  PUSH    EDI
  246. :7B2F3569  837D1000            CMP     DWORD PTR [EBP+10],00
  247. :7B2F356D  BE00000000          MOV     ESI,00000000
  248. :7B2F3572  7406                JZ      7B2F357A                  (NO JUMP)
  249. :7B2F3574  8B4510              MOV     EAX,[EBP+10]    <-- d eax
  250. :7B2F3577  8B70FC              MOV     ESI,[EAX-04]    <-- esi = 0000000C
  251. :7B2F357A  837D0C00            CMP     DWORD PTR [EBP+0C],00
  252. :7B2F357E  BF00000000          MOV     EDI,00000000
  253. :7B2F3583  7406                JZ      7B2F358B                  (NO JUMP)
  254. :7B2F3585  8B4D0C              MOV     ECX,[EBP+0C]    <-- d ecx
  255. :7B2F3588  8B79FC              MOV     EDI,[ECX-04]    <-- edi = 0000002A
  256. :7B2F358B  3BFE                CMP     EDI,ESI
  257.  
  258.  
  259. After stepping past :7B2F3574, you will see eax changing colour in the 
  260. register window. Type "d eax" and you will see this in the data window in
  261. Softice.
  262.  
  263. :00510F70 3B 00 3C 00 3D 00 3E 00-3F 00 40 00 00 00 00 00  ;.<.=.>.?.@.....
  264. :00510F80 00 00 00 00 00 00 00 00-00 00 00 00 14 00 00 A0  ................
  265.  
  266. Notice ;.<.=.>.?.@.
  267. Because this is VB, our converted key ;<=>?@ is converted to  
  268. w.i.d.e. .c.h.a.r.a.c.t.e.r
  269.  
  270. If you step pass one more line in SoftIce, you will see that esi = 0000000C
  271. C is the hex value of 12. Which is the length of the converted key in VB.
  272. Should be 6 char but because it is now in wide character, the length is 12.
  273.  
  274.  
  275. If you step pass :7B2F3585, you will see ecx changing colour. Type "d ecx"
  276. to see what is in ecx. The data window should show
  277.  
  278. :00401A8C 6B 00 58 00 79 00 5E 00-72 00 4F 00 7C 00 2A 00  k.X.y.^.r.O.|.*.
  279. :00401A9C 79 00 58 00 6F 00 2A 00-6D 00 5C 00 6B 00 4D 00  y.X.o.*.m.\.k.M.
  280. :00401AAC 75 00 4F 00 6E 00 2A 00-2B 00 00 00 64 00 00 00  u.O.n.*.+...d...
  281.  
  282. Step through one more line and you will see edi = 0000002A
  283. 2A is the hex value of 42. Since it is VB, the actual length of the hidden
  284. key is 21. So, pick out the 21 chars from the data window ignoring the "."
  285.  
  286. I've shown it below. Also, since we know how the key we entered is converted,
  287. we can reverse what is in the data window to get the key we are suppose to enter.
  288. So, the reversed step will be:
  289. 1) Asc()
  290. 2) Minus 10 from the decimal result
  291. 3) Chr() to convert the result back to Ascii.
  292.  
  293.  Data    |  Asc  | minus    | Char      
  294. Window    |    |  10    |
  295.  
  296.   k       107        97        a
  297.   X        88        78        N
  298.   y       121       111        o
  299.   ^        94        84        T
  300.   r       114       104        h
  301.   O        79        69        E
  302.   |       124       114        r
  303.   *        42        32       " "    <--Space
  304.   y       121       111        o
  305.   X        88        78        N
  306.   o       111       101        e
  307.   *        42        32       " "    <--Space
  308.   m       109        99        c
  309.   \        92        82        R
  310.   k       107        97        a
  311.   M        77        67        C
  312.   u       117       107        k
  313.   O        79        69        E
  314.   n       110       100        d
  315.   *        42        32       " "    <--Space
  316.   +        43        33        !
  317.  
  318. Correct Key: aNoThEr oNe cRaCkEd !
  319.  
  320.  
  321. CrackMes Cracked!!
  322.  
  323. __________________________________________________________________________
  324.  
  325.  
  326.                              After-thoughts
  327.  
  328. In CrackMe 3, you can probably set a bp using __vbaStrComp because this
  329. function is called. And there will be less tracing in Softice. But then,
  330. who would know that it is used? SmartCheck didn't tell us. 8)
  331.  
  332.  
  333. __________________________________________________________________________
  334.  
  335.  
  336.                              Final Notes
  337.  
  338. This tutorial is dedicated to all the newbies like me.
  339.  
  340. And because I'm a newbie myself, I may have explained certain things wrongly
  341. So, if that is the case, please forgive me. Email me if there is anything 
  342. you are not clear about.
  343.  
  344.  
  345. My thanks and gratitude goes to:-
  346.  
  347. The Sandman
  348. All the writers of Cracks tutorials and CrackMes