Summary
Enumerates local groups on a specified computer usingNetLocalGroupEnum Win32 API. Retrieves group names, comments, and generates SIDs for each local group.
- Needs Admin: False
- Version: 2
- Author: @djhohnstein
Arguments
- computer (Optional String) - Target computer name (defaults to localhost)
Usage
Detailed Summary
Agent Execution Flow
1. API Function Resolution
- Resolves
NetLocalGroupEnumfrom SAMCLI library - Resolves
NetApiBufferFreefrom NETUTILS library - Uses Apollo’s API resolution framework for dynamic loading
2. Target Computer Determination
- Uses provided computer name parameter
- Defaults to local computer name if no parameter specified
- Supports both hostname and FQDN formats
3. Local Group Enumeration
- Calls
NetLocalGroupEnumwith level 1 for group information - Uses
MAX_PREFERRED_LENGTH(-1) for optimal buffer allocation - Returns buffer containing group structures and counts
4. Structure Marshaling and Processing
- Iterates through buffer entries using pointer arithmetic
- Marshals each structure from unmanaged memory
- Converts Unicode string pointers to managed strings
- Advances pointer by structure size for next entry
5. Memory Management
- Ensures buffer cleanup using
NetApiBufferFree - Prevents memory leaks from unmanaged allocations
- Uses finally block for guaranteed cleanup
Data Structures
LocalGroupUsersInfo (Unmanaged)
NetLocalGroup (Managed)
Win32 API Integration
NetLocalGroupEnum Function
- servername: Target computer name (null for local)
- dwLevel: Information level (1 for basic group info)
- lpBuffer: Receives pointer to allocated buffer
- dwMaxLen: Preferred maximum buffer length (-1 for optimal)
- dwEntriesRead: Number of entries returned
- dwTotalEntries: Total entries available
- lpResume: Resume handle for continuation
Browser Interface Integration
The JavaScript processes the JSON response into an interactive table with:- Members Button: Launches
net_localgroup_membercommand for each group - Copy Icon: Allows copying group SIDs
- Sortable Columns: Name, comment, and SID columns
- Group Details: Computer name, group name, comment, and SID
Error Handling
- Checks API return code for errors
- Common error codes:
- 5: Access denied
- 53: Network path not found
- 1115: No more entries available
APIs Used
| API | Purpose | DLL |
|---|---|---|
NetLocalGroupEnum | Enumerate local groups | samcli.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
- Information Disclosure: Reveals local security group structure
- Privilege Enumeration: Shows administrative and privileged groups
- Attack Planning: Enables targeting of specific privilege groups
- Detection Vectors: Local group enumeration may be monitored
Limitations
- Requires network connectivity for remote computers
- May need administrative privileges for some remote systems
- Limited to local groups only (not domain groups)
- Does not show group membership details
- Subject to Windows security policies and access controls
Error Conditions
- Access Denied: Insufficient privileges to enumerate groups
- Network Path Not Found: Target computer unreachable
- Invalid Computer Name: Specified computer doesn’t exist
- RPC Server Unavailable: Remote procedure call failures
- Buffer Allocation: Memory allocation failures