@echo off
echo.
echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
echo ³ Virus testbench based on directory comparisons    ³
echo ³ By Prof. Timo Salmi, ts@uwasa.fi, Sat 19-Sep-1992 ³
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

if "%1"=="" goto _help

rem Do some housekeeping
if exist diffe.$$$ del diffe.$$$

rem Make an ex-ante directory for comparison. Add more directories
rem and files as you deem fit
dir *.* > tmp.$$$
if exist *.exe dir *.exe >> tmp.$$$
if exist *.com dir *.com >> tmp.$$$
type tmp.$$$ | find /v "bytes" | find /v "TMP      $$$" > before.$$$
if exist tmp.$$$ del tmp.$$$

rem Run the suspect program (at your own risk!)
set program_=
:_loop
set program_=%program_% %1
shift
if not "%1"=="" goto _loop
call %program_%

rem Make an ex-post directory for the comparison
dir *.* > tmp.$$$
if exist *.exe dir *.exe >> tmp.$$$
if exist *.com dir *.com >> tmp.$$$           
type tmp.$$$ | find /v "bytes" | find /v "BEFORE   $$$" | find /v "TMP      $$$" > after.$$$
if exist tmp.$$$ del tmp.$$$

rem Check for changes using the external MsDos fc.exe file compare and
rem MsDos find.exe text search utilities
fc after.$$$ before.$$$ > tmp.$$$
type tmp.$$$ | find "no differences encountered" > same.$$$
del tmp.$$$
if exist nodiffe.$$$ del nodiffe.$$$
copy same.$$$ nodiffe.$$$ > nul
if exist same.$$$ del same.$$$
if not exist nodiffe.$$$ goto _differ

rem No changes have occurred
echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
echo ³ The scanned directories and files have not been changed ³
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
goto _out

:_differ
fc before.$$$ after.$$$ > diffe.$$$
echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
echo ³ Warning: The scanned directories and files have been changed   ³
echo ³ See diffe.$$$ for details                                      ³
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
goto _out

:_help
echo.
echo Usage: VIRUS SuspectProgram [parameter1] [parameter2] [...]
echo.
echo This batch makes a directory both prior and after running the
echo suspect program, and gives a warning if the directories differ,
echo and prepares a list of the differences.
echo.
echo This batch can be also used by a knowledgeable user for the more
echo benevolent similar purpose of checking what files a certain programs
echo changes.
echo.
echo If you get an "Out of environment space" message, increase your
echo environment space by using shell configuration in config.sys:
echo MsDos 3.30 example: shell=c:\bin\command.com /e:1024 /p
goto _out2

:_out
if exist nodiffe.$$$ del nodiffe.$$$
if exist before.$$$ del before.$$$
if exist after.$$$ del after.$$$
:_out2
set program_=
echo on
