Add MBAM sections

This commit is contained in:
2Shirt 2021-05-07 04:57:31 -06:00
parent b80e73a5ad
commit 9c8c7099e5
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
3 changed files with 77 additions and 0 deletions

View file

@ -68,6 +68,9 @@ BASE_MENUS = {
),
'Manual Steps': (
MenuEntry('AdwCleaner', 'auto_adwcleaner'),
MenuEntry('Malwarebytes (Install)', 'auto_mbam_install'),
MenuEntry('Malwarebytes (Run)', 'auto_mbam_run'),
MenuEntry('Malwarebytes (Uninstall)', 'auto_mbam_uninstall'),
MenuEntry('IO Bit Uninstaller', 'auto_iobit_uninstaller'),
MenuEntry('Enable Windows Updates', 'auto_windows_updates_enable'),
),

View file

@ -41,6 +41,7 @@ SOURCES = {
'LibreOffice': 'https://download.documentfoundation.org/libreoffice/stable/7.1.2/win/x86_64/LibreOffice_7.1.2_Win_x64.msi',
'Linux Reader': 'https://www.diskinternals.com/download/Linux_Reader.exe',
'Macs Fan Control': 'https://www.crystalidea.com/downloads/macsfancontrol_setup.exe',
'MBAM': 'https://downloads.malwarebytes.com/file/mb-windows',
'NirCmd32': 'https://www.nirsoft.net/utils/nircmd.zip',
'NirCmd64': 'https://www.nirsoft.net/utils/nircmd-x64.zip',
'NotepadPlusPlus': 'https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v7.9.5/npp.7.9.5.portable.minimalist.7z',

View file

@ -112,6 +112,12 @@ PROGRAMFILES_32 = os.environ.get(
'PROGRAMFILES', r'C:\Program Files (x86)',
),
)
MBAM_EXE_PATH = 'Malwarebytes/Anti-Malware/mbam.exe'
MBAM_PRESERVE_MARKER = 'Preserve-MBAM.marker'
MBAM_UNINSTALL_KEY = (
r'Software\Microsoft\Windows\CurrentVersion\Uninstall'
r'\{35065F43-4BB2-439A-BFF7-0F1014F2E0CD}_is1'
)
OS_VERSION = float(platform.win32_ver()[0])
REG_UAC_DEFAULT_SETTINGS = {
'HKLM': {
@ -705,6 +711,28 @@ def auto_kvrt(group, name):
save_settings(group, name, result=result)
def auto_mbam_install(group, name):
"""Install Malwarebytes."""
result = TRY_PRINT.run('Malwarebytes (Install)...', install_mbam)
save_settings(group, name, result=result)
def auto_mbam_run(group, name):
"""Run Malwarebytes.
save_settings() is called first since MBAM may kill this script.
"""
save_settings(group, name, done=True, failed=False, message='DONE')
result = TRY_PRINT.run('Malwarebytes (Run)...', run_mbam, msg_good='DONE')
save_settings(group, name, result=result)
def auto_mbam_uninstall(group, name):
"""Uninstall Malwarebytes."""
result = TRY_PRINT.run('Malwarebytes (Uninstall)...', uninstall_mbam)
save_settings(group, name, result=result)
def auto_microsoft_defender(group, name):
"""Run Microsoft Defender scan."""
result = TRY_PRINT.run(
@ -924,6 +952,22 @@ def install_emsisoft_cmd():
run_tool('EmsisoftCmd', 'EmsisoftCmd', '/S', cbin=True)
def install_mbam():
"""Install Malwarebytes."""
marker = set_local_storage_path('.', MBAM_PRESERVE_MARKER)
marker.unlink(missing_ok=True)
# Check for current installation
for path in ('ProgramW6432', 'PROGRAMFILES', 'PROGRAMFILES(X86)'):
if os.path.exists(f'{os.environ.get(path, "")}/{MBAM_EXE_PATH}'):
LOG.info('Previous Malwarebytes installation detected.')
marker.touch()
break
# Install / Upgrade
run_tool('MBAM', 'MBAM', '/VERYSILENT', '/NORESTART', download=True)
def run_adwcleaner():
"""Run AdwCleaner."""
run_tool('AdwCleaner', 'AdwCleaner', download=True)
@ -1023,6 +1067,20 @@ def run_kvrt():
log_path.write_text(proc.stdout)
def run_mbam():
"""Run Malwarebytes."""
exe_path = None
# Get EXE path
for path in ('ProgramW6432', 'PROGRAMFILES'):
test_path = get_path_obj(f'{os.environ.get(path, "")}/{MBAM_EXE_PATH}')
if test_path.exists():
exe_path = str(test_path)
# Run
run_program(exe_path, check=False)
def run_microsoft_defender(full=True):
"""Run Microsoft Defender scan."""
reg_key = r'Software\Microsoft\Windows Defender'
@ -1117,6 +1175,21 @@ def uninstall_emsisoft_cmd():
delete_folder(EMSISOFT_INSTALL_PATH, force=True, ignore_errors=True)
def uninstall_mbam():
"""Uninstall Malwarebytes."""
marker = set_local_storage_path('.', MBAM_PRESERVE_MARKER)
if marker.exists():
marker.unlink()
raise GenericWarning('Leaving existing MBAM installation in place.')
# Uninstall
install_path = reg_read_value('HKLM', MBAM_UNINSTALL_KEY, 'InstallLocation')
cmd = [
fr'{install_path}\mbuns.exe', '/Uninstall', '/VERYSILENT', '/NORESTART',
]
run_program(cmd)
def update_emsisoft_cmd():
"""Update EmsisoftCmd."""
cmd = [f'{EMSISOFT_INSTALL_PATH}/a2cmd.exe', '/update']