Skip to main content

Download DMARC Attachments From Gmail

Description

A tool to download DMARC from Gmail email attachments. Consider it under development, so use with care. Feedback and PRs are welcome!

Installation

pip3 install DownloadDMARCAttachmentsFromGmail
DownloadDMARCFilesFromGmail --help

How To Use

First, you need to give the tool access to your Gmail account through the API. Here's how to do it for a workspace account:

  • Access https://console.cloud.google.com/
  • Create a new project, for example named "DownloadDMARCAttachments"
  • Select the newly created project
  • Enable the Gmail API
    • Navigate to the API Console
    • Select on ENABLE APIS AND SERVICES
    • Search for gmail
    • Select Gmail API
    • Select Enable
  • Configure the OAuth consent
  • Configure the Credentials
    • Select Credentials from the left navigation pane
    • Select CREATE CREDENTIALS and select OAuth Client ID
    • For Application type select Desktop app
    • For Name fill in "DownloadDMARCAttachments"
    • Select Create
    • Download the JSON file
  • Create a ~/.config/dmarc folder, copy the client json file into it, and rename it to client_id.json

Second, you need to ensure that all the DMARC messages in your Gmail inbox have a label. By default, the label is "DMARC".

Third, create a label under which the messages will be posted after a successful download of the attachment. By default, the tool uses "PROCESSED_DMARC".

You are now ready to run it. Just pass in the label name and the processed label name, if different from the defaults. The tool will download the attachments for messages found under the DMARC label into an out folder and replace the DMARC label with the processed label. This allows you to double check the results, and do whatever you want with the processed messages.

Renewing OAuth Client ID

When renewing the OAuth Client ID, download the OAuth client JSON file again.

Move the file to ./secrets/client_id.json.

Delete the file ./secrets/token.pickle.

Known Issues

We're still figuring out the different ways the attachment id is found in Gmail messages, so processing fails for some messages.

Limitations

Due to limitations in the Gmail API, the tool processes max. 500 messages at once. If you have more than 500 DMARC messages, just run it again until you process all the files.

Generating a report

If you're looking for a simple tool to generate a report from the downloaded attachments, check out the companion tool DMARC Reporting.

Development setup

  • Make sure you have python 3.10
  • Install pipenv

With default arguments, i.e. --labelName DMARC --processedLabelName PROCESSED_DMARC

make install-dev
make run

To pass arguments:

make run args="--labelName dmarc --processedLabelName processed-dmarc"

Development Notes

This tool was started by Alex Bolboaca to automate the DMARC processing flow that he uses.

Metadata

Release files for DownloadDMARCAttachmentsFromGmail 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for DownloadDMARCAttachmentsFromGmail 0.2.0
File Size Uploaded Provenance Actions
DownloadDMARCAttachmentsFromGmail-0.2.0.tar.gz 11.2 kB Without provenance Details for DownloadDMARCAttachmentsFromGmail-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for DownloadDMARCAttachmentsFromGmail 0.2.0
File Interpreter ABI Platform Actions
DownloadDMARCAttachmentsFromGmail-0.2.0-py3-none-any.whl Python 3 none any Details for DownloadDMARCAttachmentsFromGmail-0.2.0-py3-none-any.whl

Total release size: 19.6 kB

Release files / DownloadDMARCAttachmentsFromGmail-0.2.0.tar.gz

Download URL DownloadDMARCAttachmentsFromGmail-0.2.0.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
35441529c318652e9a4ddc4e05b33f8fbf3f68fb53dc1a6d12bd68e40c257434
BLAKE2b-256 checksum
How to use checksums
0a37fc2e7151c977f8f7d3aeb50e2f45099423eb60bb91dda8815efcfc0a738a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / DownloadDMARCAttachmentsFromGmail-0.2.0-py3-none-any.whl

Download URL DownloadDMARCAttachmentsFromGmail-0.2.0-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
06340aa37251ef0671eab28ab4807dc09b1945ae779887ea693ade14d45da69e
BLAKE2b-256 checksum
How to use checksums
02732b5645a5e6b2c11d8538e5c7835c01d71a69af7b8aceada067484acfb83f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Security for DownloadDMARCAttachmentsFromGmail 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page