@@ -201,7 +201,7 @@ def create_conn_obj(self):
201201 target_domain = sub (
202202 r",DC=" ,
203203 "." ,
204- base_dn [base_dn .lower ().find ("dc=" ) :],
204+ base_dn [base_dn .lower ().find ("dc=" ):],
205205 flags = IGNORECASE ,
206206 )[3 :]
207207 except ConnectionRefusedError as e :
@@ -322,7 +322,12 @@ def enum_host_info(self):
322322 self .output_filename = os .path .expanduser (f"~/.nxc/logs/{ self .hostname } _{ self .host } " .replace (":" , "-" ))
323323
324324 try :
325- self .db .add_host (self .host , self .hostname , self .domain , self .server_os )
325+ self .db .add_host (
326+ self .host ,
327+ self .hostname ,
328+ self .domain ,
329+ self .server_os
330+ )
326331 except Exception as e :
327332 self .logger .debug (f"Error adding host { self .host } into db: { e !s} " )
328333
@@ -338,7 +343,7 @@ def print_host_info(self):
338343 self .logger .display (f"{ self .server_os } (name:{ self .hostname } ) (domain:{ self .domain } ) ({ signing } ) ({ cbt_status } ) { ntlm } " )
339344
340345 def kerberos_login (self , domain , username , password = "" , ntlm_hash = "" , aesKey = "" , kdcHost = "" , useCache = False ):
341- self .username = username if not self .username else self .username # With ccache we get the username from the ticket
346+ self .username = username if not self .username else self .username # With ccache we get the username from the ticket
342347 self .password = password
343348 self .domain = domain
344349 self .kdcHost = kdcHost
@@ -870,12 +875,27 @@ def resolve_and_display_hostname(name, domain_name=None):
870875 trust_direction = int (trust ["trustDirection" ])
871876 trust_type = int (trust ["trustType" ])
872877 trust_attributes = int (trust ["trustAttributes" ])
873-
878+
874879 # See: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/e9a2d23c-c31e-4a6f-88a0-6646fdb51a3c
875- trust_attribute_flags = {0x1 : "Non-Transitive" , 0x2 : "Uplevel-Only" , 0x4 : "Quarantined Domain" , 0x8 : "Forest Transitive" , 0x10 : "Cross Organization" , 0x20 : "Within Forest" , 0x40 : "Treat as External" , 0x80 : "Uses RC4 Encryption" , 0x200 : "Cross Organization No TGT Delegation" , 0x800 : "Cross Organization Enable TGT Delegation" , 0x2000 : "PAM Trust" }
880+ trust_attribute_flags = {
881+ 0x1 : "Non-Transitive" ,
882+ 0x2 : "Uplevel-Only" ,
883+ 0x4 : "Quarantined Domain" ,
884+ 0x8 : "Forest Transitive" ,
885+ 0x10 : "Cross Organization" ,
886+ 0x20 : "Within Forest" ,
887+ 0x40 : "Treat as External" ,
888+ 0x80 : "Uses RC4 Encryption" ,
889+ 0x200 : "Cross Organization No TGT Delegation" ,
890+ 0x800 : "Cross Organization Enable TGT Delegation" ,
891+ 0x2000 : "PAM Trust"
892+ }
876893
877894 # For check if multiple posibble flags, like Uplevel-Only, Treat as External
878- trust_attributes_text = ", " .join (text for flag , text in trust_attribute_flags .items () if trust_attributes & flag ) or "Other" # If Trust attrs not known
895+ trust_attributes_text = ", " .join (
896+ text for flag , text in trust_attribute_flags .items ()
897+ if trust_attributes & flag
898+ ) or "Other" # If Trust attrs not known
879899
880900 # Convert trust direction/type to human-readable format
881901 direction_text = {
@@ -1091,7 +1111,10 @@ def printTable(items, header):
10911111 self .logger .highlight (outputFormat .format (* row ))
10921112
10931113 # Building the search filter
1094- search_filter = f"(&(|(UserAccountControl:1.2.840.113556.1.4.803:={ UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION } )(UserAccountControl:1.2.840.113556.1.4.803:={ UF_TRUSTED_FOR_DELEGATION } )(msDS-AllowedToDelegateTo=*)(msDS-AllowedToActOnBehalfOfOtherIdentity=*))(!(UserAccountControl:1.2.840.113556.1.4.803:={ UF_ACCOUNTDISABLE } )))"
1114+ search_filter = (f"(&(|(UserAccountControl:1.2.840.113556.1.4.803:={ UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION } )"
1115+ f"(UserAccountControl:1.2.840.113556.1.4.803:={ UF_TRUSTED_FOR_DELEGATION } )"
1116+ "(msDS-AllowedToDelegateTo=*)(msDS-AllowedToActOnBehalfOfOtherIdentity=*))"
1117+ f"(!(UserAccountControl:1.2.840.113556.1.4.803:={ UF_ACCOUNTDISABLE } )))" )
10951118 # f"(!(UserAccountControl:1.2.840.113556.1.4.803:={UF_SERVER_TRUST_ACCOUNT})))") This would filter out RBCD to DCs
10961119
10971120 attributes = ["sAMAccountName" , "pwdLastSet" , "userAccountControl" , "objectCategory" , "msDS-AllowedToActOnBehalfOfOtherIdentity" , "msDS-AllowedToDelegateTo" ]
0 commit comments