Skip to main content

Summary

Enumerates network shares on a specified computer using NetShareEnum 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

Raw Output:
Formatted Output: net_shares

Detailed Summary

Agent Execution Flow

1. API Function Resolution

  • Resolves NetShareEnum from SRVCLI library
  • Resolves NetApiBufferFree from 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 NetShareEnum with 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 NetShareEnum return 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

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

  1. Requires network connectivity for remote computers
  2. Share accessibility depends on current user’s permissions
  3. Some administrative shares may be hidden or restricted
  4. Access testing may generate audit logs
  5. 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