This script is helps you to install Comodo Client Security(ccs) and AV DB in both Windows and server.
How it works:
1. This script checks whether the Comodo Client Security(ccs) is installed or not. If not installed css. it will install css and reboot the system. After reboot the system it will check AV DB is installed or not. If not installed it's verify the database="yes", after install the AV DB.
2. The procedure is able to also uninstall any other version that the one specified, this option can be used when the update/downgrade option is no longer available.
Note:
This script could be used as an auto-remediation procedure for the below custom monitoring script.
https://scripts.comodo.com/frontend/web/topic/check-if-ccs-is-present-in-your-endpoint-if-notinstall-ccs
# If you want to enforce the CCS version choose enforceCCS = "yes"
# This option will uninstall any other CCS version and install the specified version
enforceCCS = "yes"
# Please specify the version that you want to download from Comodo servers and/or to enforce if enforceCCS = "yes"
CCSVersion = "11.6.1.7849"
# Do you want that the endpoint to download Comodo Client Security package from COMODO servers?
comodoservers = "yes"
# if variable comodoservers = "yes" the package will be downloaded from:
# In your portal please go to this path in order to indentify your Comodo Client Security version:
# SETTINGS-Portal Set-UpClient SettingsWindowsSecurity Client
# https://download.comodo.com/itsm/release/win/endpoint_security/CCSVersion/ces_64.msi
# https://download.comodo.com/itsm/release/win/endpoint_security/CCSVersion/ces_86.msi
# if comodoservers = "no" please provide the shared folder path and the CCS .msi names:
SharedFolderPath = r'\\servername\sharefolder'
CISx64Name = r'fileName'
CISx86Name = r'fileName'
# If Antivirus will be installed, do you want to download the initial Database from a shared folder ?
# ( Database is automatically updated from Comodo servers after 1 hour as default or after a reboot )
Database = "no"
# If the variable Database = "yes" you can download the latest database from this link and place it on shared folder:
# https://www.comodo.com/home/internet-security/updates/vdp/database.php
SharedFolderPathCAV = r'\\servername\sharefolder'
# FileNameCAV variable is the file name of the AV DB
FileNameCAV = r'bases.cav'
# After CCS is installed do you want to supress the reboot on the endpoint?
SuppressReboot = "no"
# If the variable SuppressReboot = "no" by default you have 5 minutes with a comment "Your device will reboot in 5 minutes because it's required by your administrator"
reboottime = "300"
# In the variable reboottime you can specify in seconds the reboot time
notes = "yes"
# In the notes = "yes" variable you can request to show show installation notes
msiLogs = "yes"
# In the msiLogs = "yes" variable you can request to enable MSI Installation log?
scan="yes"
#In the scan="yes" you can specifi if you want to start a Full Scann on the endpoint after Comodo Client Security install
# This option will work only if you have Full Scan scheduled in your profile
#########################Configuration#Section##########################################################################
# If you want to enforce the CCS version choose enforceCCS = "yes"
# This option will uninstall any other CCS version and install the specified version
enforceCCS = "yes"
# Please specify the version that you want to download from Comodo servers and/or to enforce if enforceCCS = "yes"
#CCSVersion = "11.6.1.7849"
CCSVersion = "latest"
# Do you want that the endpoint to download Comodo Client Security package from COMODO servers?
comodoservers = "yes"
# if variable comodoservers = "yes" the package will be downloaded from:
# In your portal please go to this path in order to indentify your Comodo Client Security version:
# SETTINGS-Portal Set-UpClient SettingsWindowsSecurity Client
# https://download.comodo.com/itsm/release/win/endpoint_security/CCSVersion/ces_64.msi
# https://download.comodo.com/itsm/release/win/endpoint_security/CCSVersion/ces_86.msi
# if comodoservers = "no" please provide the shared folder path and the CCS .msi names:
SharedFolderPath = r'\\servername\sharefolder'
CISx64Name = r'fileName'
CISx86Name = r'fileName'
# If Antivirus will be installed, do you want to download the initial Database from a shared folder ?
# ( Database is automatically updated from Comodo servers after 1 hour as default or after a reboot )
Database = "no"
# If the variable Database = "yes" you can download the latest database from this link and place it on shared folder:
# https://www.comodo.com/home/internet-security/updates/vdp/database.php
SharedFolderPathCAV = r'\\servername\sharefolder'
# FileNameCAV variable is the file name of the AV DB
FileNameCAV = r'bases.cav'
# After CCS is installed do you want to supress the reboot on the endpoint?
SuppressReboot = "no"
# If the variable SuppressReboot = "no" by default you have 5 minutes with a comment "Your device will reboot in 5 minutes because it's required by your administrator"
reboottime = "300"
# In the variable reboottime you can specify in seconds the reboot time
notes = "yes"
# In the notes = "yes" variable you can request to show show installation notes
msiLogs = "yes"
# In the msiLogs = "yes" variable you can request to enable MSI Installation log?
scan="yes"
#In the scan="yes" you can specifi if you want to start a Full Scann on the endpoint after Comodo Client Security install
# This option will work only if you have Full Scan scheduled in your profile
########################################################################################################################
import os
from subprocess import PIPE, Popen
import shutil
import ctypes
import re
import datetime
import platform
try:
import winreg as _winreg
except ImportError:
try:
import _winreg
except ImportError:
pass
import ssl
import time
try:
import urllib.request as urllib2
except ImportError:
try:
import urllib2
except ImportError:
pass
# Please choose what to be installed before the profile is applied.
# You can use "yes" or "no"
#Desktop
Containment = "yes"
Antivirus = "yes"
Firewall = "yes"
#Server
ContainmentS = "yes"
AntivirusS = "yes"
min = '10'
datenow = datetime.datetime.now()
datestamp = datenow + datetime.timedelta(minutes = int(min) -1)
appname = "COMODO Client - Security"
# associated with CCS uninstall
def reg(name):
blacklist=name
def collectprograms(rtkey,pK,kA):
try:
list=[]
oK=_winreg.OpenKey(rtkey,pK,0,kA)
i=0
while True:
try:
bkey=_winreg.EnumKey(oK,i)
vkey=os.path.join(pK,bkey)
oK1=_winreg.OpenKey(rtkey,vkey,0,kA)
try:
DN,bla=_winreg.QueryValueEx(oK1,'DisplayName')
inlist=[DN.strip(), vkey, pK]
list.append(inlist)
except:
pass
i+=1
except:
break
except:
pass
return list
uninstallkey_32='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall'
if 'PROGRAMFILES(X86)' in os.environ.keys():
rklist=[(_winreg.HKEY_LOCAL_MACHINE,uninstallkey_32,_winreg.KEY_WOW64_32KEY | _winreg.KEY_READ),
(_winreg.HKEY_LOCAL_MACHINE,uninstallkey_32,_winreg.KEY_WOW64_64KEY | _winreg.KEY_READ),
(_winreg.HKEY_CURRENT_USER,uninstallkey_32,_winreg.KEY_WOW64_32KEY | _winreg.KEY_READ),
(_winreg.HKEY_CURRENT_USER,uninstallkey_32,_winreg.KEY_WOW64_64KEY | _winreg.KEY_READ)]
else:
rklist=[(_winreg.HKEY_LOCAL_MACHINE,uninstallkey_32,_winreg.KEY_READ),
(_winreg.HKEY_CURRENT_USER,uninstallkey_32,_winreg.KEY_READ)]
bet=[]
for i in rklist:
col=collectprograms(i[0], i[1], i[2])
for c in col:
if blacklist in c:
bet.append(c[1])
if not bet:
print "Please blacklist Valid Installed Software"
got=0
else:
for i in bet:
j=i.replace(" ", '" "')
v='\\'
path="HKEY_LOCAL_MACHINE"+v+i
path1="HKEY_LOCAL_MACHINE"+v+j
got=path1
return got
# associated with CCS uninstall
def uninstall (find):
command="MsiExec.exe /X"+find+" /qn CESMCONTEXT=1 REBOOT=REALLYSUPPRESS"
uninst=os.popen(command).read()
time.sleep(150)
fin=reg(appname)
if fin!=0:
print "%s is still present on the Endpoint. Uninstallation failed" % appname
else:
print "%s has been uninstalled successfully" % appname
print "Restarting the Endpoint"
os.popen(r'shutdown.exe -r')
# Uninstall CCS
def CCSUninstall():
fin=reg(appname)
if fin!=0:
fina=fin.split('\\')[-1]
final1=re.findall('{.*}',fina)[0]
print "GUID from Registry is : "+final1
print "%s is installed on the Endpoint" % appname
print "Uninstalling has started "
uninstall(final1)
else:
print "%s is not installed on the Endpoint" % appname
# read CCS version
def readCCSVersion():
Path_for_CCS_Version = r""
getccsvar = ""
Os_Path = r"{0}\Program Files\COMODO\COMODO Internet Security".format(os.environ['systemdrive'])
if os.path.exists(Os_Path):
Path_for_CCS_Version = r"{0}\Program Files\COMODO\COMODO Internet Security\cfpver.dat".format(os.environ['systemdrive'])
ccsvar = open(Path_for_CCS_Version, "r")
getccsvar = ccsvar.read()
getccsvar = getccsvar.strip('\r\n')
return getccsvar
# Create 'TimeStampStatus' file and write current time
def WriteTimeStampToTheTimeStampFile(datetowrite):
Path_for_time_stamp_file = r""
Os_Path = r"{0}\Program Files (x86)".format(os.environ['systemdrive'])
if os.path.exists(Os_Path):
Path_for_time_stamp_file = r"{0}\Program Files (x86)\COMODO\Endpoint Manager\rmmlogs\TimeStampStatus.txt".format(os.environ['systemdrive'])
else:
Path_for_time_stamp_file = r"{0}\Program Files\COMODO\Endpoint Manager\rmmlogs\TimeStampStatus.txt".format(os.environ['systemdrive'])
open(Path_for_time_stamp_file, "w+").write(str(datetowrite.strftime("%y-%m-%d %H:%M:%S")))
# read 'TimeStampStatus' file
def readTimeStampStatus():
Path_for_time_stamp_file = r""
Os_Path = r"{0}\Program Files (x86)".format(os.environ['systemdrive'])
if os.path.exists(Os_Path):
Path_for_time_stamp_file = r"{0}\Program Files (x86)\COMODO\Endpoint Manager\rmmlogs\TimeStampStatus.txt".format(os.environ['systemdrive'])
else:
Path_for_time_stamp_file = r"{0}\Program Files\COMODO\Endpoint Manager\rmmlogs\TimeStampStatus.txt".format(os.environ['systemdrive'])
vartime = open(Path_for_time_stamp_file, "r")
time = vartime.read()
return time
def verifyfileexist():
Path_for_time_stamp_file = ""
Os_Path = r"{0}\Program Files (x86)".format(os.environ['systemdrive'])
if os.path.exists(Os_Path):
Path_for_time_stamp_file = r"{0}\Program Files (x86)\COMODO\Endpoint Manager\rmmlogs\TimeStampStatus.txt".format(os.environ['systemdrive'])
else:
Path_for_time_stamp_file = r"{0}\Program Files\COMODO\Endpoint Manager\rmmlogs\TimeStampStatus.txt".format(os.environ['systemdrive'])
return Path_for_time_stamp_file
def GetWindowsEdition(Key_name):
val = ""
try:
reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
ok = _winreg.OpenKey(reg, Key_name, 0, _winreg.KEY_WOW64_32KEY | _winreg.KEY_READ)
val = _winreg.QueryValueEx(ok, "ProductName")[0]
_winreg.CloseKey(ok)
return val
except Exception as exception:
val = "Windows Registry Exception: " + str(exception)
return val
WindowsVersion = GetWindowsEdition('SOFTWARE\Microsoft\Windows NT\CurrentVersion')
def Triggerfullscan():
commandscan = r'"' + os.environ['SYSTEMDRIVE'] + r'\Program Files\COMODO\COMODO Internet Security\cfpconfg.exe" --launchSchedule {F140D794-60B6-4F00-9235-D6457AA25B22}'
if (ecmd(commandscan,True)) == 0:
print ("Successfully started the Full scan in CCS...")
else:
print ("The Full Scan is NOT scheduled in this endpoint profile")
msiLogSwitch = ""
if msiLogs is "yes":
OsPath = r"C:\Program Files (x86)"
if os.path.exists(OsPath):
msiLogSwitch = r' /lv*x "C:\Program Files (x86)\COMODO\Endpoint Manager\rmmlogs\CES_Install_MSI ' + str(
datetime.datetime.now().strftime("%d-%m-%y %H-%M-%S")) + '.log"'
else:
msiLogSwitch = r' /lv*x "C:\Program Files\COMODO\Endpoint Manager\rmmlogs\CES_Install_MSI ' + str(
datetime.datetime.now().strftime("%d-%m-%y %H-%M-%S")) + '.log"'
t1 = int(reboottime) / 60
rebootcomment = "Your device will reboot in " + str(t1) + " minutes because it's required by your administrator"
class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
def __enter__(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def __exit__(self, type, value, traceback):
if self.success:
self._revert(self.old_value)
def ecmd(command, output=False):
with disable_file_system_redirection():
objt = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
out, err = objt.communicate()
ret = objt.returncode
if not out:
return ret
else:
return '%s\n%s' % (out, err)
def Download1(Download_URL, Download_Path):
print('Downloading required Comodo Client Security installation files')
fileName = Download_URL.split('/')[-1]
DownTo = os.path.join(Download_Path, fileName)
try:
context = ssl._create_unverified_context()
f = urllib2.urlopen(Download_URL, context=context)
except:
f = urllib2.urlopen(Download_URL)
data = f.read()
with open(DownTo, "wb") as code:
code.write(data)
time.sleep(10)
print('Comodo Client security has been successfully downloaded here ' + DownTo)
return DownTo
def checkCCS():
if os.path.exists(os.environ['systemdrive'] + '\Program Files\COMODO\COMODO Internet Security\cmdagent.exe'):
return True
return False
def InstallCSS():
# Check if CCS is installed on the end point
if not checkCCS():
print("Comodo Client Security is not installed on the End point")
# Checks type of the system
OsPath = r"C:\Program Files (x86)"
# If system is 64 bit
if os.path.exists(OsPath):
print("System type 64 bit")
# Download and install CCS from the link
if comodoservers is "yes":
print("Installation files will be downloaded from Comodo Servers")
# Download_URL = 'https://cdn.download.comodo.com/itsm/release/win/endpoint_security/' + CCSVersion + '/ces_64.msi'
Download_URL = 'https://download.comodo.com/itsm/release/win/endpoint_security/' + CCSVersion + '/ces_64.msi'
Download_Path = os.environ['PROGRAMDATA']
path = Download1(Download_URL, Download_Path)
if not ("Server" in WindowsVersion or "server" in WindowsVersion):
c = "0"
a = "0"
f = "0"
if Containment is "yes":
print("Containment component will be installed")
c = "1"
else:
print("Containment component will not be installed")
c = "0"
if Antivirus is "yes":
print("Antivirus component will be installed")
a = "1"
else:
print("Antivirus component will not be installed")
a = "0"
if Firewall is "yes":
print("Firewall component will be installed")
f = "1"
else:
print("Firewall component will not be installed")
f = "0"
if notes is "yes":
print(ecmd(
r'msg * /time:30 Comodo Client - Security installation has started. Do not restart PC until next announcement.',
True))
command1 = 'msiexec /i "' + path + '" /quiet REBOOT=ReallySuppress CESMCONTEXT=1 MAKE_CESM_DEFAULT_CONFIG=1 CES_SANDBOX=' + c + ' CES_FIREWALL=' + f + ' CES_ANTIVIRUS=' + a + ' INSTALLFIREWALL=' + f + msiLogSwitch
if ecmd(command1, True) == 3010:
ecmd('"C:\Program Files (x86)\COMODO\Endpoint Manager\ITSMService.exe" -c 4',True)
pass
else:
raise Exception("Failed to install CCS. Please check MSI logs for details:%s" % str(msiLogSwitch)[7:])
else:
c = "0"
a = "0"
if ContainmentS is "yes":
print("Containment component will be installed")
c = "1"
else:
print("Containment component will not be installed")
c = "0"
if AntivirusS is "yes":
print("Antivirus component will be installed")
a = "1"
else:
print("Antivirus component will not be installed")
a = "0"
if notes is "yes":
print(ecmd(
r'msg * /time:30 Comodo Client - Security installation has started. Do not restart PC until next announcement.',
True))
command1 = 'msiexec /i "' + path + '" /quiet REBOOT=ReallySuppress CESMCONTEXT=1 MAKE_CESM_DEFAULT_CONFIG=1 CES_SANDBOX=' + c + ' CES_FIREWALL=0 CES_ANTIVIRUS=0 AV_FOR_SERVERS=' + a + msiLogSwitch
if ecmd(command1, True) == 3010:
ecmd('"C:\Program Files (x86)\COMODO\Endpoint Manager\ITSMService.exe" -c 4',True)
pass
else:
raise Exception("Failed to install CCS. Please check MSI logs for details:%s" % str(msiLogSwitch)[7:])
print("Please wait until CCS will be installed")
time.sleep(10)
os.remove(path)
print('Comodo Client Security was successfully installed')
print("Installation files have been successfully removed")
if SuppressReboot is "yes":
print("Reboot of the system was suppressed")
if notes is "yes":
print(ecmd(r'msg * /time:30 CCS installation is finished. You may restart PC to complete installation.',True))
else:
print("Reboot of the system wasn't suppressed")
print('System will restart in ' + str(t1) + ' minutes')
print(ecmd(r'shutdown.exe -r -t ' + reboottime + ' /f /c "' + rebootcomment + '"', True))
# CCS will be installed from the shared folder
else:
print("Installation files will be copied from shared folder")
Source_Path = SharedFolderPath
EnvTemp = os.environ['ProgramData']
Dest_Path = os.path.join(EnvTemp, r'Comodo')
SP_64 = os.path.join(Source_Path, CISx64Name)
DP_64 = os.path.join(Dest_Path, CISx64Name)
if not os.path.exists(Dest_Path):
os.makedirs(Dest_Path)
print("Destination path was created")
if os.path.isdir(Dest_Path):
print('"' + Dest_Path + '"' + " folder exists")
else:
print('"' + Dest_Path + '"' + " folder do NOT exists")
try:
os.remove(DP_64)
except OSError:
pass
shutil.copy(SP_64, DP_64)
if os.path.getsize(SP_64) == os.path.getsize(DP_64):
print("Installation files were copied successfully")
else:
print("Installation files weren't copied")
exit(code=1)
time.sleep(10)
if not ("Server" in WindowsVersion or "server" in WindowsVersion):
c = "0"
a = "0"
f = "0"
if Containment is "yes":
print("Containment component will be installed")
c = "1"
else:
print("Containment component will not be installed")
c = "0"
if Antivirus is "yes":
print("Antivirus component will be installed")
a = "1"
else:
print("Antivirus component will not be installed")
a = "0"
if Firewall is "yes":
print("Firewall component will be installed")
f = "1"
else:
print("Firewall component will not be installed")
f = "0"
if notes is "yes":
print(ecmd(r'msg * /time:30 CCS installation is started. Do not restart PC until next anouncement.',True))
command1 = 'msiexec /i "' + DP_64 + '" /quiet REBOOT=ReallySuppress CESMCONTEXT=1 MAKE_CESM_DEFAULT_CONFIG=1 CES_SANDBOX=' + c + ' CES_FIREWALL=' + f + ' CES_ANTIVIRUS=' + a + ' INSTALLFIREWALL=' + f + msiLogSwitch
if ecmd(command1, True) == 3010:
ecmd('"C:\Program Files (x86)\COMODO\Endpoint Manager\ITSMService.exe" -c 4',True)
pass
else:
raise Exception("Failed to install CCS. Please check MSI logs for details:%s" % str(msiLogSwitch)[7:])
else:
c = "0"
a = "0"
if ContainmentS is "yes":
print("Containment component will be installed")
c = "1"
else:
print("Containment component will not be installed")
c = "0"
if AntivirusS is "yes":
print("Antivirus component will be installed")
a = "1"
else:
print("Antivirus component will not be installed")
a = "0"
if notes is "yes":
print(ecmd(r'msg * /time:30 CCS installation is started. Do not restart PC until next anouncement.',True))
command1 = 'msiexec /i "' + DP_64 + '" /quiet REBOOT=ReallySuppress CESMCONTEXT=1 MAKE_CESM_DEFAULT_CONFIG=1 CES_SANDBOX=' + c + ' CES_FIREWALL=0 CES_ANTIVIRUS=0 AV_FOR_SERVERS=' + a + msiLogSwitch
if ecmd(command1, True) == 3010:
ecmd('"C:\Program Files (x86)\COMODO\Endpoint Manager\ITSMService.exe" -c 4',True)
pass
else:
raise Exception("Failed to install CCS. Please check MSI logs for details:%s" % str(msiLogSwitch)[7:])
print("Please wait until CCS will be installed")
time.sleep(10)
os.remove(DP_64)
print('Comodo Client Security was successfully installed')
print("Installation files have been successfully removed")
if SuppressReboot is "yes":
print("Reboot of the system was suppressed")
if notes is "yes":
print(ecmd(r'msg * /time:30 CCS installation is finished. You may restart PC to complete installation.',True))
else:
print("Reboot of the system wasn't suppressed")
print('System will restart in ' + str(t1) + ' minutes')
print(ecmd(r'shutdown.exe -r -t ' + reboottime + ' /f /c "' + rebootcomment + '"', True))
else:
# If system is 32 bit
print("System type 32 bit")
# Download and install CCS from the link
if comodoservers is "yes":
print("Installation files will be downloaded from Comodo Servers")
# Download_URL = 'https://cdn.download.comodo.com/itsm/release/win/endpoint_security/' + CCSVersion + '/ces_86.msi'
Download_URL = 'https://download.comodo.com/itsm/release/win/endpoint_security' + CCSVersion + '/ces_86.msi'
Download_Path = os.environ['PROGRAMDATA']
path = Download1(Download_URL, Download_Path)
if not ("Server" in WindowsVersion or "server" in WindowsVersion):
c = "0"
a = "0"
f = "0"
if Containment is "yes":
print("Containment component will be installed")
c = "1"
else:
print("Containment component will not be installed")
c = "0"
if Antivirus is "yes":
print("Antivirus component will be installed")
a = "1"
else:
print("Antivirus component will not be installed")
a = "0"
if Firewall is "yes":
print("Firewall component will be installed")
f = "1"
else:
print("Firewall component will not be installed")
f = "0"
if notes is "yes":
print(ecmd(r'msg * /time:30 Comodo Client - Security installation has started. Do not restart PC until next announcement.',True))
command1 = 'msiexec /i "' + path + '" /quiet REBOOT=ReallySuppress CESMCONTEXT=1 MAKE_CESM_DEFAULT_CONFIG=1 CES_SANDBOX=' + c + ' CES_FIREWALL=' + f + ' CES_ANTIVIRUS=' + a + ' INSTALLFIREWALL=' + f + msiLogSwitch
if ecmd(command1, True) == 3010:
ecmd('"C:\Program Files\COMODO\Endpoint Manager\ITSMService.exe" -c 4',True)
pass
else:
raise Exception(
"Failed to install CCS. Please check MSI logs for details:%s" % str(msiLogSwitch)[7:])
else:
c = "0"
a = "0"
if ContainmentS is "yes":
print("Containment component will be installed")
c = "1"
else:
print("Containment component will not be installed")
c = "0"
if Antivirus is "yes":
print("Antivirus component will be installed")
a = "1"
else:
print("Antivirus component will not be installed")
a = "0"
if notes is "yes":
print(ecmd(r'msg * /time:30 Comodo Client - Security installation has started. Do not restart PC until next announcement.',True))
command1 = 'msiexec /i "' + path + '" /quiet REBOOT=ReallySuppress CESMCONTEXT=1 MAKE_CESM_DEFAULT_CONFIG=1 CES_SANDBOX=' + c + ' CES_FIREWALL=0 CES_ANTIVIRUS=0 AV_FOR_SERVERS=' + a + msiLogSwitch
if ecmd(command1, True) == 3010:
ecmd('"C:\Program Files\COMODO\Endpoint Manager\ITSMService.exe" -c 4',True)
pass
else:
raise Exception(
"Failed to install CCS. Please check MSI logs for details:%s" % str(msiLogSwitch)[7:])
print("Please wait until CCS will be installed")
time.sleep(10)
os.remove(path)
print('Comodo Client Security was successfully installed')
print("Installation files have been successfully removed")
if SuppressReboot is "yes":
print("Reboot of the system was suppressed")
if notes is "yes":
print(ecmd(r'msg * /time:30 CCS installation is finished. You may restart PC to complete installation.',True))
else:
print("Reboot of the system wasn't suppressed")
print('System will restart in ' + str(t1) + ' minutes')
print(ecmd(r'shutdown.exe -r -t ' + reboottime + ' /f /c "' + rebootcomment + '"', True))
# CCS will be installed from the shared folder
else:
print("Installation files will be copied from shared folder")
Source_Path = SharedFolderPath
EnvTemp = os.environ['ProgramData']
Dest_Path = os.path.join(EnvTemp, r'Comodo')
SP_86 = os.path.join(Source_Path, CISx86Name)
DP_86 = os.path.join(Dest_Path, CISx86Name)
if not os.path.exists(Dest_Path):
os.makedirs(Dest_Path)
print("Destination path was created")
if os.path.isdir(Dest_Path):
print('"' + Dest_Path + '"' + " folder exists")
else:
print('"' + Dest_Path + '"' + " folder do NOT exists")
try:
os.remove(DP_86)
except OSError:
pass
shutil.copy(SP_86, DP_86)
if os.path.getsize(SP_86) == os.path.getsize(DP_86):
print("Installation files were copied successfully")
else:
print("Installation files weren't copied")
exit(code=1)
time.sleep(10)
if not ("Server" in WindowsVersion or "server" in WindowsVersion):
c = "0"
a = "0"
f = "0"
if Containment is "yes":
print("Containment component will be installed")
c = "1"
else:
print("Containment component will not be installed")
c = "0"
if Antivirus is "yes":
print("Antivirus component will be installed")
a = "1"
else:
print("Antivirus component will not be installed")
a = "0"
if Firewall is "yes":
print("Firewall component will be installed")
f = "1"
else:
print("Firewall component will not be installed")
f = "0"
if notes is "yes":
print(ecmd(r'msg * /time:30 CCS installation is started. Do not restart PC until next anouncement.',
True))
command1 = 'msiexec /i "' + DP_86 + '" /quiet REBOOT=ReallySuppress CESMCONTEXT=1 MAKE_CESM_DEFAULT_CONFIG=1 CES_SANDBOX=' + c + ' CES_FIREWALL=' + f + ' CES_ANTIVIRUS=' + a + ' INSTALLFIREWALL=' + f + msiLogSwitch
if ecmd(command1, True) == 3010:
ecmd('"C:\Program Files\COMODO\Endpoint Manager\ITSMService.exe" -c 4',True)
pass
else:
raise Exception(
"Failed to install CCS. Please check MSI logs for details:%s" % str(msiLogSwitch)[7:])
else:
c = "0"
a = "0"
if Containment is "yes":
print("Containment component will be installed")
c = "1"
else:
print("Containment component will not be installed")
c = "0"
if Antivirus is "yes":
print("Antivirus component will be installed")
a = "1"
else:
print("Antivirus component will not be installed")
a = "0"
if notes is "yes":
print(ecmd(r'msg * /time:30 CCS installation is started. Do not restart PC until next anouncement.',
True))
command1 = 'msiexec /i "' + DP_86 + '" /quiet REBOOT=ReallySuppress CESMCONTEXT=1 MAKE_CESM_DEFAULT_CONFIG=1 CES_SANDBOX=' + c + ' CES_FIREWALL=0 CES_ANTIVIRUS=0 AV_FOR_SERVERS=' + a + msiLogSwitch
if ecmd(command1, True) == 3010:
ecmd('"C:\Program Files\COMODO\Endpoint Manager\ITSMService.exe" -c 4',True)
pass
else:
raise Exception(
"Failed to install CCS. Please check MSI logs for details:%s" % str(msiLogSwitch)[7:])
print("Please wait until CCS will be installed")
time.sleep(10)
os.remove(DP_86)
print('Comodo Client Security was successfully installed')
print("Installation files have been successfully removed")
if SuppressReboot is "yes":
print("Reboot of the system was suppressed")
if notes is "yes":
print(ecmd(r'msg * /time:30 CCS installation is finished. You may restart PC to complete installation.',True))
else:
print("Reboot of the system wasn't suppressed")
print('System will restart in ' + str(t1) + ' minutes')
print(ecmd(r'shutdown.exe -r -t ' + reboottime + ' /f /c "' + rebootcomment + '"', True))
else:
print("Comodo Client Security is installed on the end point")
def AVDB():
if os.path.exists(os.environ['programdata'] + '\COMODO\Cis\signatures'):
return True
return False
def NewDatabase():
if Database is "yes":
Source_Path = SharedFolderPathCAV
EnvTemp = os.environ['PROGRAMDATA']
Dest_Path = os.path.join(EnvTemp, r'Comodo')
File_Name_CAV = FileNameCAV
SP_CAV = os.path.join(Source_Path, File_Name_CAV)
DP_CAV = os.path.join(Dest_Path, File_Name_CAV)
if os.path.exists(SP_CAV):
print("Database source path exists")
if not os.path.exists(Dest_Path):
os.makedirs(Dest_Path)
print("Destination path was created")
if os.path.isdir(Dest_Path):
print('"' + Dest_Path + '"' + " folder exists")
else:
print('"' + Dest_Path + '"' + " folder do NOT exists")
try:
os.remove(DP_CAV)
except OSError:
pass
shutil.copy(SP_CAV, DP_CAV)
if os.path.getsize(SP_CAV) == os.path.getsize(DP_CAV):
print("Database files were copied successfully")
else:
print("Database files weren't copied")
command1 = '"C:\Program Files\COMODO\COMODO Internet Security\cfpconfg.exe" --importAVDB "' + DP_CAV + '"'
print(ecmd(command1, True))
time.sleep(60)
if AVDB():
print('Antivirus signature database was updated Successfully')
try:
os.remove(DP_CAV)
except OSError:
pass
if scan is "yes":
Triggerfullscan()
else:
print("Antivirus signature database is up to date")
if scan is "yes":
Triggerfullscan()
else:
print("Database will be updated accordingly to the schedule")
if scan is "yes":
Triggerfullscan()
print("Logic:")
print("Option 1 = Install COMODO Client Security")
print("Option 2 = Update Antivirus signature database")
print("Option 3 = Uninstall COMODO Client Security")
option=0
if checkCCS():
print ("COMODO Client Security is installed on the PC")
if enforceCCS is "yes":
testccsversion = readCCSVersion()
if testccsversion == CCSVersion:
print "\tComodo Client - Security Enforced Version = " + testccsversion + "\n"
if AVDB():
print("Antivirus signature database is up to date")
else:
print("Antivirus signature database is NOT up to date")
option=2
else:
print "\tComodo Client - Security Enforced Version is NOT " + CCSVersion + "\n"
print "\tComodo Client - Security Version " + testccsversion + " will be uninstalled\n"
option=3
else:
if AVDB():
print("Antivirus signature database is up to date")
else:
print("Antivirus signature database is NOT up to date")
option=2
else:
print ("COMODO Client Security is NOT present")
option=1
print("Option selected = " + str(option))
if option==1:
if os.path.exists(verifyfileexist()):
datenow6 = datetime.datetime.now() + datetime.timedelta(minutes = int(min))
WriteTimeStampToTheTimeStampFile(datenow6)
InstallCSS()
if option==2:
if os.path.exists(verifyfileexist()):
datenow5 = datetime.datetime.now() + datetime.timedelta(minutes = int(min))
WriteTimeStampToTheTimeStampFile(datenow5)
NewDatabase()
if option==3:
if os.path.exists(verifyfileexist()):
datenow5 = datetime.datetime.now() + datetime.timedelta(minutes = int(min))
WriteTimeStampToTheTimeStampFile(datenow5)
CCSUninstall()
Comments