Collecting the PCA Folder and AppCompatFlags Keys
How to collect C:\Windows\appcompat\pca and the AppCompatFlags keys in NTUSER.DAT and SOFTWARE: locked hives, KAPE, Velociraptor and your own traces.
TL;DR. Take the whole folder C:\Windows\appcompat\pca\, every user's NTUSER.DAT (with its .LOG1 and .LOG2 files), and the SOFTWARE hive. Add SYSTEM, Amcache and Prefetch for context. On a live system, the hives of logged-on users are locked: save them with reg save or let a raw-copy tool such as KAPE or Velociraptor read them. Start your tools from a command line, not from File Explorer, or you will add lines to the launch log yourself. Then drop the folder or archive on PCA Parser; the How to get your data guide on the home page has the same commands.
What to collect
| Item | Path | Why |
|---|---|---|
| PCA folder | C:\Windows\appcompat\pca\ (every file) | PcaAppLaunchDic.txt, PcaGeneralDb0.txt, PcaGeneralDb1.txt |
| User hives | C:\Users\<user>\NTUSER.DAT, NTUSER.DAT.LOG1, NTUSER.DAT.LOG2 | Compatibility Assistant Store or Persisted, Layers for that user |
| SOFTWARE | C:\Windows\System32\config\SOFTWARE and its logs | Layers for all users; ProfileList, which maps SIDs to profile folders |
| SYSTEM | C:\Windows\System32\config\SYSTEM and its logs | BAM and ShimCache, for comparison |
| Amcache | C:\Windows\appcompat\Programs\Amcache.hve and its logs | SHA-1 and program IDs |
| Prefetch | C:\Windows\Prefetch\ | Run counts and times |
Copy the PCA folder whole, not only the three known files. PcaGeneralDb1.txt may hold the newer records, and Sygnia found a reference to a fourth file, PcaGeneralDic.txt, that it never saw written. Anything else in the folder is evidence too.
Collect the NTUSER.DAT of every profile, not only the suspect's. In an intrusion, the account that matters is often one nobody mentioned.
Before you start: your own traces
PcaAppLaunchDic.txt records programs started from the graphical shell. If you double-click a collection tool on the suspect system, it gets a line, and a program already listed gets a new time. Andrew Rathbun's own published file has a line for gkape.exe, the KAPE GUI, run from a V: drive.
- Start tools from a console you opened once, and run everything else from it.
- Note the time you started, the tools and their paths, so that nobody mistakes your launches for the intruder's.
- Collect the PCA folder first.
Privileges and locked files
- Run elevated. Saving SOFTWARE and other users' hives needs administrator rights and the backup privilege.
- Loaded hives are locked. SOFTWARE and SYSTEM are always loaded. A user's NTUSER.DAT is loaded while the profile is in use: the user is logged on, or a process still holds the profile. A plain copy fails with a sharing violation. Use
reg saveon the loaded key, a Volume Shadow Copy, or a tool that reads NTFS directly. - Unloaded hives can be copied, but copy their
.LOG1and.LOG2files too. A hive file on disk can be behind its transaction logs. Registry Explorer and Eric Zimmerman'srlareplay the logs into a clean copy; a hive saved withreg savedoes not need them.
Live collection by hand
In an elevated PowerShell prompt:
$case = 'E:\case\FIN-WKS-07'
New-Item -ItemType Directory -Force -Path "$case\pca", "$case\hives" | Out-Null
# 1. The PCA folder, with file and folder times
robocopy C:\Windows\appcompat\pca "$case\pca" /E /COPY:DAT /DCOPY:T /R:1 /W:1
# 2. SOFTWARE, always loaded: save a consistent copy
reg save HKLM\SOFTWARE "$case\hives\SOFTWARE" /y
# 3. Loaded user profiles: save each hive by SID
$profiles = Get-CimInstance Win32_UserProfile | Where-Object { -not $_.Special }
foreach ($p in $profiles | Where-Object Loaded) {
$name = Split-Path $p.LocalPath -Leaf
New-Item -ItemType Directory -Force -Path "$case\hives\$name" | Out-Null
reg save "HKU\$($p.SID)" "$case\hives\$name\NTUSER.DAT" /y
}
# 4. Profiles not loaded: copy the hive with its transaction logs
foreach ($p in $profiles | Where-Object { -not $_.Loaded }) {
$name = Split-Path $p.LocalPath -Leaf
# /A-:SH clears the hidden and system attributes on the copies only
robocopy $p.LocalPath "$case\hives\$name" NTUSER.DAT NTUSER.DAT.LOG1 NTUSER.DAT.LOG2 /B /COPY:DAT /A-:SH /R:1 /W:1
}
# 5. Hashes outside the case folder, then an archive
Get-ChildItem $case -Recurse -File -Force | Get-FileHash -Algorithm SHA256 |
Export-Csv "$case.sha256.csv" -NoTypeInformation
tar.exe -a -c -f "$case.zip" -C $case .
Keeping one folder per user name matters: the folder is what attributes a hive to a user. The SID in ProfileList, in SOFTWARE, confirms it.
KAPE
The AppCompatPCA target, written by Andrew Rathbun, copies the whole C:\Windows\appcompat\pca folder. It is part of the EvidenceOfExecution compound target, which KapeTriage and !SANS_Triage include, along with the registry hives. For a focused collection:
kape.exe --tsource C: --tdest E:\case\FIN-WKS-07 --target AppCompatPCA,RegistryHivesUser,RegistryHivesSystem
RegistryHivesUser takes NTUSER.DAT and UsrClass.dat with their transaction logs for every profile; RegistryHivesSystem takes SOFTWARE, SYSTEM, SAM and SECURITY with theirs. KAPE reads locked files directly from NTFS, so logged-on users are not a problem. Drop the destination folder, or a zip of it, on PCA Parser.
Velociraptor
Since Velociraptor 0.75, the triage artifact is Windows.Triage.Targets, maintained outside the main release; import it from that site or with the Server.Import.Extras artifact. It replaced Windows.KapeFiles.Targets, as the Velociraptor blog explains. Select the targets AppCompatPCA, RegistryHivesUser and RegistryHivesSystem, run it on the endpoint or as an offline collector, and export the collection as a ZIP for PCA Parser.
Two exchange artifacts parse on the endpoint instead. Windows.System.AppCompatPCA reads PcaAppLaunchDic.txt only, optionally from Volume Shadow Copies. Windows.System.AppCompatPCAExtend adds PcaGeneralDb0.txt, but not PcaGeneralDb1.txt by default, and labels record type 1 differently from Sygnia's research. Collect the files as well.
From a disk image
Mount the Windows volume read-only on an analysis host and copy the same paths, relative to the volume root: Windows\appcompat\pca\, Users\*\NTUSER.DAT*, Windows\System32\config\SOFTWARE*. No file is locked on a mounted image. Volume Shadow Copies inside the image can hold older versions of the PCA files, with lines that have since been updated or removed. Disk Image Parser can hand the PCA files and hives found in an image straight to PCA Parser, in the browser.
Reading the text files
The two kinds of file use different encodings:
| File | Encoding | PowerShell |
|---|---|---|
PcaAppLaunchDic.txt | ANSI, code page 1252 per Sygnia | Get-Content <file> -Encoding Default (5.1) or -Encoding 1252 (7) |
PcaGeneralDb0.txt, PcaGeneralDb1.txt | UTF-16LE, no BOM in published samples | Get-Content <file> -Encoding Unicode |
Read copies, never the originals. To open them in Timeline Explorer or a spreadsheet, use | as the delimiter and pick UTF-16 for the PcaGeneralDb files. Details of each format are in PcaAppLaunchDic.txt explained and PcaGeneralDb files.
Handling the copies
- Keep the paths. The user folder in a hive's path, or the folder you saved it under, is what attributes it.
- Hash on collection, and work on copies.
- Do not stop PcaSvc or change the PCA policy on a system under investigation.
- Write down your own actions: elevation, commands, times, any program you started from the GUI.
What to do with the result is in investigating program execution with PCA traces.
FAQ
Do I need administrator rights to collect the PCA traces?
Yes, in practice. Saving the SOFTWARE hive and other users' NTUSER.DAT needs administrator rights and the backup privilege, and an elevated prompt avoids access problems under C:\Windows.
Why can't I copy NTUSER.DAT?
While a user's profile is loaded, Windows holds NTUSER.DAT open and a normal copy fails. Save the loaded hive with reg save HKU<SID>, read it from a Volume Shadow Copy, or use a tool that reads NTFS directly, such as KAPE or Velociraptor.
Does KAPE collect the PCA folder by default?
The AppCompatPCA target copies the whole folder. It is part of the EvidenceOfExecution compound target, which KapeTriage and SANS_Triage include. Add RegistryHivesUser and RegistryHivesSystem for the AppCompatFlags keys.
Can my own collection change the PCA files?
Yes. A program you start from File Explorer on the system can add or update a line in PcaAppLaunchDic.txt. Andrew Rathbun's published file even has a line for the KAPE GUI. Start your tools from a command line and write down what you ran and when.
Related articles
Collect the Windows Program Compatibility Assistant traces
Copy the PCA folder, save the SOFTWARE hive and every user's NTUSER.DAT from a live Windows system, hash the result, then load it in PCA Parser.
- Time
- 15 min
- Tools
- An elevated PowerShell prompt, robocopy and reg.exe (built in), PCA Parser (browser)
- Result
- A folder or zip with the PCA text files, the SOFTWARE hive and one NTUSER.DAT per user, plus SHA-256 hashes.
Open an elevated prompt
Start PowerShell as administrator from the Start menu or an existing console, note the time, and avoid launching other programs from File Explorer on the system.
Copy the PCA folder
Copy every file in C:\Windows\appcompat\pca with robocopy, keeping file times.
Save the hives
Save HKLM\SOFTWARE with reg save, save the NTUSER.DAT of each loaded profile through HKU\<SID>, and copy NTUSER.DAT with its LOG1 and LOG2 files for profiles that are not loaded.
Hash and archive
Compute SHA-256 hashes of every collected file, keep them outside the case folder, and zip the folder.
Load
Drop the folder or the zip on PCA Parser, or open the files with its file picker.
Frequently asked questions
Do I need administrator rights to collect the PCA traces?
Yes, in practice. Saving the SOFTWARE hive and other users' NTUSER.DAT needs administrator rights and the backup privilege, and an elevated prompt avoids access problems under C:\Windows.
Why can't I copy NTUSER.DAT?
While a user's profile is loaded, Windows holds NTUSER.DAT open and a normal copy fails. Save the loaded hive with reg save HKU\<SID>, read it from a Volume Shadow Copy, or use a tool that reads NTFS directly, such as KAPE or Velociraptor.
Does KAPE collect the PCA folder by default?
The AppCompatPCA target copies the whole folder. It is part of the EvidenceOfExecution compound target, which KapeTriage and SANS_Triage include. Add RegistryHivesUser and RegistryHivesSystem for the AppCompatFlags keys.
Can my own collection change the PCA files?
Yes. A program you start from File Explorer on the system can add or update a line in PcaAppLaunchDic.txt. Andrew Rathbun's published file even has a line for the KAPE GUI. Start your tools from a command line and write down what you ran and when.