The Windows registry is a central data storage for the operation system as well as for applications. It’s a key-value storage in a tree structure.
A hive is a set of keys and their values. The root hives are:
| Short | Long | Content | Source file |
|---|---|---|---|
| HKCR | HKEY_CLASSES_ROOT | Information about file types and properties | |
| HKCC | HKEY_CURRRENT_CONFIG | Information about the hardware configuration | |
| HKCU | HKEY_CURRENT_USER | Settings from the current user. This key changes depending the current user. | $userprofile\Ntuser.dat |
| HKLM | HKEY_LOCAL_MACHINE | Hardware information about devices, memory and drivers. | HKLM\SAM: \system32\config\sam HKLM\Security: \system32\config\security HKLM\Software: \system32\config\software HKLM\System: \system32\config\system |
| HKU | HKEY_USERS | Default settings for new users. |
There are also a few volatile keys like HKLM\Hardware which are deleted with system shutdown.
Enumeration
Get information about a key:
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon"
Search in the registry for passwords:
reg query HKLM /f password /t REG_SZ /s reg query HKCU /f password /t REG_SZ /s reg query "HKCU\Software\SimonTatham\PuTTY\Sessions" /s | findstr "HKEY_CURRENT_USER HostName PortNumber UserName PublicKeyFile PortForwardings ConnectionSharing ProxyPassword ProxyUsername reg query HKCU\Software\SimonTatham\PuTTY\SshHostKeys\ reg query HKEY_CURRENT_USER\Software\OpenSSH\Agent\Keys
Usage
See the permissions for registry keys like follows:
subinacl /keyreg HKEY_LOCAL_MACHINE\software\microsoft
Write a null-terminated string in the new key NewKeyName:
reg add hklm\Software\Bla /v NewKeyName /t REG_SZ /d "This is new string content."
Export a (sub-) tree:
reg export HKLM\Software\Suppensoftware exp.reg
Various
To detect autostart programs:
reg query "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run"
reg query "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce"
reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"
reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce"
Regrip
Use Regripper to export parts of a registry hive file (e.g. NTUSER.DAT) into a clear text file.
Use registry-read.py (from Impacket) to parse offline a registry hive file (NTUSER.DAT).
Reglookup is also available.
Leave a Reply
You must be logged in to post a comment.