@@ -19,17 +19,28 @@ class NXCModule:
1919 category = CATEGORY .PRIVILEGE_ESCALATION
2020
2121 def options (self , context , module_options ):
22- """No options available"""
22+ """
23+ ALL Attempt to authenticate for every computer object in the domain (userAccountControl=4096) (default: False)
24+
25+ Examples:
26+ nxc ldap $IP -u $USER -p $PASSWORD -M pre2k
27+ nxc ldap $IP -u $USER -p $PASSWORD -M pre2k -o ALL=True
28+ """
29+ self .all_option = bool (module_options .get ("ALL" , False ))
2330
2431 def on_login (self , context , connection ):
25- # Define the search filter for computer accounts
26- search_filter = "(&(objectClass=computer)(userAccountControl=4096))"
32+ # Define the search filter
33+ if (self .all_option ):
34+ search_filter = "(&(objectClass=computer))"
35+ else :
36+ search_filter = "(&(objectClass=computer)(userAccountControl=4128))" # 4128 = 4096 (WORKSTATION_TRUST_ACCOUNT) | 32 (WORKSTATION_TRUST_ACCOUNT)
37+
2738 attributes = ["sAMAccountName" , "userAccountControl" , "dNSHostName" ]
2839
2940 context .log .info (f"Using search filter: { search_filter } " )
3041 context .log .info (f"Attributes to retrieve: { attributes } " )
3142
32- computers = []
43+ computers = {}
3344
3445 try :
3546 # Use paged search to retrieve all computer accounts with specific flags
@@ -39,10 +50,8 @@ def on_login(self, context, connection):
3950
4051 for computer in results :
4152 context .log .debug (f"Processing computer: { computer ['sAMAccountName' ]} , UAC: { computer ['userAccountControl' ]} " )
42- # Check if the account is a computer account (WORKSTATION_TRUST_ACCOUNT)
43- if int (computer ["userAccountControl" ]) == 4096 :
44- computers .append (computer ["sAMAccountName" ])
45- context .log .debug (f"Added computer: { computer ['sAMAccountName' ]} " )
53+ computers [computer ["sAMAccountName" ]] = computer ["userAccountControl" ]
54+ context .log .debug (f"Added computer: { computer ['sAMAccountName' ]} " )
4655
4756 # Save computers to file
4857 domain_dir = os .path .join (f"{ NXC_PATH } /modules/pre2k" , connection .domain )
@@ -55,11 +64,15 @@ def on_login(self, context, connection):
5564 for computer in computers :
5665 file .write (f"{ computer } \n " )
5766
58- # Print discovered pre-created computer accounts
67+ # Print discovered ( pre-created) computer accounts
5968 if computers :
60- for computer in computers :
61- context .log .highlight (f"Pre-created computer account: { computer } " )
62- context .log .success (f"Found { len (computers )} pre-created computer accounts. Saved to { output_file } " )
69+ for computer , uac in computers .items ():
70+ if (int (uac )) == 4128 :
71+ context .log .highlight (f"Pre-created computer account: { computer } " )
72+ context .log .success (f"Found { len (computers )} pre-created computer accounts. Saved to { output_file } " )
73+ else :
74+ context .log .highlight (f"Computer account: { computer } " )
75+ context .log .success (f"Found { len (computers )} computer accounts. Saved to { output_file } " )
6376 else :
6477 context .log .info ("No pre-created computer accounts found." )
6578
@@ -76,7 +89,7 @@ def on_login(self, context, connection):
7689
7790 # Summary of TGT results
7891 if successful_tgts > 0 :
79- context .log .success (f"Successfully obtained TGT for { successful_tgts } pre-created computer accounts. Saved to { ccache_base_dir } " )
92+ context .log .success (f"Successfully obtained TGT for { successful_tgts } ( pre-created) computer accounts. Saved to { ccache_base_dir } " )
8093 except Exception as e :
8194 context .log .fail (f"Error occurred during search: { e } " )
8295
0 commit comments