Update ldap.py

Fixed single quotes and blank spaces

Signed-off-by: termanix <50464194+termanix@users.noreply.github.com>
main
termanix 2024-03-22 19:04:40 +03:00 committed by GitHub
parent 7c07ab04d7
commit 9603f8f450
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 9 deletions

View File

@ -880,18 +880,19 @@ class ldap(connection):
users_args = parse_result_attributes(resp_args) users_args = parse_result_attributes(resp_args)
# This try except for, if user gives a doesn't exist username. If it does, parsing process is crashing # This try except for, if user gives a doesn't exist username. If it does, parsing process is crashing
try: try:
for i in range(0, len(self.args.active_users)): for i in range(len(self.args.active_users)):
argsusers.append(users_args[i]) argsusers.append(users_args[i])
except: except Exception as e:
pass self.logger.debug("Exception:", exc_info=True)
self.logger.debug(f"Skipping item, cannot process due to error {e}")
else: else:
argsusers = allusers argsusers = allusers
for user in allusers: for user in allusers:
account_disabled = int(user.get('userAccountControl')) & 2 account_disabled = int(user.get("userAccountControl")) & 2
if not account_disabled: if not account_disabled:
count += 1 count += 1
activeusers.append(user.get('sAMAccountName').lower()) activeusers.append(user.get("sAMAccountName").lower())
if self.username == "": if self.username == "":
self.logger.display(f"Total records returned: {len(resp):d}") self.logger.display(f"Total records returned: {len(resp):d}")
@ -912,11 +913,11 @@ class ldap(connection):
parsed_pw_last_set = "<never>" parsed_pw_last_set = "<never>"
if arguser.get('sAMAccountName').lower() in activeusers and arg is False: if arguser.get('sAMAccountName').lower() in activeusers and arg is False:
self.logger.highlight(f"{arguser.get('sAMAccountName', ''):<30}{parsed_pw_last_set:<20}{arguser.get('badPwdCount', ''):<8}{arguser.get('description', ''):<60}") self.logger.highlight(f"{arguser.get("sAMAccountName", ""):<30}{parsed_pw_last_set:<20}{arguser.get('badPwdCount', ''):<8}{arguser.get('description', ''):<60}")
elif (arguser.get('sAMAccountName').lower() not in activeusers) and (arg is True): elif (arguser.get('sAMAccountName').lower() not in activeusers) and (arg is True):
self.logger.highlight(f"{arguser.get('sAMAccountName', ''):<7} {'(Disabled)':<22}{parsed_pw_last_set:<20}{arguser.get('badPwdCount', ''):<8}{arguser.get('description', ''):<60}") self.logger.highlight(f"{arguser.get("sAMAccountName", ""):<7} {'(Disabled)':<22}{parsed_pw_last_set:<20}{arguser.get('badPwdCount', ''):<8}{arguser.get('description', ''):<60}")
elif (arguser.get('sAMAccountName').lower() in activeusers) : elif (arguser.get('sAMAccountName').lower() in activeusers):
self.logger.highlight(f"{arguser.get('sAMAccountName', ''):<30}{parsed_pw_last_set:<20}{arguser.get('badPwdCount', ''):<8}{arguser.get('description', ''):<60}") self.logger.highlight(f"{arguser.get("sAMAccountName", ""):<30}{parsed_pw_last_set:<20}{arguser.get('badPwdCount', ''):<8}{arguser.get('description', ''):<60}")
def asreproast(self): def asreproast(self):
if self.password == "" and self.nthash == "" and self.kerberos is False: if self.password == "" and self.nthash == "" and self.kerberos is False: