Summary
Enumerates network shares on a specified computer usingNetShareEnum Win32 API. Tests share accessibility and categorizes share types including disk drives, print queues, and IPC shares.
- 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
NetShareEnumfrom SRVCLI library - Resolves
NetApiBufferFreefrom NETUTILS library - Uses Apollo’s dynamic API resolution framework
2. Parameter Processing
- Deserializes computer parameter
- Defaults to local computer name if not specified
3. Share Enumeration
- Calls
NetShareEnumwith level 1 for basic share information - Uses maximum preferred length (0xFFFFFFFF) for buffer allocation
- Returns enumeration result code and share count
4. Share Structure Processing
- Iterates through buffer entries using pointer arithmetic
- Marshals each structure from unmanaged memory
- Advances pointer by structure size for next entry
- Frees buffer memory after processing
5. Share Accessibility Testing
- Constructs UNC path for each share
- Attempts to list files using
Directory.GetFiles() - Sets readable flag based on access success/failure
- Handles permission exceptions gracefully
6. Share Type Classification
- Maps share type enumeration to human-readable descriptions
- Handles standard Windows share types
- Provides fallback for unknown share types
Data Structures
ShareInfo (Unmanaged)
NetShareInformation (Managed)
ShareType Enumeration
Win32 API Integration
NetShareEnum Function
- serverName: Target computer name
- level: Information level (1 for basic share 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:- List Button: Launches file browser for accessible shares
- Button State: Disabled for non-readable shares
- Share Details: Name, comment, type, and accessibility
- Dynamic Title: Shows target computer name
Error Handling
- API Errors: Captures and reports
NetShareEnumreturn codes - Access Exceptions: Gracefully handles share access failures
- Memory Management: Ensures proper buffer cleanup
- Common Errors:
- 53: Network path not found
- 5: Access denied
APIs Used
| API | Purpose | DLL |
|---|---|---|
NetShareEnum | Enumerate network shares | srvcli.dll |
NetApiBufferFree | Free allocated buffer | netutils.dll |
Directory.GetFiles() | Test share accessibility | System.IO |
Marshal.PtrToStructure | Convert unmanaged to managed | mscorlib.dll |
MITRE ATT&CK Mapping
- T1590 - Gather Victim Network Information
- T1069 - Permission Groups Discovery
Security Considerations
- Information Disclosure: Reveals available network shares and types
- Access Testing: Probes share accessibility which may be logged
- Reconnaissance: Provides attack surface information
- Detection Vectors: Share enumeration may trigger security monitoring
Limitations
- Requires network connectivity for remote computers
- Share accessibility depends on current user’s permissions
- Some administrative shares may be hidden or restricted
- Access testing may generate audit logs
- Large number of shares may impact performance
Error Conditions
- Network Path Not Found: Target computer unreachable
- Access Denied: Insufficient privileges for share enumeration
- Invalid Computer Name: Specified computer doesn’t exist
- RPC Server Unavailable: Remote procedure call failures
- Buffer Allocation: Memory allocation failures