How Investigators Extract Deleted WhatsApp & Telegram Chats

How Investigators Extract Deleted WhatsApp & Telegram Chats

Think deleting a chat makes it disappear forever? Think again. Discover the forensic techniques investigators use to recover deleted messages from WhatsApp and Telegram.

The Golden Rule: Act Fast

The single most important factor in recovering deleted chats is time. When data is deleted, the space it occupies is marked as available for new data. The longer the device is in use after deletion, the higher the chance the data will be overwritten and lost permanently. The first step in any investigation is to isolate the device (e.g., enable Airplane Mode) and create a forensic image as soon as possible.

Part 1: Extracting Deleted WhatsApp Chats

WhatsApp's use of end-to-end encryption is robust for messages in transit. However, the forensic goldmine is the local database stored on the device itself.

Method 1: The Local Database & The "msgstore.db" File

WhatsApp stores all messages in an encrypted database on the phone, typically named msgstore.db.crypt14 (or similar). The key to decrypting this file is also stored on the device.

  • How it works: When you "Delete for Everyone," WhatsApp removes the message from the local database. However, when you "Delete for Me," or if a message is deleted before you see it, it creates a forensic artifact. The message is removed from the main viewable table but can leave traces in other parts of the database or in older, unmerged database backups.

  • Investigator's Approach:

    1. Acquire a Forensic Image: Using a tool like Cellebrite UFED or Magnet AXIOM, investigators get a full file system extraction of the phone. This gives them access to the WhatsApp directory containing the msgstore.db.crypt14 file.

    2. Decrypt the Database: Forensic tools have built-in capabilities to locate the decryption key on the device and use it to decrypt the database, converting it into a readable msgstore.db SQLite file.

    3. Carve for Deleted Records: Within the SQLite database, deleted messages often remain in free pages or slack space. Advanced forensic tools can perform a SQLite Carving process, which scans the entire database file for these deleted entries that have not yet been overwritten.

    4. Analyze Backups: Both Android and iOS create local, unencrypted backups of the WhatsApp database. On Android, these are often found in the WhatsApp/Databases  folder. An investigator can compare an older backup (e.g., msgstore-2023-10-01.1.db.crypt14 ) with the current database to find messages that were present in the backup but deleted from the live version.

Method 2: Cloud Backups (The Weakest Link)

  • iCloud (iOS): If the user has iCloud Backup enabled, a copy of the WhatsApp database (encrypted by Apple's infrastructure) may be stored there. A lawful request to Apple or extraction of a known iCloud backup can provide a historical snapshot of the chats from the time of the backup.

  • Google Drive (Android): Importantly, WhatsApp backups on Android Google Drive are not protected by end-to-end encryption by default. They are encrypted, but the key is held by Google/WhatsApp. This means that with the right legal authority, investigators can potentially access these backups, which may contain messages that were later deleted from the phone.

Part 2: Extracting Deleted Telegram Chats

Telegram presents a different challenge and opportunity. Its forensic footprint varies significantly depending on the user's settings.

Method 1: The "Cache4.db" File & Secret Chats

  • Cloud Chats vs. Secret Chats:

    • Cloud Chats: These are stored on Telegram's servers. When you delete a message, it can be deleted from all devices and the cloud. Recovery then depends on Telegram's server-side retention policies, which are not public.

    • Secret Chats: These are device-specific, end-to-end encrypted, and leave no trace on Telegram's servers. They are stored locally in a database file called cache4.db .

  • Investigator's Approach:

    1. File System Extraction: A file system or physical extraction is required to get the cache4.db file.

    2. Decryption: Secret Chats are encrypted, but the keys are stored on the device. Forensic tools can often decrypt this database, revealing the chat history.

    3. Recovering Deleted Secret Chats: Similar to WhatsApp, when a message is deleted in a Secret Chat, it may be removed from the active view but remain in the database's free space until overwritten. SQLite carving can recover these traces.

Method 2: Telegram's Data Export Function (A Self-Service Loophole)

This is a unique aspect of Telegram. Users can request a full export of their cloud data directly from the app (Settings > Advanced > Export Telegram Data). This export includes all messages, media, and documents from their cloud chats.

  • The Critical Flaw: If an investigator has access to an unlocked phone, they can initiate this export even if chats have been recently deleted . The exported data often includes messages that are no longer visible in the app interface because the deletion may not have fully propagated on Telegram's servers or the export includes a recently cached version.

Method 3: Residual Media Files

When photos, videos, or files are sent via Telegram, they are cached in the device's storage. Even if a chat is deleted, these media files can often be recovered through standard file carving techniques on the device's free space, as they may not be immediately erased.

Summary: The Investigator's Toolkit

 
PlatformKey Data SourcePrimary Method for Deleted ChatsKey Challenge
WhatsAppLocal msgstore.db fileSQLite Carving of the local database; Comparing local backups.End-to-end encrypted local database (requires device key).
TelegramLocal cache4.db file; Cloud ExportSQLite Carving for Secret Chats; Requesting Data Export for Cloud Chats.Cloud Chats can be deleted server-side; Secret Chats are device-specific.

Can You Truly Permanently Delete Chats?

It's difficult. To maximize the chance of deletion:

  1. Delete the chat.

  2. Uninstall the app.

  3. Continue using the device heavily to overwrite the freed storage space with new data.

However, a forensic examination performed immediately after deletion has a very high chance of success.

Mrityunjay Singh
Author

Mrityunjay Singh

Leave a comment

Your email address will not be published. Required fields are marked *

Request A Call Back

Ever find yourself staring at your computer screen a good consulting slogan to come to mind? Oftentimes.

shape
Your experience on this site will be improved by allowing cookies.