diff --git a/nxc/protocols/ldap.py b/nxc/protocols/ldap.py index 83243b55c4..121ac0c441 100644 --- a/nxc/protocols/ldap.py +++ b/nxc/protocols/ldap.py @@ -20,6 +20,7 @@ from impacket.dcerpc.v5.samr import ( UF_ACCOUNTDISABLE, UF_DONT_REQUIRE_PREAUTH, + UF_DONT_EXPIRE_PASSWD, UF_TRUSTED_FOR_DELEGATION, UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION, UF_SERVER_TRUST_ACCOUNT, @@ -1400,6 +1401,23 @@ def password_not_required(self): else: self.logger.fail("No entries found!") + def password_never_expires(self): + search_filter = f"(&(userAccountControl:1.2.840.113556.1.4.803:={UF_DONT_EXPIRE_PASSWD})(!(userAccountControl:1.2.840.113556.1.4.803:={UF_ACCOUNTDISABLE})))" + attributes = ["sAMAccountName", "pwdLastSet"] + resp = self.search(search_filter, attributes, baseDN=self.baseDN) + resp_parsed = parse_result_attributes(resp) + self.logger.debug(f"Total of records returned {len(resp_parsed):d}") + + if resp_parsed: + self.logger.highlight(f"{'-Username-':<30}{'-Last PW Set-':<20}") + for user in resp_parsed: + pwd_last_set = user.get("pwdLastSet", "") + if pwd_last_set: + pwd_last_set = "" if pwd_last_set == "0" else datetime.fromtimestamp(self.getUnixTime(int(pwd_last_set))).strftime("%Y-%m-%d %H:%M:%S") + self.logger.highlight(f"{user.get('sAMAccountName', ''):<30}{pwd_last_set:<20}") + else: + self.logger.fail("No entries found!") + def admin_count(self): # Building the search filter resp = self.search(searchFilter="(&(adminCount=1)(objectClass=user))", attributes=["sAMAccountName"], sizeLimit=0) diff --git a/nxc/protocols/ldap/proto_args.py b/nxc/protocols/ldap/proto_args.py index e9813c6341..8788b236c1 100644 --- a/nxc/protocols/ldap/proto_args.py +++ b/nxc/protocols/ldap/proto_args.py @@ -29,6 +29,7 @@ def proto_args(parser, parents): vgroup.add_argument("--find-delegation", action="store_true", help="Finds delegation relationships within an Active Directory domain. (Enabled Accounts only)") vgroup.add_argument("--trusted-for-delegation", action="store_true", help="Get the list of users and computers with flag TRUSTED_FOR_DELEGATION") vgroup.add_argument("--password-not-required", action="store_true", help="Get the list of users with flag PASSWD_NOTREQD") + vgroup.add_argument("--password-never-expires", action="store_true", help="Get the list of users with flag DONT_EXPIRE_PASSWORD") vgroup.add_argument("--admin-count", action="store_true", help="Get user that had the value adminCount=1") vgroup.add_argument("--users", nargs="*", help="Enumerate domain users") vgroup.add_argument("--users-export", help="Enumerate domain users and export them to the specified file") diff --git a/tests/e2e_commands.txt b/tests/e2e_commands.txt index bb70bdd51f..3945622266 100644 --- a/tests/e2e_commands.txt +++ b/tests/e2e_commands.txt @@ -241,6 +241,7 @@ netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --kerberoa netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --kerberoast /tmp/kerberoasting2.txt netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --kerberoasting /tmp/kerberoasting3.txt --kerberoast-account test_user netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --trusted-for-delegation +netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --password-never-expires netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --admin-count netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --gmsa netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --pso