SlideShare a Scribd company logo
http://belkasoft.com
SQLite Forensics
Yuri Gubanov, Belkasoft
Introducing myself
Yuri Gubanov
• CEO and Founder of Belkasoft
• Belkasoft – digital forensics software manufacturer
• Frequent speaker on industry-known conferences
• Senior lecturer in St-Petersburg State University, Russia
• Software developer by education, MSc
http://belkasoft.com
Today’s agenda
Digging deep about SQLite
• What is SQLite?
• Why is it important?
• Deleting data from SQLite: Freelists
• Unallocated: not only a hard drive
• SQLite WAL and journal files
• Some real stories
• A little practice
http://belkasoft.com
Before we start: my Skype profile
http://belkasoft.com
What is SQLite?
Popular database engine
• Relational SQL-based database
• Lightweight
• Does not require installation
• Just a file on disk
• Well, sometimes more than one
• Does not require system services
http://belkasoft.com
Why SQLite is important?
SQLite is massively used in modern apps
• Database of choice for 90+% of new apps
• Especially mobile ones
• Most of apps in Android/iOS
• E.g.: messengers Skype, WhatsApp, Viber
• E.g.: Major browsers such as Firefox, Chrome, Safari
• E.g. iPhone SMS database
http://belkasoft.com
Frequent approach to SQLite forensics
Often SQLite analysis is like following:
• Select free or open source tool
• E.g. DB Browse for SQLite (formerly SQLite Database Browser)
• E.g. SQLite viewer addon to Mozilla Firefox
• The price is reasonable! 
• Open database in the viewer
• Trust the results
• End of story
http://belkasoft.com
Drawbacks of using a non-forensic tool
“Free” does not equal “trustworthy”
• Does not show deleted records
• Does not even indicate presence of deleted records
• Does not show uncommitted records
• Does not show remnants in “unallocated”
• Does not carve database files
• Does not find SQLite files in RAM memory/dumps/hibernation/pagefile
Even single feature above can change investigation conclusions
dramatically (and we had real cases for that!)
http://belkasoft.com
Tool used for demos today
To demonstrate SQLite forensics today we will use
Belkasoft Evidence Center 2015 (Ultimate edition):
• Shows deleted records (“freelists”)
• Shows uncommitted records (WAL/journal files)
• Shows remnants in “unallocated”
• Carves SQLite files
• Find SQLite in RAM memory/dumps/hibernation/pagefile
• Has built-in SQLite Viewer
• Allows to review SQLite database in binary mode in built-in HexViewer
http://belkasoft.com
SQLite database structure
SQLite is a set of data pages of a fixed size
http://belkasoft.com
Freelist
Freelist: a list of free pages in a SQLite database
http://belkasoft.com
What is freelist
http://belkasoft.com
SQLite.org
“A database file might contain one or more pages that are not in active use.
Unused pages can come about, for example, when information is deleted from the
database. Unused pages are stored on the freelist and are reused when additional
pages are required.”
Is it true for every deleted record?
Freelists are only there if “auto_vacuum” option is not set
• Default: 0 (no autovacuum)
• 1 (Full) requires database rebuilding and implies
performance penalty
• Autovacuum makes database fragmentation worse
http://belkasoft.com
www.belkasoft.com
Do you see any records?
www.belkasoft.com
But in fact there are 38!
www.belkasoft.com
But why?!?
Why standard viewer does not show freelist information?
Because freelist is a technical trick to improve performance. It is not supposed
that regular user can see what’s inside.
What are you going to miss:
• Deleted SMSes on iPhone
• Deleted Chrome/Firefox browsing history
• Deleted Skype, WhatsApp, Kik chats
• and hundreds of other apps’ data stored in SQLite
Unallocated space: SQLite’s, not a hard drive’s
• Data pages: “leaf table B-tree”, filled from end to beginning
• Unallocated page space: Free space inside a SQLite page with
unstructured data
http://belkasoft.com
Unallocated space: SQLite’s, not a hard drive’s
• Unlike freelists, unallocated space is not formally referenced from
anywhere in the SQLite database
• Can’t determine, which page they originally belonged to
• Carving inside unallocated can give good results
http://belkasoft.com
SQLite Write-Ahead-Log file
Initial stage
Data changing
Commit
Since version 3.7.0, SQLite employs “Write Ahead Log”
Process of writing data to a SQLite database:
http://belkasoft.com
WAL journal
• Most actual data, which did not yet have a chance to merge to the
main database file
• “Checkpoint” event does actual commit
• Triggered by reaching a certain size
• By default, 1000 pages
• Awful lot for chat or browsing sessions
• What is the difference with Rollback Journal?
http://belkasoft.com
So, where data can hide in SQLite?
Deleted SQLite data can reside in one of the following:
• Freelist
• Unallocated space
Uncommitted data can reside in
• WAL journal (or, old records can reside in rollback journal)
http://belkasoft.com
Carving SQLite databases
SQLite has excellent header signature, what’s the difficulty?
• Indeed: “SQLite format 3”
• Easy to find, no false positives
• But… where’s the footer?
• There is no footer for SQLite database!
• There is also no data on DB size in DB header
http://belkasoft.com
Our solution
The only thing we know is a page size
• Read database header
• Find first page
• Read page size
• Read whole page and write to file
• Read next page header and validate it
• If valid, read page size and continue the process
Drawbacks
• Time-consuming
• Don’t work well with fragmentation
http://belkasoft.com
Case: Trade Secret Disclosed
• A big enterprise suspected an employee to disclose an important
know-how
• Employee’s computer was imaged and investigated
• Particularly, an Android backup and Skype account found
• Nothing interesting there, but
• WhatsApp history encrypted
• Skype history empty
The plot
Decrypting encrypted WhatsApp
• Skype stores its history in a SQLite database
• Belkasoft Evidence Center has a built-in SQLite Viewer
• Why do you need it?
• Damaged carved SQLite databases
• Freelist analysis
• Unnalocated space analysis
• Unnoticed WAL/journal files
Dealing with empty Skype database
• More than 100 deleted Skype chats recovered by Belkasoft
• Recovered Skype logs along with decrypted WhatApp history solved
the case
Result
• My Skype: journal
• Sample db+journal and SQLite Database Browser
• HexViewer and Skype
• Carving unallocated
• Carving SQLite in Live RAM
Practice
Before we say “goodbye”
Belkasoft article on SQLite:
http://belkasoft.com/sqlite-analysis
Would like to get this presentation?
• Contact me at yug@belkasoft.com!
• Leave me your card
• Add me in LinkedIn (search for Yuri Gubanov)
Free demo version
• Downloadable full 1-month trial for all conference attendees:
belkasoft.com/trial
Request today!
http://belkasoft.com

