-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not a database error when running sigtop db #48
Comments
The key format for SQLite was changed in latest versions of desktop Signal. It's now stored in encrypted form in JSON under key encryptedKey, e.g. on MacOS: ~/Library/Application Support/Signal/config.json To decrypt it the special OS mechanism for safe storage is used, like Keychain on MacOS. First, you need to extract it from safe storage (for example, manually or via some API), it's Base64 encoded and used as input to PBKDF2 HMAC SHA-1 algorithm with salt set to saltysalt, number of iterations set to 1003 and derived key length set to 128 bit. The resulting 128-bit key is our key encryption key (KEK) which will be used later. Then you should take hexadecimal string of encrypted key from Signal's JSON config, decode it as bytes and strip leading prefix v10. Then apply the result to AES-128 CBC algorithm with KEK and IV consisted of 16 bytes of space characters, unpad it using block size of 16 bytes. You should get ASCII text with hexadecimal character which is your key for SQLite database. It can be used with modifications to sigtop or by crafting old-style JSON config with key parameter that have value of this hexadecimal string. PoC: https://gist.github.com/flatz/3f242ab3c550d361f8c6d031b07fb6b1 |
As @flatz explained, Signal Desktop recently started to encrypt the database key in I have pushed a commit that should make it possible to decrypt the database key on macOS and Linux (GNOME). For the time being, you will have to fetch the encryption password manually. @sylasabdullahnguyen, could you please try the following:
Note that |
I've managed to do what @flatz suggested and also ran the commands you've suggested successfully with a working signal.db file created and queryable. Thanks to you both! I am not very familiar with security technology--would storing the encryption password in |
It's not less secure. Before the Signal update, you had an unencrypted key in Nevertheless, it's a good idea either to delete |
sigtop can now also read the password from standard input so you won't have to create a
|
any tips for windows users? |
sigtop should now be able to decrypt the database key on Windows. No extra steps are needed. |
Here are provisional instructions for Linux. If you are using GNOME or any other desktop that uses GNOME Keyring, use
(If you are using Signal Beta, replace Note that If you are using KDE, use
Again, note that sigtop can also read the password from standard input so you won't have to create a
|
but how? could you please give some more details? would be much appreciated! |
sigtop should now be able to get the encryption key from the keychain on macOS. You no longer have to run the @sylasabdullahnguyen, or anyone else on macOS, it would be great if you could give this a try. The following commands should run without problems:
|
The latest version does work on MacOS without manual keychain access. Thanks. |
@flatz Great, thanks very much! @stefanputz The database key is encrypted with the encryption key in the file So sigtop first decrypts the encryption key with DPAPI. It then uses the (decrypted) encryption key to decrypt the database key. Finally, it uses the (decrypted) database key to decrypt the database. |
Works great for me, it solved the problem! I've tried 2 different machines:
Thanks a lot! |
Hello,
I am getting the following error when running
sigtop db signal.db
,sigtop check
andsigtop query pragma user_version
:I am on a MacBook M1 Pro with Ventura 13.6.3. I have the following versions of sqlite and sqlcipher:
or
after running
and
From what I've found googling, the "not a database" issue generally means that the file is corrupted--but the Signal app itself seems to be functioning fine (for now, anyway). This is the output of
hexdump -C db.sqlite | head -1
:This seems to be a bad sign according to what I read here, except that my Signal app starts up without an error. I've tried accessing the db.sqlite file (copied over from the /sql folder of the Signal app) directly in:
with no success. I have also updated sigtop to the latest release. Would you happen to have an idea as to what is going on?
The text was updated successfully, but these errors were encountered: