home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / Hack / MISC / HTC2.ZIP / HOWTO2.TXT
Encoding:
Text File  |  1996-05-18  |  24.2 KB  |  467 lines

  1.  
  2.               HOW TO CRACK, A TUTORIAL - LESSON 2
  3.                  by +ORC (the old red cracker)
  4.  
  5. How to crack, an approach                         LESSON 1
  6. -> How to crack, tools and tricks of the trade    LESSON 2
  7. How to crack, hands on, paper protections         LESSON 3 (1-2)
  8. How to crack, hands on, time limits               LESSON 4
  9. How to crack, hands on, disk-CDrom access         LESSON 5
  10. How to crack, funny tricks                        LESSON 6 (1-2)
  11. How to crack, intuition and luck                  LESSON 7
  12. How to crack windows, an approach                 LESSON 8
  13. How to crack windows, tools of the trade          LESSON 9
  14. How to crack, advanced cracking                   LESSON A (1-2)
  15. How to crack, zen-cracking                        LESSON B
  16. How to crack, cracking as an art                  LESSON C
  17. How to crack                                      INDEX
  18.  
  19. LESSON 2- How to crack, tools and tricks of the trade       
  20.  
  21. LOST IN THE DARK CODEWOODS
  22.      When you break into a program you end up in portions of code
  23. that are unfamiliar to you. It is also not uncommon for the
  24. breakpoints to occur outside of the confines of the program you
  25. want to crack. Getting your bearings is, in these cases, very
  26. important.
  27.      One of the handiest utilities is the memory dump tool -it
  28. tells you where all the device drivers and TSR are loaded, in
  29. which memory locations the program you are cracking dwells, how
  30. much memory is left and what the next program load point is. The
  31. tools you use should report on the following:
  32. -    the contents of interrupt vectors
  33. -    the state of the BIOS data area, beginning at address 40:0
  34. -    internal structures within DOS, such as the MCB chain, the
  35.      SFT (System File Table) chain, the chain of installed
  36.      device drivers, the PSPs and memory allocations associated
  37.      with installed TSRs
  38. -    memory allocation statistic from XMS and EMS drivers
  39.  
  40.      When seeking to understand a section of foreign code, you
  41. must be especially careful to seek the real intent of the code.
  42. Consider using a profiler prior to undertaking an analysis of an
  43. unfamiliar program. This will help you by ensuring that you don't
  44. waste time studying sections of the program that aren't even
  45. involved in the protection scheme you are chasing down.
  46.      Using a utility that charts a program's calling hierarchy
  47. can give you an important perspective on how your babe conducts
  48. its internal operations.
  49.  
  50. YOUR DEBUGGER: YOUR FAVOURITE TOOL
  51.      First and foremost, your debugger must be designed for use
  52. with resident modules (or must be itself a resident module).
  53. Trying to crack with simplistic [debug.com] is a sure way to get
  54. absolutely nowhere. We recommend Softice.exe from Nu-Mega
  55. technologies (Version 2.6 [S-Ice.exe] has been cracked by MARQUIS
  56. DE SOIREE and its vastly available on the Web). You could also
  57. use [Periscope] or [Codeview] or Borland's Turbodebugger... all
  58. these programs have been boldly cracked and/or distributed and
  59. are now on the Web for free... learn how to use YAHOO and find
  60. them. In emergency cases you could fix some quick cracking
  61. patches using [debug] or [symdeb], but, as said above, most of
  62. the time these older debuggers won't do. I'll nevertheless ALWAYS
  63. give the final crack procedure for [debug.com], in order to
  64. permit even idiots to crack their programs (altruistic, isn't
  65. it... besides, every wizard has started with debug.com).
  66.      When you first smell a protection, it can be tempting to
  67. immediately begin your crack using invasive types of techniques.
  68. While there is certainly nothing wrong with this approach,
  69. provided that you are fairly familiar with the protection scheme
  70. used, going in too deep too soon can be a problem when you don't
  71. have a strong hunch. Most of the time you'll end up missing
  72. important details. So first of all sit down and ponder... that's
  73. the zen-way, the only one that really works.
  74.      Single-stepping is expensive, not only because of the time
  75. it requires but also because of the amount of detail with which
  76. you must contend. Your immediate goal is to home in on the
  77. protection scheme through a series of successively refined traps,
  78. your broader aim is to get an overview idea of the program's
  79. action... the wise use of breakpoints will condense these
  80. minutiae into an understandable form.
  81.      The first step is to try to identify the section of the
  82. program where the protection scheme is snapping.
  83.      Once you are able to isolate a certain section of a program,
  84. breakpoints can be used to gather a trace history of the
  85. program's execution. If your debugger sports a backtrace buffer,
  86. logging window, or similar feature, by all means learn how to use
  87. it. The debugger it's your best weapon, you must know all the
  88. possibilities it offers and all the capabilities it possesses.
  89. Having a debugger's display output echoed to a printer is another
  90. possibility.
  91.      Using breakpoints is beneficial for two basic reasons: speed
  92. and reduction of detail. Manual single-stepping is invaluable
  93. when you are close to the protection scheme, but too much of it
  94. will bore you to death.
  95.      When selecting breakpoint locations and the types of
  96. breakpoint to use, it is important to step back once more, drink
  97. a cool Martini-Wodka (use only Moskovskaja: non-russian Wodkas
  98. are appalling) and ask yourself: "What is this going to tell me?"
  99. and "What else will I need to know once the break occurs?". MOST
  100. IMPORTANT OF ALL: "Is my current cracking approach the simplest
  101. and most direct?", coz you do not want to waste precious cracking
  102. time.
  103.      When devising a set of breakpoints it is wise to consider
  104. how "a trail of bread crumbs" can be left. Not allowing for an
  105. execution chronicle from the start can mean having to restart a
  106. cracking session.
  107.      Setting breakpoints on certain software interrupt calls is
  108. an excellent way to get an overview of a program's operations.
  109. The INT_21 DOS services interrupt is probably the most universal
  110. useful of these, with BIOS interrupts such as the INT_13 (BIOS
  111. Disk services) and INT_16 (BIOS keyboard services) useful for
  112. specific cracking.
  113.      When working with a debugger, evaluative breakpoints are
  114. usually your best shot. To avoid having to deal with a plethora
  115. of calls, you would want to have a debugger capable of being told
  116. to "break on any INT_21 call except where AH == 2C or AH == 0B".
  117.      A real understanding of the working of a program is surely
  118. important, but don't overdo it! To reverse-engineer even a small
  119. program can involve many hours of analysis and documentation
  120. work. If you'll not be able to use the zen-cracking techniques
  121. described in this tutorial (sadly not everybody can) pace
  122. yourself and make sure your chair is comfortable: you'll be
  123. sitting for quite a spell.
  124.      Much of the work involved in reverse-engineering consist of
  125. chasing down tentacles. In order to understand the operations of
  126. one function, you must understand what happens within each of the
  127. functions it calls- its child functions. To understand these
  128. child functions you must study their children; and so on down the
  129. calling hierarchy tree. Then there is the data. Tracing tentacles
  130. based on a program's calling hierarchy is a directed process.
  131. Each function you encounter is basically a list of other
  132. functions you must reckon with. When it comes to analyzing a
  133. function's interrelationship with the program's data structure,
  134. no such list is provided. You must have instinct, feeling and
  135. luck.
  136.      Data analysis requires more of a broad-based inquisition.
  137. For each memory variable you are interested in, you must survey
  138. all functions to determine which ones read and write that
  139. variable. The use of memory conditional breakpoints and of a
  140. disassembler that builds a cross-reference table can make this
  141. task a lot easier. (Use Sourcer! It's a fairly good tool and
  142. version 4.08 of [sr.exe] has been long ago cracked by me, +ORC,
  143. and distributed on the Web).
  144.  
  145. ALL SYSTEM CALLS IN ONE LOCATION
  146.      Remember that if the program you are cracking was written
  147. in assembler in the first place (very unlikely knowing the
  148. laziness of to_days programmers), it is probable that system
  149. calls are made directly from the functions which need them. But
  150. when a program is developed in a high-level language, it is more
  151. likely that common library functions will be used for many
  152. operations involving system calls. When a program makes all of
  153. its INT_21 calls from the same location, you know that this is
  154. certainly the case.
  155.      Now, what happens sometimes is that the programmers write
  156. the whole application in a overbloated language like C++, but are
  157. afterwards compelled to "speed up" critical sections of the code
  158. writing them in assembler. And loo! A section where you
  159. repeatedly find assembler crafted patches is precisely the
  160. section containing the protection scheme! So you could have a
  161. program with all INT_21 calls from the same location but for one
  162. or two calls which are coming out of the section where the morons
  163. have "hidden" their protection strategy. By just "looking" at the
  164. dead code of a program, you should be capable to tell wich parts
  165. have been "added on" in a later phase. They presents themselves
  166. as unevenness and irregularities, especially if you use an
  167. utility that represents graphicallly the code of a program.
  168. Protections are often added on at the end.
  169.      Should you determine that the system calls relevant to your
  170. cracking are made from common library functions, all is not lost.
  171. The specific function from which these library calls were made,
  172. the function you are seeking to locate, is executing at some
  173. point in between these calls. Break in with your debugger at the
  174. end of the first system call, just where it is returning to the
  175. point of call. From there, trace through the remainder of the
  176. common library routine until it returns to its caller. In short
  177. order, you should find yourself in the function you need to see.
  178. The trick is to be able to identify it for what it is.
  179.  
  180. ASCIIZ IN CODE
  181.      In the interest of gaining an overall familiarity with the
  182. program you want to crack, it can be enlightening to use a hex
  183. dump utility to examine the message strings contained within the
  184. program's binary modules. If the program happens to load its
  185. message strings from separate files, your search has just been
  186. simplified.
  187.      Your debugger's memory-dumping feature is one tool that can
  188. be useful for this type of exploration. You could also construct
  189. a filtering program, which would read a binary file and output
  190. all sequences of bytes that are comprised of displayable
  191. characters and are over a certain minimum length (the best
  192. cracker tools are often the ones you write yourself).
  193.      When a protection scheme is marked by the issuance of a
  194. specific message on the screen, you could go into the program and
  195. locate the code that emits this message, and then determine what
  196. triggers it. A good way to start the location process is to see
  197. if a system call is used to display the string. Interrupt INT_21,
  198. INT_10 or INT_29 are usually used to display text messages to the
  199. console.
  200.      When the message's display is not a result of one of these
  201. system calls, direct video writing is probably being used. If you
  202. know the screen location used, and if that part of video memory
  203. is not used for anything else at the time (a big if), a memory
  204. write breakpoint could be set on the video buffer address
  205. corresponding to the first character's position. If this won't
  206. work, use the step-over/step-around tracing technique while
  207. watching for the message to appear.
  208.      Now you found it: from a disassembled listing, you could
  209. locate the address of the message string and then survey the
  210. reminder of the file for any instructions that reference this
  211. address. [Sourcer.exe] can generate labels for specific memory
  212. locations and then generate a cross-reference table showing where
  213. these labelled locations are referenced. Otherwise, load the
  214. disassembled listing file into your editor and use its search
  215. capabilities. Manually searching for such things in a listing
  216. will make you old before your time.
  217.  
  218. CODE AND DATA
  219.      When stepping through code at the assembler level, watch out
  220. for interrupt calls that are followed by data. Sometimes you will
  221. find an interrupt call, typically within the range INT_34 to
  222. INT_3F, where several bytes immediately following the interrupt
  223. instruction will be data rather than code.
  224.      Be especially suspicious of this type of code-and-data
  225. mixture when your debugger's disassembly output of the
  226. instructions immediately following an interrupt call doesn't make
  227. sense. Sometimes you  can determine the offset of the next true
  228. instruction by inspecting the following code and data. In other
  229. cases, you will have to trace through the interrupt call to see
  230. how it accesses the data following the interrupt call instruction
  231. and how it manipulates the return address on the stack.
  232.  
  233. HOOKED VECTORS
  234.      Seeing what interrupt intercepts already exist within a
  235. system before running the program you want to crack, as well as
  236. what interrupt handlers are established by the target program,
  237. can provide useful clues. For example, if a protection
  238. establishes an INT_09 intercept just before the snapping of a
  239. keyboard verification routine, your range of suspects has just
  240. been narrowed significantly.
  241.      To study the interrupt vector activities of an application,
  242. a vector dump map utility is useless. It can't be run while the
  243. application you want to crack is running. One solution is to run
  244. the program under a debugger and watch for system calls to INT_21
  245. functions 25h (set interrupt vector) and 35h (get interrupt
  246. vector), but in the event that the program  reads and writes
  247. interrupt vectors directly, this method will not give you a
  248. complete picture. Normally you'll use a spy (trace) utility.
  249.      APPLYING A MEMORY WRITE BREAKPOINT TO A SPECIFIC VECTOR OR
  250. TO THE ENTIRE TABLE is another way to deal with this.
  251.      Note that some sort of direct vector writing must be
  252. occurring if a vector change is detected between system calls.
  253.      If a vector change is detected during a system call but it
  254. isn't function 25h of INT_21, suspect that an IRQ handler may be
  255. effecting the change.
  256.  
  257. LITTLE TRICKS OF THE TRADE: determining interrupt vector
  258. addresses
  259.      How do you determine the interrupt vector addresses? As
  260. example let's find the address of the INT_21 interrupt vector.
  261. Since the interrupt vector table starts at address 0000:0000
  262. (easy to remember, isn't it?) and there are four bytes per
  263. vector, the basic process is to multiply the interrupt number
  264. four times and use the result at the offset with a segment of
  265. zero.
  266. x21h + x21h = x42
  267. x42h + x42h = x84
  268. The int_21 vector is located at address 0000:0084
  269. You could also use a calculator, for instance, the address of
  270. INT_63 is x63*4=x18c = 0000:018C 
  271.      
  272. LITTLE TRICKS OF THE TRADE: address conversion 
  273.      After a painstaking cracking session, you have finally
  274. determined that a byte of memory at address 6049:891C is the
  275. trigger. But when you isolate the offending instruction, you find
  276. that the address it is generating when the protection occur is
  277. different, being 6109:7D1C instead! How can this be?
  278.      An 80x86 type CPU, when running in real or VM86 mode, uses
  279. what is known as segment:offset type addressing. One side effect
  280. of this addressing method is that one physical address can be
  281. equivalent to many different segment:offset addresses.
  282.      To find the PHYSICAL ADDRESS for a given segment:offset do
  283. the following:
  284. - convert the segment portion of the address to a 1-based number
  285. by multiplying it by 16 (x10)... it's easy: add 0 at the right
  286. end of the number!... 
  287.      6049 -> 60490
  288.      6109 -> 61090
  289. now all you have to do is to add this value to the offset value
  290.      60490+891C  -> 68DAC     
  291.      61090+7D1C  -> 68DAC
  292. Got it?
  293. And the other way round? If you have a physical address, say
  294. 19AC3, and you want to obtain a segment:offset address you must
  295. first of all decide in which segment you want the address... if,
  296. say, you choose segment 16CC, you proceed as follows:
  297.      16CC           -> 16CC0
  298.      19AC3-16CC0    =  2E03 (offset)
  299.      address for 19AC3 in segment 16CC = 16CC:2E03
  300.  
  301. TOOLS OF THE TRADE
  302. [MEMSCAN.EXE]
  303.      One of the most fascinating tools that I have ever seen is
  304. a (very old) program: MEMSCAN.EXE.
  305. This program was originally written in 1988 by Scott A. Mebust,
  306. running in CGA. It's a "visual" utility: it enables you to see
  307. graphically the 1-meg of PC memory in 8 kbyte chunks. It's a
  308. powerful tool in order to locate quickly bit mapped graphics and
  309. other 'objects' in memory, like program data tables, stack areas,
  310. code areas, available RAM, etc. I used this great idea to create
  311. (in C) my own tools: a "dead_programs scanner" and an ameliorate
  312. version of Memscan itself. Looking at the VISUAL STRUCTURE of a
  313. program it's a great help when you'll crack higher levels.
  314.  
  315. [TRACKMEM.COM]
  316.      A very good tool by James W.Birdsall, tracks memory usage
  317. of programs (EMS, XMS, conventional).
  318.  
  319. [SCANCODE.COM]
  320.      "THE" scancode lister, by the code_masters from clockwork
  321. software. The must utility for crackers that do not learn all
  322. scancodes by heart.
  323.  
  324. [MAP.EXE]
  325.      Actually "MAP2", THE memory mapper from the code_masters at
  326. clockwork software. It's a very good tool and an interesting one
  327. too, coz you get it with the "Nigel" nag screens. They are not
  328. difficult to remove (a "passletter" protection scheme, you'll
  329. learn how to find and remove it from [Map.exe] in LESSON 3.2).
  330.  
  331. [FILEDUMP.COM] [HEXDUMP.COM] [TDUMP.EXE] [DUMP.EXE]
  332.      There are hundred of file dump utilities, coz file dumping
  333. is one of the first exercise they learn you at C-school.
  334. Hexdump.com is 558 bytes long, Tdump.exe 120.704, pick the one
  335. you like better or write your own (even better). Filedump.com,
  336. by Daniel M.O'Brien, 1046 bytes long, it's nice.
  337.  
  338. [SPRAY.COM]
  339.      That's a good crack utility indeed! This 1989 program by
  340. Daniel M.O'Brien gives you a "post-mortem" picture of your
  341. memory. You redirect it to <myfile> and study it at ease. It's
  342. difficult to say how many hours of cracking it did spare me (you
  343. should study the program, only 252 bytes long, and will have to
  344. modify it a bit, coz it's pretty primitive, in the original
  345. version, for instance, the redirection to the printer works only
  346. if there is NO SPACE between "spray" and ">").
  347.  
  348. [VEXE.EXE]
  349.      A good EXE files analyzer, useful for windows programs too
  350. (see --> LESSON 7). Some of its functions are present in
  351. TDUMP.EXE too. This 1991 program by S.Krupa it's sometimes very
  352. useful.
  353.  
  354. [SNOOP UTILITIES --> KGB.EXE INTMON.EXE INTRSPY.EXE etc...]
  355. [TRACE UTILITIES --> TRACE.EXE STEPDOS.EXE etc...]
  356.      A must to study the "calling hierarchy" of an unknown
  357. program. KGB.EXE, a 1992 program by Petr Hor k could be the best
  358. one. I'll teach you how to crack without any of them (you do not
  359. need them if you zen-crack), but they can nevertheless be very
  360. useful in some situations. Stepdos.exe is a excellent program:
  361. a pleasure to crack in order to use it for slightly different
  362. purposes :=)
  363.       
  364. [SOURCERING UTILITIES]
  365.      SR.EXE can be used for sourcering unknown programs. It's a
  366. fairly good sourcering tool. Version 4.08 has been long ago
  367. cracked by me (it's a "ORIGINAL NUMBERCODE" protected program)
  368. and distributed on the Web, so you should easily find it. This
  369. said, you should NEVER use such a brute force approach, unless
  370. you are really desperate: I'll teach you how to crack without
  371. sourcering (you don't need to sourcer if you zen-crack). 
  372.  
  373. [HEXEDITORS]
  374. Every idiot has written at least one hexeditor, and you can find
  375. very bad tools everywhere (the SIMTEL collection, on the Web,
  376. lists at least 35 hexeditors). I suggest you write your own and
  377. contribute to the flood, or (better) get PSEDIT.EXE, a good 1990
  378. program by Gary C. Crider (Parity Solutions, 1903 Pavia Ct.
  379. Arlington, TX 76006... sometimes even americans can write good
  380. programs). If you do use it (as you should) disapt the nag screen
  381. as small exercise in cracking.
  382.  
  383. [DEBUGGER]
  384.      Your best friend in cracking, your weapon, your hidecloak...
  385. I suggest [Softice.exe] from Nu-Mega technologies (Version 2.6
  386. has been cracked by MARQUIS DE SOIREE and its vastly available
  387. on the Web). You could also use [Periscope] or [Codeview] or
  388. Borland's Turbodebugger... all these programs have been boldly
  389. cracked and/or distributed and are now on the Web for free...
  390. learn how to use YAHOO and find them. It's the only tool you 'll
  391. REALLY need, believe me. So choose wisely and learn how to use
  392. backtrace ranges and breakpoint on user written qualifications
  393. routines. You 'll be able to crack almost EVERYTHING using these
  394. features in the right way. 
  395.  
  396.      You should get all the programs mentioned above (and more)
  397. for free on the Web. Use them, but also modify them recklessly!
  398. REMEMBER THAT YOU ARE (GOING TO BE) A CRACKER! The first programs
  399. you should crack and modify are therefore your very tools! So
  400. steal the code of the best tools you find! Snatch the best
  401. routines and change them for the better! That's the whole point
  402. in cracking: a mission to IMPROVE the best accomplishments of
  403. humanity's genius :).
  404.  
  405. HOW TO CRACK, ZEN-CRACKING
  406.      You 'll learn, beginning with next lesson, how to crack
  407. systematically the different protection schemes: paper & password
  408. protections, time protections, access protections. At the end of
  409. the "methodolocical" part, you'll be able to deprotect programs,
  410. but you will still not be a cracker. In order to crack in a real
  411. effective way you must use what I call (lacking a better
  412. definition) "zen-cracking". I 'll give you right now an example
  413. of this, so that you know what I'm talking about, but -unless you
  414. are already capable- you'll have to finish the tutorial for
  415. "normal" cracking before attempting this techniques. Let's zen-
  416. crack together a password protection scheme (aka "paper
  417. protection", coz you need the original manual of the program in
  418. order to answer). This one is based on the typing, at the nag
  419. screen, of the correct sequence of numbers. We are using as
  420. example a game for the reasons explained in lesson 1, but you 'll
  421. find the SAME protection scheme in the access protection
  422. procedure of the old Tapestry networks... so do not frown upon
  423. games protections.
  424.  
  425. INDIANAPOLIS 500, Papyrus software & Electronic Arts, 1989
  426. It's a rather widespread program, so you should be able to find
  427. it pretty easily. The nag screen asks for data based on the
  428. historical performances of race cars... that means that the
  429. answers will consist in two to three digits. 
  430.      Now, the normal way to crack such a program will be
  431. described in lesson 3.1 and embodyes following steps:
  432. -    snap save program memory areas before typing your answer
  433. -    snap compare after typing, say, "666"
  434. -    search for the sequence 36,36,36 (i.e. 666)
  435. -    breakpoint on memory range for reading
  436. -    look at the program part fetching your data
  437. -    find the snap procedure
  438. -    disable it.
  439.      The above it's a relatively quick crack, and most of the
  440. time 'll be fairly effective, but there is a better way: the "zen
  441. way", the only one that can really bring you to crack peculiar
  442. protection schemes.
  443. -    Run the program and break in at the nag screen
  444. -    Answer consist of 2-3 digits? Search for "AC" (i.e. the
  445. instruction LODSB, load digit of answer in AL) in the area 500
  446. bytes BEFORE and 500 bytes AFTER your position. You'll get some
  447. locations. (In the case of INDY 500 you get 6 such locations).
  448. -    "feel" the locations (that's the tricky part).
  449. -    OK, you already made it! Here is the protection strategy:
  450.   8BBF28A5     MOV  DI,[BX+A528]<-- DI points to coded data area
  451. :compare_loop
  452.   AC      LODSB          <-- load first digit of answer in AL
  453.   B4FF    MOV  AH,FF     <-- load mask in AH
  454.   2A25    SUB  AH,[DI]   <-- sub coded data from mask and get
  455.                          real answer
  456.   47      INC  DI        <-- ready to get next coded data
  457.   3AC4    CMP  AL,AH     <-- user answer = real answer ?
  458.   751A    JNZ  bagger_off_you_do_not_know_the_right_answer
  459.   0AC0    OR   AL,AL     <-- more numbers?
  460.   75F2    JNZ  compare_loop
  461.   59      POP  CX        <-- nice guy, you may go on
  462.   ...
  463. And if the protection scheme had been more far away? And if you
  464. cannot "feel" the right one? And if my grandma had wheels? You'll
  465. learn it, believe me.
  466. Now let's quickly crack this crap.
  467.