Search code examples
powershellscheduled-tasksmcafee

McAfee Update download script


I'm setting PC with McAfee install on them and be told that I need to stop the program going on line to download update (DAT). I need to create a script to download dat file from McAfee web site and put this file on server where McAfee can access and install this.

Has anyone done this in past.


Solution

  • I actually have done this. I haven't tested this script in a year or two but here is what I was using. This isn't written in Powershell but if you change the directories I think this can run on Windows.

    #!/usr/bin/python
    
    import ftplib
    import tarfile
    import shutil
    import os
    import re
    import time
    
    scannerDir = "/usr/local/uvscan/"
    tmp = "/tmp/avscanner/"
    
    def downloadDat():
        datfile = ""
        r = re.compile("^avvdat")
        ftp = ftplib.FTP("ftp.nai.com", "anonymous", "email@yourdomain.com")
        ftp.cwd("/pub/datfiles/english")
        list = ftp.nlst()
        for x in list:
            if r.search(x):
                datFile = x
        f = open(tmp + "datfile", 'wb')
        ftp.retrbinary("RETR " + datFile, f.write)
        f.close()
        ftp.quit()
    
    def unpackDat():
        tFile = tarfile.open(tmp + "datfile", 'r')
        for f in tFile.getnames():
            tFile.extract(f, tmp)
    
    def createDirs():
        if os.path.isdir(tmp) == False:
            os.mkdir(tmp, 0700)
        os.chown(tmp, 0, 95)
        os.chmod(tmp, 0755)
    
    def doCleanup():
        shutil.rmtree(tmp)
    
    def installFiles():
        shutil.copyfile(tmp + "/avvclean.dat", scannerDir + "/avvclean.dat")
        shutil.copyfile(tmp + "/avvnames.dat", scannerDir + "/avvnames.dat")
        shutil.copyfile(tmp + "/avvscan.dat", scannerDir + "/avvscan.dat")          
    
    def isOld():
        if os.path.isfile(scannerDir + "/avvclean.dat"):
            if time.time() - os.path.getctime(scannerDir + "/avvclean.dat") < 80000:
                return True
            else:
                return False
        else:
            return True
    
    def main():
        if isOld():
            createDirs()
            downloadDat()
            unpackDat()
            installFiles()  
            doCleanup()
    
    if __name__ == "__main__":
        main()