Skip to main content

A Python module and command line parser for SPF and DMARC records

Project description

checkdmarc

Build Status

A Python module and command line utility for validating SPF and DMARC DNS records

usage: checkdmarc.py [-h] [-p] [--ns NS [NS ...]] [--mx MX [MX ...]] [-d]
                     [-f FORMAT] [-o OUTPUT [OUTPUT ...]]
                     [-n NAMESERVER [NAMESERVER ...]] [-t TIMEOUT] [-v]
                     [-w WAIT] [--skip-starttls] [--debug]
                     domain [domain ...]

Validates and parses SPF amd DMARC DNS records

positional arguments:
  domain                one or more domains, or a single path to a file
                        containing a list of domains

optional arguments:
  -h, --help            show this help message and exit
  -p, --parked          indicate that the domains are parked
  --ns NS [NS ...]      approved nameserver substrings
  --mx MX [MX ...]      approved MX hostname substrings
  -d, --descriptions    include descriptions of DMARC tags in the JSON output
  -f FORMAT, --format FORMAT
                        specify JSON or CSV screen output format
  -o OUTPUT [OUTPUT ...], --output OUTPUT [OUTPUT ...]
                        one or more file paths to output to (must end in .json
                        or .csv) (silences screen output)
  -n NAMESERVER [NAMESERVER ...], --nameserver NAMESERVER [NAMESERVER ...]
                        nameservers to query (Default is Cloudflare's
  -t TIMEOUT, --timeout TIMEOUT
                        number of seconds to wait for an answer from DNS
                        (default 6.0)
  -v, --version         show program's version number and exit
  -w WAIT, --wait WAIT  number of seconds to wait between checking domains
                        (default 0.0)
  --skip-starttls       skip STARTTLS testing
  --debug               enable debugging output
$ checkdmarc fbi.gov
{
  "domain": "fbi.gov",
  "base_domain": "fbi.gov",
  "ns": {
    "hostnames": [
      "a1.fbi.gov",
      "a2.fbi.gov",
      "a3.fbi.gov"
    ],
    "warnings": []
  },
  "mx": {
    "hosts": [
      {
        "preference": 10,
        "hostname": "mx-east.fbi.gov",
        "addresses": [
          "153.31.160.5"
        ],
        "starttls": false
      }
    ],
    "warnings": [
      "mx-east.fbi.gov: Connection refused"
    ]
  },
  "spf": {
    "record": "v=spf1 +mx ip4:153.31.0.0/16 -all",
    "valid": true,
    "dns_lookups": 1,
    "warnings": [],
    "parsed": {
      "pass": [
        {
          "value": "mx-east.fbi.gov",
          "mechanism": "mx"
        },
        {
          "value": "153.31.0.0/16",
          "mechanism": "ip4"
        }
      ],
      "neutral": [],
      "softfail": [],
      "fail": [],
      "include": [],
      "redirect": null,
      "exp": null,
      "all": "fail"
    }
  },
  "dmarc": {
    "record": "v=DMARC1; p=reject; rua=mailto:dmarc-feedback@fbi.gov,mailto:reports@dmarc.cyber.dhs.gov; ruf=mailto:dmarc-feedback@fbi.gov; pct=100",
    "valid": true,
    "location": "fbi.gov",
    "warnings": [],
    "tags": {
      "v": {
        "value": "DMARC1",
        "explicit": true
      },
      "p": {
        "value": "reject",
        "explicit": true
      },
      "rua": {
        "value": [
          {
            "scheme": "mailto",
            "address": "dmarc-feedback@fbi.gov",
            "size_limit": null
          },
          {
            "scheme": "mailto",
            "address": "reports@dmarc.cyber.dhs.gov",
            "size_limit": null
          }
        ],
        "explicit": true
      },
      "ruf": {
        "value": [
          {
            "scheme": "mailto",
            "address": "dmarc-feedback@fbi.gov",
            "size_limit": null
          }
        ],
        "explicit": true
      },
      "pct": {
        "value": 100,
        "explicit": true
      },
      "adkim": {
        "value": "r",
        "explicit": false
      },
      "aspf": {
        "value": "r",
        "explicit": false
      },
      "fo": {
        "value": [
          "0"
        ],
        "explicit": false
      },
      "rf": {
        "value": [
          "afrf"
        ],
        "explicit": false
      },
      "ri": {
        "value": 86400,
        "explicit": false
      },
      "sp": {
        "value": "reject",
        "explicit": false
      }
    }
  }
}

Installation

checkdmarc requires Python 3.

On Debian or Ubuntu systems, run:

$ sudo apt-get install python3-pip

Python 3 installers for Windows and macOS can be found at https://www.python.org/downloads/

To install or upgrade to the latest stable release of checkdmarc on macOS or Linux, run

$ sudo -H pip3 install -U checkdmarc

Or, install the latest development release directly from GitHub:

$ sudo -H pip3 install -U git+https://github.com/domainaware/checkdmarc.git

Documentation

https://domainaware.github.io/checkdmarc

Bug reports

Please report bugs on the GitHub issue tracker

https://github.com/domainaware/checkdmarc/issues

Resources

DMARC guides

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

checkdmarc-4.0.2.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

checkdmarc-4.0.2-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file checkdmarc-4.0.2.tar.gz.

File metadata

  • Download URL: checkdmarc-4.0.2.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.31.0 CPython/3.7.2+

File hashes

Hashes for checkdmarc-4.0.2.tar.gz
Algorithm Hash digest
SHA256 3e78603a8e06805d466e73353f9e6d200e3b86c23214f73ea855f77be3afba96
MD5 687eb76d0c86bec8eee55a17d278e196
BLAKE2b-256 e1beb83042f50ff8bb2772d8998a11545256813051cb59b2de9a25292faeaedc

See more details on using hashes here.

File details

Details for the file checkdmarc-4.0.2-py3-none-any.whl.

File metadata

  • Download URL: checkdmarc-4.0.2-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.31.0 CPython/3.7.2+

File hashes

Hashes for checkdmarc-4.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dbd9ef328c7472b8cbf3e7680d9496418126f27235c76567dcf0f7b247e95be8
MD5 a27b8b404d117d26cfa8b3d3b50eaadb
BLAKE2b-256 7d1de64eff0808fb7f4536dda38c93c32449e2bb71c24e4c0592a599a478c0c6

See more details on using hashes here.

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