Eric Christensen
03/04/2024, 10:45 PMAdministrators
group? I have found several posts online regarding members of Administrators
, but this only takes local users into account. It does not show domain users or domain groups. There are the users
and groups
tables, but nothing that I can find like a group_members
sort of table.seph
Eric Christensen
03/05/2024, 3:00 PMseph
Eric Christensen
03/08/2024, 10:25 PMEric Christensen
03/08/2024, 10:35 PMgroup_members
?Eric Christensen
03/08/2024, 10:39 PMNET LOCALGROUP Administrators
, so it should be possible without having to enumerate the entire domain.seph
user_groups
seems to be indexed by user, and not by group.seph
seph
group_members
table would be that the user_groups
table is not already.
Looking at table implementations, I’d expect user_groups
to enumerate all the user/group pairs. It looks like it’s only indexed off user, but maybe it makes more sense to add group index support there, instead of a new table?
Probably the other issue, is that osquery implements a lot via uid
and not the more native sid
Eric Christensen
03/11/2024, 6:08 PMuser_groups
table only takes local users into account. I need a way to audit all members of the local Administrators groups; regardless if the member is a local user/group or domain user/group.
The reason I suggested a group_members
sort of table is because users
only shows information on local users, groups
only shows information on local groups, and user_groups
only correlates those local users to local groups. None of those query the groups directly for their members.
I am not sure what method Osquery uses for its queries of users and groups, but NET LOCALGROUP Administrators
shows all members (local users, local groups, domain users, and domain groups), and WMI can be used as well. This might be a bit ugly, but here is a WMI example to get all members (local users, local groups, domain users, and domain groups) from the Administrators group. I tested this on a domain VM with the NIC removed, and it successfully returned all the members I am expecting to see.
Dim strComputer
Dim objWMI
strComputer = CreateObject("WScript.Network").ComputerName
Set objWMI = GetObject("WinMgmts:{ImpersonationLevel=Impersonate}!\\" & strComputer & "\Root\CIMV2")
Set colItems = objWMI.ExecQuery("SELECT * FROM Win32_GroupUser WHERE GroupComponent = " & chr(34) & "Win32_Group.Domain='" & strComputer & "',Name='Administrators'" & Chr(34))
For Each objItem in colItems
arrComponent = Split(objItem.PartComponent, ",")
if inStr(arrComponent(0), "Win32_UserAccount") Then
strAccountType = "User"
ElseIf inStr(arrComponent(0), "Win32_Group") Then
strAccountType = "Group"
End If
strMemberName = Replace(Replace(arrComponent(1), Chr(34), ""), "Name=", "")
DomainNameArray = Split(arrComponent(0), "=")
strDomainName = Replace(DomainNameArray(1), Chr(34), "")
If UCase(strDomainName) <> UCase(strComputer) Then
strMemberName = strDomainName & "\" & strMemberName
strDomain = "Domain"
Else
strDomain = "Local"
End If
msgBox strDomain & " " & strAccountType & ": " & strMemberName, 0+64, "Administrators Group Member"
Next