Last active
May 21, 2018 01:23
-
-
Save stevejenkins/1b61d15cc5aaf3e6819f to your computer and use it in GitHub Desktop.
Imports data from OpenDMARC's opendmarc.dat file into a local MySQL DB and sends DMARC failure reports to domain owners.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Imports data from OpenDMARC's opendmarc.dat file into a local MySQL DB | |
# and sends DMARC failure reports to domain owners. | |
# Based on a script from Hamzah Khan (http://blog.hamzahkhan.com/) | |
set -e | |
# Database and History File Info | |
DBHOST='localhost' | |
DBUSER='opendmarc' | |
DBPASS='secretpassword' | |
DBNAME='opendmarc' | |
HISTDIR='/var/spool/opendmarc' | |
HISTFILE='opendmarc' | |
# Make sure history file exists | |
touch ${HISTDIR}/${HISTFILE}.dat | |
# Move history file temp dir for processing | |
mv ${HISTDIR}/${HISTFILE}.dat /tmp/${HISTFILE}.$$ | |
# Import temp history file data and send reports | |
/usr/sbin/opendmarc-import -dbhost=${DBHOST} -dbuser=${DBUSER} -dbpasswd=${DBPASS} -dbname=${DBNAME} -verbose < /tmp/${HISTFILE}.$$ | |
/usr/sbin/opendmarc-reports -dbhost=${DBHOST} -dbuser=${DBUSER} -dbpasswd=${DBPASS} -dbname=${DBNAME} -verbose -interval=86400 -report-email 'postmaster@cheatcodes.com' -report-org 'CheatCodes.com' | |
/usr/sbin/opendmarc-expire -dbhost=${DBHOST} -dbuser=${DBUSER} -dbpasswd=${DBPASS} -dbname=${DBNAME} -verbose | |
# Delete temp history file | |
rm -rf *.$$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment