Skip to main content

Scan domains and return data based on trustworthy email best practices

Project description

Trustworthy Mail

Latest Version Build Status Coverage Status

trustymail is a tool that evaluates SPF/DMARC records set in a domain's DNS. It also checks the mail servers listed in a domain's MX records for STARTTLS support. It saves its results to CSV or JSON.

Getting Started

trustymail can be installed as a module or run directly from the repository.

Installed as a module

trustymail can be installed directly via pip:

pip install trustymail

It can then be run directly:

trustymail [options] example.com

Running directly

To run the tool locally from the repository, without installing, first install the requirements:

pip install -r requirements.txt

Then run the CLI:

python scripts/trustymail [options] example.com

Usage and examples

trustymail [options] INPUT

trustymail dhs.gov
trustymail --output=homeland.csv --debug dhs.gov us-cert.gov usss.gov
trustymail agencies.csv

Note: if INPUT ends with .csv, domains will be read from CSV. CSV output will always be written to disk, defaulting to results.csv.

Options

  -h --help                   Show this message.
  -o --output=OUTFILE         Name of output file. (Default results)
  -t --timeout=TIMEOUT        The DNS lookup timeout in seconds. (Default is 5.)
  --smtp-timeout=TIMEOUT      The SMTP connection timeout in seconds. (Default 
                              is 5.)
  --smtp-localhost=HOSTNAME   The hostname to use when connecting to SMTP 
                              servers.  (Default is the FQDN of the host from
                              which trustymail is being run.)
  --smtp-ports=PORTS          A comma-delimited list of ports at which to look 
                              for SMTP servers.  (Default is '25,465,587'.)
  --no-smtp-cache             Do not cache SMTP results during the run.  This 
                              may results in slower scans due to testing the 
                              same mail servers multiple times.
  --mx                        Only check mx records
  --starttls                  Only check mx records and STARTTLS support. 
                              (Implies --mx.)
  --spf                       Only check spf records
  --dmarc                     Only check dmarc records
  --debug                     Output should include error messages.
  --dns=HOSTNAMES             A comma-delimited list of DNS servers to query 
                              against.  For example, if you want to use 
                              Google's DNS then you would use the 
                              value --dns-hostnames='8.8.8.8,8.8.4.4'.  By 
                              default the DNS configuration of the host OS 
                              (/etc/resolv.conf) is used.  Note that 
                              the host's DNS configuration is not used at all 
                              if this option is used.
  --psl-filename=FILENAME     The name of the file where the public suffix list
                              (PSL) cache will be saved.  If set to the name of
                              an existing file then that file will be used as
                              the PSL.  If not present then the PSL cache will
                              be saved to a file in the current directory called
                              public_suffix_list.dat.
  --psl-read-only             If present, then the public suffix list (PSL) 
                              cache will be read but never overwritten.  This 
                              is useful when running in AWS Lambda, for
                              instance, where the local filesystem is read-only.

What's Checked?

For a given domain, MX records, SPF records (TXT), DMARC (TXT, at _dmarc.), and support for STARTTLS are checked.

The following values are returned in results.csv:

Domain and redirect info

  • Domain - The domain you're scanning!
  • Base Domain - The base domain of Domain. For example, for a Domain of sub.example.gov, the Base Domain will be example.gov. Usually this is the second-level domain, but trustymail will download and factor in the Public Suffix List when calculating the base domain.
  • Live - The domain is actually published in the DNS.

Mail sending

  • MX Record - If an MX record was found that contains at least a single mail server.
  • Mail Servers - The list of hosts found in the MX record.
  • Mail Server Ports Tested - A list of the ports tested for SMTP and STARTTLS support.
  • Domain Supports SMTP - True if and only if any mail servers specified in a MX record associated with the domain supports SMTP.
  • Domain Supports SMTP Results - A list of the mail server and port combinations that support SMTP.
  • Domain Supports STARTTLS - True if and only if all mail servers that support SMTP also support STARTTLS.
  • Domain Supports STARTTLS Results - A list of the mail server and port combinations that support STARTTLS.

SPF

  • SPF Record - Whether or not a SPF record was found.
  • Valid SPF - Whether the SPF record found is syntactically correct, per RFC 4408.
  • SPF Results - The textual representation of any SPF record found for the domain.

DMARC

  • DMARC Record - True/False whether or not a DMARC record was found.
  • Valid DMARC - Whether the DMARC record found is syntactically correct.
  • DMARC Results - The DMARC record that was discovered when querying DNS.
  • DMARC Record on Base Domain, Valid DMARC Record on Base Domain, DMARC Results on Base Domain - Same definition as above, but returns the result for the Base Domain. This is important in DMARC because if there isn't a DMARC record at the domain, the base domain (or "Organizational Domain", per RFC 7489), is checked and applied.
  • DMARC Policy - An adjudication, based on any policies found in DMARC Results and DMARC Results on Base Domain, of the relevant DMARC policy that applies.
  • DMARC Policy Percentage - The percentage of mail that should be subjected to the DMARC Policy according to the DMARC Results.
  • DMARC Aggregate Report URIs - A list of the DMARC aggregate report URIs specified by the domain.
  • DMARC Forensic Report URIs - A list of the DMARC forensic report URIs specified by the domain.
  • DMARC Has Aggregate Report URI - A boolean value that indicates if DMARC Results included rua URIs that tell recipients where to send DMARC aggregate reports.
  • DMARC Has Forensic Report URI - A boolean value that indicates if DMARC Results included ruf URIs that tell recipients where to send DMARC forensic reports .

Etc.

  • Syntax Errors - A list of syntax errors that were encountered when analyzing SPF records.
  • Debug - A list of any other warnings or errors encountered, such as DNS failures. These can be helpful when determining how trustymail reached its conclusions, and are indispensible for bug reports.

Public domain

This project is in the worldwide public domain.

This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.

All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.

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

trustymail-0.6.2.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

trustymail-0.6.2-py2.py3-none-any.whl (18.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file trustymail-0.6.2.tar.gz.

File metadata

  • Download URL: trustymail-0.6.2.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for trustymail-0.6.2.tar.gz
Algorithm Hash digest
SHA256 634c95bbde1194cd4589128c9a861109581314c4b9a5bb690159d0cf52e8754f
MD5 d604fd386d18d1499bf42b23728a111f
BLAKE2b-256 c41dc4b300d88ec6d71cdd7c3847abd12bde2b124ddb19b32e5e2b163d990007

See more details on using hashes here.

Provenance

File details

Details for the file trustymail-0.6.2-py2.py3-none-any.whl.

File metadata

  • Download URL: trustymail-0.6.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for trustymail-0.6.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2c9d4a9fa2d90136cd9ad36472621dd2451241bcf3a0a87427981e0e63346204
MD5 ea425941632118d87c6a66d591a21186
BLAKE2b-256 169f0ca8e07a2facd82b07c53074011e3c183027d41c2aa2454eebc5ed4f708b

See more details on using hashes here.

Provenance

Supported by

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