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

  1.                      HOW TO CRACK, by +ORC, A TUTORIAL
  2.  
  3. ---------------------------------------------------------------------------
  4.  
  5.                 Lesson 3.1: hands on, paper protections (1)
  6.  
  7. ---------------------------------------------------------------------------
  8.  
  9.                    [UMS.EXE] [LIGHTSPD.EXE] [GENERAL.EXE]
  10.  
  11.                    --------------------------------------
  12.  
  13. SOME PROBLEMS WITH INTEL's INT
  14.  
  15. The INT instruction is the source of a great deal of the
  16.  
  17. flexibility in the PC architecture, because the ability to get
  18.  
  19. and set interrupt vectors means that system services (included
  20.  
  21. DOS itself) are infinitely extensible, replaceable and
  22.  
  23. MONITORABLE. Yet the Int instruction is also remarkably
  24.  
  25. inflexible in two key ways:
  26.  
  27. -    an interrupt handler DOES NOT KNOW which interrupt number
  28.  
  29.      invoked it.
  30.  
  31. -    the int instruction itself expects an IMMEDIATE operand:
  32.  
  33.      you cannot write MOV AX,x21, and then INT AX; you must
  34.  
  35.      write INT x21.
  36.  
  37. That would be very good indeed for us cracker... unfortunately
  38.  
  39. many high level language compilers compile interrupts into PUSHF
  40.  
  41. and FAR CALL instruction sequences, rather than do an actual INT.
  42.  
  43. Another method is to PUSH the address of the handler on the stack
  44.  
  45. and do RETF to it.
  46.  
  47.      Some protection schemes attempt to disguise interrupt calls,
  48.  
  49. 1) camouflaging the code, 2) putting in substitute interrupt
  50.  
  51. instructions which look harmless and modifying them "on the fly"
  52.  
  53. or 3) replicating whole interrupt routines inside the code. This
  54.  
  55. is particularly frequent in the various "disk access" protection
  56.  
  57. schemes that utilize INT_13 (the "disk" interrupt) and will
  58.  
  59. therefore be thoroughly explained in -> lesson 5.
  60.  
  61. A LITTLE BASIC ASSEMBLER
  62.  
  63. In order to understand the protection schemes and to defeat them,
  64.  
  65. you must acquire a passing knowledge of assembler, the "machine
  66.  
  67. language" code. You can find a lot of good, well explained code
  68.  
  69. for free: viruses are one of the best sources for good "tight and
  70.  
  71. tricky" assembler code. You can find the source code of almost
  72.  
  73. all viruses on the web: oddly all the would be hackers seem to
  74.  
  75. have an aberrant passion for this kind of stuff instead of
  76.  
  77. studying cracking techniques. But there are millions of lines of
  78.  
  79. good explained "commercial" assembler code on the net, just fish
  80.  
  81. it out and study it: the more you know, the better you crack.
  82.  
  83. I'll restrict myself to some observations, sprinkled throughout
  84.  
  85. this tutorial. Let's start with some must_know:
  86.  
  87. ------------------------ STRINGS ----------------------------
  88.  
  89. The string instructions are quite powerful (and play a great role
  90.  
  91. in password protection scheme). ALL of them have the property
  92.  
  93. that:
  94.  
  95. 1)   The source of data is described by the combination DS:SI
  96.  
  97. 2)   The destination of data is described by the combination
  98.  
  99.      ES:DI
  100.  
  101. 3)   As part of the operation, the SI and/or DI register(s)
  102.  
  103.      is(are) incremented or decremented so the operation can be
  104.  
  105.      repeated.
  106.  
  107. ------------------------- JUMPS -----------------------------
  108.  
  109. JZ   ero       means what it says
  110.  
  111. JNZ  ero       means what it says
  112.  
  113. JG   reater    means "if the SIGNED difference is positive"
  114.  
  115. JA   bove      means "if the UNSIGNED difference is positive"
  116.  
  117. JL   ess       means "if the SIGNED difference is negative"
  118.  
  119. JB   elow      means "if the UNSIGNED difference is negative"
  120.  
  121. JC   arry      assembles the same as JB, it's a matter of
  122.  
  123.                aesthetic choice
  124.  
  125. CRACKING PASSWORD PROTECTED PROGRAMS
  126.  
  127.      Refer to lesson one in order to understand why we are using
  128.  
  129. games instead of commercial applications as learn material: they
  130.  
  131. offer the same protection used by the more "serious" applications
  132.  
  133. (or BBS & servers) although inside files that are small enough
  134.  
  135. to be cracked without loosing too much time.
  136.  
  137.      A whole series of programs employ copy protection schemes
  138.  
  139. based upon the possess of the original manual or instructions.
  140.  
  141. That's obviously not a very big protection -per se- coz everybody
  142.  
  143. nowadays has access to a photocopier, but it's bothering enough
  144.  
  145. to motivate our cracks and -besides- you'll find the same schemes
  146.  
  147. lurking in many other password protected programs.
  148.  
  149.      Usually, at the beginning of the program, a "nag screen"
  150.  
  151. requires a word that the user can find somewhere inside the
  152.  
  153. original manual, something like: "please type in the first word
  154.  
  155. of line 3 of point 3.3.2". Often, in order to avoid mistakes, the
  156.  
  157. program indicates the first letter of the password... the user
  158.  
  159. must therefore only fill the remaining letters.
  160.  
  161. Some examples, some cracks:
  162.  
  163. ---------------------------------------------------
  164.  
  165. UMS (Universal Military Simulator) version 1
  166.  
  167. by Dr Ezra SIDRAN
  168.  
  169. (c) 1987 Intergalactic Development
  170.  
  171. European Union:     Rainbird Software
  172.  
  173. United States:      Firebird Software
  174.  
  175. ---------------------------------------------------
  176.  
  177.      This very old EGA program is one of the first I cracked in
  178.  
  179. my youth, and it's very interesting coz it employs a very basilar
  180.  
  181. protection scheme (a "PRIMITIVE"! More than 80% of the protection
  182.  
  183. schemes used to day (January 1996) are directly derived from one
  184.  
  185. of the 12 primitives.
  186.  
  187.      The nag screen snaps at the beginning and keeps indefinitely
  188.  
  189. asking your answer, only the use of CTRL+C will bring you out of
  190.  
  191. it, back to DOS. That's a clear sign of older protection schemes:
  192.  
  193. newer schemes let you in for only 3 attempts or even only one,
  194.  
  195. and pop out to the OS if you fail. In UMS, besides, there is no
  196.  
  197. "first letter" aid, a later improvement.
  198.  
  199.      The cracking procedure for password protected programs is,
  200.  
  201. first of all, to find out where are stored the letters that you
  202.  
  203. type in. So examine your memory map, find out where the program
  204.  
  205. dwells in memory, do a snap save of these memory areas and a
  206.  
  207. series of snap compares as you type your password in.
  208.  
  209.      Strangely enough, in the case of UMS, as you type your
  210.  
  211. password there seems to be no difference at all in the memory
  212.  
  213. locations where this program dwells... yet the data must be
  214.  
  215. somewhere... Usually such a situation is a clear sign that an
  216.  
  217. hooked interrupt is used to hide the data.
  218.  
  219.      Checking the hooked vectors you find out the following:
  220.  
  221. vecs 00, 02, 22          are hooked where needs be
  222.  
  223. vecs 34-3D               are hooked at xxxx:0
  224.  
  225. vec  3E                  is hooked at xxxx:00CA
  226.  
  227.      Ha! Let's have a closer look at this bizarre 3E hook. Let's
  228.  
  229. search for some words used in the nag_screen and then let's dump
  230.  
  231. the area where we find them (in UMS that will be at 3E_hook
  232.  
  233. address + 7656) and loo! You'll see the content of the nag screen
  234.  
  235. and, immediately afterwards, ALL the passwords "in extenso", i.e.
  236.  
  237. not encoded, not scrambled, nothing at all... THERE THEY ARE
  238.  
  239. (that's a very old protection scheme indeed). You could now, for
  240.  
  241. instance, easily patch all the different passwords to (for
  242.  
  243. instance) "PASS", and this would work... it's a very primitive
  244.  
  245. protection, as we said, nevertheless the use of a hooked vector
  246.  
  247. as hiding place for the protection code is not yet obsolete...
  248.  
  249. we'll find it elsewhere, in many "more modern" programs.
  250.  
  251.      Now let's go deeper and examine the "compare" mechanism, we
  252.  
  253. want to crack, here, not just to patch.
  254.  
  255.      Password protected programs (and access protection routines
  256.  
  257. for server and BBS, for that matter) have quite a lot of weak
  258.  
  259. points. The most obvious one (you 'll find out the other when
  260.  
  261. you'll high crack) is that they MUST compare the password of the
  262.  
  263. user with the original one(s). So you do not need to steal a
  264.  
  265. password, you just need to "ear" the echo of the original one in
  266.  
  267. the memory locations used for the compare, or, and that's more
  268.  
  269. correct, to crack the compare mechanism itself so as to make it
  270.  
  271. let you in even with a totally false password.
  272.  
  273.      The compare mechanism of UMS can be found setting a
  274.  
  275. breakpoint on the memory range that covers the three locations
  276.  
  277. where the password is stored (and you 'll find these with your
  278.  
  279. search capabilities and with a pair of snap compares):
  280.  
  281. ES:0F8E   (here you 'll see a copy of the password that the
  282.  
  283.           program is asking)
  284.  
  285. ES:0F5C   (here you 'll see a copy of the password that the user
  286.  
  287.           types in)
  288.  
  289. INT_3E hook_address + 7656 (here are all the possible passwords
  290.  
  291.           in extenso).
  292.  
  293. Here is how the protection scheme looks out:
  294.  
  295. MOV       CX,FFFF        Charge MAX in CX
  296.  
  297. REPNZ     SCASB          Scan ES:DI (the user password)
  298.  
  299. NOT       CX             Now CX holds the number of the
  300.  
  301.                          character that the user typed in
  302.  
  303. MOV       DI,SI          Real password offset to DI
  304.  
  305. LDS       SI,[BP+0A]     User password offset in SI
  306.  
  307. REPZ      CMPSB          Compares DS:SI with ES:DI (user
  308.  
  309.                          password and real password) then snap
  310.  
  311.                          out at CX=0 or at char_different,
  312.  
  313.                          whichever comes first.
  314.  
  315. Nice, we found the compare schema... how do we crack it now?
  316.  
  317. There are many elegant solutions, but let's remain on a basic
  318.  
  319. level... you look at the code that follows the CMPSB searching
  320.  
  321. the "snapping schema"... here it is immediately afterwards
  322.  
  323. (that's the case in most of the primitives). Remember: we sprung
  324.  
  325. out of the CMPSB check at the first different char, OR at the end
  326.  
  327. of the count of the user chars. Here it is what follows:
  328.  
  329.      MOV  AL,[SI-01]     loads in AL the before_different char
  330.  
  331.                          of the user password (should be zero)
  332.  
  333.      SUB  AL,ES:[DI-01]  subs with the before_different char of
  334.  
  335.                          the real password (should be zero)
  336.  
  337.      CBW                 zero flag set, "TRUE", if OK_match
  338.  
  339. Well let's now look for the next JZ near (it's a "74" code)
  340.  
  341.      CS:IP 740D     JZ  location no_good
  342.  
  343. Wait, let's continue a little... is there another check (often
  344.  
  345. you have a double check on DI)... yes there is!
  346.  
  347.      CS:IP 7590     JNZ location no_good
  348.  
  349. Cracking such a schema is very easy: you just need to substitute
  350.  
  351. 75 to 74 and 74 to 75: transform your JZ in a JNZ and the JNZ in
  352.  
  353. a JZ... now you will always pass, no matter what you write,
  354.  
  355. unless you exactly guess the password!
  356.  
  357. Now let's quickly crack it:
  358.  
  359. ------------------------------------------------
  360.  
  361. CRACKING UMS.EXE (by +ORC, January 1996)
  362.  
  363. ren ums.exe ums.ded
  364.  
  365. symdeb ums.ded
  366.  
  367. -    s (cs+0000):0 Lffff 74 0D 1E B8 C2 3F
  368.  
  369. (nothing)
  370.  
  371. -    s (cs+1000):0 Lffff 74 0D 1E B8 C2 3F
  372.  
  373. (nothing)
  374.  
  375. -    s (cs+2000):0 lffff 74 0D 1E B8 C2 3F
  376.  
  377. xxxx:yyyy           (this is the answer of the debugger)
  378.  
  379. -    e xxxx:yyyy    75
  380.  
  381. -    e xxxx:yyyy+17 74
  382.  
  383. -    w
  384.  
  385. -    q
  386.  
  387. ren ums.ded ums.exe
  388.  
  389. -------------------------------------------------
  390.  
  391.      In the debug/symdeb crack above we use as search string the
  392.  
  393. bytes comprising and following immediately the first JZ.
  394.  
  395. I know, I know... we saw them in [Soft-ice] and we could have
  396.  
  397. modified them there, but I'm teaching also pupils who may not
  398.  
  399. have [Soft-ice].
  400.  
  401.      Note that the program is x431A0 bytes long, and therefore
  402.  
  403. has a BX=4 sectors adding to the CX=31A0 in the initial
  404.  
  405. registers... that's the reason I wanted to examine all the
  406.  
  407. sectors (even if I knew that the snap was in sector (cs+2000):
  408.  
  409. that's good practice! If you do not find your string in the first
  410.  
  411. sector you must search for it in the next sectors, till you find
  412.  
  413. it, coz in many programs there may be MORE THAN ONE repetitions
  414.  
  415. of the same schema (more about this double check later).
  416.  
  417. That's it, pupils, that's the way to crack old [UMS.EXE].
  418.  
  419. Let's go over, now, to more elaborate and more modern password
  420.  
  421. protection schemes.
  422.  
  423. --------------------------------------------------------
  424.  
  425. LIGHTSPEED, from Microprose (we crack here version 461.01)
  426.  
  427. --------------------------------------------------------
  428.  
  429.      This program, released in 1990, operates a more "modern"
  430.  
  431. variation of the previous scheme. You 'll find this variation in
  432.  
  433. many access routines of remote servers (and this makes it very
  434.  
  435. interesting indeed).
  436.  
  437.      Let's begin as usual, with our hooked vectors examination
  438.  
  439. and our snap compares.
  440.  
  441. Hooked vectors: 00, 08, 1B, 22, 23: nothing particular.
  442.  
  443. The snap_comparisons of the main memory area -as you type the
  444.  
  445. password in- gives more than six pages of changing locations...
  446.  
  447. that's clearly much too much to examine.
  448.  
  449. What now?
  450.  
  451.      Sit down, have a Martini Wodka (I'm afraid that only
  452.  
  453. Moskovskaja 'll do) and meditate. Get the memory map of the
  454.  
  455. program's layout. Start anew: snap_save (before typing anything
  456.  
  457. in). Type as password "ABCDE". Get the print of the snap
  458.  
  459. compares. Sit down, sip Martini Wodka, relax. You know that the
  460.  
  461. code for A is x41, for B x42, for C x43 and so on... and in the
  462.  
  463. snap_compares, that you made between letters, you 'll have only
  464.  
  465. some locations with these values changing. Focus on these.
  466.  
  467.      You 'll soon enough find out that for LIGHTSPEED absolute
  468.  
  469. location (in my computer) 404307, i.e.: relative locations (in
  470.  
  471. my computer) 30BE:F857 or 4043:0007 evoke the characters you
  472.  
  473. type, i.e. something like
  474.  
  475. -----------------------------------------------------
  476.  
  477. F855 F856 F857                F858                F859...
  478.  
  479. 41   3E   first_ready_letter  your_1st_letter     your_2nd_one...
  480.  
  481. -----------------------------------------------------
  482.  
  483. Inspecting the same prints, you 'll find out that absolute
  484.  
  485. location 30C64 (imc) or relative location 30BE:F83E evokes the
  486.  
  487. LAST character you typed in. The relative code line is:
  488.  
  489.      CS:0097   MOV  AX,[BP-08] where SS:F83E = 00+letter_code
  490.  
  491.      Now breakpoint at these locations and investigate what's
  492.  
  493. going on (for instance, the instruction that follows is
  494.  
  495.      CS:009A   MOV [BX], AX
  496.  
  497. and this means that the code of the letter you just typed in will
  498.  
  499. be now copied in BX=F85A. What else can you do? Time to use a
  500.  
  501. little intuition: look for an instruction "CMP AX,000D", which
  502.  
  503. is the typical "IF the user hits ENTER then" instruction, coz
  504.  
  505. "x1D" its the ENTER keystroke. This must be somewhere around
  506.  
  507. here. Ha! You 'll soon enough find the line
  508.  
  509.      CS:0073  3D0D00     CMP AX,000D
  510.  
  511. And now the way is open to the crack. But YOU DO NOT NEED ALL
  512.  
  513. THIS! Since the password protection schemes are -as I told you-
  514.  
  515. all more or less the same, I would suggest that you use first of
  516.  
  517. all following trick: in the largest part of the program (use
  518.  
  519. memory map to see where the program dwells) search the "F3A6"
  520.  
  521. sequence, that's instruction REPZ CMPSB.
  522.  
  523.      In the case of Lightspd you 'll get as answer FOUR addresses
  524.  
  525. with this instruction: (pgsg=program main segment)
  526.  
  527.      pgsg:C6F9
  528.  
  529.      pgsg:E5CA
  530.  
  531.      pgsg:E63E
  532.  
  533.      pgsg:EAB0
  534.  
  535. There you are! Only four... have a short look at each of them:
  536.  
  537. you 'll see that the second one (pgsg:E5CA) is the "good" one.
  538.  
  539. The compare mechanism in this program of 1990 it's more or less
  540.  
  541. the same as in 1987'UMS (and do believe me: the same mechanism
  542.  
  543. is still in use to day (1996)!
  544.  
  545. B9FFFF    MOV       CX,FFFF   charge Max in CX
  546.  
  547. F2AE      REPNZ     SCASB     this scans ES:DI (the original
  548.  
  549.                               password)
  550.  
  551. F7D1      NOT       CX        so many chars in the original pw
  552.  
  553. 2BF9      SUB       DI,CX     change DI for compare
  554.  
  555. F3A6      REPZ      CMPSB     compares DS:SI with ES:DI (real
  556.  
  557.                               pw with user pw) then snaps out
  558.  
  559.                               at CX=0 or at char_differs
  560.  
  561.      See how easy? They all use the same old tricks the lazy
  562.  
  563. bastards! Here the section is preceded by a small routine to
  564.  
  565. lowercase the user password, coz the original muster is always
  566.  
  567. lowercased.
  568.  
  569.      Now you would like, may be, to breakpoint at one of these
  570.  
  571. locations, in order to stop the program "in the snap area" and
  572.  
  573. inspect the snap mechanism... that WILL NOT DO with a "fixed"
  574.  
  575. breakpoint, coz these locations are called by the snap with a
  576.  
  577. different segment:offset numeration as the one you found (that's
  578.  
  579. old dos magic). So you MUST first set a memory_read/write
  580.  
  581. breakpoint on these locations, and then get at them at the snap.
  582.  
  583. Now you can find out the segment:offset used by the snap and only
  584.  
  585. now you'll be able to set a fixed breakpoint (for instance on the
  586.  
  587. NOT CX instruction).
  588.  
  589.      Now run the program and breakpoint in: have a dump of the
  590.  
  591. ES:DI and see the original password. How nice! We have now the
  592.  
  593. original password in extenso in our memory dump window. That's
  594.  
  595. the "echo". By the way, there is a whole school of cracking
  596.  
  597. devoted to find and use these echoes... we work on different
  598.  
  599. paths, nevertheless password fishing can be interesting: where
  600.  
  601. are the password stored? From which locations do they come from?
  602.  
  603. A common practice of the protectionists is to hide them in
  604.  
  605. different files, far away, or in hooked vectors, or in SMC parts.
  606.  
  607. This is a program of 1990, that differs in respect to UMS: the
  608.  
  609. passwords are not "hidden" inside a hooked vector, coz that's a
  610.  
  611. pretty stupid protection: any hexdump utility would still permit
  612.  
  613. you to see them. Here the passwords are encoded (albeit in a very
  614.  
  615. primitive manner): looking for them (with memory range
  616.  
  617. breakpoints) you'll quickly find a section of the program code
  618.  
  619. that looks like this:
  620.  
  621. sg:0118   8C 91 9D 95 9B 8D 00 B8 EC 94 9B 8D 8F 8B 9B
  622.  
  623. sg:0128   94 9B 8D 00 AE EC 9C 9B 8A 9B 86 00 A9 EC 91
  624.  
  625. This is a typical encoded matrix, with clear 00 fences between
  626.  
  627. the encoded passwords.
  628.  
  629. Ha! If all codes where so easy to crack! This is no better than
  630.  
  631. children's crypt! It's a NEG matrix! And there is direct
  632.  
  633. correspondence: 91=6F="o"; 92=6E="n"; 93=6D="m" and so on... Ha!
  634.  
  635.      Let's now leave the "hidden" passwords and proceed with our
  636.  
  637. cracking... let's follow the snap procedure after the REPZ CMPSB
  638.  
  639. instruction looking for the "jump to OK" instruction...
  640.  
  641. F3A6      REPZ      CMPSB          ; compares DS:SI with ES:DI
  642.  
  643. 7405      JZ   preserved_AX=0000   <--- Here the first JZ
  644.  
  645. 1BC0      SBB  AX,AX
  646.  
  647. ADFFFF    SBB  AX,FFFF
  648.  
  649. :preserved_AX=0000
  650.  
  651. 8BF3      MOV  SI,BX
  652.  
  653. 8BFA      MOV  DI,DX
  654.  
  655. 5D        POP  BP
  656.  
  657. CB        RETF
  658.  
  659. ....
  660.  
  661. 83C404    ADD  SP,+04
  662.  
  663. 0BC0      OR   AX,AX
  664.  
  665. 7509      JNZ  0276                <------ And here it is!
  666.  
  667.      Now, remembering the UMS crack, you would probably want to
  668.  
  669. change the JZ instruction in a JNZ instruction (you tried it on
  670.  
  671. the fly INSIDE  [Soft-Ice] and it did work!), the "74" with a
  672.  
  673. "75" also. And then you would like to change the JNZ instruction
  674.  
  675. in a JZ instruction... Please feel free to try it... it will NOT
  676.  
  677. work! (You will not even find the second JNZ in the program
  678.  
  679. code). You should always be aware of the SMC (self modifying
  680.  
  681. code) protections: parts of the code my be decrypted "on the
  682.  
  683. fly", as needs arise, by the program. The code you modify while
  684.  
  685. the program is running may be different from the code of the
  686.  
  687. "dead" program.
  688.  
  689.      Here we have a small "improvement" of the primitive: the
  690.  
  691. same instruction is used as "muster" for manipulation of other
  692.  
  693. parts of the program... if you do change it in a JNZ you get an
  694.  
  695. overlay message and the program pops out with instability! You
  696.  
  697. cannot easily modify the JNZ instruction either, coz the part
  698.  
  699. after the RETF will be compiled "on the fly" by lightspeed, and
  700.  
  701. you would therefore have to search the decryption mechanism and
  702.  
  703. modify the original encrypted byte somewhere... and may be they
  704.  
  705. do encrypt it twice... and then you must hack all night long...
  706.  
  707. very annoying.
  708.  
  709.      So do the following: back to the snap, a sip of martini-
  710.  
  711. Wodka and meditate: loo! The only thing that happens after the
  712.  
  713. JZ, is the setting of the AX register to flag *FALSE* (AX=1...
  714.  
  715. that's what the two SBB instructions do) if the snap went out
  716.  
  717. with a non-zero flag... i.e. if you did not know the password.
  718.  
  719. So let's nop the 5 bytes of the two SBB instructions, or, more
  720.  
  721. elegantly, let's have a INC AX, DEC AX, NOP, INC AX, DEC AX
  722.  
  723. sequence instead of the two SBB! There is a good reason to use
  724.  
  725. a sequence of working instructions instead of a series of NOPs:
  726.  
  727. recent protection schemes "smell" patched nops inside the program
  728.  
  729. and trash everything if they find more than -say- three
  730.  
  731. consecutive NOPs! You should always try to choose THE LESS
  732.  
  733. INTRUSIVE and MORE "CAMOUFLAGED" solution when you crack!
  734.  
  735.      Eliminating the two SBBs we get our crack! No need to bother
  736.  
  737. with the second JNZ either... the program will work as if you got
  738.  
  739. the password if you have it AND if you do not (that's better as
  740.  
  741. the previous type of crack -seen for UMS- when you crack computer
  742.  
  743. accesses: hereby the legitimate user will not have any suspects
  744.  
  745. 'coz the system will not shut him out... everybody will access:
  746.  
  747. the good guys and the bad ones... that's nice isn't it?).
  748.  
  749.      Now let's quickly crack LIGHTSPD:
  750.  
  751. ------------------------------------------------
  752.  
  753. CRACKING LIGHTSPEED.EXE (by +ORC, January 1996)
  754.  
  755. ren lightspd.exe lightspd.ded
  756.  
  757. symdeb lightspd.ded
  758.  
  759. -    s (cs+0000):0 Lffff 2B F9 F3 A6 74
  760.  
  761. xxxx:yyyy           (this is the answer of the debugger)
  762.  
  763. -    s (cs+1000):0 Lffff 2B F9 F3 A6 74
  764.  
  765. (nothing, but do it nonetheless, just to be sure)
  766.  
  767. -    s (cs+2000):0 lffff 2B F9 F3 A6 74
  768.  
  769. (nothing, just to be sure, now it's enough)
  770.  
  771. -    e xxxx:yyyy+6  40 [SPACE] 48 [SP] 90 [SP] 40 [SP] 48
  772.  
  773. -    w
  774.  
  775. -    q
  776.  
  777. ren lightspd.ded lightspd.exe
  778.  
  779. -------------------------------------------------
  780.  
  781. All this CMPSB is very common. Some programs, nevertheless,
  782.  
  783. utilize a password protection scheme that is slightly different,
  784.  
  785. and does not rely on a F3A6 REPZ CMPSB instruction. Let's
  786.  
  787. analyze, for instance, the protection scheme used in the first
  788.  
  789. version of Perfect general I from QQP-White wolf, July 1992.
  790.  
  791. When you break in, at the nag screen, you are in the middle of
  792.  
  793. the BIOS procedures, coz the program expects your input (your
  794.  
  795. password, that's is). You 'll quickly find out (MAP MEMORY
  796.  
  797. USAGE!) that [General.exe] dwells in two main areas; Setting
  798.  
  799. breakpoints on memory write you 'll find out that the memory area
  800.  
  801. "queried" by the protection mechanism is
  802.  
  803.      xxxx:1180 to xxxx:11C0
  804.  
  805. where xxxx represents the second of the memory segments where the
  806.  
  807. program dwells. Now do the following (a very common cracking
  808.  
  809. procedure):
  810.  
  811. *    Breakpoint on memory range WRITE for the small memory area
  812.  
  813.      touched by the program in querying you for the password.
  814.  
  815. *    Breakpoint TRACE on the whole memory range of the MAIN
  816.  
  817.      CODE.
  818.  
  819. *    Run anew everything
  820.  
  821. It's already done! Now it's your intuition that should work a
  822.  
  823. little: Here the last 9 traces (traces [!], not instructions
  824.  
  825. following on a line) before the calling of the procedure sniffing
  826.  
  827. your memory area:
  828.  
  829. -9   xxxx:0185 7425           JZ   somewhere, not taken
  830.  
  831. -8   xxxx:0187 2D1103         SUB  AX,0311
  832.  
  833. -7   xxxx:018A 7430           JZ   somewhere, not taken
  834.  
  835. -6   xxxx:018C 2DFD04         SUB  AX,04FD
  836.  
  837. -5   xxxx:018F 7443           JZ   next_trace, taken
  838.  
  839. -4   xxxx:01D4 E85500         CALL funny_procedure
  840.  
  841. -3   xxxx:022C 803E8F8C11     CMP  BYTE PTR[8C8F],11
  842.  
  843. -2   xxxx:0231 750E           JNZ  somewhere, not taken
  844.  
  845. -1   xxxx:0233 9A0A0AC33E     CALL procedure_that_sniffs
  846.  
  847.                                    our_memory_area
  848.  
  849. Well, the call to funny_procedure followed by a byte compare
  850.  
  851. "feels" fishy from very far away, so let's immediately look at
  852.  
  853. this part of the code of [General.exe]
  854.  
  855. :funny_procedure
  856.  
  857.      803E8F8C11     CMP  BYTE PTR[8C8F],11
  858.  
  859.      750E           JNZ  compare_byte
  860.  
  861.      9A0A0AC333     CALL procedure_that_sniffs
  862.  
  863.      0AC0           OR   AL,AL
  864.  
  865.      7405           J2   compare_byte
  866.  
  867.      C6068F8C2A     MOV  BYTE PTR [8C8F],2A
  868.  
  869. :compare_byte
  870.  
  871.      803E8F8C2A     CMP  BYTE PTR [8C8F],2A
  872.  
  873.      7504           JNZ  after_ret
  874.  
  875.      B001           MOV  AL,01
  876.  
  877.      C3             RET
  878.  
  879. You should be enough crack-able ;=), by this lesson, to notice
  880.  
  881. immediately the inconsistency of the two successive instructions
  882.  
  883. MOV 2A and CMP 2A, coz there would be no sense in comparing the
  884.  
  885. "2A" in order to JNZ to after_ret if you just had the 2A set with
  886.  
  887. the precedent MOV instruction... but the first JNZ jumps to the
  888.  
  889. compare WITHOUT putting the "2A" inside. And "2A" is nothing else
  890.  
  891. as the "*" symbol, commonly used by programmer as "OK"! This
  892.  
  893. protection works in the following way (this is the above code
  894.  
  895. explained):
  896.  
  897. -    compare holy_location with 11
  898.  
  899. -    jump non zero to compare holy_loc with "*"
  900.  
  901. -    else call sniffing protection part
  902.  
  903. -    or al,al (al must be zero, else)
  904.  
  905. -    jump zero to compare holy_loc with "*"
  906.  
  907. -    if al was zero mov "*" inside holy_loc
  908.  
  909. -    compare holy_loc with "*"
  910.  
  911. -    if there is a difference then JNZ beggar_off_ugly_copier
  912.  
  913. -    else ret_ahead_nice_buyer
  914.  
  915. Now let's quickly crack it:
  916.  
  917. ------------------------------------------------
  918.  
  919. CRACKING GENERAL.EXE (by +ORC, January 1996)
  920.  
  921. ren general.exe general.ded
  922.  
  923. symdeb general.ded
  924.  
  925. -    s (cs+0000):0 Lffff 8C 11 75 0E
  926.  
  927. xxxx:yyyy           (this is the answer of the debugger)
  928.  
  929. -    e xxxx:yyyy+2  EB [SPACE] 09
  930.  
  931. -    w
  932.  
  933. -    q
  934.  
  935. ren general.ded general.exe
  936.  
  937. -------------------------------------------------
  938.  
  939. And in this way you changed the JNZ to the cmp "*" instruction
  940.  
  941. in a JMP to the mov "*" instruction. So no more nag screens, no
  942.  
  943. more protections... serene, placid, untroubled [general.exe].
  944.  
  945. Well, that's it for this lesson, reader. Not all lessons of my
  946.  
  947. tutorial are on the Web.
  948.  
  949.      You 'll obtain the missing lessons IF AND ONLY IF you mail
  950.  
  951. me back (via anon.penet.fi) with some tricks of the trade I may
  952.  
  953. not know that YOU discovered. Mostly I'll actually know them
  954.  
  955. already, but if they are really new you'll be given full credit,
  956.  
  957. and even if they are not, should I judge that you "rediscovered"
  958.  
  959. them with your work, or that you actually did good work on them,
  960.  
  961. I'll send you the remaining lessons nevertheless. Your
  962.  
  963. suggestions and critics on the whole crap I wrote are also
  964.  
  965. welcomed.
  966.  
  967.                                 E-mail +ORC
  968.  
  969.                         +ORC an526164@anon.penet.fi
  970.