@@ -1410,7 +1410,7 @@ def pso_mins(ldap_time):
14101410 return f"{ rd (seconds = int (abs (int (ldap_time )) / 10000000 )).minutes } minutes"
14111411
14121412 # Are there even any FGPPs?
1413- self .logger .success ("Attempting to enumerate policies..." )
1413+ self .logger .info ("Attempting to enumerate policies..." )
14141414 resp = self .search (searchFilter = "(objectclass=*)" , baseDN = f"CN=Password Settings Container,CN=System,{ self .baseDN } " , attributes = [])
14151415 if len (resp ) > 1 :
14161416 self .logger .highlight (f"{ len (resp ) - 1 } PSO Objects found!" )
@@ -1419,57 +1419,42 @@ def pso_mins(ldap_time):
14191419
14201420 # Who do they apply to?
14211421 resp = self .search (searchFilter = "(objectclass=*)" , attributes = ["DistinguishedName" , "msDS-PSOApplied" ])
1422- for attrs in resp :
1423- if isinstance (attrs , ldapasn1_impacket .SearchResultEntry ) is not True :
1424- continue
1425- for attr in attrs ["attributes" ]:
1426- if str (attr ["type" ]) in "msDS-PSOApplied" :
1427- self .logger .highlight (f"Object: { attrs ['objectName' ]} " )
1428- self .logger .highlight ("Applied Policy: " )
1429- for value in attr ["vals" ]:
1430- self .logger .highlight (f"\t { value } " )
1431- self .logger .highlight ("" )
1422+ resp_parsed = parse_result_attributes (resp )
1423+ for attrs in resp_parsed :
1424+ if "msDS-PSOApplied" in attrs :
1425+ # Get the distinguished name from the original response for objectName
1426+ for orig_resp in resp :
1427+ if isinstance (orig_resp , ldapasn1_impacket .SearchResultEntry ):
1428+ self .logger .highlight (f"Object: { orig_resp ['objectName' ]} " )
1429+ break
1430+ self .logger .highlight ("Applied Policy: " )
1431+ pso_applied = attrs ["msDS-PSOApplied" ]
1432+ self .logger .highlight (f"\t { pso_applied } " )
1433+ self .logger .highlight ("" )
14321434
14331435 # Let's find out even more details!
1434- self .logger .success ("Attempting to enumerate details...\n " )
1436+ self .logger .info ("Attempting to enumerate details...\n " )
14351437 resp = self .search (searchFilter = "(objectclass=msDS-PasswordSettings)" ,
14361438 attributes = ["name" , "msds-lockoutthreshold" , "msds-psoappliesto" , "msds-minimumpasswordlength" ,
14371439 "msds-passwordhistorylength" , "msds-lockoutobservationwindow" , "msds-lockoutduration" ,
14381440 "msds-passwordsettingsprecedence" , "msds-passwordcomplexityenabled" , "Description" ,
14391441 "msds-passwordreversibleencryptionenabled" , "msds-minimumpasswordage" , "msds-maximumpasswordage" ])
1440- for attrs in resp :
1441- if not isinstance (attrs , ldapasn1_impacket .SearchResultEntry ):
1442- continue
1443- policyName , description , passwordLength , passwordhistorylength , lockoutThreshold , observationWindow , lockoutDuration , complexity , minPassAge , maxPassAge , reverseibleEncryption , precedence , policyApplies = ("" ,) * 13
1444- for attr in attrs ["attributes" ]:
1445- if str (attr ["type" ]) == "name" :
1446- policyName = attr ["vals" ][0 ]
1447- elif str (attr ["type" ]) == "msDS-LockoutThreshold" :
1448- lockoutThreshold = attr ["vals" ][0 ]
1449- elif str (attr ["type" ]) == "msDS-MinimumPasswordLength" :
1450- passwordLength = attr ["vals" ][0 ]
1451- elif str (attr ["type" ]) == "msDS-PasswordHistoryLength" :
1452- passwordhistorylength = attr ["vals" ][0 ]
1453- elif str (attr ["type" ]) == "msDS-LockoutObservationWindow" :
1454- observationWindow = attr ["vals" ][0 ]
1455- elif str (attr ["type" ]) == "msDS-LockoutDuration" :
1456- lockoutDuration = attr ["vals" ][0 ]
1457- elif str (attr ["type" ]) == "msDS-PasswordSettingsPrecedence" :
1458- precedence = attr ["vals" ][0 ]
1459- elif str (attr ["type" ]) == "msDS-PasswordComplexityEnabled" :
1460- complexity = attr ["vals" ][0 ]
1461- elif str (attr ["type" ]) == "msDS-PasswordReversibleEncryptionEnabled" :
1462- reverseibleEncryption = attr ["vals" ][0 ]
1463- elif str (attr ["type" ]) == "msDS-MinimumPasswordAge" :
1464- minPassAge = attr ["vals" ][0 ]
1465- elif str (attr ["type" ]) == "msDS-MaximumPasswordAge" :
1466- maxPassAge = attr ["vals" ][0 ]
1467- elif str (attr ["type" ]) == "description" :
1468- description = attr ["vals" ][0 ]
1469- elif str (attr ["type" ]) == "msDS-PSOAppliesTo" :
1470- policyApplies = ""
1471- for value in attr ["vals" ]:
1472- policyApplies += f"{ value } ;"
1442+ resp_parsed = parse_result_attributes (resp )
1443+ for attrs in resp_parsed :
1444+ policyName = attrs .get ("name" , "" )
1445+ description = attrs .get ("description" , "" )
1446+ passwordLength = attrs .get ("msDS-MinimumPasswordLength" , "" )
1447+ passwordhistorylength = attrs .get ("msDS-PasswordHistoryLength" , "" )
1448+ lockoutThreshold = attrs .get ("msDS-LockoutThreshold" , "" )
1449+ observationWindow = attrs .get ("msDS-LockoutObservationWindow" , "" )
1450+ lockoutDuration = attrs .get ("msDS-LockoutDuration" , "" )
1451+ complexity = attrs .get ("msDS-PasswordComplexityEnabled" , "" )
1452+ minPassAge = attrs .get ("msDS-MinimumPasswordAge" , "" )
1453+ maxPassAge = attrs .get ("msDS-MaximumPasswordAge" , "" )
1454+ reverseibleEncryption = attrs .get ("msDS-PasswordReversibleEncryptionEnabled" , "" )
1455+ precedence = attrs .get ("msDS-PasswordSettingsPrecedence" , "" )
1456+ policyApplies = attrs .get ("msDS-PSOAppliesTo" , "" )
1457+
14731458 self .logger .highlight (f"Policy Name: { policyName } " )
14741459 if description :
14751460 self .logger .highlight (f"Description: { description } " )
@@ -1484,9 +1469,12 @@ def pso_mins(ldap_time):
14841469 self .logger .highlight (f"Reversible Encryption: { reverseibleEncryption } " )
14851470 self .logger .highlight (f"Precedence: { precedence } (Lower is Higher Priority)" )
14861471 self .logger .highlight ("Policy Applies to:" )
1487- for value in str (policyApplies )[:- 1 ].split (";" ):
1488- if value :
1489- self .logger .highlight (f"\t { value } " )
1472+ if isinstance (policyApplies , list ):
1473+ for value in policyApplies :
1474+ if value :
1475+ self .logger .highlight (f"\t { value } " )
1476+ elif policyApplies :
1477+ self .logger .highlight (f"\t { policyApplies } " )
14901478 self .logger .highlight ("" )
14911479
14921480 def bloodhound (self ):
0 commit comments