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

  1.             VBCrackMe 1 explained
  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: 13th April 1999
  8.  
  9. Program Details:
  10. Language: Visual Basic
  11.  
  12. Learning Method:
  13. Code Explanation
  14.  
  15. Viewing Method:
  16. Use Notepad with Word Wrap switched OFF
  17. Screen Area set to 800 X 600 pixels (Optional)
  18.  
  19. __________________________________________________________________________
  20.  
  21.                 About the Essay
  22.  
  23. I've known that VB cracking has been a curse to newbies. When I started
  24. cracking, I decided to go into what most people hated. What I believe was
  25. that to crack something, it is best to know how the author thinks, how the
  26. language used will affect the cracking process. So, I took up VB programming.
  27. In the end, I realised that I learnt quite a lot about VB coding and how
  28. useful/limited the language is.
  29.  
  30. This is the first of the series of explanation on how coding in VB will
  31. affect the cracking process. In these essays, I'll also show you how crackmes
  32. are generally written in VB. I've included my thought process which went
  33. through my mind while coding for this crackme.
  34.  
  35. __________________________________________________________________________
  36.  
  37.                 About the Protection
  38.  
  39. This crackme uses a hard-coded code which is hidden among other strings.
  40. A string is a "sentence" comprising of words and letters and in a certain
  41. way, is treated like a sentence in VB programs.
  42.  
  43. The reason why the code is hidden among other strings is because such strings
  44. can be seen using a Hex Editor. So, if I had used a unique code such as
  45. "reg-192834-code", you will see it easily in a Hex Editor as
  46. "r.e.g.-.1.9.2.8.3.4.-.c.o.d.e". Now, it won't take much to realise that
  47. it is the correct code required, right? 8)
  48.  
  49. __________________________________________________________________________
  50.  
  51.         A brief explanation on how VB coding is done...
  52.  
  53. When you start a new VB project in microsoft, you will get to choose
  54. different types of programs you are going to code for. A standard exe is
  55. what I used to create this CrackMe.
  56.  
  57. You will then be given a blank window (so called "form") and from there, it
  58. is up to you to code for anything you want. The main thing is to add in the
  59. controls eg Textboxes (for you to fill in things), Buttons (for you to click)
  60.  
  61. When you create a textbox, it will be named automatically as "Text1" for the
  62. first textbox you create and "Text2" for the second and so on and so forth.
  63. Creating buttons involves the same naming system but in this case, the first
  64. button is called "Command1".
  65.  
  66. The names of these controls can be seen in your properties window.
  67.  
  68. Labels are another type of control which can be used to show words in the
  69. window or display words such as "Registered" etc. Naming system is the same,
  70. "Label1" for the first label etc.
  71.  
  72. After creating all the controls you need (you might want to create for some
  73. more as you go), you will need to make the CrackMe start the registration
  74. calculation when the Cracker clicks on the "register" button. To do this,
  75. double click on the involved button. In this particular essay, it will be 
  76. the first button I created, so named "Command1". When you double click on it,
  77. you will be shown a blank page with "Private Sub Command1_Click()" at the 
  78. start and "End Sub" at the end.
  79.  
  80. This is the routine that is called when a Cracker clicks on the first button.
  81. To make the CrackMe function, we are left to add in the codes BETWEEM these
  82. two lines.
  83.  
  84. __________________________________________________________________________
  85.  
  86.  
  87.                 Main Code
  88.  
  89. I've copied and pasted the main routine found in this crackme which is
  90. the protection scheme, the heart of the crackme. In the next section, I'll
  91. go into the explanation of some of the lines.
  92.  
  93.  
  94. Private Sub Command1_Click()
  95. On Error GoTo err
  96. If Text1.Text = "Enter the Code..." Then
  97. Text1.Text = "You have to enter something!"
  98. Text1.Enabled = False
  99. Command1.Enabled = False
  100. Label2.Enabled = False
  101. Label3.Enabled = False
  102. Label4.Enabled = False
  103. GoTo err
  104. End If
  105. If Text1.Text <> "use hexeditor to look for hardcoded codes" Then
  106. If ((Text1.Text = "Use bpx __vbastrcomp to break with Softice") Or (Text1.Text = "Use hexeditor to look for hardcoded codes") Or (Text1.Text = "Use SmartCheck to look for the code")) Then
  107. Text1.Text = "It's not that easy!!"
  108. Text1.Enabled = False
  109. Command1.Enabled = False
  110. Label2.Enabled = False
  111. Label3.Enabled = False
  112. Label4.Enabled = False
  113. GoTo err
  114. End If
  115. Text1.Text = "Wrong! Try Again!!"
  116. Text1.Enabled = False
  117. Command1.Enabled = False
  118. Label2.Enabled = False
  119. Label3.Enabled = False
  120. Label4.Enabled = False
  121.  
  122. Else
  123. Text1.Text = "Yes! You have solved it!!"
  124. Text1.Enabled = False
  125. Command1.Enabled = False
  126. Label2.Enabled = False
  127. Label3.Enabled = False
  128. Label4.Enabled = False
  129. Command2.Caption = "Once More!"
  130. End If
  131. err:
  132. End Sub
  133.  
  134. __________________________________________________________________________
  135.  
  136.  
  137.                 Code Explanation
  138.  
  139. 1) On Error GoTo err
  140. ====================
  141. This tells the CrackMe to go to the pointer named "err" which is just one
  142. line above the "End Sub" and is effectively ending the whole routine whenever
  143. an error occurs.
  144.  
  145. 2) If Text1.Text = "Enter the Code..." Then
  146.    Text1.Text = "You have to enter something!"
  147.    Text1.Enabled = False
  148.    Command1.Enabled = False
  149.    Label2.Enabled = False
  150.    Label3.Enabled = False
  151.    Label4.Enabled = False
  152.    GoTo err
  153. ============================================
  154. This small section of code is used because If you had run my CrackMe, you
  155. would have noticed that the textbox shows "Enter the Code..."
  156. "Text1.Text" tells the CrackMe to look at the text in the 1st textbox
  157. So, if the text in it is "Enter the Code...", then it means that the Cracker
  158. did not enter anything and had just click on the 1st button (which is to register)
  159. A message "You have to enter something!" will be shown in the textbox.
  160. At the end of this section, there is the "GoTo err" code which tells the CrackMe
  161. to stop processing the rest of the codes and go to the pointer I mentioned above.
  162.  
  163. 3) If Text1.Text <> "use hexeditor to look for hardcoded codes" Then
  164. ====================================================================
  165. This is the most important line of all because it compares the correct code
  166. "use hexeditor to look for hardcoded codes" with what is in textbox 1.
  167.  
  168. <> means not equal. So, in "human" terms, it means if the text in textbox 1
  169. is not equal to "use hexeditor to look for hardcoded codes", then do
  170. the following lines.
  171.  
  172. 4) If ((Text1.Text = "Use bpx __vbastrcomp to break with Softice") Or (Text1.Text = "Use hexeditor to look for hardcoded codes") Or (Text1.Text = "Use SmartCheck to look for the code")) Then
  173. ==============================================================================================================================================================================================
  174. This line will be processed if the Cracker entered the wrong code. It basically
  175. compares the text in the textbox with the few strings shown. 
  176. If you had run my CrackMe, you would have seen these lines shown when you click
  177. on Task 1, Task 2 and Task 3.
  178. Notice the similarity between the second string and the correct code. The only difference
  179. is in the first character. The correct code is a "u" and the string you see when you
  180. click on task 1 is a "U". That is what I mean by hidding the correct code among the other
  181. strings. Using a Hexeditor, if you are not observant enough, you would have thought that
  182. they are the same! 8)
  183.  
  184. What this line does is to compare the text you entered with the strings. If they are the
  185. same, the next few lines will be processed...
  186.  
  187. 5) Text1.Text = "It's not that easy!!"
  188.    Text1.Enabled = False
  189.    Command1.Enabled = False
  190.    Label2.Enabled = False
  191.    Label3.Enabled = False
  192.    Label4.Enabled = False
  193.    GoTo err
  194.    End If
  195. ======================================
  196. As mentioned in 4, if the Cracker just clicks on one of the 3 tasks and click on
  197. the "Register" button (Command1), the text in textbox 1 will show "It's not that easy!!"
  198. and then there is the familiar "GoTo err" line, ending the routine.
  199. Note the "End If" line. This is essential to close this particular query.
  200. A "If...Then" line must always have a "End If" closing line.
  201.  
  202. But you might have notice that in 3, there is no "End If". That is because in
  203. 4 and 5, they are inside the query used in 3. So, the "End If" for 3 has not yet
  204. been reached.
  205.  
  206. 6) Text1.Text = "Wrong! Try Again!!"
  207.    Text1.Enabled = False
  208.    Command1.Enabled = False
  209.    Label2.Enabled = False
  210.    Label3.Enabled = False
  211.    Label4.Enabled = False
  212. ====================================
  213. Ok, so what if the Cracker entered other text which is not correct and is not the
  214. strings seen when he clicks on the Tasks?
  215. 6 is used to counter this situation. A message "Wrong! Try Again!!" will be shown
  216. in the textbox 1.
  217.  
  218. A summary on 3-6 is like this:
  219. 3) check if it is the wrong code and proceed to the next line if wrong code
  220. 4) if it is wrong, check if it is one of the strings in the 3 Tasks
  221. 5) if the text entered is one of the strings, a message will be shown
  222. 6) if wrong code and not one of the strings, another message will be shown.
  223.  
  224.  
  225. 7) Else
  226.    Text1.Text = "Yes! You have solved it!!"
  227.    Text1.Enabled = False
  228.    Command1.Enabled = False
  229.    Label2.Enabled = False
  230.    Label3.Enabled = False
  231.    Label4.Enabled = False
  232.    Command2.Caption = "Once More!"
  233.    End If
  234. ===========================================
  235. Notice the "Else" line. This is a continuation of 3. If the code is not wrong,
  236. ie, it is the correct code, 4-6 will be skipped and 7 will be processed instead.
  237.  
  238. So, when the correct code is entered, textbox 1 will show "Yes! You have solved it!!"
  239.  
  240. Near the end of the codes, you will see "End If". It is just before the "err" pointer.
  241. This is the closing line for the first "If...Then" statement used in 3.
  242.  
  243. So, the whole routine can be said to use this:
  244. If wrong Then
  245.     If one of the strings Then
  246.         show "It's not that easy!!"
  247.         goto end of code
  248.     End If
  249.     show "Wrong! Try Again!!" (if wrong and not the strings)
  250. Else
  251.     show "Yes! You have solved it!!"
  252. End If
  253.  
  254. __________________________________________________________________________
  255.  
  256.         How to Crack such VB protection schemes
  257.  
  258. You should have realised that the whole protection routine uses nothing else
  259. but string comparision. This is the simplest comparison method used by a lot
  260. of sharewares. Even when the comparison involves only serial and not text,
  261. if the author chooses to use quotation marks " VB will consider it as a string
  262. and Presto! this string compare function is called.
  263.  
  264. In VB, the function to compare strings is __vbaStrComp (STRing COMPare)
  265. So, in Softice, setting the breakpoint using "bpx msvbvm60!__vbaStrComp" 
  266. (or msvbvm60!__vbastrcomp)
  267. will cause Softice to break when the Cracker click on the "Register" button.
  268. msvbvm60! is added in front because this CrackMe is written in VB6.
  269.  
  270. If you keep tracing in this string compare function, you will notice that
  271. it is always the same code. So, it is definite something you must get to 
  272. grips with.
  273.  
  274. Notice that there are 5 string comparisons here. So, Softice will break 5 times
  275. on this breakpoint. Upon breaking, you just have to trace into the calls and
  276. sniff out the correct serial. Easy. 8)
  277.  
  278. __________________________________________________________________________
  279.  
  280.             Additional points
  281.  
  282.  
  283. For other breakpoints and compare methods, you can get my two essays on VB
  284. cracking found on my website. Some of my tutorials uses this breakpoint to
  285. crack the CrackMes as well so I'll not go into details here.
  286.  
  287. Also, this CrackMe was used as a project in my forum and I've compiled the 
  288. solutions written by various Crackers. 
  289. So, download the whole project file and read the solutions.
  290.  
  291. In the zipped file, I have included a SmartCheck logfile with the source included.
  292. It is in Debug1.zip found inside the project zip file. Unzip everything in it
  293. and double click on the debug1.sce file. 
  294.  
  295. If you have installed SmartCheck, SmartCheck will open up and the usual
  296. lot of information is shown. However, in this case, since the source code is
  297. included, when you click on threads in Command1_Click line, you will see
  298. how the source code is processed and how it is presented in SmartCheck.
  299. A definite learning experience for those who are struggling with SmartCheck usage.
  300.  
  301. __________________________________________________________________________
  302.  
  303.                 End of File
  304.  
  305. I would like to thank Jeff for giving me this idea of writing essays on how
  306. I created my CrackMe, what commands will result in what breakpoints to use
  307. in Softice and how SmartCheck's usefulness is exploited.
  308.  
  309. Also, I'd like to thank all those Crackers who joined in the particular
  310. project when this CrackMe was used.
  311.  
  312.