def get_reg(self):
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa384911(v=vs.85).aspx
HKEY_CLASSES_ROOT = 2147483648
HKEY_CURRENT_USER = 2147483649
HKEY_LOCAL_MACHINE = 2147483650
HKEY_USERS = 2147483651
HKEY_CURRENT_CONFIG = 2147483653
KEY_QUERY_VALUE = 1 # Required to query the values of a registry key.
KEY_SET_VALUE = 2 # Required to create, delete, or set a registry value.
KEY_DEFAULT_VALUE = 3 # KEY_QUERY_VALUE | KEY_SET_VALUE Default value, allows querying, creating, deleting, or setting a registry value.
KEY_CREATE_SUB_KEY = 4 # Required to create a subkey of a registry key.
KEY_ENUMERATE_SUB_KEYS = 8 # Required to enumerate the subkeys of a registry key.
KEY_NOTIFY = 16 # Required to request change notifications for a registry key or for subkeys of a registry key.
KEY_CREATE = 32 # Required to create a registry key.
DELETE = 65536 # Required to delete a registry key.
READ_CONTROL = 131072 # Combines the STANDARD_RIGHTS_READ, KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS, and KEY_NOTIFY values.
WRITE_DAC = 262144 # Required to modify the DACL in the object's security descriptor.
WRITE_OWNER = 524288 # Required to change the owner in the object's security descriptor.
#c = wmi.WMI(computer="XXX.XXX.XXX.XXX", user="devuser",password="devpass1!",namespace="root/default").StdRegProv
c = wmi.WMI(find_classes=False,namespace="default",computer=self.computer).StdRegProv
print "Methods: "
print str(c)
try:
subkey = r"SYSTEM\CurrentControlSet\Services\LanmanWorkstations"
name = "EnablePlainTextPassword"
result, grants = c.CheckAccess(hDefKey = HKEY_LOCAL_MACHINE, sSubKeyName=subkey, uRequired=KEY_DEFAULT_VALUE);
print "Access : " + str(grants)
#result, value = c.GetStringValue(hDefKey=_winreg.HKEY_LOCAL_MACHINE, sSubKeyName=subkey, sValueName=name)
#print "HKEY_LOCAL_MACHINE " + str(HKEY_LOCAL_MACHINE)
#err, sids = c.EnumKey (hDefKey=2147483650, sSubKeyName=subkey)
#for sid in sids:
# print sid
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa390461(v=vs.85).aspx
name = "OtherDomains"
subkey = r"SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters"
err, names, types = c.EnumValues (hDefKey=HKEY_LOCAL_MACHINE, sSubKeyName=subkey)
for i in range(len(names)):
if types[i] == REG_SZ:
tipo = "Data Type: String"
result, value = c.GetStringValue(hDefKey=HKEY_LOCAL_MACHINE, sSubKeyName=subkey, sValueName=names[i])
elif types[i] == REG_EXPAND_SZ:
tipo = "Data Type: Expanded String"
result, value = c.GetExpandedStringValue(hDefKey=HKEY_LOCAL_MACHINE, sSubKeyName=subkey, sValueName=names[i])
elif types[i] == REG_BINARY:
tipo = "Data Type: Binary"
result, value = c.GetBinaryValue(hDefKey=HKEY_LOCAL_MACHINE, sSubKeyName=subkey, sValueName=names[i])
elif types[i] == REG_DWORD:
tipo = "Data Type: DWORD"
# 32 Bits
result, value = c.GetDWORDValue(hDefKey=HKEY_LOCAL_MACHINE, sSubKeyName=subkey, sValueName=names[i])
# 64 Bits
#result, value = c.GetQWORDValue(hDefKey=HKEY_LOCAL_MACHINE, sSubKeyName=subkey, sValueName=names[i])
elif types[i] == REG_MULTI_SZ:
tipo = "Data Type: Multi String"
result, value = c.GetMultiStringValue(hDefKey=HKEY_LOCAL_MACHINE, sSubKeyName=subkey, sValueName=names[i])
print names[i] + " = " + tipo + " " + str(value)
except Exception as e:
print "Erro: ", str(e)