One day, My boss came and told me that we need to keep the backup of .jdb files from symantec, so that in case we run into some disaster then we can use these files to restore definitions rather than syncing with Symantec and downloading entire distribution through internet. So I scripted the entire thing in powershell. Now I have scheduled this script in my desktop and twice a week I have the file in my harddisk.
Paste it in a text file and save it as .ps1 file.
---------------------------------------------------------------------------------------------------------------------------------
cls
[int]$dwcount = 0
################ Download JDB function definition #####################
function downloadjdb($dwdetails, $hashfile)
{
$dwdir = get-location
$weblink = "http://www.symantec.com/security_response/definitions/download/detail.jsp?gid=savce"
Write-output "Obtaining download details from $weblink"
Write-Output " "
$dwdetails = "$dwdir\details.txt"
$client = new-object System.Net.Webclient
$client.DownloadFile($weblink, $dwdetails)
$hashmd5 = "http://www.symantec.com/avcenter/download/md5-hash.txt"
$hashfile = "$dwdir\md5-hash.txt"
$client.DownloadFile($hashmd5, $hashfile)
$str = findstr ".jdb" $dwdetails
$data = $($str[1]).split("<")
$req = "$($data[3])"
$final = $req.split(">")
$jdbname = $($final[1])
$url="ftp://ftp.symantec.com/public/english_us_canada/antivirus_definitions/norton_antivirus/jdb/$jdbname"
Write-output "Downloading JDB from $url"
Write-output " "
$dest="$dwdir\$jdbname"
Write-Output "Saving to file $dest"
$client.DownloadFile($url, $dest) 2> $null
$detail = get-content $hashfile | findstr $jdbname
$symhash = $detail.split(" ")
fciv -md5 $dest | findstr .jdb | %{$filehash = $_.split(" ")}
if ($($symhash[0]) -eq $($filehash[0]))
{
Write-output "$jdbname download successful"
}
elseif ($dwcount -lt 3)
{
Write-Output "Downloading $jdbname unsuccessful. Attempting to download again...."
$dwcount=$dwcount+1
downloadjdb($dwdetails, $hashfile)
}
else
{
Write-Output "$jdbname cannot be downloaded..."
}
del $hashfile
del $dwdetails
}
#######################################################################
downloadjdb($dwdetails, $hashfile)
start-sleep 5
---------------------------------------------------------------------------------------------------------------------------------------------