Skip to content

Instantly share code, notes, and snippets.

@waffle2k
Created January 12, 2011 20:08
Show Gist options
  • Save waffle2k/776786 to your computer and use it in GitHub Desktop.
Save waffle2k/776786 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
#
# This script takes a series of ARF messages, and stores certain attributes
# about these messages, so that other applications can easily look into
# only the messages that they care about without having to go into lots
# and lots of files.
use strict;
use lib( qw( /abuse/AUP/lib /abuse/AUP/plugins ) );
use Email::ARF::Report;
use MLDBM;
use Fcntl;
my %o;
my $dbm = tie %o, 'MLDBM', '/abuse/AUP/bin/complaintdb', O_CREAT|O_RDWR, 0640 or die $!;
for( sort( keys %o ) ){
#print "Filename: $_\n";
my $tmp = $o{$_};
my ($filename , $auth, $ips ) = ( $_, undef, undef );
my ($subject, $from, $replyto, $epoch );
for my $k ( keys %$tmp ){
$auth = $tmp->{$k} if $k eq 'auth';
$ips = $tmp->{$k} if $k eq 'ips';
$from = $tmp->{$k} if $k eq 'from';
$replyto = $tmp->{$k} if $k eq 'replyto';
$subject = $tmp->{$k} if $k eq 'subject';
$epoch = $tmp->{$k} if $k eq 'epoch';
}
next unless defined $tmp->{auth};
print "filename:[/data/staff/abuse/fbl/$filename] auth:[$auth] subject:[$subject] from:[$from] replyto:[$replyto] ips:[" . join( ",", @{$ips} ) . "] epoch:[$epoch]\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment