Video Screencast Help

Script That Downloads .JDB Automatically

Created: 20 Apr 2013 • Updated: 24 Apr 2013 | 3 comments
Darshan G. Parab's picture
+1 1 Vote
Login to vote

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

 

---------------------------------------------------------------------------------------------------------------------------------------------

Comments 3 CommentsJump to latest comment

.Brian's picture

Very nice, thanks for posting.

Please click the "Mark as solution" link at bottom left on the post that best answers your question. This will benefit admins looking for a solution to the same problem.

0
Login to vote
Darshan G. Parab's picture

Thanks Brian.. :)

0
Login to vote
Darshan G. Parab's picture

Forgot one thing.. This scipt need Microsoft's FCIV tool to verify checksum. You can download the same from below mentioned link.

 

http://www.microsoft.com/en-in/download/details.aspx?id=11533

 

Save it in "%homedrive%\Windows\System32"

+1
Login to vote