Skip to content
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

Question: Is there a way to check if a database has been encrypted in sqleet? #47

Open
hidemat opened this issue Feb 22, 2022 · 4 comments

Comments

@hidemat
Copy link

hidemat commented Feb 22, 2022

This way I could ask for a password if one is needed to open the database.

@hidemat hidemat changed the title Question: Is there a way to check if a database has been encrypted sqleet? Question: Is there a way to check if a database has been encrypted in sqleet? Feb 22, 2022
@2shady4u
Copy link

2shady4u commented Feb 25, 2022

I think this is a possibility, but I didn't verify this yet myself:

Parameter header represents the first 16 bytes of the database file, that is, 
SQLite3 magic header string for unencrypted databases. 
For encrypted databases, header defaults to the value of salt unless explicitly set to other value. 
Remember that salt is a parameter for the key derivation function (KDF) which is 
stored in the beginning of the database file by default, in which case both 
salt and header contain the same value (KDF salt). 

(See the README.md)

As such you should be able to check the first 16 bytes of the database and see if it either contains the salt value or if it contains the default header string?

(See also: https://www.sqlite.org/fileformat.html for the default value of the header string)

@2shady4u
Copy link

Without encryption:
no_encryption

With encryption:
yes_encryption

So you can clearly see that the first sixteen bytes contain the 'SQLite format 3\000'-header, while the encrypted file contains a randomized salt value.

@Atom735
Copy link

Atom735 commented Mar 13, 2022

How i can compile this with last version of sqlite3?

@johnfound
Copy link

Simply execute "select count() from sqlite_master" or other simple query that is guaranteed to succeed; If the database is encrypted the statement will fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants