home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / pc / crack / crak4.doc < prev    next >
Encoding:
Text File  |  2003-06-11  |  12.2 KB  |  312 lines

  1.  
  2. Chapter 4                               Cracking Self Booters
  3.  
  4.  
  5.  
  6.      -------------------------------------------------------------
  7.      Now we'll take a look at cracking self booters.  A few compa-
  8.      nies  have found this to be the best copy  protection  scheme
  9.      for them, one of which is DataEast, makers of Ikari Warriors,
  10.      Victory Road,  Lock-On, Karnov, etc...  This posses a special
  11.      problem  to the Amateur Cracker, since they seldom use  stan-
  12.      dard DOS formats.  So let's jump right in!
  13.      -------------------------------------------------------------
  14.  
  15.  
  16.      This  is the area where a "Higher than Normal"  knowledge  of
  17.      Assembly  Language and DOS Diskette structures,  so first  of
  18.      all, the Basic's.
  19.  
  20.  
  21.      The Disk's Physical Structure
  22.  
  23.      Data is recorded on a disk in a series of concentric circles,
  24.      called Tracks.   Each track if further divided into segments,
  25.      called  Sectors.   The  standard  double-density  drives  can
  26.      record  40 tracks of data, while the new quad-density  drives
  27.      can record 80 tracks.
  28.  
  29.      However, the location, size, and number of the sectors within
  30.      a  track are under software control.   This is why  the  PC's
  31.      diskettes are known as soft-sectored.  The characteristics of
  32.      a  diskette's sectors (Their size, and the number per  track)
  33.      are set when each track is formatted.  Disk Formatting can be
  34.      done either by the operating system or by the ROM-BIOS format
  35.      service.   A lot of self booters and almost all forms of copy
  36.      protection  create unusual formats via the ROM-BIOS  diskette
  37.      services.
  38.  
  39.      The  5 1/4-inch diskettes supported by the standard  PC  BIOS
  40.      may  have  sectors that are 128,256,512,  or 1,024  bytes  in
  41.      size.   DOS, from versions 1.00 through 4.01 has consistently
  42.      used sectors of 512 bytes, and it is quite possible that this
  43.      will continue.
  44.  
  45.      Here is a table displaying 6 of the most common disk formats:
  46.      _____________________________________________________________
  47.  
  48.      Type      Sides        Sectors       Tracks       Size(bytes)
  49.      _____________________________________________________________
  50.  
  51.       S-8        1             8            40            160K
  52.       D-8        2             8            40            320K
  53.       S-9        1             9            40            180K
  54.       D-9        2             9            40            360K
  55.      QD-9        2             9            80            720K
  56.      QD-15       2            15            80          1,200K
  57.      _____________________________________________________________
  58.  
  59.  
  60.  
  61.      S  - Single Density
  62.      D  - Double Density
  63.      QD - Quad Density
  64.  
  65.      Of all these basic formats,  only two are in widespread  use:
  66.      S-8  and D-9.   The newer Quad Density formats are for the  3
  67.      1/2" and 5 1/4" high density diskettes.
  68.  
  69.  
  70.      The Disk's Logical Structure
  71.  
  72.      So,  as we have already mentioned,  the 5  1/4-inch  diskette
  73.      formats have 40 tracks,  numbered from 0 (the outside  track)
  74.      through 39 (the inside track,  closest to the center).   On a
  75.      double  sided diskette,  the two sides are numbered 0  and  1
  76.      (the  two  recording heads of a double-sided disk  drive  are
  77.      also numbered 0 and 1).
  78.  
  79.      The BIOS locates the sectors on a disk by a three-dimensional
  80.      coordinate  composed of a track number (also referred  to  as
  81.      the  cylinder number),  a side number (also called  the  head
  82.      number),  and a sector number.  DOS,  on the other hand,  lo-
  83.      cates information by sector number,  and numbers the  sectors
  84.      sequentially from the outside to inside.
  85.  
  86.      We   can  refer  to  particular  sectors  either   by   their
  87.      three-dimensional  coordinates or by their sequential  order.
  88.      All ROM-BIOS operations use the three-dimensional coordinates
  89.      to locate a sector.  All DOS operations and tools such as DE-
  90.      BUG use the DOS sequential notation.
  91.  
  92.      The BASIC formula that converts the three-dimensional coordi-
  93.      nates  used by the ROM-BIOS to the sequential sector  numbers
  94.      used by DOS is as follows:
  95.  
  96.           DOS.SECTOR.NUMBER = (BIOS.SECTOR - 1) + DIOS.SIDE
  97.             * SECTORS.PER.SIDE + BIOS.TRACK * SECTORS.PER.SIDE
  98.             * SIDES.PER.DISK
  99.  
  100.      And  here are the formulas for converting  sequential  sector
  101.      numbers to three-dimensional coordinates:
  102.  
  103.           BIOS.SECTOR = 1 + DOS.SECTOR.NUMBER MOD SECTORS.PER.SIDE
  104.             BIOS.SIDE = (DOS.SECTOR.NUMBER \ SECTORS.PER.SIDE)
  105.             MOD SIDE.PER.DISK
  106.             BIOS.TRACK = DOS.SECTOR.NUMBER \ (SECTORS.PER.SIDE
  107.             * SIDES.PER.DISK)
  108.  
  109.           (Note:  For double-sided nine-sector diskettes, the PC's
  110.           most  common disk format, the value of  SECTORS.PER.SIDE
  111.           is  9 and the value of SIDES.PER.DISK is 2.   Also  note
  112.           that  sides and tracks are numbered differently  in  the
  113.           ROM-BIOS numbering system: The sides and tracks are num-
  114.           bered from 0, but the sectors are numbered from 1.)
  115.  
  116.      Diskette Space Allocation
  117.  
  118.      The  formatting  process divides the sectors on a  disk  into
  119.      four sections, for four different uses.  The sections, in the
  120.      order they are stored, are the boot record,  the file alloca-
  121.      tion  table (FAT),  the directory, and the data  space.   The
  122.      size of each section varies between formats,  but the  struc-
  123.      ture and the order of the sections don't vary.
  124.  
  125.           The Boot Record:
  126.  
  127.           This section is always a single sector located at sector
  128.      1 of track 0, side 0.  The boot record contains,  among other
  129.      things,  a short program to start the process of loading  the
  130.      operating system on it.   All diskettes have the boot  record
  131.      on them even if they don't have the operating system.  Asisde
  132.      from  the start-up program,  the exact contents of  the  boot
  133.      record vary from format to format.
  134.  
  135.           The File Allocation Table:
  136.  
  137.           The  FAT follows the boot record,  usually  starting  at
  138.      sector 2 of track 0,  side 0.   The FAT contains the official
  139.      record of the disk's format and maps out the location of  the
  140.      sectors used by the disk files.   DOS uses the FAT to keep  a
  141.      record of the data-space usage.  Each entry in the table con-
  142.      tains  a specific code to indicate what space is being  used,
  143.      what space is available,  and what space is unusable (Due  to
  144.      defects on the disk).
  145.  
  146.           The File Directory:
  147.  
  148.           The file directory is the next item on the disk.   It is
  149.      used  as a table of contents,  identifying each file  on  the
  150.      disk  with a directory entry that contains several pieces  of
  151.      information, including the file's name and size.  One part of
  152.      the entry is a number that points to the first group of  sec-
  153.      tors  used by the file (this number is also the  first  entry
  154.      for this file in the FAT).
  155.  
  156.           The Data Space:
  157.  
  158.           Occupies  the bulk of the diskette (from  the  directory
  159.      through the last sector),  is used to store data,  while  the
  160.      other  three  sections are used to support  the  data  space.
  161.      Sectors  in  the  data space are allocated  to  files  on  an
  162.      as-needed basis,  in units known as clusters.   The  clusters
  163.      are one sector long and on double-sided diskettes, they are a
  164.      pair of adjacent sectors.
  165.  
  166.  
  167.  
  168.      (From  here  on I'll continue to describe the basics  of  DOS
  169.      disk structures, and assembly language addressing technics.
  170.  
  171.  
  172.      -------------------------------------------------------------
  173.      Here  is a simple routine to just make a backup copy  of  the
  174.      Flight Simulator Version 1.0 by Microsoft.  I know the latest
  175.      version  is  3.x but this version will serve the  purpose  of
  176.      demonstrating  how to access the data and program files of  a
  177.      selfbooter.
  178.      -------------------------------------------------------------
  179.  
  180.  
  181.      By:            PTL
  182.      Title:         Microsoft Flight Simulator 1.00 Unprotect
  183.  
  184.  
  185.      This procedure will NOT convert the Flight Simulator disk  to
  186.      files  that can be loaded on a hard drive.   But...  it  will
  187.      read  off the data from the original and put it onto  another
  188.      floppy.  And this should give you an idea of how to read data
  189.      directly from a disk and write it back out to another disk.
  190.  
  191.      First of all take UNFORMATTED disk and place it in drive  B:.
  192.      This will be the target disk.
  193.  
  194.      Now  place your DOS disk (which has Debug) into drive A:,  or
  195.      just load Debug off you hard disk.
  196.  
  197.                     A>DEBUG
  198.  
  199.      Then  we  are going to enter (manually) a little  program  to
  200.      load the FS files off the disk.
  201.  
  202.                     -E CS:0000 B9 01 00 BA 01 00 BB 00
  203.                                01 0E 07 06 1F 88 E8 53
  204.                                5F AA 83 C7 03 81 FF 1C
  205.                                01 76 F6 B8 08 05 CD 13
  206.                                73 01 90 FE C5 80 FD 0C
  207.                                76 E1 90 CD 20
  208.  
  209.                     -E CS:0100 00 00 01 02 00 00 02 02 00 00 03 02
  210.                                00 00 04 02 00 00 05 02 00 00 06 02
  211.                                00 00 07 02 00 00 08 02
  212.  
  213.      Next we'll [R]eset the IP Register by typing.
  214.  
  215.                     -R IP
  216.  
  217.      And then typing four zeros after the address prefix.
  218.  
  219.                     xxxx:0000
  220.  
  221.      Next insert the original Flight Simulator disk into drive  A:
  222.      and we'll run our little loader.
  223.  
  224.                     -G =CS:0000 CS:22 CS:2A
  225.  
  226.      Now enter a new address to load from.
  227.  
  228.                     -E CS:02 0E
  229.                     -E CS:27 19
  230.  
  231.      And run the Loader again.
  232.  
  233.                     -G =CS:0000 CS:22 CS:2A
  234.  
  235.      New address
  236.  
  237.                     -E CS:02 27
  238.                     -E CS:27 27
  239.  
  240.      Run Loader
  241.  
  242.                     -G =CS:0000 CS:22 CS:2A
  243.  
  244.      Here  we'll  do some [L]oading directly from  the  disk  our-
  245.      selves.
  246.  
  247.                     -L DS:0000 0 0 40
  248.  
  249.      And the in turn, write it back out to the B: (1) drive
  250.  
  251.                     -W DS:0000 1 0 40
  252.  
  253.      Etc...
  254.  
  255.                     -L DS:0000 0 40 28
  256.                     -W DS:0000 1 70 30
  257.                     -L DS:0000 0 A0 30
  258.                     -W DS:0000 1 A0 30
  259.                     -L DS:0000 0 138 8
  260.                     -W DS:0000 1 138 8
  261.  
  262.      When  we are all through,  [Q]uit from debug and  you  should
  263.      have a backup copy of the Flight Simulator.
  264.  
  265.                     -Q
  266.  
  267.      And that's all there is to it.
  268.  
  269.      END.
  270.  
  271.  
  272.  
  273.  
  274.  
  275.             ///////////////////////////////////////////////////////
  276.             //               The PIRATES' HOLLOW                 //
  277.             //                  415-236-2371                     //
  278.             //         over 12 Megs of Elite Text Files          //
  279.             //                  ROR-ALUCARD                      //
  280.             //             Sysop: Doctor Murdock                 //
  281.             // C0-Sysops: That One, Sir Death, Sid Gnarly & Finn //
  282.             //                                                   //
  283.             //    "The Gates of Hell are open night and day;     //
  284.             //     Smooth is the Descent, and Easy is the way.." //
  285.             ///////////////////////////////////////////////////////
  286.  
  287.  
  288.  
  289.  
  290.  
  291. Which G-file (Q=Quit) ? 
  292.  
  293.  
  294.      Another file downloaded from:                     NIRVANAnet(tm)
  295.  
  296.      & the Temple of the Screaming Electron              415-935-5845
  297.      Just Say Yes                                        415-922-1613
  298.      Rat Head                                            415-524-3649
  299.      Cheez Whiz                                          408-363-9766
  300.      Reality Check                                       415-474-2602
  301.  
  302.    Specializing in conversations, obscure information, high explosives,
  303.        arcane knowledge, political extremism, diversive sexuality,
  304.        insane speculation, and wild rumours. ALL-TEXT BBS SYSTEMS.
  305.  
  306.   Full access for first-time callers.  We don't want to know who you are,
  307.    where you live, or what your phone number is. We are not Big Brother.
  308.  
  309.                          "Raw Data for Raw Nerves"
  310.  
  311.  
  312.