34 lines
798 B
Python
34 lines
798 B
Python
# -*- coding: utf-8 -*-
|
|
from setuphelpers import *
|
|
import os
|
|
import subprocess
|
|
|
|
uninstallkey = []
|
|
|
|
|
|
def _run(action):
|
|
script = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'hardening.ps1')
|
|
result = subprocess.run(['powershell.exe', '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-File', script, '-Action', action], capture_output=True, text=True)
|
|
print(result.stdout)
|
|
if result.stderr:
|
|
print(result.stderr)
|
|
if result.returncode != 0:
|
|
raise Exception('Hardening %s failed with code %s' % (action, result.returncode))
|
|
|
|
|
|
def install():
|
|
_run('install')
|
|
|
|
|
|
def audit():
|
|
try:
|
|
_run('audit')
|
|
return 'OK'
|
|
except Exception as exc:
|
|
print(exc)
|
|
return 'WARNING'
|
|
|
|
|
|
def uninstall():
|
|
_run('uninstall')
|