py-win-ban-hyperv 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ from .core import ban_hyper_v
2
+
3
+ __all__ = [
4
+ "ban_hyper_v"
5
+ ]
@@ -0,0 +1,15 @@
1
+ from . import ban_hyper_v
2
+ import sys
3
+
4
+ def main():
5
+ yn_inp = ""
6
+ while yn_inp == "" or yn_inp[0] not in ["y", "n"]:
7
+ yn_inp = input("Are you sure to ban hyperV (y/N):").lower().strip()
8
+
9
+ if yn_inp[0] == "y":
10
+ reboot = "--reboot" in sys.argv
11
+ ban_hyper_v(reboot)
12
+ else:
13
+ print("Operation Abort.")
14
+
15
+ main()
@@ -0,0 +1,56 @@
1
+ echo "+================================================+"
2
+ echo "+ py-win-ban-hyperv: v0.1.0 +"
3
+ echo "+================================================+"
4
+ echo ""
5
+
6
+ Set-Location -LiteralPath $PSScriptRoot
7
+
8
+ echo "Disabling the Windows hypervisor launch at boot for the current boot entry."
9
+ bcdedit /set "{current}" hypervisorlaunchtype off
10
+ echo ""
11
+
12
+ echo "Disabling Virtualization-Based Security in Device Guard settings."
13
+ reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard" /v EnableVirtualizationBasedSecurity /t REG_DWORD /d 0 /f
14
+ echo ""
15
+
16
+ echo "Disabling required platform security features for Device Guard."
17
+ reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard" /v RequirePlatformSecurityFeatures /t REG_DWORD /d 0 /f
18
+ echo ""
19
+
20
+ echo "Disabling Hypervisor-Enforced Code Integrity."
21
+ reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" /v Enabled /t REG_DWORD /d 0 /f
22
+ echo ""
23
+
24
+ echo "Disabling Credential Guard through the LSA configuration flag."
25
+ reg add "HKLM\SYSTEM\CurrentControlSet\Control\Lsa" /v LsaCfgFlags /t REG_DWORD /d 0 /f
26
+ echo ""
27
+
28
+ echo "Disabling all Microsoft Hyper-V optional features."
29
+ dism /online /disable-feature /featurename:Microsoft-Hyper-V-All /norestart
30
+ echo ""
31
+
32
+ echo "Disabling the Virtual Machine Platform optional feature."
33
+ dism /online /disable-feature /featurename:VirtualMachinePlatform /norestart
34
+ echo ""
35
+
36
+ echo "Disabling the Windows Hypervisor Platform optional feature."
37
+ dism /online /disable-feature /featurename:HypervisorPlatform /norestart
38
+ echo ""
39
+
40
+ echo "Disabling the Windows Sandbox optional feature."
41
+ dism /online /disable-feature /featurename:Containers-DisposableClientVM /norestart
42
+ echo ""
43
+
44
+ echo "Allowing scripts to run in this PowerShell process only."
45
+ Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
46
+ echo ""
47
+
48
+ echo "Running the Device Guard and Credential Guard readiness tool to disable DG/CG."
49
+ & .\dgreadiness_v3.6\DG_Readiness_Tool_v3.6.ps1 -Disable
50
+ echo ""
51
+
52
+ echo "Done. Please reboot to validate the settings."
53
+ if ($args[0] -eq "True") {
54
+ shutdown -r -t 30
55
+ }
56
+ pause
@@ -0,0 +1,10 @@
1
+ import py_admin_launch
2
+ import os
3
+ DIRNOW = os.path.dirname(os.path.abspath(__file__))
4
+ BAN_HYPERV_PS1 = os.path.join(DIRNOW, "ban_hyperv.ps1")
5
+
6
+ def ban_hyper_v(reboot:bool):
7
+ py_admin_launch.launch(["powershell", BAN_HYPERV_PS1, str(reboot)], cwd=DIRNOW)
8
+
9
+ if __name__ == "__main__":
10
+ ban_hyper_v(True)