Skip to main content

Fetch recipients and chat messages from the chat.db database.

Project description

imessage_reader

This is a forensic tool written in Python 3. Use this tool to fetch the content (phone numbers, email addresses, messages and the account) from the chat.db database file on macOS (version 10.14 or above).

The following information is currently being read from the database:

  • user id (sender's phone number or email address)
  • message
  • date and time
  • service (iMessage or SMS)
  • account (recipient account)

Background

Received messages (iMessage or SMS) and attachments will be saved in "~/Library/Messages". This directory contains a "chat.db" file (SQLite3) with two tables of interest: handle and message. The handle table contains the recipients (email address or phone number). The received messages are in the message table.

Note

Since the iMessage database is only available under macOS, it makes no sense to use this tool under Windows or Linux.

Requirements

  • Python 3.8+
  • openpyxl

To run tests install pytest:

pip3 install pytest

Install

pip3 install imessage_reader

Usage (CLI)

Start the program with:

imessage_reader

This will show you all users and messages.

Use

imessage_reader -e

to create an Excel file containing users, messages, date and service (SMS or iMessage). The file will be stored in the Desktop folder.

Use

imessage_reader -s

to create a SQLite3 database containing users, messages, date and service (SMS or iMessage). The file will be stored in the Desktop folder.

Note: You need access to the Library folder in order to read the iMessage database file ("chat.db"). You can add access (for Terminal or iTerm) in

> System Preferences > Security & Privacy > Privacy > Full Disk Access

Usage (import module)

To get the messages use following code:

from imessage_reader import fetch_data

# Create a FetchData instance
fd = fetch_data.FetchData()

# Store messages in my_data
# This is a list of tuples containing user id, message and service.
# service -> iMessage or SMS
my_data = fd.get_messages()
print(my_data)

ToDo

  • Get the date of messages
  • Fetch the date of received messages.
  • Show a list of all known recipients.
  • Did the user receive the message via SMS or via iMessage?
  • Create SQLite3 database.
  • Show attachments.
  • Add more tests.

Changelog

see CHANGELOG.rst

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imessage_reader-0.2.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

imessage_reader-0.2.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file imessage_reader-0.2.0.tar.gz.

File metadata

  • Download URL: imessage_reader-0.2.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.2

File hashes

Hashes for imessage_reader-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c7a919163fe4e5386cfa618250d4590651d6a309148cd5f404e88d3bf22d0631
MD5 4eb8156a26caf014d86b351f7924e7eb
BLAKE2b-256 9679a8a83d217f640f8997e348185cc12727f65b6a5385a304871a3a313702d9

See more details on using hashes here.

File details

Details for the file imessage_reader-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: imessage_reader-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.2

File hashes

Hashes for imessage_reader-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16aa7fb40c3e9f9ee9450070f5d062d6204ba2a8ab4525d9e41db6561c39ddf0
MD5 10c414963c6616df4966b78c15fdbeed
BLAKE2b-256 4c5bb3cf7cebb1c5bf93af56c0b4758e3b1acfb0ff08d8c6a6169a32447d7e61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page