Skip to content

Commit 74dcef7

Browse files
committed
Add CAS attribute
1 parent 2151520 commit 74dcef7

1 file changed

Lines changed: 27 additions & 6 deletions

File tree

nxc/modules/sccm.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def on_login(self, context, connection):
3838
self.base_dn = connection.ldapConnection._baseDN if not self.base_dn else self.base_dn
3939
self.sc = ldap.SimplePagedResultsControl()
4040

41+
# Basic SCCM enumeration
4142
try:
4243
# Search for SCCM root object
4344
search_filter = f"(distinguishedName=CN=System Management,CN=System,{self.base_dn})"
@@ -69,16 +70,36 @@ def on_login(self, context, connection):
6970
self.context.log.highlight(f"{self.sccm_sites[site]['cn']}")
7071
self.context.log.highlight(f" Site Code: {site.rjust(14)}")
7172
self.context.log.highlight(f" Assignment Site Code: {self.sccm_sites[site]['AssignmentSiteCode'].rjust(3)}")
72-
self.context.log.highlight(" Management Points:")
73-
for mp in self.sccm_sites[site]["ManagementPoints"]:
74-
self.context.log.highlight(f"\t CN:{' ':<12}{mp['cn']}")
75-
self.context.log.highlight(f"\t DNS Hostname:{' ':<2}{mp['dNSHostName']}")
76-
self.context.log.highlight(f"\t IP Address:{' ':<4}{mp['IPAddress']}")
77-
self.context.log.highlight(f"\t Default MP:{' ':<4}{mp['mSSMSDefaultMP']}")
73+
74+
# If there aren't Management Points, it's a Central Administration Site
75+
if self.sccm_sites[site]["ManagementPoints"]:
76+
self.context.log.highlight(f" CAS: {' ':<17}{False}")
77+
self.context.log.highlight(" Management Points:")
78+
for mp in self.sccm_sites[site]["ManagementPoints"]:
79+
self.context.log.highlight(f"\t CN:{' ':<12}{mp['cn']}")
80+
self.context.log.highlight(f"\t DNS Hostname:{' ':<2}{mp['dNSHostName']}")
81+
self.context.log.highlight(f"\t IP Address:{' ':<4}{mp['IPAddress']}")
82+
self.context.log.highlight(f"\t Default MP:{' ':<4}{mp['mSSMSDefaultMP']}")
83+
else:
84+
self.context.log.highlight(f" CAS: {' ':<17}{True}")
7885
self.context.log.highlight("")
7986
except LDAPSearchError as e:
8087
context.log.fail(f"Got unexpected exception: {e}")
8188

89+
# Enumerate users/groups/computers with "SCCM" in their name
90+
# hippity hoppity your code is now my property, filter stolen from the awesome sccmhunter repository
91+
# https://github.com/garrettfoster13/sccmhunter
92+
try:
93+
yoinkers = '(|(samaccountname=*sccm*)(samaccountname=*mecm*)(description=*sccm*)(description=*mecm*)(name=*sccm*)(name=*mecm*))'
94+
context.log.display("Searching for SCCM related objects")
95+
result = connection.ldapConnection.search(
96+
searchFilter=yoinkers,
97+
searchBase=self.base_dn,
98+
attributes=["sAMAccountName", "distinguishedName"],
99+
)
100+
except LDAPSearchError as e:
101+
context.log.fail(f"Got unexpected exception: {e}")
102+
82103
def get_management_points(self):
83104
"""Searches for all SCCM management points in the Active Directory and maps them to their SCCM site via the site code."""
84105
try:

0 commit comments

Comments
 (0)