SlideShare a Scribd company logo
In-depth forensic analysis of
Windows registry files
Maxim Suhanov
Registry basics
A typical registry path:
HKEY_LOCAL_MACHINESoftwareMicrosoft
This path is different in a kernel:
• RegistryMachineSoftwareMicrosoft
This hive is non-volatile (stored on a disk), backing files:
• C:WindowsSystem32configSOFTWARE
• C:WindowsSystem32configSOFTWARE.LOG (+ .LOG1/.LOG2)
Predefined key Mount point
of a hive
Key
Some hives do not have a visible
mount point!
Hive format (NT family)
Seven versions of the format:
from 1.0 (pre-release versions ofWindows NT 3.1)
to 1.6 (introduced inWindows 10 “Redstone 1”, not used yet)
The structure of a hive file:
Base block
(file header)
Hive bin Hive bin More hive bins
Remnant
data
The base block contains the size of all [allocated] hive bins.
Hive format (NT family)
A hive bin contains a header and cells.
Hive bin
Header Cell Cell More cells
A cell may contain:
• Key node (nk)
• Key value (vk)
• Key security (sk)
• List of subkeys (li, lf, lh)
• List of subkeys lists (ri)
• List of values
• Value data
• Big data records (db)
• List of segments
• Value data segments
The first 4 bytes of a cell are used to record the size of this cell
(positive value: unallocated cell, negative value: allocated cell)
The header contains the size of this hive bin.
Hive format (NT family)
Records (entities) point to other records (entities) using a relative offset of a cell.A base block
points to a root key node.
File offset of a cell = Length of a base block + Relative offset of a cell
File offset of a cell = 4096 + Relative offset of a cell
Key node
Key
security
List of
subkeys
List of
values
Key node
Key node
Key value Value data
Hive format (NT family)
All registry structures are documented here:
https://github.com/msuhanov/regf/
Transaction log files (NT family)
• Before writing dirty data to a primary file, this data is stored in a transaction log file.
• If a system crash occurs when writing to a transaction log file, a primary file will be intact.
• If a system crash occurs when writing to a primary file, a transaction log file will be used to repeat
the write operation.
The old format (before Windows 8.1):
Base block
(backup copy)
Dirty vector
(bitmap)
Dirty sectors (pages)
Remnant
data
G
a
p
Transaction log files (NT family)
• Every bit of the bitmap corresponds to a single 512-byte sector of the hive bins data in a primary
file.
• If set, a sector is dirty (and modified contents are in the transaction log file).
Relative offset of a dirty sector in a transaction log file = Index of a bit in the bitmap * 512
Relative from the start of dirty sectors (pages).
Zero-based.
As of Windows XP, a single run of dirty data is not smaller than a page (4096 bytes).
Transaction log files (NT family)
• A bad sector in a primary file results in the following:
 Dirty data cannot be written to a primary file (to the location with a bad sector).
 We cannot overwrite dirty data in an existing transaction log file (otherwise a system crash may leave us
without a good copy of dirty data).
 We cannot mark mounted hives as read-only.
 No further writes (after a failed one) to a primary file will be allowed (new dirty data will be discarded).
Transaction log files (NT family)
• Solution: the dual-logging scheme (starting from Windows Vista).
 After a failed write to a primary file, switch the log file being used (.LOG1 -> .LOG2, .LOG2 -> .LOG1),
and try the write operation again.
 Repeat this until a bad sector is gone.
