home *** CD-ROM | disk | FTP | other *** search
- {$I-}
- {
- testvir.pas
- Stealth Bomber Version 2.2
-
- Kevin Dean
- Fairview Mall P.O. Box 55074
- 1800 Sheppard Avenue East
- Willowdale, Ontario
- CANADA M2J 5B9
- CompuServe ID: 76336,3114
-
- February 10, 1992
-
- This program demonstrates the anti-virus CRC algorithm in
- VIRCHECK.PAS. The response to error codes is entirely up to the programmer.
-
- To set the CRC for this program and its supporting files, the command
- is:
-
- crcset -p testvir.exe vircheck.tpu -d crc.dat vircheck.pas
-
- This code is public domain.
- }
-
-
- program TestVIR;
-
-
- uses
- DOS, VirCheck;
-
-
- const
- FN : array [1 .. 3] of string[12] =
- (
- 'TESTVIR.EXE', 'VIRCHECK.TPU', 'VIRCHECK.PAS'
- );
-
- { Normally this would be defined by changing StealthNFiles in VIRUSDAT.PAS to
- 3; it has not been done that way for this program as this is a sample file
- only. }
- _FCRC : array [1 .. 3] of FileCRC =
- (
- (
- SearchStr : ('_', 'S', 'T', 'E', 'A', 'L', 'T', 'H')
- ),
- (
- SearchStr : (' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ')
- ),
- (
- SearchStr : (' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ')
- )
- );
-
-
- {$F+}
- {***}
- { Override default handling of memory allocation errors (see chapter 15 - Inside Turbo Pascal). }
- function HeapFunc(Size : word) : integer;
-
- begin
- HeapFunc := 1;
- end;
- {$F-}
-
-
- var
- SysResult : word;
- FileResult : word;
- ErrFound : boolean;
- CRCFile : file of FileCRC;
- I : integer;
-
-
- begin
- HeapError := @HeapFunc;
-
- ErrFound := false;
-
- { Check system. }
- SysResult := StealthSysCheck;
-
- if SysResult and StealthIntrErr <> 0 then
- begin
- WriteLn('System interrupts have been set beyond current code space. This may indicate');
- WriteLn('the presence of a virus in system memory.');
- end;
- if SysResult and StealthDOSMemErr <> 0 then
- begin
- WriteLn('Memory reported by DOS is inconsistent with memory reported by BIOS. This may');
- WriteLn('inidicate the presence of a virus in system memory.');
- end;
- if SysResult and StealthDOSHijacked <> 0 then
- begin
- WriteLn('A DOS interrupt has been covertly redirected by another program. This may');
- WriteLn('inidicate the presence of a virus in system memory.');
- end;
- if SysResult <> StealthOK then
- begin
- WriteLn;
- ErrFound := true;
- end;
-
- Assign(CRCFile, 'CRC.DAT');
- Reset(CRCFile);
- if IOResult = 0 then
- begin
- Read(CRCFile, _FCRC[3]);
- Close(CRCFile);
- end
- else
- WriteLn('Error opening CRC.DAT file.');
-
- for I := 1 to 3 do
- begin
- if (I <> 1) or (Lo(DOSVersion) < 3) then
- FileResult := StealthFileCheck(FN[I], _FCRC[I])
- else
- FileResult := StealthFileCheck(ParamStr(0), _FCRC[I]);
-
- if FileResult and StealthFileErr <> 0 then
- WriteLn('Error accessing ', FN[I], ' for CRC check.');
- if FileResult and StealthFileDateErr <> 0 then
- begin
- WriteLn('Date stamp error on file ', FN[I], '. This may indicate the presence of a');
- WriteLn('virus in the file. Please take appropriate steps to secure your computer from');
- WriteLn('further possible infection.');
- end;
- if FileResult and StealthFileSizeErr <> 0 then
- begin
- WriteLn('File size error on file ', FN[I], '. This may indicate the presence of a');
- WriteLn('virus in the file. Please take appropriate steps to secure your computer from');
- WriteLn('further possible infection.');
- end;
- if FileResult and (StealthCRCBadPoly or StealthCRCInvalid) <> 0 then
- begin
- WriteLn('CRC error on file ', FN[I], '. This file has been tampered with and may be');
- WriteLn('infected by a computer virus. Please take appropriate steps to secure your');
- WriteLn('computer from further possible infection.');
- end;
- if FileResult and StealthNoMem <> 0 then
- WriteLn('Insufficient memory to run CRC check on file ', FN[I], '.');
- if FileResult <> 0 then
- begin
- WriteLn;
- ErrFound := true;
- end;
- end;
-
- if not ErrFound then
- WriteLn('No viruses found.');
- end.
-