echo off
echo.
echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
echo ³ Scan a zip file for viruses including execompressed files ³
echo ³ By Prof. Timo Salmi, ts@chyde.uwasa.fi, Sun 30-Aug-1992   ³
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
echo.

rem If no parameters then give the instructions
if "%1"=="" goto _help

rem First check that the zip file(s) exists
if not exist %1 goto _err1

rem Check that you have the drive r: available (I have r: as ramdisk)
if not exist r:\nul goto _err2

rem Check that the virus programs are available
if not exist c:\tools\scan.exe goto _err3
if not exist d:\virus\f-prot.exe goto _err4
if not exist d:\virus\sign.def goto _err5
if not exist d:\virus\virx.exe goto _novirx

rem Check that pkunzip.exe is available
if not exist c:\tools\pkunzip.exe goto _err6

rem Check that exeuncompressors are available
if not exist c:\tools\pklite.exe goto _err7
if not exist c:\box\boxtools\unlzexe.exe goto _err8
if not exist c:\box\boxtools\diet.exe goto _err9

rem Check that the ask.exe facility is available
set _found=
if exist ask.exe set _found=yes
for %%d in (%path%) do if exist %%d\ask.exe set _found=yes
for %%d in (%path%) do if exist %%dask.exe set _found=yes
if not "%_found%"=="yes" goto _err10

rem Make a temporary directory and ensure that it is empty
if not exist r:\tmp$$$\nul mkdir r:\tmp$$$
if exist r:\tmp$$$\*.* echo Delete all old files from r:\TMP$$$ directory
if exist r:\tmp$$$\*.* del r:\tmp$$$\*.*

rem Unzip all .exe, .com, overlay-files and embedded zips from the zipfile
c:\tools\pkunzip %1 *.exe *.com *.ov* *.zip r:\tmp$$$
if exist r:\tmp$$$\*.zip c:\tools\pkunzip r:\tmp$$$\*.zip r:\tmp$$$
if exist r:\tmp$$$\*.zip del r:\tmp$$$\*.zip
if errorlevel=1 goto _ziperror

rem Check for nasties with scan, first pass
if exist r:\tmp$$$\*.* scan /a r:\tmp$$$\*.* /nomem
if errorlevel=2 goto _scanerr
if errorlevel=1 goto _virus

rem Check for nasties with virx, first and only pass
:_ask_virx
ask Perform virx virus check (y/n)? /d /u
if errorlevel==89 if not errorlevel==90 goto _do_virx
if errorlevel==78 if not errorlevel==79 goto _do_fprot
goto _ask_virx
:_do_virx
if exist r:\tmp$$$\*.* d:\virus\virx -m -a -l -f -o r:\tmp$$$\*.*

rem Check for nasties with f-prot, first pass
:_do_fprot
if exist r:\tmp$$$\*.* d:\virus\f-prot r:\tmp$$$\*.* /all /nomem
:_ask_fprot
echo.
ask Next second pass, with expansion, continue (y/n)? /d /u
if errorlevel==89 if not errorlevel==90 goto _expand
if errorlevel==78 if not errorlevel==79 goto _rmdir
goto _ask_fprot

rem Expand execompressed files
:_expand
for %%f in (r:\tmp$$$\*.exe r:\tmp$$$\*.com) do c:\tools\pklite -x %%f
for %%f in (r:\tmp$$$\*.exe r:\tmp$$$\*.com) do c:\box\boxtools\diet -ra %%f
for %%f in (r:\tmp$$$\*.exe) do c:\box\boxtools\unlzexe %%f
if exist r:\tmp$$$\*.olz del r:\tmp$$$\*.olz

:_nounlzexe
rem Check for nasties with scan, second pass
if exist r:\tmp$$$\*.* scan /a r:\tmp$$$\*.* /nomem
if errorlevel=2 goto _scanerr
if errorlevel=1 goto _virus

rem Check for nasties with f-prot, second pass
if exist r:\tmp$$$\*.* d:\virus\f-prot r:\tmp$$$\*.* /all /nomem
goto _rmdir

:_virus
echo Viruses have been detected, batch terminated
echo The infected files remain in directory r:\TMP$$$
echo Take immediate measures to protect yourself
goto _out

rem Error in zipfile
:_ziperror
echo Error in .zip file, batch terminated

rem Remove the temporary directory and its files
:_rmdir
if not exist r:\tmp$$$\*.* goto _chdir
echo y | del r:\tmp$$$\*.* > nul
:_chdir
cd r:\
if exist r:\tmp$$$\nul rmdir r:\tmp$$$
goto _out

rem The instructions
:_help
echo Usage: SCANZ [ZipFileName]
echo.
echo You will need the following shareware and PD programs to use this batch.
echo They are available from good BBSes or from garbo.uwasa.fi by anonymous ftp.
echo    PKUNZIP.EXE from PKZ110.EXE or PKZ110EU.EXE
echo    SCAN.EXE from SCANV95.ZIP
echo    VIRX.EXE from VIRX23.ZIP
echo    F-PROT.EXE and its auxiliary files from FP-205.ZIP
echo    PKLITE.EXE from PKLTE115.EXE
echo    UNLZEXE.EXE from UNLZEXE7.ZIP
echo    DIET.EXE from DIET144.ZIP
echo    ASK.EXE from TSBAT37.ZIP
echo Before using this batch you have to edit all the directory paths of this
echo batch to correspond to your own configuration
echo (or adjust your configuration :-).
echo.
echo.
goto _out

:_err1
echo File %1 not found
goto _out

:_err2
echo Drive R: not found
echo Adjust your configuration or this batch
goto _out

:_err3
echo File c:\tools\scan.exe not found
goto _out

:_err4
echo File d:\virus\f-fchk.exe not found
goto _out

:_err5
echo File d:\tools\sign.txt not found
goto _out

:_novirx
echo File d:\virus\virx.exe not found
goto _out

:_err6
echo File c:\tools\pkunzip.exe not found
goto _out

:_err7
echo File c:\tools\pklite.exe not found
goto _out

:_err8
echo File c:\box\boxtools\unlzexe.exe not found
goto _out

:_err9
echo File c:\box\boxtools\diet.exe not found
goto _out

:_err10
echo Timo's ask.exe must be at path or current directory
goto _out

:_scanerr
echo Abnormal SCAN program termination
goto _out

:_out
set _found=
echo on
