home *** CD-ROM | disk | FTP | other *** search
- NAME:
- filecrc - calculate CRCs for all files on a disk.
-
- SYNOPSIS:
- filecrc [options]
-
- DESCRIPTION:
- This program calculates a CRC (cyclic redundancy check) for
- all the files on the disk, including "hidden" and "system"
- files. The CRCs are placed in a file (CHECK$$$.NEW) to be
- compared with the CRCs calculated at a previous time (in
- CHECK$$$.CRC). The comparison is done with the program
- COMPARE.
-
- By default, FILECRC checks all files on a disk. This takes on
- the order of 5 minutes for 20 MB. Options are available to
- check only certain classes of files (see below).
-
- Before starting, FILECRC calculates a CRC on its own executable
- file. If the file has been modified (as by a virus) the user
- is warned and may abort execution. The first time it is
- executed, it must write this CRC into the file.
-
- METHOD:
- Cyclic Redundancy Checks (CRCs) were designed to detect
- inadvertant changes to data, as during transmission over an
- imperfect communications link. If the change is made
- intentionally, as by a virus adding its own code to a victim
- program, it is relatively simple to ensure that any particular
- CRC is unchanged.
-
- One approach to improving detection would be to provide several
- CRC polynomials. Different users could use different
- polynomials, or different combinations of polynomials, for
- their checks. This would make intentional changes much harder
- to hide. Three "standard" CRC polynomials are listed in the
- FILECRC source code. However, good CRC polynomials are not
- easy to find.
-
- A second way to modify the procedure would be to initialize the
- remainder to some value other than zero. Note that the
- starting value is the CRC reported for a zero length file.
- FILECRC uses a third way of inserting unpredictability into the
- procedure.
-
- Conventionally, the CRC calculation is started at the beginning
- of a file with the remainder initialized to zero. FILECRC
- instead starts the calculation at an offset into the file and
- wraps around to the beginning of the file. The user picks a
- constant DEFAULT_OFFSET_DISTANCE which is compiled into the
- code. FILECRC reads the file length from the directory and
- calculates
-
- offset = file_length (mod DEFAULT_OFFSET_DISTANCE)
-
- or, using the C syntax,
-
- offset = file_length % DEFAULT_OFFSET_DISTANCE.
-
- Changing the offset also changes the calculated CRC.
-
- IMPLEMENTATION NOTES:
- Near the beginning of the source code, there is a group of
- seven #defines which can be customized by the user. The
- symbols, and the reasons for customizing each, are as follows:
-
- OFFSET_DISTANCE
- As discussed above, each different offset results in
- a different set of CRCs. This prevents a virus from
- compensating for its changes.
-
- FLAG1, FLAG2
- FILECRC uses these strings to find the customizable
- parameters and the record of its CRC in its own object
- code. If the virus could find these values it could
- compensate for its changes and even infect FILECRC
- itself.
-
- CRC_PROGRAM_NAME, COMPARE_PROGRAM_NAME
- Naturally, we don't want a virus to substitute its own
- version of one of these programs.
-
- CHECK_NEW, CHECK_CRC
- We also don't want the virus to be able to read and/or
- delete the file of previously calculated CRCs.
-
- Filenames can include volume and/or subdirectory names. The
- above parameters can also be changed at run time (see the -u
- switch below).
-
- The user may also want to change CRC polynomials. The present
- one is the same as that used in ARC and PKARC. (If you wish to
- confirm this, first set OFFSET_DISTANCE to zero.)
-
- FILECRC is set to automatically chain to COMPARE to automate
- the disk checking procedure. This can be turned off by
- deleting the lines:
-
- if(comparing_crc_files) /* Now compare this with the previous CRCs */
- exec(COMPARE_PROGRAM_NAME, conservative?"-c":"");
-
- at the end of main(), or by giving FILECRC the wrong name (or
- path) for the comparison program.
-
-
- OPTIONS:
- These command line switches may appear in any order, and may be
- combined:
-
- -e check executable files: .COM, .EXE, .BAT, and .SYS
- -h check "hidden" files
- -r check "read-only" files
- -s check "system" files
- -c Conservative checking: report changes to "hidden",
- "system", and "read-only" files to the screen. (This
- switch is actually passed on to COMPARE.)
- -u update crc offset and other parameters.
-
- EXAMPLES:
- filecrc would check all files.
- filecrc -er would check only executable and "read-only" files.
- filecrc -u would update parameters without checking any files.
-
- FILES:
- filecrc.c source code
- filecrc.exe object code
- CHECK$$$.CRC a existing set of file CRCs
- CHECK$$$.NEW a newly calculated set of file CRCs
-
- AUTHOR:
- This program was written by Ted H. Emigh -- emigh@ncsugn.uucp or
- NEMIGH@TUCC.BITNET
-
- It has been placed in the public domain, to be used at the user's
- discretion. The CRC routines and the discussion of the CRC were
- written by David Dantowitz, Digital Equipment Corporation,
- Dantowitz%eagle1.dec@decwrl.
-
- Modifications by Jim Van Zandt, August 1988...
- Translated from Pascal to C.
- Adapted assembly language code to the DeSmet C compiler.
- Calculating CRC starting at an offset into the file.
- Checking own object code before proceeding.
- Writing time and date of CRC check to output file.
- Implemented options for checking executable, system, hidden
- and/or read-only files.
- Drive to be checked need not be current drive.
- Parameters can be updated at run time.
-
- Please send comments to: jrv@mitre-bedford.arpa
-
-