More Related Content

Similar to SQLite forensics - Free Lists, unallocated space, carving

SSIS Monitoring Deep Dive
SSIS Monitoring Deep Dive�SSIS Monitoring Deep Dive�
SSIS Monitoring Deep Dive
SolidQIT
 
Domino testing presentation
Domino testing presentationDomino testing presentation
Domino testing presentation
Ari Elias-Bachrach
 
Sql data base
Sql data baseSql data base
Sql data base
Ali Jafar
 
10 Things Learned Releasing Databricks Enterprise Wide
10 Things Learned Releasing Databricks Enterprise Wide10 Things Learned Releasing Databricks Enterprise Wide
10 Things Learned Releasing Databricks Enterprise Wide
Databricks
 
Free Training: How to Build a Lakehouse
Free Training: How to Build a LakehouseFree Training: How to Build a Lakehouse
Free Training: How to Build a Lakehouse
Databricks
 
Share point development 101
Share point development 101Share point development 101
Share point development 101
Becky Bertram
 
Sq lite database
Sq lite databaseSq lite database
Sq lite database
AYESHA JAVED
 
Top 10 DBA Mistakes on Microsoft SQL Server
Top 10 DBA Mistakes on Microsoft SQL ServerTop 10 DBA Mistakes on Microsoft SQL Server
Top 10 DBA Mistakes on Microsoft SQL Server
Kevin Kline
 
