How to extract a phone number from a WhatsApp archive?

How to extract a phone number from a WhatsApp archive - briefly?

To extract a phone number from a WhatsApp archive, follow these steps:

  1. Locate the "User_Info" file within the archive.
  2. Open this file with a text editor and search for the "PhoneNumber" field to find the associated contact information.

How to extract a phone number from a WhatsApp archive - in detail?

Extracting a phone number from a WhatsApp archive can be accomplished through several methods, each with its own level of detail and technical complexity. Below is a comprehensive guide on how to achieve this:

Method 1: Using File Explorer (Windows) or Finder (Mac)

Step-by-Step Guide:

  1. Locate the Archive: Find your WhatsApp archive file, typically named msgstore.db.crypt12 and located in the backup folder on your device.

    • On Windows: C:\Users\<YourUsername>\WhatsApp\Databases
    • On Mac: ~/Library/Application Support/WhatsApp/Databases
  2. Rename the File: Change the file extension from .crypt12 to .zip. This is because WhatsApp archives are encrypted and compressed in a .zip format.
  3. Extract the ZIP File: Use a file extraction tool (like WinRAR or 7-Zip) to extract the contents of the renamed file. You will get a new file named msgstore.db.
  4. Decrypt the Database: WhatsApp uses SQLCipher for encryption, so you'll need an SQLite browser that supports decryption. Download and install DB Browser for SQLite.
  5. Open the Database: Launch DB Browser for SQLite and open the msgstore.db file. When prompted for a password, use any random string (e.g., "1234567890"). This placeholder will be replaced in the next step.
  6. Execute SQL Commands: Use the following SQL command to extract phone numbers:

    SELECT DISTINCT msg_from_jid FROM messages;

    Note that msg_from_jid contains both the phone number and the country code, formatted as +<countrycode><phonenumber>.

  7. Copy the Results: Copy the extracted phone numbers from the results window.

Method 2: Using Command Line Tools (Advanced)

For users comfortable with command-line interfaces, SQLite and OpenSSL can be used to decrypt and extract data.

Step-by-Step Guide:

  1. Install Required Tools: Ensure you have SQLite and OpenSSL installed on your system.
  2. Decrypt the Database: Use OpenSSL to decrypt the database. The command below assumes a placeholder password of "1234567890":

    openssl enc -d -aes-256-cbc -k 1234567890 -in msgstore.db.crypt12 -out msgstore.db
  3. Extract Data Using SQLite: Open a terminal or command prompt and navigate to the directory containing msgstore.db. Use the following SQL command:

    sqlite3 msgstore.db "SELECT DISTINCT msg_from_jid FROM messages;"
  4. Copy the Results: Copy the phone numbers from the terminal output.

Conclusion

Both methods outlined above provide a detailed approach to extracting phone numbers from a WhatsApp archive. While the File Explorer/Finder method is more user-friendly, the command line tools offer greater flexibility and control for advanced users. Always ensure you have the necessary permissions and tools installed before beginning the extraction process.