@@ -17,70 +17,4 @@ def options(self, context, module_options):
1717 pass
1818
1919 def on_login (self , context , connection ):
20- search_filter = "(&(objectClass=trustedDomain))"
21- attributes = ["flatName" , "trustPartner" , "trustDirection" , "trustAttributes" ]
22-
23- context .log .debug (f"Search Filter={ search_filter } " )
24- resp = connection .ldap_connection .search (searchFilter = search_filter , attributes = attributes , sizeLimit = 0 )
25-
26- trusts = []
27- context .log .debug (f"Total of records returned { len (resp )} " )
28- for item in resp :
29- if isinstance (item , ldapasn1_impacket .SearchResultEntry ) is not True :
30- continue
31- flat_name = ""
32- trust_partner = ""
33- trust_direction = ""
34- trust_transitive = []
35- try :
36- for attribute in item ["attributes" ]:
37- if str (attribute ["type" ]) == "flatName" :
38- flat_name = str (attribute ["vals" ][0 ])
39- elif str (attribute ["type" ]) == "trustPartner" :
40- trust_partner = str (attribute ["vals" ][0 ])
41- elif str (attribute ["type" ]) == "trustDirection" :
42- if str (attribute ["vals" ][0 ]) == "1" :
43- trust_direction = "Inbound"
44- elif str (attribute ["vals" ][0 ]) == "2" :
45- trust_direction = "Outbound"
46- elif str (attribute ["vals" ][0 ]) == "3" :
47- trust_direction = "Bidirectional"
48- elif str (attribute ["type" ]) == "trustAttributes" :
49- trust_attributes_value = int (attribute ["vals" ][0 ])
50- if trust_attributes_value & 0x1 :
51- trust_transitive .append ("Non-Transitive" )
52- if trust_attributes_value & 0x2 :
53- trust_transitive .append ("Uplevel-Only" )
54- if trust_attributes_value & 0x4 :
55- trust_transitive .append ("Quarantined Domain" )
56- if trust_attributes_value & 0x8 :
57- trust_transitive .append ("Forest Transitive" )
58- if trust_attributes_value & 0x10 :
59- trust_transitive .append ("Cross Organization" )
60- if trust_attributes_value & 0x20 :
61- trust_transitive .append ("Within Forest" )
62- if trust_attributes_value & 0x40 :
63- trust_transitive .append ("Treat as External" )
64- if trust_attributes_value & 0x80 :
65- trust_transitive .append ("Uses RC4 Encryption" )
66- if trust_attributes_value & 0x100 :
67- trust_transitive .append ("Cross Organization No TGT Delegation" )
68- if trust_attributes_value & 0x2000 :
69- trust_transitive .append ("PAM Trust" )
70- if not trust_transitive :
71- trust_transitive .append ("Other" )
72- trust_transitive = ", " .join (trust_transitive )
73-
74- if flat_name and trust_partner and trust_direction and trust_transitive :
75- trusts .append ((flat_name , trust_partner , trust_direction , trust_transitive ))
76- except Exception as e :
77- context .log .debug (f"Cannot process trust relationship due to error { e } " )
78-
79- if trusts :
80- context .log .success ("Found the following trust relationships:" )
81- for trust in trusts :
82- context .log .highlight (f"{ trust [1 ]} -> { trust [2 ]} -> { trust [3 ]} " )
83- else :
84- context .log .display ("No trust relationships found" )
85-
86- return True
20+ context .log .fail ('[REMOVED] This module moved to the --dc-list LDAP flag.' )
0 commit comments