Microsoft left the CmpFailPrimarySave kernel variable used to simulate failed writes!
Transaction log files (NT family)
• The old format requires dirty data to be written to a disk twice.
• The new format is used to stash dirty pages in a transaction log file without writing them to a
primary file.These pages will be written to a primary file later.
The new format (as ofWindows 8.1):
Base block
(backup copy)
Log entries
Remnant
data
Also, each log entry has a checksum for dirty data (Marvin32).
• When all users are inactive.
• During the full shutdown.
• After 3600 seconds since the latest write.
Deleted data (NT family)
• When a key or a value is deleted, all corresponding cells are marked as unallocated.
• A cell will be coalesced with an adjacent unallocated cell.
• A single unallocated cell may contain multiple delete records (entities).
Deleted data (NT family)
Well, not all cells are marked as unallocated when a corresponding record (entity) is deleted…
• In recent releases of Windows 10, renaming a key will leave an old key node in an allocated cell.
• This key node will be present until the hive is defragmented.
Thus,
Cells with deleted data = All cells – Referenced cells
Deleted data (NT family)
Also, deleted records (entities) can be found in:
• Remnant data at the end of a primary file.
• Slack space of allocated and referenced records (especially, in cells with subkeys/values lists).
• Transaction log files (old log entries, remnant data, gaps).
Distribution of recoverable deleted keys and values in primary files:
• Unallocated cells: 97.9%
• Remnant data at the end of a file: 0.6%
• Slack space in allocated and referenced cells: 1.5%
• Allocated but unreferenced cells: 0% (only 1 key was found)
Preallocated space.
Caveats
• Most registry viewers ignore data in transaction log files.
 Registry Explorer, Windows Registry Recovery, Registry Recon, libregf, reglookup.
 Latest changes to registry keys and values (made in Windows 8.1 and later versions of Windows) may
be invisible to such tools.
 Malicious programs can hide data from offline registry viewers by manipulating the CmpFailPrimarySave
kernel variable (modified keys and values will be stored outside of a primary file).
Example:
A laptop with a USB cellular modem, building the timeline for the
Software hive, looking for timestamps related to the activity of the
modem.
With transaction log files: 13 different key modification timestamps
were found for a single registry key.
Without transaction log files: 1 timestamp for that key.
Caveats
• Offline registry libraries in antivirus software ignore transaction log files too.
 Kaspersky Rescue Disk 10 (based on Linux) will delete malicious keys/values from a primary file only,
without applying dirty data from a transaction log file.
 When running Windows 8.1 and later versions of Windows, it is possible to create a malicious autorun
entry that will not be deleted when performing an antivirus scan from Kaspersky Rescue Disk 10.
 The same is also possible with older versions of Windows by exploiting the CmpFailPrimarySave kernel
variable.
Caveats
• When recovering deleted data from primary files, many tools skip the slack space of allocated
records (entities).
• 1.5% of recoverable keys and values are not recovered!
Slack space
A cell with a subkeys list
Signature
Number
of
elements
Offset Offset Offset Offset Offset
Cell
size
Caveats
• Treating the registry as a typical file system is dangerous too!
 A subkey and a value of a single key can share the same name.
 A name of a key or a value could be “.” or “..”.
 Also: null byte, “/”, and “”.
GRR: a value shadows a key with the same name
Yet another registry parser (yarp)
https://github.com/msuhanov/yarp/
(library & tools, Python 3)
- Parse Windows registry files in a proper way (with forensics in mind).
- Expose values of all fields of underlying registry structures.
- Support for truncated registry files and registry fragments.
- Support for recovering deleted keys and values.
- Support for carving of registry hives.
- Support for transaction log files.
?

More Related Content

PPTX
Windows Forensic 101
PPTX
Memory Forensics
PPTX
Mobile Forensics
PPT
Unix File System
ODT
Operating System Forensics
PDF
Fat File Systems
PPTX
Memory forensics.pptx
PDF
Next Generation Memory Forensics
Windows Forensic 101
Memory Forensics
Mobile Forensics
Unix File System
Operating System Forensics
Fat File Systems
Memory forensics.pptx
Next Generation Memory Forensics

What's hot (20)

