Skip to content

Commit 01c4a44

Browse files
Merge pull request Pennyw0rth#235 from Pennyw0rth/users-enum-fix
fix --users for LDAP proto
2 parents 2457ac0 + 63d6e19 commit 01c4a44

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

nxc/protocols/ldap.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -753,11 +753,14 @@ def users(self):
753753
self.logger.highlight(f"{'-Username-':<30}{'-Last PW Set-':<20}{'-BadPW-':<8}{'-Description-':<60}")
754754
for user in users:
755755
# TODO: functionize this - we do this calculation in a bunch of places, different, including in the `pso` module
756-
timestamp_seconds = int(user.get("pwdLastSet", "")) / 10**7
757-
start_date = datetime(1601, 1, 1)
758-
parsed_pw_last_set = (start_date + timedelta(seconds=timestamp_seconds)).replace(microsecond=0).strftime("%Y-%m-%d %H:%M:%S")
759-
if parsed_pw_last_set == "1601-01-01 00:00:00":
760-
parsed_pw_last_set = "<never>"
756+
parsed_pw_last_set = ""
757+
pwd_last_set = user.get("pwdLastSet", "")
758+
if pwd_last_set != "":
759+
timestamp_seconds = int(pwd_last_set) / 10**7
760+
start_date = datetime(1601, 1, 1)
761+
parsed_pw_last_set = (start_date + timedelta(seconds=timestamp_seconds)).replace(microsecond=0).strftime("%Y-%m-%d %H:%M:%S")
762+
if parsed_pw_last_set == "1601-01-01 00:00:00":
763+
parsed_pw_last_set = "<never>"
761764
# we default attributes to blank strings if they don't exist in the dict
762765
self.logger.highlight(f"{user.get('sAMAccountName', ''):<30}{parsed_pw_last_set:<20}{user.get('badPwdCount', ''):<8}{user.get('description', ''):<60}")
763766

0 commit comments

Comments
 (0)