Skip to content

Commit f3f85ba

Browse files
authored
Update README.md
1 parent d55d9bb commit f3f85ba

1 file changed

Lines changed: 58 additions & 1 deletion

File tree

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,60 @@
11
[![Build status](https://ci.appveyor.com/api/projects/status/6p494gy556gjat6d?svg=true)](https://ci.appveyor.com/project/nooperation/userpreferencesexplorer)
22
# UserPreferencesTool
3-
Tools for interacting with the encrypted UserPreferences.bag for Project Sansar
3+
UserPreferencesExplorer is a tool that was created to provide an insight into the encrypted data being stored on your personal computer in the form of 'Userpreferences.bag'.
4+
5+
```json
6+
{
7+
"username":"example@example.com",
8+
"refresh_token":"<refresh_token>",
9+
"scope_string":"email,persona_info,persona_create,user_info,sansar_login,read_marketplace,write_marketplace,read_subscription_json,read_subscription,persona_id:01234567-89AB-CDEF-0123-456789ABCDEF"
10+
}
11+
```
12+
13+
# Description
14+
15+
UserPreferences.bag is stored under the current user's local app data `C:\Users\<username>\AppData\Local\LindenLab\SansarClient` and is encrypted with a combination of a unique machine ID and a constant salt. The unique machine ID is generated by Windows on installation and can be found in the registry under the `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography` key as `MachineGuid`.
16+
17+
# Decryption process
18+
19+
1. Read `MachineGuid` from `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography`
20+
21+
2. Mangle the `MachineGuid` using the the following algorithm
22+
```cpp
23+
for(size_t index = 0; index < MachineGuid.size(); ++i)
24+
{
25+
MachineGuid[index] = ((index + 2) * MachineGuid[index]) % 128
26+
}
27+
```
28+
29+
3. Generate a key and initialization vector using the constant salt and mangled data via EVP_BytesToKey
30+
* Cipher: AES 256 CBC cipher
31+
* Digest: SHA-1
32+
* Iterations: 5
33+
* Salt: 0x6E3F032949637D2E
34+
* Data: MangledData
35+
```cpp
36+
auto derived_key_length = EVP_BytesToKey(
37+
EVP_aes_256_cbc(),
38+
EVP_sha1(),
39+
kSalt,
40+
mangled_data,
41+
mangled_data.size(),
42+
5,
43+
&out_key,
44+
&out_initialization_vector
45+
);
46+
```
47+
48+
4. Decrypt the contents of UserPreferences.bag with the generated key and initialization vector
49+
```cpp
50+
auto cipher = EVP_aes_256_cbc();
51+
auto ctx = EVP_CIPHER_CTX_new();
52+
53+
EVP_CIPHER_CTX_init(ctx);
54+
EVP_EncryptInit_ex(ctx, cipher, nullptr, &key, &initialization_vector);
55+
EVP_EncryptUpdate(ctx, &out_plaintext, &plaintext_length, &plaintext, plaintext.size());
56+
EVP_EncryptFinal_ex(ctx, &out_plaintext[plaintext_length], &additional_length);
57+
EVP_CIPHER_CTX_free(ctx);
58+
```
59+
60+
5. out_plaintext now contains the decrypted contents

0 commit comments

Comments
 (0)