Optimizing Access with SQL Server
Optimizing Access with SQL ServerOptimizing Access with SQL Server
Optimizing Access with SQL Server
PRPASS Chapter
 
Where to save my data, for devs!
Where to save my data, for devs!Where to save my data, for devs!
Where to save my data, for devs!
SharePoint Saturday New Jersey
 
Version Control meets Database Control
Version Control meets Database ControlVersion Control meets Database Control
Version Control meets Database Control
DBmaestro - Database DevOps
 
Introduction SQL Analytics on Lakehouse Architecture
Introduction SQL Analytics on Lakehouse ArchitectureIntroduction SQL Analytics on Lakehouse Architecture
Introduction SQL Analytics on Lakehouse Architecture
Databricks
 
SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!
Ben Steinhauser
 
Designing and Building Next Generation Data Pipelines at Scale with Structure...
Designing and Building Next Generation Data Pipelines at Scale with Structure...Designing and Building Next Generation Data Pipelines at Scale with Structure...
Designing and Building Next Generation Data Pipelines at Scale with Structure...
Databricks
 
Introduction to SQLite: The Most Popular Database in the World
Introduction to SQLite: The Most Popular Database in the WorldIntroduction to SQLite: The Most Popular Database in the World
Introduction to SQLite: The Most Popular Database in the World
jkreibich
 
Data modeling trends for analytics
Data modeling trends for analyticsData modeling trends for analytics
Data modeling trends for analytics
Ike Ellis
 
The databases in SSDT: A work with project and best practices
The databases in SSDT: A work with project and best practicesThe databases in SSDT: A work with project and best practices
The databases in SSDT: A work with project and best practices
Kamil Nowinski
 
SQLSaturday 664 - Troubleshoot SQL Server performance problems like a Microso...
SQLSaturday 664 - Troubleshoot SQL Server performance problems like a Microso...SQLSaturday 664 - Troubleshoot SQL Server performance problems like a Microso...
SQLSaturday 664 - Troubleshoot SQL Server performance problems like a Microso...
Marek Maśko
 
Uklug 2014 connections dev faq
Uklug 2014  connections dev faqUklug 2014  connections dev faq
Uklug 2014 connections dev faq
Mark Myers
 
Products.intro.forum version
Products.intro.forum versionProducts.intro.forum version
Products.intro.forum version
sqlserver.co.il
 

Similar to SQLite forensics - Free Lists, unallocated space, carving (20)

SSIS Monitoring Deep Dive
SSIS Monitoring Deep Dive�SSIS Monitoring Deep Dive�
SSIS Monitoring Deep Dive
 
Domino testing presentation
Domino testing presentationDomino testing presentation
Domino testing presentation
 
Sql data base
Sql data baseSql data base
Sql data base
 
10 Things Learned Releasing Databricks Enterprise Wide
10 Things Learned Releasing Databricks Enterprise Wide10 Things Learned Releasing Databricks Enterprise Wide
10 Things Learned Releasing Databricks Enterprise Wide
 
Free Training: How to Build a Lakehouse
Free Training: How to Build a LakehouseFree Training: How to Build a Lakehouse
Free Training: How to Build a Lakehouse
 
Share point development 101
Share point development 101Share point development 101
Share point development 101
 
Sq lite database
Sq lite databaseSq lite database
Sq lite database
 
Top 10 DBA Mistakes on Microsoft SQL Server
Top 10 DBA Mistakes on Microsoft SQL ServerTop 10 DBA Mistakes on Microsoft SQL Server
Top 10 DBA Mistakes on Microsoft SQL Server
 
Optimizing Access with SQL Server
Optimizing Access with SQL ServerOptimizing Access with SQL Server
Optimizing Access with SQL Server
 
Where to save my data, for devs!
Where to save my data, for devs!Where to save my data, for devs!
Where to save my data, for devs!
 
Version Control meets Database Control
Version Control meets Database ControlVersion Control meets Database Control
Version Control meets Database Control
 
