Skip to main content
Artifacts Generated: Registry Read

Summary

Queries Windows registry keys and values using Microsoft.Win32.RegistryKey APIs. Enumerates subkeys and values within a specified registry path, handling multiple data types and generating registry access artifacts.
  • Needs Admin: False
  • Version: 2
  • Author: @djhohnstein

Arguments

  • hive (ChooseOne) - Registry hive (HKLM, HKCU, HKU, HKCR, HKCC)
  • key (String, Optional) - Registry key path within the hive

Usage

subkeys Raw Output:
Formatted Output: subkeys

Detailed Summary

Agent Execution Flow

1. Parameter Processing

  • Deserializes registry hive and key path
  • Supports both full and abbreviated hive names

2. Subkey Enumeration

  • Uses RegistryUtils.GetRegistryKey() to open registry key
  • Calls GetSubKeyNames() to enumerate child keys
  • Constructs full path for each subkey
  • Marks entries as “key” type

3. Registry Value Enumeration

  • Enumerates value names within the registry key
  • Retrieves actual value data for each name
  • Processes value types for proper display

4. Value Type Processing

  • Handles multiple registry data types
  • Converts binary data to hex string representation
  • Provides fallback for unknown types

5. Artifact Generation

  • Creates registry read artifact for each key access
  • Generates separate artifacts for value reads
  • Tracks all registry access operations

6. Error Handling

  • Separates subkey and value enumeration errors
  • Continues processing if one operation fails
  • Reports errors only if no results obtained

Registry Hive Mapping

Supported Hives

Hive Resolution

  • Accepts both full and abbreviated hive names
  • Normalizes to abbreviated format for consistency

Data Structures

RegQueryResult

Registry Data Types

Supported Types

  • String: REG_SZ and REG_EXPAND_SZ values
  • Integer: REG_DWORD values
  • Binary: REG_BINARY displayed as hex
  • Null: Empty or null values
  • Unknown: Fallback for unsupported types

Binary Data Handling

  • Converts byte arrays to hex string format
  • Uses hyphen-separated hex representation

Registry Access Patterns

Key Enumeration

  1. Open registry key with read access
  2. Call GetSubKeyNames() to list child keys
  3. Build full paths for navigation
  4. Mark as “key” type results

Value Enumeration

  1. Open same registry key
  2. Call GetValueNames() to list values
  3. Retrieve value data with GetValue()
  4. Process data types appropriately
  5. Mark as “value” type results

APIs Used

MITRE ATT&CK Mapping

  • T1012 - Query Registry
  • T1552 - Unsecured Credentials (registry stored credentials)

Security Considerations

  • Information Disclosure: Reveals registry structure and sensitive values
  • Credential Exposure: May expose stored passwords or keys
  • System Configuration: Shows security settings and configurations
  • Attack Planning: Provides reconnaissance for privilege escalation

Limitations

  1. Access depends on current user privileges
  2. Some registry keys require elevated permissions
  3. Large registry trees may impact performance
  4. Binary data displayed as hex strings only
  5. No write or modification capabilities

Error Conditions

  • Access Denied: Insufficient permissions for registry key
  • Key Not Found: Specified registry path doesn’t exist
  • Invalid Hive: Unsupported or malformed hive name
  • Path Too Long: Registry path exceeds maximum length
  • System Error: Underlying registry API failures

Common Use Cases

System Information

  • HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion - OS version info
  • HKLM\SYSTEM\CurrentControlSet\Services - Service configurations
  • HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall - Installed programs

User Settings

  • HKCU\Software - User application settings
  • HKCU\Environment - User environment variables
  • HKCU\Software\Microsoft\Windows\CurrentVersion\Run - User startup programs

Security Settings

  • HKLM\SYSTEM\CurrentControlSet\Control\Lsa - LSA settings
  • HKLM\SOFTWARE\Policies - Group policy settings
  • HKCU\Software\Policies - User policy settings