Video Screencast Help

Script That Downloads .JDB Automatically

Created: 20 Apr 2013 • Updated: 24 Apr 2013 | 6 comments
Darshan G. Parab's picture
+2 2 Votes
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 6 CommentsJump to latest comment

ℬrίαη's picture

Very nice, thanks for posting.

​​

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
hakeem.abdulkareem@gtbank.com's picture

Pls Darshan,can you please modify this to download from http instead of ftp. I need to do same thing but cant download via ftp.

http://www.symantec.com/security_response/definitions/download/detail.jsp?gid=sep

Pls revet. 

Thank you

0
Login to vote
Darshan G. Parab's picture

Hi Hakeem,

Soryy for delayed reply. I'm working on it. I'll revert back soon.

Thanks.

0
Login to vote
hakeem.abdulkareem@gtbank.com's picture

Dear Darshan,

I'm yet to get any feedback on this request.

However, after little modification to the script it's still didn't work as it came up with error messages.

Counting on your swift response.

Thank you.

0
Login to vote