forked from p34709852/monkey
check SidType everywhere to make sure we don't have type errors
This commit is contained in:
parent
9594fab1a2
commit
1d25ba9085
|
@ -39,6 +39,16 @@ DsRole_RoleMemberServer = 3
|
||||||
DsRole_RoleBackupDomainController = 4
|
DsRole_RoleBackupDomainController = 4
|
||||||
DsRole_RolePrimaryDomainController = 5
|
DsRole_RolePrimaryDomainController = 5
|
||||||
|
|
||||||
|
SidTypeUser = 1
|
||||||
|
SidTypeGroup = 2
|
||||||
|
SidTypeDomain = 3
|
||||||
|
SidTypeAlias = 4
|
||||||
|
SidTypeWellKnownGroup = 5
|
||||||
|
SidTypeDeletedAccount = 6
|
||||||
|
SidTypeInvalid = 7
|
||||||
|
SidTypeUnknown = 8
|
||||||
|
SidTypeComputer = 9
|
||||||
|
|
||||||
def myntlm(x):
|
def myntlm(x):
|
||||||
hash = hashlib.new('md4', x.encode('utf-16le')).digest()
|
hash = hashlib.new('md4', x.encode('utf-16le')).digest()
|
||||||
return str(binascii.hexlify(hash))
|
return str(binascii.hexlify(hash))
|
||||||
|
@ -162,6 +172,9 @@ class Machine(object):
|
||||||
for user in doc["data"]["Win32_UserAccount"]:
|
for user in doc["data"]["Win32_UserAccount"]:
|
||||||
if eval(user["Name"]) != username:
|
if eval(user["Name"]) != username:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if eval(user["SIDType"]) != SidTypeUser:
|
||||||
|
continue
|
||||||
|
|
||||||
return eval(user["SID"])
|
return eval(user["SID"])
|
||||||
|
|
||||||
|
@ -190,6 +203,9 @@ class Machine(object):
|
||||||
for user in doc["data"]["Win32_UserAccount"]:
|
for user in doc["data"]["Win32_UserAccount"]:
|
||||||
if eval(user["SID"]) != sid:
|
if eval(user["SID"]) != sid:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if eval(user["SIDType"]) != SidTypeUser:
|
||||||
|
continue
|
||||||
|
|
||||||
return { "Domain": eval(user["Domain"]),
|
return { "Domain": eval(user["Domain"]),
|
||||||
"Username": eval(user["Name"]),
|
"Username": eval(user["Name"]),
|
||||||
|
@ -280,6 +296,9 @@ class Machine(object):
|
||||||
if eval(group["Name"]) != group_name:
|
if eval(group["Name"]) != group_name:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if eval(group["SIDType"]) != SidTypeGroup:
|
||||||
|
continue
|
||||||
|
|
||||||
return eval(group["SID"])
|
return eval(group["SID"])
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
@ -293,10 +312,16 @@ class Machine(object):
|
||||||
for group_user in doc["data"]["Win32_GroupUser"]:
|
for group_user in doc["data"]["Win32_GroupUser"]:
|
||||||
if eval(group_user["GroupComponent"]["SID"]) != sid:
|
if eval(group_user["GroupComponent"]["SID"]) != sid:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if eval(group_user["GroupComponent"]["SIDType"]) != SidTypeGroup:
|
||||||
|
continue
|
||||||
|
|
||||||
if "PartComponent" not in group_user.keys():
|
if "PartComponent" not in group_user.keys():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if eval(group_user["PartComponent"]["SIDType"]) != SidTypeUser:
|
||||||
|
continue
|
||||||
|
|
||||||
users[eval(group_user["PartComponent"]["SID"])] = eval(group_user["PartComponent"]["Name"])
|
users[eval(group_user["PartComponent"]["SID"])] = eval(group_user["PartComponent"]["Name"])
|
||||||
|
|
||||||
return users
|
return users
|
||||||
|
@ -335,6 +360,9 @@ class Machine(object):
|
||||||
SIDs = set()
|
SIDs = set()
|
||||||
|
|
||||||
for user in doc["data"]["Win32_UserAccount"]:
|
for user in doc["data"]["Win32_UserAccount"]:
|
||||||
|
if eval(user["SIDType"]) != SidTypeUser:
|
||||||
|
continue
|
||||||
|
|
||||||
SIDs.add(eval(user["SID"]))
|
SIDs.add(eval(user["SID"]))
|
||||||
|
|
||||||
return SIDs
|
return SIDs
|
||||||
|
|
Loading…
Reference in New Issue