Metadata is structured data about a file that is not directly visible in its content (like the pixels of an image or the text of a document), but reveals potentially sensitive information about the author, device, software used, and geographical location (GPS coordinates).
This module provides documentation and tools for file anonymization by removing this metadata using mat2 (Metadata Anonymisation Toolkit v2).
When you share a file (images, PDFs, audios, documents), you often inadvertently share:
- GPS Coordinates: The exact location where a photo was taken.
- Device Identifiers: The brand, model, and serial number of your camera or smartphone.
- Software and History: Versions of image editing software, operating systems, local usernames, and file paths on your system.
- Dates and Times: Exact file creation and modification timestamps.
It is the standard anonymization tool recommended by PrivacyGuides and used in systems like Tails OS.
- FOSS: Licensed under GPLv3, written in Python.
- Operation Mode: Cleans metadata safely and destructively (by replacing the file or creating a clean copy).
- Supported Formats: PNG, JPEG, TIFF, PDF, ODT, DOCX, PPTX, XLSX, MP3, FLAC, Torrent, among others.
- Official Repository: https://0xacab.org/jvoisin/mat2
A highly powerful CLI tool for reading, writing, and editing metadata information. Used as an analysis complement.
- Official Repository: https://exiftool.org/
sudo pacman -S mat2 perl-image-exiftoolsudo apt update
sudo apt install mat2 exiftoolTo check if a file contains suspicious/sensitive metadata using mat2:
mat2 --show file.jpgOr using exiftool for a comprehensive analysis:
exiftool file.jpgBy default, mat2 will create a copy of the file with the .cleaned extension (e.g., file.cleaned.jpg) free of metadata:
mat2 file.jpgIf you wish to clean the original file directly (overwriting it), use the -i or --inplace flag:
mat2 --inplace file.jpgWe have provided the clean_metadata.sh script to automate metadata cleanup for individual files or entire folders recursively, verifying format compatibility beforehand to avoid terminal errors.
-
Grant execution permissions:
chmod +x clean_metadata.sh
-
Run it by passing a file or directory as an argument:
./clean_metadata.sh /path/to/directory_or_file
Use the -i or --inplace flag before the path to overwrite the original files directly.
If you prefer to skip the script and clean metadata recursively in a full directory using native terminal commands:
find /path/to/directory -type f -exec mat2 {} +find /path/to/directory -type f -exec mat2 --inplace {} +Note: Using find ... -exec mat2 directly will print warning messages for any unsupported file formats found. The automated script avoids this by validating format support for each file beforehand.