Summary
Enumerates members of a specified local group usingNetLocalGroupGetMembers Win32 API. Retrieves member names, SIDs, and distinguishes between user and group members.
- Needs Admin: False
- Version: 2
- Author: @djhohnstein
Arguments
- computer (Optional String) - Target computer name (defaults to localhost)
- group (String) - Local group name to enumerate members
Usage
Detailed Summary
Agent Execution Flow
1. API Function Resolution
- Resolves
NetLocalGroupGetMembersfrom SAMCLI library - Resolves
ConvertSidToStringSidfrom ADVAPI32 library - Resolves
NetApiBufferFreefrom NETUTILS library
2. Parameter Processing
- Deserializes computer and group parameters
- Defaults to local computer name if not specified
3. Group Member Enumeration
- Calls
NetLocalGroupGetMemberswith level 2 for detailed member information - Uses preferred maximum length (-1) for optimal buffer allocation
- Returns buffer containing member structures and counts
4. Member Structure Processing
- Creates array to hold member structures
- Iterates through buffer using pointer arithmetic
- Marshals each structure from unmanaged memory
5. SID Conversion and Member Processing
- Converts binary SID to string representation
- Determines if member is a group or user based on
SidNameUse - Extracts domain and name from Unicode string pointer
- Skips members where SID conversion fails
6. Memory Management
- Frees allocated buffer using
NetApiBufferFree - Prevents memory leaks from unmanaged allocations
Data Structures
LocalGroupMembersInfo (Unmanaged)
NetLocalGroupMember (Managed)
SidNameUse Enumeration
Win32 API Integration
NetLocalGroupGetMembers Function
- servername: Target computer name
- localgroupname: Local group to enumerate
- level: Information level (2 for detailed member info)
- bufptr: Receives buffer pointer
- prefmaxlen: Preferred maximum buffer length
- entriesread: Number of entries returned
- totalentries: Total entries available
- resume_handle: Continuation handle
Browser Interface Integration
The JavaScript processes the JSON response into an interactive table with:- Group Type Column: Distinguishes between “User” and “Group” members
- Copy Icons: Allows copying member names and SIDs
- Dynamic Title: Shows group name in table title
- Member Details: Computer, group, member name, SID, and type
APIs Used
| API | Purpose | DLL |
|---|---|---|
NetLocalGroupGetMembers | Enumerate group members | samcli.dll |
ConvertSidToStringSid | Convert SID to string | advapi32.dll |
NetApiBufferFree | Free allocated buffer | netutils.dll |
Marshal.PtrToStructure | Convert unmanaged to managed | mscorlib.dll |
Marshal.PtrToStringUni | Convert Unicode pointer to string | mscorlib.dll |
MITRE ATT&CK Mapping
- T1590 - Gather Victim Network Information
- T1069 - Permission Groups Discovery
- T1069.001 - Local Groups
Security Considerations
- Privilege Enumeration: Reveals members of privileged groups
- User Discovery: Exposes user accounts with local privileges
- Attack Planning: Enables targeting of specific privileged users
- Detection Vectors: Group membership enumeration may be monitored
Limitations
- Requires access to target computer for remote enumeration
- May need administrative privileges for some groups/systems
- Only shows local group membership (not domain groups)
- SID conversion failures skip affected members
- Subject to Windows security policies and access controls
Error Conditions
- Access Denied: Insufficient privileges to enumerate group
- Group Not Found: Specified group doesn’t exist
- Network Path Not Found: Target computer unreachable
- Invalid Parameter: Malformed group or computer name
- SID Conversion Failure: Unable to convert binary SID to string