Files
codebuddy-scripts/Dat File Script/decrypt-dat-file.md
2025-09-17 10:52:06 -05:00

5.4 KiB

How to read/edit store.dat on Windows

What this does

  • Decrypts %AppData%\rIDE\<userId>\store.dat using Windows DPAPI (CurrentUser).
  • Lets you view keys and update a value (e.g., GithubToken, SupabaseToken, etc.).
  • Must be run as the same Windows user account that created the file.

0) One-time setup

  1. Save the script (name it exactly): decrypt-dat-file.ps1
    (Use the version Jimmy shared --- it already loads the System.Security assembly and includes Set-StoreValue.)

  2. Put it somewhere easy, e.g.:

    C:\Users\<you>\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1
    

1) Open PowerShell & allow running the script (this session only)

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

2) Find your userId folder and back up the file

store.dat lives at:

%AppData%\rIDE\<userId>\store.dat

In PowerShell, reference %AppData% as $env:APPDATA. Example:

# Replace <userId> with the actual folder name (GUID)
cd "$env:APPDATA\rIDE\<userId>"
Copy .\store.dat .\store.bak

Tip: to list the available userId folders:

Get-ChildItem "$env:APPDATA\rIDE"

3) List keys / read values (no edits yet)

Option A --- run the script with parameters (no functions loaded)

Use the call operator & when passing parameters:

& "C:\Users\<you>\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "<userId>" -ListKeys
# Example output: GithubToken, SupabaseToken, AzureAccessToken, ...

Read a specific key:

& "C:\Users\<you>\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "<userId>" -Key GithubToken -Raw

-Raw prints the exact string. Without -Raw, JSON values (like SupabaseToken) are pretty-printed.


4) Edit a value

You have two ways to edit:

Dot-sourcing loads the helper functions into your shell:

. "C:\Users\<you>\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1"

Now update a key:

  • Plain string key (e.g., GithubToken):
Set-StoreValue -UserId "<userId>" -Key "GithubToken" -Value "ghp_or_ghu_yourNewTokenHere"
  • JSON key (e.g., SupabaseToken expects JSON):
$newPat = '{"AccessToken":"myNewSupabasePAT","RefreshToken":null,"ExpiresAt":"2025-12-31T23:59:59Z"}'
Set-StoreValue -UserId "<userId>" -Key "SupabaseToken" -Value $newPat

Verify:

& "C:\Users\<you>\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "<userId>" -Key GithubToken -Raw
# or
& "C:\Users\<you>\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "<userId>" -Key SupabaseToken

Option B: stay "no functions" and only run the script

Use this only to view or list; editing requires Option A.


5) Common pitfalls & fixes

  • The term 'Set-StoreValue' is not recognized
    You ran the script but didn't dot-source it. Dot-source first:

    . "C:\Users\<you>\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1"
    
  • Unable to find type [System.Security.Cryptography.ProtectedData]
    Use the script Jimmy provided (it includes Add-Type -AssemblyName System.Security).
    If you still see it:

    Add-Type -AssemblyName System.Security
    
  • DPAPI Unprotect failed...
    You're not running as the same Windows user that created the file. Switch to that user profile.

  • %AppData% doesn't work in PowerShell
    Use $env:APPDATA (PowerShell style):

    cd "$env:APPDATA\rIDE\<userId>"
    
  • Edited value shape

    • Keys like GithubToken are plain strings.\
    • Keys like SupabaseToken and projectSecret_* are JSON. Make sure you pass valid JSON.

6) Quick examples (ready to paste)

List keys

& "C:\Users\<you>\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "<userId>" -ListKeys

Read GitHub token (raw)

& "C:\Users\<you>\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "<userId>" -Key GithubToken -Raw

Update GitHub token

. "C:\Users\<you>\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1"
Set-StoreValue -UserId "<userId>" -Key "GithubToken" -Value "ghp_or_ghu_yourNewTokenHere"

Update Supabase token (JSON)

. "C:\Users\<you>\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1"
$newPat = '{"AccessToken":"myNewSupabasePAT","RefreshToken":null,"ExpiresAt":"2025-12-31T23:59:59Z"}'
Set-StoreValue -UserId "<userId>" -Key "SupabaseToken" -Value $newPat

Verify

& "C:\Users\<you>\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "<userId>" -Key GithubToken -Raw
& "C:\Users\<you>\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "<userId>" -Key SupabaseToken