Introduction SQL Analytics on Lakehouse Architecture
Introduction SQL Analytics on Lakehouse ArchitectureIntroduction SQL Analytics on Lakehouse Architecture
Introduction SQL Analytics on Lakehouse Architecture
 
SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!
 
Designing and Building Next Generation Data Pipelines at Scale with Structure...
Designing and Building Next Generation Data Pipelines at Scale with Structure...Designing and Building Next Generation Data Pipelines at Scale with Structure...
Designing and Building Next Generation Data Pipelines at Scale with Structure...
 
Introduction to SQLite: The Most Popular Database in the World
Introduction to SQLite: The Most Popular Database in the WorldIntroduction to SQLite: The Most Popular Database in the World
Introduction to SQLite: The Most Popular Database in the World
 
Data modeling trends for analytics
Data modeling trends for analyticsData modeling trends for analytics
Data modeling trends for analytics
 
The databases in SSDT: A work with project and best practices
The databases in SSDT: A work with project and best practicesThe databases in SSDT: A work with project and best practices
The databases in SSDT: A work with project and best practices
 
SQLSaturday 664 - Troubleshoot SQL Server performance problems like a Microso...
SQLSaturday 664 - Troubleshoot SQL Server performance problems like a Microso...SQLSaturday 664 - Troubleshoot SQL Server performance problems like a Microso...
SQLSaturday 664 - Troubleshoot SQL Server performance problems like a Microso...
 
Uklug 2014 connections dev faq
Uklug 2014  connections dev faqUklug 2014  connections dev faq
Uklug 2014 connections dev faq
 
Products.intro.forum version
Products.intro.forum versionProducts.intro.forum version
Products.intro.forum version
 

Recently uploaded

E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
ssuserad3af4
 

Recently uploaded (20)

E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
 

