Overview
Thewinregistry module provides parsers for Windows Registry hives in both binary (saveRegistryParser) and exported text (exportRegistryParser) formats.
Factory Function
get_registry_parser()
Automatically detect and return the appropriate registry parser.Parameters
- hive (str/file): Path to registry file or file-like object
- isRemote (bool): Whether the file is remote (default: False)
Returns
saveRegistryParser or exportRegistryParser instance
Binary Registry Parser
saveRegistryParser
Parser for binary registry hive files (SYSTEM, SAM, SECURITY, SOFTWARE, etc.).Finding Keys
findKey()
Find a registry key by path.Parameters
- key (str): Registry key path (use
\\as separator)
Returns
REG_NK structure or None if not foundEnumerating Keys
enumKey()
List all subkeys of a key.Parameters
- parentKey (REG_NK): Parent key structure
Returns
List of subkey names (strings)Reading Values
getValue()
Get a registry value.Parameters
- keyValue (str): Full path to value or path to key
- valueName (str): Value name if keyValue is key path (optional)
Returns
Tuple of (ValueType, ValueData) or NoneWriting Values
setValue()
Modify a registry value (in-memory only).Parameters
- keyValue (str): Full path to the value
- valueData (bytes): New value data
Returns
Tuple of (ValueType, BytesWritten) or None Note: Length must match existing value. Writing different lengths is not implemented.Enumerating Values
enumValues()
List all values in a key.Parameters
- key (REG_NK): Key structure
Returns
List of value names (bytes)Walking the Registry
walk()
Recursively walk and print all subkeys.Parameters
- parentKey (str): Starting key path
Getting Class Data
getClass()
Retrieve class name data for a key.Registry Value Types
Constants
printValue()
Format and print a registry value.Export Registry Parser
exportRegistryParser
Parser for exported registry files (.reg format).Usage
The export parser provides the same interface as the binary parser:HKEY_LOCAL_MACHINE\\...).
Complete Examples
Extract SAM Hashes
Query Service Configuration
Extract Network Interfaces
Modify Registry Value
Search for Values
Registry Structure Classes
REG_NK (Named Key)
Key structure with subkeys and values.REG_VK (Value Key)
Value structure.Performance Tips
- Cache keys - Store frequently accessed key structures
- Use enumeration - More efficient than repeated findKey calls
- Close files - Always close registry files when done
- Remote access - Use
isRemote=Truefor remote file objects - Batch operations - Group related operations together
Limitations
- Write support limited - Can only modify existing values of same length
- No creation - Cannot create new keys or values
- No deletion - Cannot delete keys or values
- Transaction logs - Does not process transaction logs
- Hive recovery - Limited support for damaged hives
Common Registry Hives
SYSTEM
- Hardware configuration
- Services
- Network settings
- Boot configuration
SAM
- Local user accounts
- Password hashes
- Group memberships
SECURITY
- Security policies
- LSA secrets
- Cached credentials
SOFTWARE
- Installed applications
- Windows settings
- File associations
NTUSER.DAT
- Per-user settings
- Desktop configuration
- Application preferences