Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

regsecurity.py 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  1. import ntsecuritycon
  2. import win32api
  3. import win32con
  4. import win32security
  5. new_privs = (
  6. (
  7. win32security.LookupPrivilegeValue("", ntsecuritycon.SE_SECURITY_NAME),
  8. win32con.SE_PRIVILEGE_ENABLED,
  9. ),
  10. (
  11. win32security.LookupPrivilegeValue("", ntsecuritycon.SE_TCB_NAME),
  12. win32con.SE_PRIVILEGE_ENABLED,
  13. ),
  14. )
  15. ph = win32api.GetCurrentProcess()
  16. th = win32security.OpenProcessToken(
  17. ph, win32security.TOKEN_ALL_ACCESS | win32con.TOKEN_ADJUST_PRIVILEGES
  18. )
  19. win32security.AdjustTokenPrivileges(th, 0, new_privs)
  20. hkey = win32api.RegOpenKey(
  21. win32con.HKEY_LOCAL_MACHINE, None, 0, win32con.KEY_ALL_ACCESS
  22. )
  23. win32api.RegCreateKey(hkey, "SYSTEM\\NOTMP")
  24. notmpkey = win32api.RegOpenKey(
  25. hkey, "SYSTEM\\notmp", 0, win32con.ACCESS_SYSTEM_SECURITY
  26. )
  27. tmp_sid = win32security.LookupAccountName("", "tmp")[0]
  28. sacl = win32security.ACL()
  29. sacl.AddAuditAccessAce(win32security.ACL_REVISION, win32con.GENERIC_ALL, tmp_sid, 1, 1)
  30. sd = win32security.SECURITY_DESCRIPTOR()
  31. sd.SetSecurityDescriptorSacl(1, sacl, 1)
  32. win32api.RegSetKeySecurity(notmpkey, win32con.SACL_SECURITY_INFORMATION, sd)