PDF
Email Forensics
PPT
Registry forensics
PDF
Data recovery
PPTX
Anti forensic
PPTX
Digital forensic tools
PPTX
Directory implementation and allocation methods
PPTX
Controls events
PPTX
Introduction to filesystems and computer forensics
PDF
LTEC 2013 - EnCase v7.08.01 presentation
ODP
Introduction to Version Control
PPT
Windowsforensics
PDF
MindMap - Forensics Windows Registry Cheat Sheet
PDF
PPTX
Windows form application_in_vb(vb.net --3 year)
PPTX
Processing Crimes and Incident Scenes
PPT
Digital Forensic
PDF
Digital Forensic: Brief Intro & Research Challenge
PPTX
Introduction git
PDF
Introduction to Data Flow Diagram (DFD)
PPTX
file compression ,zip file
Email Forensics
Registry forensics
Data recovery
Anti forensic
Digital forensic tools
Directory implementation and allocation methods
Controls events
Introduction to filesystems and computer forensics
LTEC 2013 - EnCase v7.08.01 presentation
Introduction to Version Control
Windowsforensics
MindMap - Forensics Windows Registry Cheat Sheet
Windows form application_in_vb(vb.net --3 year)
Processing Crimes and Incident Scenes
Digital Forensic
Digital Forensic: Brief Intro & Research Challenge
Introduction git
Introduction to Data Flow Diagram (DFD)
file compression ,zip file
Ad

Viewers also liked (20)

PPTX
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
PPTX
In-Memory Computing Essentials for Architects and Engineers
PPTX
Docker Networking
PPTX
Walk through an enterprise Linux migration
PDF
[若渴計畫] Challenges and Solutions of Window Remote Shellcode
PDF
Scale Up with Lock-Free Algorithms @ JavaOne
PPTX
Graduating To Go - A Jumpstart into the Go Programming Language
PPTX
Communication hardware
PDF
OCCIware, an extensible, standard-based XaaS consumer platform to manage ever...
PDF
Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017)
PPTX
What in the World is Going on at The Linux Foundation?
PDF
numPYNQ @ NGCLE@e-Novia 15.11.2017
PPT
DevRomagna / Golang Intro
PDF
Advanced memory allocation
PDF
Go Execution Tracer
PPTX
Virtualization
PPTX
Server virtualization
PPTX
SDN Architecture & Ecosystem
PPTX
OpenFlow
PPTX
Network Virtualization
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
In-Memory Computing Essentials for Architects and Engineers
Docker Networking
Walk through an enterprise Linux migration
[若渴計畫] Challenges and Solutions of Window Remote Shellcode
Scale Up with Lock-Free Algorithms @ JavaOne
Graduating To Go - A Jumpstart into the Go Programming Language
Communication hardware
OCCIware, an extensible, standard-based XaaS consumer platform to manage ever...
Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017)
What in the World is Going on at The Linux Foundation?
numPYNQ @ NGCLE@e-Novia 15.11.2017
DevRomagna / Golang Intro
Advanced memory allocation
Go Execution Tracer
Virtualization
Server virtualization
SDN Architecture & Ecosystem
OpenFlow
Network Virtualization
Ad

Similar to In-depth forensic analysis of Windows registry files (20)

PPT
Vista Forensics
PPTX
Windows Registry analysis with RegRipper
PPTX
3170725_Unit-4.pptx
PDF
FINDING FORENSIC ARTIFACTS FROM WINDOW REGISTRY
PDF
Windows Registry Analysis
PDF
FORENSIC ANALYSIS OF WINDOWS REGISTRY AGAINST INTRUSION
PDF
Windows registry troubleshooting (2015)
PDF
www.indonezia.net Hacking Windows Registry
PPT
Registry Forensics
PDF
Windows Forensics
PPTX
Windows Registry
PPTX
Windows File Systems
PDF
CNIT 152 12 Investigating Windows Systems (Part 2)
PDF
CNIT 152: 12b Windows Registry
PPTX
Windows File Systems
PDF
How to erase private data permanently
PPTX
Windows forensic
PDF
Registry
PDF
AntiForensics - Leveraging OS and File System Artifacts.pdf
Vista Forensics
Windows Registry analysis with RegRipper
3170725_Unit-4.pptx
FINDING FORENSIC ARTIFACTS FROM WINDOW REGISTRY
Windows Registry Analysis
FORENSIC ANALYSIS OF WINDOWS REGISTRY AGAINST INTRUSION
Windows registry troubleshooting (2015)
www.indonezia.net Hacking Windows Registry
Registry Forensics
Windows Forensics
Windows Registry
Windows File Systems
CNIT 152 12 Investigating Windows Systems (Part 2)
CNIT 152: 12b Windows Registry
Windows File Systems
How to erase private data permanently
Windows forensic
Registry
AntiForensics - Leveraging OS and File System Artifacts.pdf

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Electronic commerce courselecture one. Pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Modernizing your data center with Dell and AMD
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
cuic standard and advanced reporting.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Cloud computing and distributed systems.
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Approach and Philosophy of On baking technology
NewMind AI Weekly Chronicles - August'25 Week I
Electronic commerce courselecture one. Pdf
MYSQL Presentation for SQL database connectivity
Network Security Unit 5.pdf for BCA BBA.
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Modernizing your data center with Dell and AMD
Encapsulation_ Review paper, used for researhc scholars
cuic standard and advanced reporting.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Understanding_Digital_Forensics_Presentation.pptx
Cloud computing and distributed systems.
Diabetes mellitus diagnosis method based random forest with bat algorithm
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Approach and Philosophy of On baking technology

