home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / trojanpr / file_crc.arc / FILECRC.DOC < prev    next >
Text File  |  1988-11-19  |  6KB  |  152 lines

  1. NAME:
  2.     filecrc - calculate CRCs for all files on a disk.
  3.  
  4. SYNOPSIS:
  5.     filecrc  [options]
  6.  
  7. DESCRIPTION:
  8.     This program calculates a CRC (cyclic redundancy check) for
  9.     all the files on the disk, including "hidden" and "system"
  10.     files.  The CRCs are placed in a file (CHECK$$$.NEW) to be
  11.     compared with the CRCs calculated at a previous time (in
  12.     CHECK$$$.CRC).  The comparison is done with the program
  13.     COMPARE.
  14.   
  15.     By default, FILECRC checks all files on a disk.  This takes on
  16.     the order of 5 minutes for 20 MB.  Options are available to
  17.     check only certain classes of files (see below).
  18.  
  19.     Before starting, FILECRC calculates a CRC on its own executable
  20.     file.  If the file has been modified (as by a virus) the user
  21.     is warned and may abort execution.  The first time it is
  22.     executed, it must write this CRC into the file.
  23.  
  24. METHOD:
  25.     Cyclic Redundancy Checks (CRCs) were designed to detect
  26.     inadvertant changes to data, as during transmission over an
  27.     imperfect communications link.  If the change is made
  28.     intentionally, as by a virus adding its own code to a victim
  29.     program, it is relatively simple to ensure that any particular
  30.     CRC is unchanged.  
  31.  
  32.     One approach to improving detection would be to provide several
  33.     CRC polynomials.  Different users could use different
  34.     polynomials, or different combinations of polynomials, for
  35.     their checks.  This would make intentional changes much harder
  36.     to hide.  Three "standard" CRC polynomials are listed in the
  37.     FILECRC source code.  However, good CRC polynomials are not
  38.     easy to find.  
  39.  
  40.     A second way to modify the procedure would be to initialize the
  41.     remainder to some value other than zero.  Note that the
  42.     starting value is the CRC reported for a zero length file. 
  43.     FILECRC uses a third way of inserting unpredictability into the
  44.     procedure.
  45.  
  46.     Conventionally, the CRC calculation is started at the beginning
  47.     of a file with the remainder initialized to zero.  FILECRC
  48.     instead starts the calculation at an offset into the file and
  49.     wraps around to the beginning of the file.  The user picks a
  50.     constant DEFAULT_OFFSET_DISTANCE which is compiled into the
  51.     code.  FILECRC reads the file length from the directory and
  52.     calculates 
  53.  
  54.         offset = file_length (mod DEFAULT_OFFSET_DISTANCE)
  55.  
  56.     or, using the C syntax, 
  57.  
  58.         offset = file_length % DEFAULT_OFFSET_DISTANCE.  
  59.  
  60.     Changing the offset also changes the calculated CRC.
  61.  
  62. IMPLEMENTATION NOTES:
  63.     Near the beginning of the source code, there is a group of
  64.     seven #defines which can be customized by the user.  The
  65.     symbols, and the reasons for customizing each, are as follows:
  66.  
  67.     OFFSET_DISTANCE
  68.         As discussed above, each different offset results in
  69.         a different set of CRCs.  This prevents a virus from
  70.         compensating for its changes.
  71.  
  72.     FLAG1, FLAG2
  73.         FILECRC uses these strings to find the customizable
  74.         parameters and the record of its CRC in its own object
  75.         code.  If the virus could find these values it could
  76.         compensate for its changes and even infect FILECRC
  77.         itself.
  78.  
  79.     CRC_PROGRAM_NAME, COMPARE_PROGRAM_NAME
  80.         Naturally, we don't want a virus to substitute its own
  81.         version of one of these programs.
  82.  
  83.     CHECK_NEW, CHECK_CRC
  84.         We also don't want the virus to be able to read and/or
  85.         delete the file of previously calculated CRCs.
  86.  
  87.     Filenames can include volume and/or subdirectory names.  The
  88.     above parameters can also be changed at run time (see the -u
  89.     switch below).
  90.  
  91.     The user may also want to change CRC polynomials.  The present
  92.     one is the same as that used in ARC and PKARC.  (If you wish to
  93.     confirm this, first set OFFSET_DISTANCE to zero.)
  94.  
  95.     FILECRC is set to automatically chain to COMPARE to automate
  96.     the disk checking procedure.  This can be turned off by
  97.     deleting the lines:
  98.  
  99.     if(comparing_crc_files)  /* Now compare this with the previous CRCs */
  100.         exec(COMPARE_PROGRAM_NAME, conservative?"-c":"");
  101.  
  102.     at the end of main(), or by giving FILECRC the wrong name (or
  103.     path) for the comparison program.
  104.  
  105.  
  106. OPTIONS:
  107.     These command line switches may appear in any order, and may be
  108.     combined:
  109.  
  110.     -e    check executable files: .COM, .EXE, .BAT, and .SYS
  111.     -h    check "hidden" files
  112.     -r    check "read-only" files
  113.     -s    check "system" files
  114.     -c    Conservative checking: report changes to "hidden",
  115.         "system", and "read-only" files to the screen.  (This
  116.         switch is actually passed on to COMPARE.)
  117.     -u    update crc offset and other parameters.
  118.  
  119. EXAMPLES:
  120.     filecrc           would check all files.
  121.     filecrc -er       would check only executable and "read-only" files.
  122.     filecrc -u        would update parameters without checking any files.
  123.  
  124. FILES:
  125.     filecrc.c    source code
  126.     filecrc.exe    object code
  127.     CHECK$$$.CRC    a existing set of file CRCs
  128.     CHECK$$$.NEW    a newly calculated set of file CRCs
  129.  
  130. AUTHOR:
  131.     This program was written by Ted H. Emigh -- emigh@ncsugn.uucp or
  132.     NEMIGH@TUCC.BITNET
  133.  
  134.     It has been placed in the public domain, to be used at the user's
  135.     discretion.  The CRC routines and the discussion of the CRC were
  136.     written by David Dantowitz, Digital Equipment Corporation,
  137.     Dantowitz%eagle1.dec@decwrl.
  138.  
  139.     Modifications by Jim Van Zandt, August 1988...
  140.         Translated from Pascal to C.
  141.         Adapted assembly language code to the DeSmet C compiler.
  142.         Calculating CRC starting at an offset into the file.
  143.         Checking own object code before proceeding.
  144.         Writing time and date of CRC check to output file.
  145.         Implemented options for checking executable, system, hidden
  146.             and/or read-only files.
  147.         Drive to be checked need not be current drive.
  148.         Parameters can be updated at run time.
  149.  
  150.     Please send comments to: jrv@mitre-bedford.arpa
  151.  
  152.