Skip to content

Commit 7fb80e6

Browse files
authored
Update search filter for computer accounts
The userAccountControl search filter is a bit restrictive. I changed it from 4128 (32 - PASSWD_NOTREQD + 4096 - WORKSTATION_TRUST_ACCOUNT) to only 4096 since "After a computer account has joined the domain, it will just have the WORKSTATION_TRUST_ACCOUNT flag set (4096)" - https://www.trustedsec.com/blog/diving-into-pre-created-computer-accounts Signed-off-by: ledrypotato <matt.taylor3@proton.me>
1 parent d2342db commit 7fb80e6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

nxc/modules/pre2k.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def options(self, context, module_options):
2222
"""No options available"""
2323

2424
def on_login(self, context, connection):
25-
# Define the search filter for pre-created computer accounts
26-
search_filter = "(&(objectClass=computer)(userAccountControl=4128))"
25+
# Define the search filter for computer accounts
26+
search_filter = "(&(objectClass=computer)(userAccountControl=4096))"
2727
attributes = ["sAMAccountName", "userAccountControl", "dNSHostName"]
2828

2929
context.log.info(f"Using search filter: {search_filter}")
@@ -39,8 +39,8 @@ def on_login(self, context, connection):
3939

4040
for computer in results:
4141
context.log.debug(f"Processing computer: {computer['sAMAccountName']}, UAC: {computer['userAccountControl']}")
42-
# Check if the account is a pre-created computer account
43-
if int(computer["userAccountControl"]) == 4128: # 4096 | 32
42+
# Check if the account is a computer account (WORKSTATION_TRUST_ACCOUNT)
43+
if int(computer["userAccountControl"]) == 4096:
4444
computers.append(computer["sAMAccountName"])
4545
context.log.debug(f"Added computer: {computer['sAMAccountName']}")
4646

0 commit comments

Comments
 (0)