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

  1.             Tutorial Number 8
  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:17th Feb 1999
  8.  
  9. Program Details:
  10. Name: CrackMe v3.0a
  11. Author: Borna Janes
  12. Language: Visual Basic 6
  13.  
  14. Tools Used:
  15. Softice
  16. SmartCheck
  17. HexEditor
  18.  
  19. Cracking Method:
  20. Patching, SmartCheck analysis
  21.  
  22. Viewing Method:
  23. Use Notepad with Word Wrap switched on
  24. Screen Area set to 800 X 600 pixels (Optional)
  25.  
  26. __________________________________________________________________________
  27.  
  28.  
  29.                         About this protection system
  30.  
  31. No disabled function. Protection is based on a serial number which is 
  32. checked using two different routines and the results must be equal.
  33.  
  34. __________________________________________________________________________
  35.  
  36.  
  37.                                  The Essay
  38.  
  39. As this is a tutorial for newbies, I'll go into details about how I go 
  40. about cracking the program. I suggest that you read this tutorial first.
  41. When you have completed the tutorial, leave this tutorial open and follow
  42. the instructions. Re-do it once more after you have completed the step 
  43. by step guide...
  44.  
  45. In this essay, when I write type "d edx" or similar commands in Softice,
  46. I mean it without the quotes.
  47.  
  48. __________________________________________________________________________
  49.  
  50.  
  51.             Running with SmartCheck
  52.  
  53. I'll not go into the settings and how to configure SmartCheck anymore. If
  54. this is the first time you are reading my tutorials, I suggest you download
  55. the first few that use SmartCheck.
  56.  
  57. Run the program with SmartCheck. Type in any serial you want. I used 12121.
  58. Click on "Check it"
  59. You will notice that your computer is running like mad but nothing is 
  60. showing in SmartCheck at all... 
  61.  
  62. Ok. Read the Readme.txt by Borna. You will see that he has added in an
  63. Anti-SmartCheck routine. And this is what you are experiencing. Don't worry.
  64. My computer is running like mad now while I'm typing this... 8P
  65.  
  66. Finally, your computer has stopped running... You will see a message box
  67. saying "You have SmartCheck loaded!...Close it and try again!!!"
  68.  
  69. So, we can't use SmartCheck... Nope... We still can. 8)
  70.  
  71.  
  72. __________________________________________________________________________
  73.  
  74.  
  75.             Softice to the Rescue
  76.  
  77. Click on the "OK" button and stop the CrackMe in SmartCheck. 
  78. Close SmartCheck and let it rest.
  79.  
  80. Now, back to basics... Try the few breakpoints commonly used in VB programs.
  81. I started with "bpx msvbvm60!__vbastrcomp"
  82.  
  83. **Note: You have to add in "msvbvm60!" because this is a VB 6 program.
  84.  
  85. Run the CrackMe without using SmartCheck and type in any serial and click
  86. "Check it".
  87.  
  88. You will break into the program. The aim of using Softice here is because
  89. the Anti-SmartCheck routine written by Borna is dependent on time. 
  90. This means that after going through the routine, if the time taken is 
  91. very long, it will mean that SmartCheck is used.
  92.  
  93. Now that you are in Softice, we need to go to the main program code to see
  94. where is the Anti-SmartCheck routine...
  95.  
  96. Press F10 until you see BJCM30A!... below the code window in Softice.
  97. You will be at location 00404401
  98.  
  99. This is something you will see:
  100.  
  101. :00404391  3BC7                CMP     EAX,EDI        <--start of big loop
  102. :00404393  0F84C8000000        JZ      00404461        <--to jump out of big loop
  103. :00404399  B801000000          MOV     EAX,00000001
  104. ..
  105. ..            __________Snip___________
  106. ..
  107. :004043E1  899DF8FEFFFF        MOV     [EBP-0108],EBX
  108. :004043E7  899DE8FEFFFF        MOV     [EBP-0118],EBX
  109. :004043ED  FF1538104000        CALL    [MSVBVM60!__vbaVarForInit]
  110. :004043F3  3BC7                CMP     EAX,EDI        <--start of small loop
  111. :004043F5  744D                JZ      00404444        <--to jump out of small loop
  112. :004043F7  68342A4000          PUSH    00402A34
  113. :004043FC  68342A4000          PUSH    00402A34
  114. :00404401  FF1568104000        CALL    [MSVBVM60!__vbaStrCmp]    <--break inside here
  115. :00404407  85C0                TEST    EAX,EAX
  116. :00404409  751F                JNZ     0040442A
  117. ..
  118. ..            __________Snip___________
  119. ..
  120. :0040443B  51                  PUSH    ECX
  121. :0040443C  FF15E8104000        CALL    [MSVBVM60!__vbaVarForNext]
  122. :00404442  EBAF                JMP     004043F3        <--back to small loop
  123. :00404444  8D95A4FEFFFF        LEA     EDX,[EBP-015C]
  124. ..
  125. ..            __________Snip___________
  126. ..
  127. :00404455  51                  PUSH    ECX
  128. :00404456  FF15E8104000        CALL    [MSVBVM60!__vbaVarForNext]
  129. :0040445C  E930FFFFFF          JMP     00404391        <--back to big loop
  130.  
  131.  
  132. You must disable your breakpoint now or you will keep breaking...
  133. If you keep tracing using F10 you will notice that you go around in circles
  134. for a long long time...
  135.  
  136. **That is how I found out that this part of the code is the 
  137.   Anti-SmartCheck code.
  138.  
  139. Refering to the above code, you will notice that I have labelled 2 loops.
  140. A small one inside a bigger one.
  141. If you try jumping out of the small loop at 004043F5, you will encounter
  142. the big loop and you will be brought back into the small loop again.
  143. So, to solve this, you will need to jump out of the big loop at 00404393.
  144.  
  145. Now, if you have been thinking, you will probably know that if we were to 
  146. run this CrackMe in SmartCheck and before clicking on the "Check it" button,
  147. if you set a breakpoint at 00404393, you can force the program to jump out
  148. of the big loop and you can continue to use SmartCheck without any problems
  149. at all. 8)
  150.  
  151. But then, this means that you have to do it everytime you restart the CrackMe.
  152.  
  153.  
  154. __________________________________________________________________________
  155.  
  156.  
  157.             HexEditor as Support
  158.  
  159. To permanently disable the Anti-SmartCheck routine, we will need to patch
  160. the conditional jump at 00404393. To do this, copy down the code for this
  161. jump (0F84C8000000) and open the CrackMe using a HexEditor.
  162.  
  163. Search for this hex combination. There is only one location for it.
  164.  
  165. Since the instruction is JZ 00404461 if we want to reverse it, we can
  166. change it to JNZ 00404461. So if you refer to an opcode reference, you will
  167. know that we need to change 0F84C8000000 to 0F85C8000000. Do it and save it
  168. as a different file.
  169.  
  170.  
  171. __________________________________________________________________________
  172.  
  173.  
  174.             Time for the King
  175.  
  176.  
  177. Load the new patched file using SmartCheck. And type in the serial 12121
  178. Click on "Check it". *Fingers crossed*
  179.  
  180. Your computer didn't run like mad, did it?? 8)
  181.  
  182. Now, click on the + sign next to Command1_Click to expand the threads.
  183. You will see a lot of Len, Asc, Hex$ and Mid$. This are basically the 
  184. commands to get the characters from your serial.
  185.  
  186. Explanation:
  187. Len - get the length of a string
  188. Asc - to convert the char into decimal number
  189. Hex$ - to convert the char into Hex
  190. Mid$ - to extract a char from a string base on the location
  191. UCase$ - Convert any lowercase letters into UPPERCASE
  192.  
  193. Look at the lines within Command1_Click and try to "feel" what is happening.
  194. Most of the commands are described in my 2 essays on VB cracking which is 
  195. available on my websites...
  196.  
  197. You will observe that most of the lines seems to be repeating themselves...
  198. So look for something different. For the moment, you don't have to choose
  199. "Show All Events" in SC yet.
  200.  
  201. Near the starting inside Command1_Click, you will see something like this:
  202. Mid$(String:"12121",long:?,VARIANT:Integer:1)
  203. Mid$(String:"12121",long:?+1,VARIANT:Integer:1)
  204. where ? increases from 1 to 5. 
  205. **If you choose show all events here, you will each char is compared with 
  206.   the other in the next sequence.
  207.  
  208. Next few lines (actually repeating 3 times)
  209. Text1.Text
  210. Len(String:"12121") returns LONG:5
  211. **It just gets the length of the serial you entered
  212.   Not sure why the author has to do it 3 times...
  213.   Maybe so that you won't miss it!! 8P
  214.  
  215. Then there is
  216. Left(VARIANT:VT_DISPATCH:....., long:1)
  217. Asc(String:"1") returns Integer:49
  218. **This is to get your first char which is 1 and convert it
  219.   to decimal number. So, 1 has the decimal number of 49
  220.   This is repeated a LOT of times inside the Command1_Click
  221.   so you can't miss it.
  222.  
  223. After the Asc line, if you count down, on the 21st line,
  224. you will see
  225. Hex$(VARIANT:Long:245)
  226. hmmm... where did 245 come from??
  227.  
  228. Ok. Click on the the line and then choose "Show All Events"...
  229. You will see a lot of __vbaStrCmp and at the start of it, a
  230. __vbaStrCopy(String:"*",....)...
  231.  
  232. Just above the Hex$ line, you will see
  233. __vbaStrCmp(String:"*", String:"*") returns DWORD:0
  234. ahh... a match...
  235.  
  236. **The char * in VB means multiple. For the rest of the commands, you
  237.   will have to refer to my 2 essays on VB cracking. No point in me
  238.   writing them and repeating them again.
  239.  
  240. So, something is multiplied with something else to get 245...
  241. Try multiplying 49 with 5... = 245!!
  242. Where do we get 49 and 5 then??
  243. If you scroll up the tutorial abit, you will see that 5 is the length
  244. of the serial you entered, 49 is the decimal of the 1st char.
  245.  
  246. After the Hex$ line and still in "Show All Events" mode, you will see
  247. __vbaStrMove(String:"F5",...)...
  248. Now, where did F5 comes from?
  249. Try converting 245 to Hex... You will get F5 !!!!!
  250.  
  251. **I recommend Volatility's CrackersConvert v1.0 which can be found in
  252.   http://www.ImmortalDescendants.com
  253.  
  254. This is repeated a few times and is not useful anymore... Just remember
  255. the magic numbers 245 and F5
  256.  
  257. Now, go back to "Show Errors and Specific Events" to cut out the rubbish.
  258.  
  259. Locate the 2nd Hex$(VARIANT:Long:245)
  260. The 3rd line after it, you will see
  261. Mid$(String:"12121",long:2,VARIANT:Integer:1)
  262. Asc(String:"2") returns Integer:50
  263.  
  264. Click on the Asc line and choose "Show All Events" again.
  265. The next line below is
  266. __vbaVarAdd(VARIANT:Integer:49,VARIANT:Integer:50)...
  267. **Adding 49(decimal value of 1) from above to 50(decimal value of 2)
  268. So, I hope you still remember where 49 comes from. 50 is the decimal
  269. value of 2.
  270.  
  271. The next line is
  272. __vbaVarMove(VARIANT:Integer:99,VARIANT:Integer:49)...
  273. Replacing 49 by the total which is 99 in memory.
  274. 99 is the result of 49 + 50
  275.  
  276. Choose "Show Errors and Specific Events" again.
  277. Ok. We have seen the CrackMe getting the 1st and 2nd char and converting
  278. them to decimal values and then adding them.
  279. What we need to look for is if the 3rd, 4th and 5th numbers are used as well.
  280.  
  281. Look for Mid$(String:"12121",long:3,VARIANT:Integer:1)
  282. It is about 29 lines below Mid$(String:"12121",long:2,VARIANT:Integer:1)
  283. **You have to choose "Show Errors and Specific Events" or you will be lost.
  284.  
  285. Mid$(String:"12121",long:3,VARIANT:Integer:1)
  286. **get the 3rd char from 12121
  287.  
  288. Asc(String:"1") returns Integer:49
  289. Click on the Asc line and choose "Show All Events" again.
  290. The next 2 lines below are
  291. __vbaVarAdd(VARIANT:99, VARIANT:Integer:49)...
  292. **Adding 49(decimal value of 1) from above to 50(decimal value of 2)
  293.  
  294. __vbaVarMove(VARIANT:Integer:148, VARIANT:99)...
  295. **actions similar to the above
  296.  
  297.  
  298. Choose "Show Errors and Specific Events" again.
  299.  
  300. 29 lines after Mid$(String:"12121",long:3,VARIANT:Integer:1)
  301. you will see
  302. Mid$(String:"12121",long:4,VARIANT:Integer:1)
  303. **get the 4th char from 12121
  304. Asc(String:"2") returns Integer:50
  305.  
  306. Click on the Asc line and choose "Show All Events" again
  307. The next 2 lines are very similar...
  308.  
  309. __vbaVarAdd(VARIANT:Integer:148,VARIANT:Integer:50)...
  310. __vbaVarMove(VARIANT:Integer:198,VARIANT:Integer:148)...
  311. **actions similar to the above
  312.  
  313. Do the same while looking for Mid$(String:"12121",long:5,VARIANT:Integer:1)
  314. About 29 lines down again, you will see
  315.  
  316. Mid$(String:"12121",long:5,VARIANT:Integer:1)
  317. **get the 5th char from 12121
  318. Asc(String:"1") returns Integer:49
  319.  
  320. You have to choose "Show All Events" again
  321. __vbaVarAdd(VARIANT:198, VARIANT:Integer:49)...
  322. __vbaVarMove(VARIANT:Integer:247, VARIANT:198)...
  323. **actions similar to the above
  324.  
  325. Now, after seeing the lines, go back to "Show Errors and Specific Events"
  326. You will see 2 lines below Mid$(String:"12121",long:5,VARIANT:Integer:1)
  327.  
  328. Hex$(VARIANT:Integer:247)
  329. If you click on this Hex$ line and choose "Show All Events" 
  330. __vbaStrMove(String:"F7",...)...
  331. Now, something appears out of nowhere again... (I am refering to F7)
  332. Try converting 247 onto HEX. You will get F7
  333.  
  334. The next line is
  335. __vbaStrCopy(String:"=",...)...
  336. Looks interesting!!!
  337.  
  338. Click on Hex$(VARIANT:Integer:247) and 
  339. go back to "Show Errors and Specific Events".
  340.  
  341. Between this line to the end, you will see a lot of F5 and F7
  342. Do you still remember where F5 comes from? What about F7?
  343.  
  344. Basically, the CrackMe is converting F5 and F7 to decimal again... 
  345. (weird. since they were converted from decimal!!)
  346. So, you can ignore all that rubbish.
  347.  
  348. Scroll all the way down, you will see Hex$(VARIANT:Boolean:False)
  349. Click on it and choose "Show All Events"
  350. Ahh... you will see a few __vbaStrCmp again and the start of these lines
  351. is __vbaStrCopy(String:"=",...)...
  352. __vbaStrCmp(String:"=",String"=")...
  353. is the last line before Hex$(VARIANT:Boolean:False)
  354. So, what do you think is happening?
  355.  
  356.  
  357. Think now...
  358. F5 - from the multiplication of the decimal of the 1st char with the length of serial
  359.      then convert to HEX
  360. F7 - from the sum of all the decimal values of the serial
  361.      then convert to HEX
  362. then now, there is an "=" sign...
  363.  
  364. Lets give it a try...
  365.  
  366. Suppose we don't change the value of F5. We must leave the 1st char as 1 and length as 5
  367. We will need to change F7 to become F5. How?
  368.  
  369. By reducing the sum of the values of the decimal of the serial by 2. So,
  370. instead of 12121 (49 + 50 + 49 + 50 + 49), we can try with
  371. 12020 (49 + 50 + 48 + 50 + 48) which is 245 and when converted to HEX = F5
  372.  
  373. Now, run the CrackMe without using SC. 
  374. Try it on the original CrackMe. (I hope you have a backup before you patch it)
  375.  
  376. You will get "Good job, tell me how you do that!"
  377. You can change the characters around except for the 1st one which must be
  378. always 1
  379.  
  380. Program Cracked...
  381.  
  382. __________________________________________________________________________
  383.  
  384.  
  385.                 Afterthought
  386.  
  387. Looking at the complexity of the calculation routine, I can say that it is
  388. practically impossible to crack using Softice alone. That is why I have to 
  389. resort to patching it to allow SC usage.
  390.  
  391. Think cracking this is difficult? Try writing a tutorial on it. 8(
  392.  
  393.  
  394. __________________________________________________________________________
  395.  
  396.                 
  397.                              Final Notes
  398.  
  399. This tutorial is dedicated to all the newbies like me.
  400.  
  401. And because I'm a newbie myself, I may have explained certain things wrongly
  402. So, if that is the case, please forgive me. Email me if there is anything 
  403. you are not clear about.
  404.  
  405.  
  406. My thanks and gratitude goes to:-
  407.  
  408. The Sandman
  409. All the writers of Cracks tutorials and CrackMes