Jump to content
Sign in to follow this  
iceberg

Symantec Anti Virus

Recommended Posts

iceberg

#include <Date.au3>

Global $url, $now

Check()

Func Check()
    $sNewDate = _DateAdd('D', 0, _NowCalcDate())
    $date = StringRegExpReplace($sNewDate, "/", "")
    $i = 1
    While $i <= 9
        $url = "http://definitions.symantec.com/defs/" & $date & "-00" & $i & "-i32.exe"
        $size = InetGetSize($url)
        If $size > 1048576 Then
            If $date & "-00" & $i & "-i32.exe" <> IniRead("C:\sav.ini", "date", "1", "NotFound") Then
                InetGet($url, @DesktopDir & "\" & $date & "-00" & $i & "-i32.exe", 1, 1)
                $now = "Today's"
                Show()
                FileDelete("c:\sav.ini")
                IniWrite("c:\sav.ini", "date", "1", $date & "-00" & $i & "-i32.exe")
                If FileExists(@DesktopDir & "\" & $date & "-00" & $i & "-i32.exe") Then RunWait(@DesktopDir & "\" & $date & "-00" & $i & "-i32.exe")
                Exit
            EndIf
        Else
            $i = $i + 1
        EndIf
    WEnd

    $sNewDate2 = _DateAdd('D', -1, _NowCalcDate())
    $date2 = StringRegExpReplace($sNewDate2, "/", "")
    $j = 1
    While $j <= 9
        $url = "http://definitions.symantec.com/defs/" & $date2 & "-00" & $j & "-i32.exe"
        $size2 = InetGetSize($url)
        If $size2 > 1048576 Then
            If $date2 & "-00" & $j & "-i32.exe" <> IniRead("c:\sav.ini", "date", "1", "NotFound") Then
                InetGet($url, @DesktopDir & "\" & $date2 & "-00" & $j & "-i32.exe", 1, 1)
                $now = "Yesterday's"
                Show()
                FileDelete("c:\sav.ini")
                IniWrite("c:\sav.ini", "date", "1", $date2 & "-00" & $j & "-i32.exe")
                If FileExists(@DesktopDir & "\" & $date2 & "-00" & $j & "-i32.exe") Then RunWait(@DesktopDir & "\" & $date2 & "-00" & $j & "-i32.exe")
                Exit
            EndIf
        Else
            $j = $j + 1
        EndIf
    WEnd

EndFunc  ;==>Check

Func Show()
    While @InetGetActive
        $fSize = Round((InetGetSize($url) / 1048576), 2)
        $fRead = Round((@InetGetBytesRead / 1048576), 2)
        $fCent = Round((($fRead / $fSize) * 100), 0)
        TrayTip("Downloading " & $now, $fRead & " of " & $fSize & "MB (" & $fCent & "%)", 10, 16)
        Sleep(250)
    WEnd
EndFunc  ;==>Show

take note...this only downloads the i32.exe versions. feel free to modify the codes according to your needs. some of my client pc do not receive the updates from the server periodically. as such i thought of this method to download the files and distribute manually as LiveUpdate is blocked.

comments and suggestions welcome.


mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites
rajeshontheweb

i will dig out the source code i use for installing those files.

as u seem to be versed with symantec update distro, u might have noticed if the user tries to install older version it would still install the old updates over new ones. so what i had done was to detect ur local pc's update versions (yes , it is possible i will post the information in a day or two ) and proceed with update ...

this is really a good one..

Share this post


Link to post
Share on other sites
urie

Here is one i use that someone over on MSFN done.

; -------------------------------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author: PaulIA
;
; Script Function: Download latest Intelligent Updater from Symantec
;
; -------------------------------------------------------------------------------------------------

; Initialize status messages
SplashTextOn("[Status]", "Initializing...", 500, 60, -1, @DesktopHeight/6, 1, "", 12, 600)

; As it turns out, Symantec has a file called md5-hash.txt on their web site that contains  all  of
; the MD5 hash information for the files on their site.  I could care less about the hash info, but
; the file has a list of all of the files on the FTP site, which is what I'm after.
gpDownload("md5-hash.txt", "md5-hash.txt")

; Open hash file
$File = FileOpen(@ScriptDir & "\md5-hash.txt", 0)
if $File = -1 then
  MsgBox(16 + 4096, "Error", "Unable to open hash file")
  Exit
endif

; Parse hash file
$FileName = ""
$Last    = ""
while 1
  $Line = FileReadLine($File)
  if @error = -1 then ExitLoop

; Check for comment
  if StringMid($Line, 1, 1) = "#" then ContinueLoop

; Strip MD5 hash value
  $N = StringInStr($Line, " ")
  if $N = 0 then ContinueLoop
  $Line = StringMid($Line, $N + 1)

; Make sure the file starts with the current year
  if StringMid($Line, 1, 4) <> @Year then ContinueLoop

; Make sure we're looking at the x86 installer
  if StringInStr($Line, "-x86.exe") = 0 then ContinueLoop

; Extract date and compare to Last
  $Date = StringMid($Line, 1, 12)
  if $Date < $Last then ContinueLoop
  $FileName = StringStripWS($Line, 3)
  $Last  = $Date
wend

; Close hash file
FileClose($File)

; Failsafe check
if $FileName = "" then
  MsgBox(16 + 4096, "Error", "Unable to parse hash file")
  Exit
endif

; Get latest intelligent updater.  You can change the second $FileName
; to a constant value if you want to be able to use the same file name
; in your UA script. I left the file name as it is on the FTP site for
; testing purposes.
gpDownload($FileName, $FileName)

; Install the update
RunWait(@ScriptDir & "\" & $FileName & " /q", @ScriptDir)

; Hide status messages
SplashOff()

Exit

; -------------------------------------------------------------------------------------------------
; gpDownload                    : Download a file from Symantec
; -------------------------------------------------------------------------------------------------
Func gpDownload($FTP, $Local)
; Build URL
  $URL = "ftp://ftp.symantec.com/AVDEFS/norton_antivirus_corp/" & $FTP

; Download file with feedback
  InetGet($URL, @ScriptDir & "\" & $Local, 1, 1)
  while @InetGetActive
    ControlSetText("[Status]", "", "Static1", @CR & "Downloading: " & @InetGetBytesRead)
    Sleep(250)
  wend

  if @InetGetBytesRead = -1 then
    MsgBox(16 + 4096, "Error", "Unable to download file from Symantec")
    Exit
  endif
EndFunc

you can rem this part out if you dont want it to install the update

; Install the update

RunWait(@ScriptDir & "\" & $FileName & " /q", @ScriptDir)

Share this post


Link to post
Share on other sites
rajeshontheweb

hmmm, something similar is what i have been working on. i have seen another thread which uses the FTP location. i am gonna use both file names and MD5 just to ensure the download was complete. onething is that i didnt realise FTP also works well with (does it?) with INetGet, i thought i should be using FTP udfs available here, Symantec FTP Servers allow anonymous login

  • My current plan:
  • Use The MD5 Hash information file to check for file name
  • Check local PC for last installed version
  • Download the remote file and save it in a common folder (which will be checked before downloading next update)
  • If download is interrupted, delete local file preferably..(will work on resume partial download later in future)
  • Check for file integrity (using MD5 Hash)
  • before installing the update, ensure local update version is lesser than the available downloaded version and proceed.
  • The Intelligent updater file has a command line option to extract data to temp folder and then install the updates , try to use it and install the updates just in case the user might have some different config , let the user run the update using runwait.
Edited by rajeshontheweb

Share this post


Link to post
Share on other sites
rajeshontheweb

though very primitive, this is how i would use the script you have posted, urie.

; -------------------------------------------------------------------------------------------------
;~ http://www.autoitscript.com/forum/index.php?showtopic=93773
;
; AutoIt Version: 3.3.0
; Author: PaulIA
; Modified: Rajesh V R
;
; Script Function: Download latest Intelligent Updater from Symantec
;
; -------------------------------------------------------------------------------------------------

; Initialize status messages
;~ SplashTextOn("[Status]", "Initializing...", 500, 60, -1, @DesktopHeight/6, 1, "", 12, 600)
ProgressOn("Symantec Update Downloader","","",-1,-1,16) ; i like the splash screen movable 

; As it turns out, Symantec has a file called md5-hash.txt on their web site that contains  all  of
; the MD5 hash information for the files on their site.  I could care less about the hash info, but
; the file has a list of all of the files on the FTP site, which is what I'm after.


gpDownload("md5-hash.txt", "md5-hash.txt")

; Open hash file
$File = FileOpen(@ScriptDir & "\md5-hash.txt", 0)
if $File = -1 then
  MsgBox(16 + 4096, "Error", "Unable to open hash file")
  Exit
endif

; Parse hash file
$FileName = ""
$Last     = ""
while 1
  $Line = FileReadLine($File)
  if @error = -1 then ExitLoop

; Check for comment
  if StringMid($Line, 1, 1) = "#" then ContinueLoop

; Strip MD5 hash value
  $N = StringInStr($Line, " ")
  if $N = 0 then ContinueLoop
  $Line = StringMid($Line, $N + 1)

; Make sure the file starts with the current year
  if StringMid($Line, 1, 4) <> @Year then ContinueLoop

; Make sure we're looking at the x86 installer
  if StringInStr($Line, "-x86.exe") = 0 then ContinueLoop

; Extract date and compare to Last
  $Date = StringMid($Line, 1, 12)
  if $Date < $Last then ContinueLoop
  $FileName = StringStripWS($Line, 3)
  $Last     = $Date
wend

; Close hash file
FileClose($File)

; Failsafe check
if $FileName = "" then
  MsgBox(16 + 4096, "Error", "Unable to parse hash file")
  Exit
endif

; Get latest intelligent updater.  You can change the second $FileName
; to a constant value if you want to be able to use the same file name
; in your UA script. I left the file name as it is on the FTP site for
; testing purposes.
gpDownload($FileName, $FileName)

; Install the update
RunWait(@ScriptDir & "\" & $FileName & " /q", @ScriptDir)

; Hide status messages
;~ SplashOff()
Progressoff()
Exit

; -------------------------------------------------------------------------------------------------
; gpDownload                    : Download a file from Symantec
; -------------------------------------------------------------------------------------------------
Func gpDownload($FTP, $Local)
; Build URL
  $URL = "ftp://ftp.symantec.com/AVDEFS/norton_antivirus_corp/" & $FTP
    ConsoleWrite("downloading "& $URL &@CRLF)

ProgressSet(0,"Retrieving file info..","Downloading " & _GetNameFromINetPath($URL))


$FileSize = InetGetSize($URL) 
; Download file with feedback
  InetGet($URL, @ScriptDir & "\" & $Local, 1, 1)
  
  while @InetGetActive
    $percent = Round(@InetGetBytesRead/$FileSize *100,2)
    $completed = Round( @InetGetBytesRead/1024,2)  & " KB of " & Round($FileSize/1024,2) & " KB " 
    ConsoleWrite(@TAB & $percent & " % complete " & $completed & @CRLF )
    ProgressSet($percent,$completed,"Downloading " & _GetNameFromINetPath($URL))
;~     ControlSetText("[Status]", "", "Static1", @CR & "Downloading: " & @InetGetBytesRead)
    Sleep(250)
  wend

  If @InetGetBytesRead = -1 then
    MsgBox(16 + 4096, "Error", "Unable to download file from Symantec")
    Exit
  endif
EndFunc


Func _GetNameFromINetPath($FullPath)
; Version 1 created 29 Apr 2008
; Purpose : Get File Name only from a full Internet path given
; based on _GetNameFromPath of Dec 2008
; Usage: GetNameFromPath(Full File name with path) will return only the file or folder name at the end 

    Local $DirLen , $FindSlash, $FName

    ; Clear Trailing Slash "\" if it is a directory
    If StringRight($FullPath,1) = "/" Then $FullPath = StringTrimRight($FullPath,1)

    $DirLen = StringLen($FullPath)
    $FindSlash = StringInStr( $FullPath, "/" ,0 , -1 )
    $FName = StringRight($FullPath ,$DirLen - $FindSlash)
    
    IF @ERROR Then Exit 
    Return $FName 

EndFunc

Share this post


Link to post
Share on other sites
iceberg

thanks for the comments guys!

you can try this for reading current def files on local pc

IniRead("C:\Program Files\Common Files\Symantec Shared\VirusDefs\definfo.dat", "DefDates", "CurDefs", "NotFound")

Edited by iceberg

mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites
sbranky

Thank you gentlemen for scripts, but I have a need. Sorry primarily for my bad English.

It would be ok but the first script does not have the resume function, very important for slow connections, the script of rajeshontheweb it seems to me that it includes, but being in the proxy can not get to the ftp site of Symantec, you can adjust for a replic Http site internal at my network?

I tried unsuccessfully a number of changes, is very attractive to update my server inside my network, but the manager does not allow external FTP connections, but provides the new definitions on an internal website. Thank you

Oh sorry, not the network provider provides the md5-file hash.txt

Edited by sbranky

Share this post


Link to post
Share on other sites
rajeshontheweb

actually that was the reason i had deviced the udf this udf (as long as you can access the md5-file hash.txt will provide you with an array of files containing

If $FileList = _GetSymantecFileList()
$FileList[0][1] & $FileList[1][0] is the http download location for the file 
$FileList[1][1] contains its MD5 Hash

check the latest version of the UDF i have included an example to demonstrate this..

PS: IF the md5-hash file.txt is available to you locally, just modify the script a little bit.

Edited by rajeshontheweb

Share this post


Link to post
Share on other sites
yuxian25

hi guys. i am new into scripting.

i would like to use the script to download the AV files and save it in a specific location. what do i have to add in?

Do i run the codes in a .bat file?

Share this post


Link to post
Share on other sites
rajeshontheweb

unless its pertaining tothis thread, it is advisable u open up a seperate thread for your query. it makes it easier.

1) get a new thread opened, refer to this thread if it is relevant to your issue.

2) try the code given here, if it works for you well n good if u need modifications to it or need help customising it, making it work your way, etc continue this thread itself.

3) you might be a newbie, but you are welcome with hands wide spread when u start coding yourself. a blunt question may not welcome replies but a small piece of code that shows ur interest, trials will make it more responsive. help is availabel here, but the more you show ur efforts the better response u get.

now, u said AV explain it a bit better pls. if it is general then open a new thread, if u are talking about the script sample posted here, then try something in ur direction (help file is ur best friend) and u will get help here.

Share this post


Link to post
Share on other sites
Wooltown

Nice idea, I used it in an environment where the computers have limited internet access.

I download from a computer that can reach internet 06:00 in the morning.

At 06:30 the clients extracts the virus definitions and then stops and starts the AV progran

Edited by Wooltown

Share this post


Link to post
Share on other sites
Wooltown

Made it faster, download it to a server location, then I have a script that will update all clients (these clients are not connected to the Internet)

The Download script is scheduled on download PC to 06:00 am

Update Script will start at logon and then 06:30 am every morning

Download script

#AutoIt3Wrapper_Change2CUI=Y
#include <Date.au3>
#include <Process.au3>
#include <Constants.au3>
#include <IE.au3>
Opt("TrayIconDebug", 1)
Opt("MustDeclareVars", 1)   
; ***************************************************************************************************
; * Download the latest Anti-Virus definitions from Symantec.  2009-07-17                           *
; ***************************************************************************************************
CleanOldFiles()

If Check(_DateAdd('D', 0, _NowCalcDate())) Then Exit
Check(_DateAdd('D', -1, _NowCalcDate()))

Func CleanOldFiles()
    Local $sFile, $hFilesToFind = FileFindFirstFile("\\server\share\TV-BR_RegTest\Installer\Symantec_AVdefs\20*.exe")
    While 1
        $sFile = FileFindNextFile ( $hFilesToFind )
        If @ERROR Then ExitLoop
        If _DateDiff("D", StringLeft($sFile,4) & "/" & StringMid($sFile,5,2) & "/" & StringMid($sFile,7,2) ,@YEAR & "/" & @MON & "/" & @MDAY) > 10 Then FileDelete("R:\Installer\Symantec_AVdefs\" & $sFile)
    WEnd
    FileClose($hFilesToFind)
EndFunc

Func Check($sNewDate)
    Local $sAVfile, $sUrl, $iSize, $oElements
    Local $date = StringRegExpReplace($sNewDate, "/", "")
    Local $oIE = _IECreate ("http://definitions.symantec.com/defs/", 0, 0, 0)
    Sleep(3000)
    $oElements = _IETagNameGetCollection  ($oIE,"A")
    For $oElement In $oElements
        $sAVfile = StringReplace($oElement.innerText," ","")
        If StringInStr($sAVfile,$date & "-") > 0 And StringInStr($sAVfile,"-i32.exe") > 0 Then
            $sUrl = "http://definitions.symantec.com/defs/" & $sAVfile
            $iSize = InetGetSize($sUrl)
            If Not FileExists("R:\Installer\Symantec_AVdefs\" & $sAVfile) Then
                If $iSize > 1048576 Then
                    InetGet($sUrl, "\\server\share\TV-BR_RegTest\Installer\Symantec_AVdefs\work\" & $sAVfile, 1, 0)
                    FileMove ("\\server\share\TV-BR_RegTest\Installer\Symantec_AVdefs\work\" & $sAVfile,"R:\Installer\Symantec_AVdefs\")
                    _IEQuit ($oIE)
                    Return 1
                EndIf
            EndIf
        EndIf
    Next
    _IEQuit ($oIE)
    Return 0
EndFunc  ;==>Check

Client Script

Opt("TrayIconHide", 1)   
#Include <Date.au3>
#Include <Array.au3>
Global $sFile
Global $hFilesToFind
Global $asFiles[99]
While 1
    ReDim $asFiles[99]
    $asFiles[0] = 0
    $hFilesToFind = FileFindFirstFile("\\server\share\TV-BR_RegTest\Installer\Symantec_AVdefs\20*.exe")
    While 1
        $sFile = FileFindNextFile ( $hFilesToFind )
        If @ERROR Then ExitLoop
        $asFiles[0] += 1
        $asFiles[$asFiles[0]] = $sFile
    WEnd
    FileClose($hFilesToFind)
    ReDim $asFiles[$asFiles[0] + 1]
    _ArraySort($asFiles,1,1)
    If Not FileExists("C:\Program Files\Common Files\Symantec Shared\VirusDefs\" & StringLeft($asFiles[1],8) & "." & StringMid($asFiles[1],10,3)) Then
        RunWait("\\server\share\TV-BR_RegTest\Installer\Symantec_AVdefs\" & $asFiles[1] & " /q")
    EndIf
    RunWait('Net stop "Symantec AntiVirus"','',@SW_HIDE)
    RunWait('Net stop "Symantec Event Manager"','',@SW_HIDE)
    RunWait('Net stop "Symantec Settings Manager"','',@SW_HIDE)
    RunWait('Net stop "Symantec AntiVirus Definition Watcher"','',@SW_HIDE)
    Sleep(10000)
    RunWait('Net start "Symantec AntiVirus"','',@SW_HIDE)
    RunWait('Net start "Symantec Event Manager"','',@SW_HIDE)
    RunWait('Net start "Symantec Settings Manager"','',@SW_HIDE)
    RunWait('Net start "Symantec AntiVirus Definition Watcher"','',@SW_HIDE)
    $sec = _DateDiff("s",@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, _DateAdd('D', 1, @YEAR & "/" & @MON & "/" & @MDAY) & " 06:30:00")
    Sleep($sec * 1000)  ;sleep until 06:30 tomorrow
WEnd

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.