Forensic Analysis of Damaged SQLite Databases

SQLite databases are very common sources of forensic artifacts nowadays. A lot of mobile applications store data in such databases: you can also find them on desktop computers and laptops as well as, for example, forensicating web-browsers, messengers and some other digital evidence sources.

There are a lot of forensic tools on the market that support analysis of SQLite databases, for example, Magnet AXIOM, Belkasoft Evidence Center and BlackBag BlackLight to name a few. The tools can automatically parse some of these databases and even carve data out of free lists and unallocated space. Also they provide SQLite viewers forensicators can use to analyze this type of databases manually.

But what about damaged or corrupted databases? Let’s find out!

One of our DFIR-mates sent us a SQLite database he couldn’t open with any tool he had. He even wrote an email to one of the vendors, but the answer was – the database contained no tables.

Ok, let’s start our journey. The database has the following name: “contacts2.db”. If you are forensicating mobile devices often enough, you notice that it’s a typical Android database, the one containing information about a user’s contacts.

As we have quite a big forensic toolkit, we decided to start from trying to open the database with the most popular tools, including Belkasoft Evidence Center, BlackBag BlackLight, Cellebrite UFED Physical Analyser, DB Browser for SQLite, Magnet AXIOM and Oxygen Forensic Detective. Unfortunately, none of the tools could open the database. Look at the following screenshots:

The database opened with Belkasoft Evidence Center

The database opened with BlackBag BlackLight

The database opened with Cellebrite UFED Physical Analyzer

The database opened with DB Browser for SQLite

The database opened with Magnet AXIOM

The database opened with Oxygen Forensic Detective

As you can see, none of the big guys could solve the problem. So what should a forensic analyst do in such situation? Go back to the roots!

First of all, go to to the official SQLite website and download the command-line tools for managing database files.

Now extract the contents of the archive and put the database into the same folder (optional).

Start Windows Command Prompt and change the directory to the one to which you extracted the SQLite command-line tools.

Now you have an SQL file with dumped database tables. If you are lucky, you can just delete the transaction statements, like BEGIN TRANSACTION and ROLLBACK, and import the file to a new SQLite database, for example, using DB Browser for SQLite. But in our case the database was heavily damaged, so we had to examine the file manually and save tables of interest in separate SQL files.

We saved it into a separate SQL file and used DB Browser for SQLite to create a database.

Here is how to do it:

Open DB Browser for SQLite.

Go to File – Import – Database from SQL file…

Choose the SQL file you saved the table of interest.

Choose the name of the database to be created.

Now you can browse the data and use simple SQL queries to export it.

Recovered table

Of course, you can do the same with all the other tables of interest. And yes, our database actually contains tables. This is one more proof that digital forensic analysts mustn’t rely solely on forensic tools, even if they have most of the top commercial products. Don’t forget to check potential digital evidence sources manually!