McAfee setup for XWall

with improved reliability

The McAfee update may fail on occasions. We had the problem occur on our XWall installation this past June. We were running the McAfee autoupdate process on our XWall server every hour. In talking to McAfee technical support, they recommended not running the autoupdate process this frequently. To get around this problem I wrote a vbs script to perform the dat update instead of replying on the McAfee's autoupdate process.

by Joe Gasper, a senior advisor on the Ceratec XWall Forum

I like to use the daily DATs (sometimes several per day) from McAfee for use with XWall (ePO manages the DATs for Exchange using the standard DATs). It keeps XWall's anti-virus skills bleeding edge, while Exchange runs with the "production" DATs. I get them from here: http://vil.nai.com/vil/virus-4d.asp

I check that McAfee web page hourly to see if there's a new beta DAT out, then initiate a download only when there's been an update. This keeps the downloads to a minimum. I had been downloading the DATs every 4 hrs all the time for the last few months without problems, but Michael's setup got me to rewrite my code to be more net-friendly :-) Feel free to use at your own risk my code below (you'll need to install 2 free controls, one for unzipping, one for reading a web page).


code:

'Author: Joe Gasper - joegasper@hotmail.com
'Version: 1.10
'Purpose: Download NAI Daily Dat files from http://vil.nai.com/vil/virus-4d.asp
'Uses free ActiveX control for unzipping:
' http://xstandard.com/ (or could use cli unzipper)

'Uses free AspTear for checking updated DATs:
' http://www.alphasierrapapa.com/IisDev/Components/AspTear/

Dim strRemoteFile 'Remote file to download, URL format.
Dim strLocalFile 'Local file path and name to save remote file to.

strLocalPath = "c:\xwall\av\"
strLocalFile = "win_netware_betadat.zip"
strRemoteFile = "http://download.nai.com/products/mcafee-avert/beta_packages/win_netware_betadat.zip"

'Begin Main

If isNewFile Then
saveBinaryFile strLocalFile, getBinaryURL(strRemoteFile)
unZip strLocalPath, strLocalFile
End If

'End Main


Function getBinaryURL(URL)
Dim objHTTP
' Too many choices, one of these should work right?
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
' Set objHTTP = CreateObject("WinHttp.WinHttpRequest")
' Set objHTTP = CreateObject("Microsoft.XMLHTTP")
' Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objHTTP.Open "GET", URL, False
objHTTP.Send
getBinaryURL = objHTTP.ResponseBody
End Function

Sub saveBinaryFile(FileName, ByteArray)
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = adTypeBinary
BinaryStream.Open
BinaryStream.Write ByteArray
BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
End Sub

Sub unZip(FilePath, FileName)
Set objZip = CreateObject("XStandard.Zip")
objZip.UnPack FilePath & FileName, FilePath
Set objZip = Nothing
End Sub

Function isNewFile()
Dim strSiteCheck, objTear, strSiteHTML, intFindDate, dtmUpdated, strSearchText

strSiteCheck = "http://vil.nai.com/vil/virus-4d.asp"
strSearchText = " PT"

Set objTear = CreateObject("SOFTWING.ASPtear")

On Error Resume Next
' URL, action, payload, username, password
strSiteHTML = objTear.Retrieve(strSiteCheck, 2, "", "", "")
dtmInstalled = CDate(getInstalledDATdate)
If Err.Number <> 0 Then
isNewFile = True 'fail-safe
logError
Else
intFindDate = InStr(1, strSiteHTML, strSearchText, vbBinaryCompare)
dtmUpdated = CDate(Trim(Mid(strSiteHTML, intFindDate - 16, 16)))
If dtmUpdated = dtmInstalled Then
isNewFile = False
Else
isNewFile = True
setInstalledDATdate(dtmUpdated)
End If
End If

Set objTear = Nothing
End Function

Function getInstalledDATdate
Const ForReading = 1, CreateIfNotExist = True
Dim fso, f, d, dtmFailSafe
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("InstalledDATDate.txt", ForReading, CreateIfNotExist)
If NOT f.AtEndOfStream Then
d = CDate(f.ReadLine)
If IsDate(d) Then
getInstalledDATdate = CDate(d)
Else
getInstalledDATdate = #1/1/2004 12:00# 'fail-safe
logError
End If
Else
getInstalledDATdate = #1/1/2004 12:00# 'fail-safe
End If
f.Close
Set f = Nothing
End Function

Function setInstalledDATdate(dtmDate)
Const ForWriting = 2, CreateIfNotExist = True
Dim fso, f, d
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("InstalledDATDate.txt", ForWriting, CreateIfNotExist)
f.Write(dtmDate)
f.Close
Set f = Nothing
End Function

Function logError
Const ForAppending = 8, CreateIfNotExist = True
Dim fso, f, d
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("DATupdateError.txt", ForAppending, CreateIfNotExist)
f.WriteLine(Now())
f.Close
Set f = Nothing
End Function

'Code if you want to use a CLI unzipper:
Sub unZipFileCLI(zipFile)
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "c:\xwall\av\unzip.exe -oq " & zipFile, 0, true
End Sub