Changeset 501


Ignore:
Timestamp:
May 3, 2010, 10:13:45 PM (10 years ago)
Author:
obibi
Message:

Scramble ip addresses by dividing them by 3, see #12,

File:
1 edited

Legend:

Unmodified
Added
Removed
  • postfix-logtools/poststat/anonymizer.pl

    r496 r501  
    11#!/usr/bin/env perl
    22
    3 # 2010-04-29 <vschmitt@bearstech.com>
     3# 2010-05-03 <vschmitt@bearstech.com>
    44
    55# Anonymizer for Postfix mail logs.
     
    1212    # Only keep postfix/* related lines
    1313    next unless /postfix\//;
    14     # Quick and dirty way to scramble most email addresses or hostname
    15     #s/<[^<]*>/<hostname_or_email_address>/g
    1614    # Scramble ip addresses
    17     s/([0-9]{1,3}\.){3}[0-9]{1,3}/ip.add.re.ss/g;
     15    s| (([\d]{1,3}\.){3}[\d]{1,3}) | join('.', map {int($_/3)} split(/\./, $1)) |gexo;
    1816    # Scramble email addresses and message ids
    19     s/<[^<]*@[^<]*(\.[a-zA-Z]{2,6})>/<name\@domain$1>/g;
    20     s/(sasl_username=).*@.*(\.[a-zA-Z]{2,6})/$1name\@domain$2/g;
    21     s/(message-id)=<.*@.*>/$1=<$1\@domain>/g;
     17    s/<[^<]*@[^<]*(\.[a-zA-Z]{2,6})>/<name\@domain$1>/go;
     18    s/(sasl_username=).*@.*(\.[a-zA-Z]{2,6})/$1name\@domain$2/go;
     19    s/(message-id)=<.*@.*>/$1=<$1\@domain>/go;
    2220    # Scramble hostnames
    23     s/(hostname |from |connect to |client=|relay=)[\w\-\.]*/$1hostname/g
     21    s/(hostname |from |connect to |client=|relay=)[\w\-\.]*/$1hostname/go
    2422        unless /(hostname |from |client=|relay=)(localhost|ns3\.bearstech\.net)/;
    25     s/(helo=<).*>/$1hostname>/;
    26     s/<[^<]*>:/<hostname_or_email_address>:/g;
     23    s/(helo=<).*>/$1hostname>/o;
     24    s/<[^<]*>:/<hostname_or_email_address>:/go;
    2725    # Move dates to a fixed offset
    28     s/^[a-zA-Z]* [0-9]{1,2}/Apr 1/;
     26    s/^[a-zA-Z]* [\d]{1,2}/Apr 1/o;
    2927    print $_;
    3028}
    3129
     30# TODO
     31# try s///o
Note: See TracChangeset for help on using the changeset viewer.