forked from halon/opendmarc-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opendmarc-halonlog
executable file
·85 lines (82 loc) · 2.63 KB
/
opendmarc-halonlog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/perl
#use warnings;
use strict;
my $reporter = $0;
while (<STDIN>)
{
chomp;
next if $_ !~ m/\[DMARC\][^\(]*\((.*)\)$/s;
my %result = map { split(/=/, $_, 2) } split(/; */, $1);
if ($_ =~ m/ ([^ ]+) smtpd\[[1-9]*\]:.*\[DMARC\]/s) {
$reporter = $1;
}
print "job ", $result{'id'}, "\n";
print "reporter ", $reporter, "\n";
print "received ", $result{'ts'}, "\n";
print "ipaddr ", $result{'ipaddr'}, "\n";
print "from ", $result{'from'}, "\n";
print "mfrom ", $result{'mfrom'}, "\n";
print "pdomain ", $result{'pdomain'}, "\n";
map { print "rua ", $_, "\n" } split(',', $result{'rua'}) if defined($result{'rua'});
print "aspf ";
print ord('s') if $result{'aspf'} eq 'strict';
print ord('r') if $result{'aspf'} eq 'relaxed';
print "\n";
print "adkim ";
print ord('s') if $result{'adkim'} eq 'strict';
print ord('r') if $result{'adkim'} eq 'relaxed';
print "\n";
print "pct ", $result{'pct'}, "\n";
print "p ";
print ord('n') if $result{'p'} eq 'none';
print ord('r') if $result{'p'} eq 'reject';
print ord('q') if $result{'p'} eq 'quarantine';
print '0' if ! defined($result{'p'});
print "\n";
print "sp ";
print ord('n') if $result{'sp'} eq 'none';
print ord('r') if $result{'sp'} eq 'reject';
print ord('q') if $result{'sp'} eq 'quarantine';
print '0' if ! defined($result{'sp'});
print "\n";
print "spf ";
print '0' if $result{'spf'} eq 'pass';
print '2' if $result{'spf'} eq 'softfail';
print '3' if $result{'spf'} eq 'neutral';
print '6' if $result{'spf'} eq 'none';
print '7' if $result{'spf'} eq 'fail';
print '-1' if $result{'spf'} eq 'unknown';
print "\n";
foreach my $key (keys %result)
{
next if $key !~ m/^dkim:(.+)$/s;
print "dkim ", $1, " ";
print '0' if $result{$key} eq 'pass';
print '2' if $result{$key} eq 'softfail';
print '4' if $result{$key} eq 'tempfail';
print '5' if $result{$key} eq 'permfail';
print "\n";
}
print "align_spf ";
print '4' if $result{'align_spf'} eq 'pass';
print '5' if $result{'align_spf'} eq 'fail';
print '5' if $result{'align_spf'} eq 'unaligned';
print "\n";
print "align_dkim ";
print '4' if $result{'align_dkim'} eq 'pass';
print '5' if $result{'align_dkim'} eq 'fail';
print '5' if $result{'align_dkim'} eq 'unaligned';
print "\n";
print "policy ";
print '15' if $result{'policy'} eq 'pass';
print '16' if $result{'policy'} eq 'reject';
print '17' if $result{'policy'} eq 'quarantine';
print '18' if $result{'policy'} eq 'none';
print "\n";
print "action ";
print '0' if $result{'action'} eq 'reject';
print '2' if $result{'action'} eq 'pass';
print '2' if $result{'action'} eq 'none';
print '4' if $result{'action'} eq 'quarantine';
print "\n";
}