In-depth forensic analysis of Windows registry files

  • 1. In-depth forensic analysis of Windows registry files Maxim Suhanov
  • 2. Registry basics A typical registry path: HKEY_LOCAL_MACHINESoftwareMicrosoft This path is different in a kernel: • RegistryMachineSoftwareMicrosoft This hive is non-volatile (stored on a disk), backing files: • C:WindowsSystem32configSOFTWARE • C:WindowsSystem32configSOFTWARE.LOG (+ .LOG1/.LOG2) Predefined key Mount point of a hive Key Some hives do not have a visible mount point!
  • 3. Hive format (NT family) Seven versions of the format: from 1.0 (pre-release versions ofWindows NT 3.1) to 1.6 (introduced inWindows 10 “Redstone 1”, not used yet) The structure of a hive file: Base block (file header) Hive bin Hive bin More hive bins Remnant data The base block contains the size of all [allocated] hive bins.
  • 4. Hive format (NT family) A hive bin contains a header and cells. Hive bin Header Cell Cell More cells A cell may contain: • Key node (nk) • Key value (vk) • Key security (sk) • List of subkeys (li, lf, lh) • List of subkeys lists (ri) • List of values • Value data • Big data records (db) • List of segments • Value data segments The first 4 bytes of a cell are used to record the size of this cell (positive value: unallocated cell, negative value: allocated cell) The header contains the size of this hive bin.
  • 5. Hive format (NT family) Records (entities) point to other records (entities) using a relative offset of a cell.A base block points to a root key node. File offset of a cell = Length of a base block + Relative offset of a cell File offset of a cell = 4096 + Relative offset of a cell Key node Key security List of subkeys List of values Key node Key node Key value Value data
  • 6. Hive format (NT family) All registry structures are documented here: https://github.com/msuhanov/regf/
  • 7. Transaction log files (NT family) • Before writing dirty data to a primary file, this data is stored in a transaction log file. • If a system crash occurs when writing to a transaction log file, a primary file will be intact. • If a system crash occurs when writing to a primary file, a transaction log file will be used to repeat the write operation. The old format (before Windows 8.1): Base block (backup copy) Dirty vector (bitmap) Dirty sectors (pages) Remnant data G a p
  • 8. Transaction log files (NT family) • Every bit of the bitmap corresponds to a single 512-byte sector of the hive bins data in a primary file. • If set, a sector is dirty (and modified contents are in the transaction log file). Relative offset of a dirty sector in a transaction log file = Index of a bit in the bitmap * 512 Relative from the start of dirty sectors (pages). Zero-based. As of Windows XP, a single run of dirty data is not smaller than a page (4096 bytes).
  • 9. Transaction log files (NT family) • A bad sector in a primary file results in the following:  Dirty data cannot be written to a primary file (to the location with a bad sector).  We cannot overwrite dirty data in an existing transaction log file (otherwise a system crash may leave us without a good copy of dirty data).  We cannot mark mounted hives as read-only.  No further writes (after a failed one) to a primary file will be allowed (new dirty data will be discarded).
  • 10. Transaction log files (NT family) • Solution: the dual-logging scheme (starting from Windows Vista).  After a failed write to a primary file, switch the log file being used (.LOG1 -> .LOG2, .LOG2 -> .LOG1), and try the write operation again.  Repeat this until a bad sector is gone. Microsoft left the CmpFailPrimarySave kernel variable used to simulate failed writes!
  • 11. Transaction log files (NT family) • The old format requires dirty data to be written to a disk twice. • The new format is used to stash dirty pages in a transaction log file without writing them to a primary file.These pages will be written to a primary file later. The new format (as ofWindows 8.1): Base block (backup copy) Log entries Remnant data Also, each log entry has a checksum for dirty data (Marvin32). • When all users are inactive. • During the full shutdown. • After 3600 seconds since the latest write.
  • 12. Deleted data (NT family) • When a key or a value is deleted, all corresponding cells are marked as unallocated. • A cell will be coalesced with an adjacent unallocated cell. • A single unallocated cell may contain multiple delete records (entities).
  • 13. Deleted data (NT family) Well, not all cells are marked as unallocated when a corresponding record (entity) is deleted… • In recent releases of Windows 10, renaming a key will leave an old key node in an allocated cell. • This key node will be present until the hive is defragmented. Thus, Cells with deleted data = All cells – Referenced cells
  • 14. Deleted data (NT family) Also, deleted records (entities) can be found in: • Remnant data at the end of a primary file. • Slack space of allocated and referenced records (especially, in cells with subkeys/values lists). • Transaction log files (old log entries, remnant data, gaps). Distribution of recoverable deleted keys and values in primary files: • Unallocated cells: 97.9% • Remnant data at the end of a file: 0.6% • Slack space in allocated and referenced cells: 1.5% • Allocated but unreferenced cells: 0% (only 1 key was found) Preallocated space.
  • 15. Caveats • Most registry viewers ignore data in transaction log files.  Registry Explorer, Windows Registry Recovery, Registry Recon, libregf, reglookup.  Latest changes to registry keys and values (made in Windows 8.1 and later versions of Windows) may be invisible to such tools.  Malicious programs can hide data from offline registry viewers by manipulating the CmpFailPrimarySave kernel variable (modified keys and values will be stored outside of a primary file). Example: A laptop with a USB cellular modem, building the timeline for the Software hive, looking for timestamps related to the activity of the modem. With transaction log files: 13 different key modification timestamps were found for a single registry key. Without transaction log files: 1 timestamp for that key.
  • 16. Caveats • Offline registry libraries in antivirus software ignore transaction log files too.  Kaspersky Rescue Disk 10 (based on Linux) will delete malicious keys/values from a primary file only, without applying dirty data from a transaction log file.  When running Windows 8.1 and later versions of Windows, it is possible to create a malicious autorun entry that will not be deleted when performing an antivirus scan from Kaspersky Rescue Disk 10.  The same is also possible with older versions of Windows by exploiting the CmpFailPrimarySave kernel variable.
  • 17. Caveats • When recovering deleted data from primary files, many tools skip the slack space of allocated records (entities). • 1.5% of recoverable keys and values are not recovered! Slack space A cell with a subkeys list Signature Number of elements Offset Offset Offset Offset Offset Cell size
  • 18. Caveats • Treating the registry as a typical file system is dangerous too!  A subkey and a value of a single key can share the same name.  A name of a key or a value could be “.” or “..”.  Also: null byte, “/”, and “”. GRR: a value shadows a key with the same name
  • 19. Yet another registry parser (yarp) https://github.com/msuhanov/yarp/ (library & tools, Python 3) - Parse Windows registry files in a proper way (with forensics in mind). - Expose values of all fields of underlying registry structures. - Support for truncated registry files and registry fragments. - Support for recovering deleted keys and values. - Support for carving of registry hives. - Support for transaction log files.
  • 20. ?