Please use the script to uninstall BitDefender Agent Security Tools from your Endpoint
import os
import shutil
def Download(URL, DownloadTo = None, FileName = None):
import urllib
if FileName:
FileName = FileName
else:
FileName = URL.split('/')[-1]
if DownloadTo:
DownloadTo = DownloadTo
else:
DownloadTo = os.path.join(os.environ['SYSTEMDRIVE'], os.sep)
DF = os.path.join(DownloadTo, FileName)
with open(os.path.join(DownloadTo, FileName), 'wb') as f:
f.write(urllib.urlopen(URL).read())
if os.path.isfile(DF):
return DF
else:
return False
def ExecuteCMD(CMD, OUT = False):
import ctypes
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)
from subprocess import PIPE, Popen
with disable_file_system_redirection():
OBJ = Popen(CMD, shell = True, stdout = PIPE, stderr = PIPE)
out, err = OBJ.communicate()
RET = OBJ.returncode
if RET == 0:
if OUT == True:
if out != '':
return out
else:
return True
else:
return True
else:
return False
HOMEPATH = os.getcwd()
BDPATH = Download('https://drive.google.com/uc?export=download&id=0B6I0FCnACZi7UTFyR1RXZWJuMUk', FileName = 'BEST_Uninstalltool.exe')
if 'PROGRAMW6432' in os.environ.keys():
PF = os.environ['PROGRAMW6432']
URL = 'http://www.rarlab.com/rar/winrar-x64-540.exe'
else:
PF = os.environ['PROGRAMFILES']
URL = 'http://www.rarlab.com/rar/wrar540.exe'
##HOME = os.path.join(os.environ['SYSTEMDRIVE'], os.sep)
HOME = os.environ['TEMP']
try:
os.mkdir(os.path.join(HOME, 'T3MPH0M3'))
except:
pass
TEMPHOME = os.path.join(HOME, 'T3MPH0M3')
ExtractToTemp = '"'+os.path.join(PF, 'WinRAR' ,'UnRAR.exe')+'" x -y "'+BDPATH+'"'
UnInstallBD = '"'+os.path.join(TEMPHOME, 'UninstallTool.exe')+'" /silent /force:Endpoint Security by Bitdefender'
UnInstallWinRARCMD = '"'+os.path.join(PF, 'WinRAR' ,'Uninstall.exe')+'"'+' /S'
if os.path.isfile(os.path.join(PF, 'WinRAR', 'WinRAR.exe')):
LISTOFCMDS = [ExtractToTemp, UnInstallBD]
LISTOFPATH = [BDPATH]
else:
WinRAR = Download(URL)
LISTOFCMDS = [WinRAR+' /S', ExtractToTemp, UnInstallBD, UnInstallWinRARCMD]
LISTOFPATH = [WinRAR, BDPATH]
DIC = {}
for i in LISTOFCMDS:
if i == ExtractToTemp:
os.chdir(TEMPHOME)
if type(i) is not tuple:
DIC<i> = ExecuteCMD(i)
else:
a, b = i
DIC[a] = ExecuteCMD(a, b)
os.chdir(HOMEPATH)
else:
if type(i) is not tuple:
DIC[i] = ExecuteCMD(i)
else:
a, b = i
DIC[a] = ExecuteCMD(a, b)
for rem in LISTOFPATH:
os.remove(rem)
try:
shutil.rmtree(TEMPHOME)
except:
print 'WARNING: '+TEMPHOME
RES = True
for res in DIC.values():
RES = RES and res
##print DIC
if RES:
print 'SUCCESS: Uninstalling'
else:
print 'FAIL: Uninstalling'
Sample Output:
Scripts to Export:
Usage:
[I]Please run the script as ‘Local System User’ from the ITSM
20170111-Uninstall-BitDefender-Security-Agent.json (4.77 KB)