SQLite forensics - Free Lists, unallocated space, carving

  • 2. Introducing myself Yuri Gubanov • CEO and Founder of Belkasoft • Belkasoft – digital forensics software manufacturer • Frequent speaker on industry-known conferences • Senior lecturer in St-Petersburg State University, Russia • Software developer by education, MSc http://belkasoft.com
  • 3. Today’s agenda Digging deep about SQLite • What is SQLite? • Why is it important? • Deleting data from SQLite: Freelists • Unallocated: not only a hard drive • SQLite WAL and journal files • Some real stories • A little practice http://belkasoft.com
  • 4. Before we start: my Skype profile http://belkasoft.com
  • 5. What is SQLite? Popular database engine • Relational SQL-based database • Lightweight • Does not require installation • Just a file on disk • Well, sometimes more than one • Does not require system services http://belkasoft.com
  • 6. Why SQLite is important? SQLite is massively used in modern apps • Database of choice for 90+% of new apps • Especially mobile ones • Most of apps in Android/iOS • E.g.: messengers Skype, WhatsApp, Viber • E.g.: Major browsers such as Firefox, Chrome, Safari • E.g. iPhone SMS database http://belkasoft.com
  • 7. Frequent approach to SQLite forensics Often SQLite analysis is like following: • Select free or open source tool • E.g. DB Browse for SQLite (formerly SQLite Database Browser) • E.g. SQLite viewer addon to Mozilla Firefox • The price is reasonable!  • Open database in the viewer • Trust the results • End of story http://belkasoft.com
  • 8. Drawbacks of using a non-forensic tool “Free” does not equal “trustworthy” • Does not show deleted records • Does not even indicate presence of deleted records • Does not show uncommitted records • Does not show remnants in “unallocated” • Does not carve database files • Does not find SQLite files in RAM memory/dumps/hibernation/pagefile Even single feature above can change investigation conclusions dramatically (and we had real cases for that!) http://belkasoft.com
  • 9. Tool used for demos today To demonstrate SQLite forensics today we will use Belkasoft Evidence Center 2015 (Ultimate edition): • Shows deleted records (“freelists”) • Shows uncommitted records (WAL/journal files) • Shows remnants in “unallocated” • Carves SQLite files • Find SQLite in RAM memory/dumps/hibernation/pagefile • Has built-in SQLite Viewer • Allows to review SQLite database in binary mode in built-in HexViewer http://belkasoft.com
  • 10. SQLite database structure SQLite is a set of data pages of a fixed size http://belkasoft.com
  • 11. Freelist Freelist: a list of free pages in a SQLite database http://belkasoft.com
  • 12. What is freelist http://belkasoft.com SQLite.org “A database file might contain one or more pages that are not in active use. Unused pages can come about, for example, when information is deleted from the database. Unused pages are stored on the freelist and are reused when additional pages are required.”
  • 13. Is it true for every deleted record? Freelists are only there if “auto_vacuum” option is not set • Default: 0 (no autovacuum) • 1 (Full) requires database rebuilding and implies performance penalty • Autovacuum makes database fragmentation worse http://belkasoft.com
  • 16. www.belkasoft.com But why?!? Why standard viewer does not show freelist information? Because freelist is a technical trick to improve performance. It is not supposed that regular user can see what’s inside. What are you going to miss: • Deleted SMSes on iPhone • Deleted Chrome/Firefox browsing history • Deleted Skype, WhatsApp, Kik chats • and hundreds of other apps’ data stored in SQLite
  • 17. Unallocated space: SQLite’s, not a hard drive’s • Data pages: “leaf table B-tree”, filled from end to beginning • Unallocated page space: Free space inside a SQLite page with unstructured data http://belkasoft.com
  • 18. Unallocated space: SQLite’s, not a hard drive’s • Unlike freelists, unallocated space is not formally referenced from anywhere in the SQLite database • Can’t determine, which page they originally belonged to • Carving inside unallocated can give good results http://belkasoft.com
  • 19. SQLite Write-Ahead-Log file Initial stage Data changing Commit Since version 3.7.0, SQLite employs “Write Ahead Log” Process of writing data to a SQLite database: http://belkasoft.com
  • 20. WAL journal • Most actual data, which did not yet have a chance to merge to the main database file • “Checkpoint” event does actual commit • Triggered by reaching a certain size • By default, 1000 pages • Awful lot for chat or browsing sessions • What is the difference with Rollback Journal? http://belkasoft.com
  • 21. So, where data can hide in SQLite? Deleted SQLite data can reside in one of the following: • Freelist • Unallocated space Uncommitted data can reside in • WAL journal (or, old records can reside in rollback journal) http://belkasoft.com
  • 22. Carving SQLite databases SQLite has excellent header signature, what’s the difficulty? • Indeed: “SQLite format 3” • Easy to find, no false positives • But… where’s the footer? • There is no footer for SQLite database! • There is also no data on DB size in DB header http://belkasoft.com
  • 23. Our solution The only thing we know is a page size • Read database header • Find first page • Read page size • Read whole page and write to file • Read next page header and validate it • If valid, read page size and continue the process Drawbacks • Time-consuming • Don’t work well with fragmentation http://belkasoft.com
  • 24. Case: Trade Secret Disclosed
  • 25. • A big enterprise suspected an employee to disclose an important know-how • Employee’s computer was imaged and investigated • Particularly, an Android backup and Skype account found • Nothing interesting there, but • WhatsApp history encrypted • Skype history empty The plot
  • 27. • Skype stores its history in a SQLite database • Belkasoft Evidence Center has a built-in SQLite Viewer • Why do you need it? • Damaged carved SQLite databases • Freelist analysis • Unnalocated space analysis • Unnoticed WAL/journal files Dealing with empty Skype database
  • 28. • More than 100 deleted Skype chats recovered by Belkasoft • Recovered Skype logs along with decrypted WhatApp history solved the case Result
  • 29. • My Skype: journal • Sample db+journal and SQLite Database Browser • HexViewer and Skype • Carving unallocated • Carving SQLite in Live RAM Practice
  • 30. Before we say “goodbye” Belkasoft article on SQLite: http://belkasoft.com/sqlite-analysis Would like to get this presentation? • Contact me at yug@belkasoft.com! • Leave me your card • Add me in LinkedIn (search for Yuri Gubanov) Free demo version • Downloadable full 1-month trial for all conference attendees: belkasoft.com/trial Request today! http://belkasoft.com