refactor: clean up parse_perms logic
parent
5b5ed0c880
commit
bc0254d97e
|
@ -431,17 +431,12 @@ class NXCModule:
|
||||||
|
|
||||||
# Parses an access mask to extract the different values from a simple permission
|
# Parses an access mask to extract the different values from a simple permission
|
||||||
# https://stackoverflow.com/questions/28029872/retrieving-security-descriptor-and-getting-number-for-filesystemrights
|
# https://stackoverflow.com/questions/28029872/retrieving-security-descriptor-and-getting-number-for-filesystemrights
|
||||||
# - fsr : the access mask to parse
|
def parse_perms(self, access_mask):
|
||||||
def parse_perms(self, fsr):
|
perms = [PERM.name for PERM in SIMPLE_PERMISSIONS if (access_mask & PERM.value) == PERM.value]
|
||||||
_perms = []
|
# use bitwise NOT operator (~) and sum() function to clear the bits that have been processed
|
||||||
for PERM in SIMPLE_PERMISSIONS:
|
access_mask &= ~sum(PERM.value for PERM in SIMPLE_PERMISSIONS if (access_mask & PERM.value) == PERM.value)
|
||||||
if (fsr & PERM.value) == PERM.value:
|
perms += [PERM.name for PERM in ACCESS_MASK if access_mask & PERM.value]
|
||||||
_perms.append(PERM.name)
|
return perms
|
||||||
fsr = fsr & (not PERM.value)
|
|
||||||
for PERM in ACCESS_MASK:
|
|
||||||
if fsr & PERM.value:
|
|
||||||
_perms.append(PERM.name)
|
|
||||||
return _perms
|
|
||||||
|
|
||||||
# Parses a specified ACE and extract the different values (Flags, Access Mask, Trustee, ObjectType, InheritedObjectType)
|
# Parses a specified ACE and extract the different values (Flags, Access Mask, Trustee, ObjectType, InheritedObjectType)
|
||||||
# - ace : the ACE to parse
|
# - ace : the ACE to parse
|
||||||
|
|
Loading…
Reference in New Issue