NAME
lr_anonimize - anonimize a logfile
SYNOPSIS
lr_anonimize dumpfilestem
DESCRIPTION
lr_anonimize reads a file containing emailaddresses, ipnumbers, and hostnames (typically a logfile from an internet service) from stdin, and prints an "anonimized" version of this file to stdout. It dumps the information to "deanonimize" the file, using lr_deanonimize(1), to 5 Berkeley DB databases; the names of the files holding these databases is contructed by concatenating the strings 'inaddr', 'maildomain', 'email', 'ip' and 'domain' to dumpfilestem. dumpfilestem can be e.g. /tmp/dump, ../../var/dump or dump. The db files created silently overwrite stale ones, if found.
The script builds temporary files. By default, these are created in /tmp. One can override this by setting the TMPDIR environment variable.
CONNECTION WITH lr_deanonimize
When running
$ lr_anonimize dump < log > log.anon$ lr_deanonimize dump < log.anon > log.new
then log and log.new have the same content (except for case, check it with diff -i).
NOTES
We tried to optimize this script for memoryusage. This has the drawback the script will run for quite some time when anonimizing a big logfile.
We've run the script on a 25 M sendmail logfile.
Typical values in such a case are 2500 K for total amount of physical memory used, and 15m real, 8m user and 22s systime spent on a 64 MB system with a 300 MHz Pentium II processor. de_anonimizing this file took 11m real, 8m user and 17s system time.
We store maildomains in the dumpfile. These are used by lr_deanonimize(1), in case email addresses in our input file reoccur in the file read by lr_deanonimize(1) in split form, i.e. [email protected] occurs as both [email protected] and example.com in the to be deanonimized file.
All dumped objects are casted to lowercase.
BACKGROUND
For your convenience, we quote a bit of rfc822:
SPACE = <ASCII SP, space> ; ( 40, 32.)CTL = <any ASCII control ; ( 0- 37, 0.- 31.)character and DEL> ; ( 177, 127.)specials = "(" / ")" / "<" / ">" / "@" ; Must be in quoted-/ "," / ";" / ":" / "\" / <"> ; string, to use/ "." / "[" / "]" ; within a word.atom = 1*<any CHAR except specials, SPACE and CTLs>quoted-string = <"> *(qtext/quoted-pair) <">; Regular qtext or; quoted chars.word = atom / quoted-stringdomain-ref = atom ; symbolic referencedomain-literal = "[" *(dtext / quoted-pair) "]"sub-domain = domain-ref / domain-literaldomain = sub-domain *("." sub-domain)local-part = word *("." word) ; uninterpreted; case-preservedaddr-spec = local-part "@" domain ; global address
and of rfc 2181
The DNS itself places only one restriction on the particular labelsthat can be used to identify resource records. That one restrictionrelates to the length of the label and the full name. The length ofany one label is limited to between 1 and 63 octets. A full domainname is limited to 255 octets (including the separators).
rfc1123
However, a valid host name can neverhave the dotted-decimal form #.#.#.#, since at least thehighest-level component label will be alphabetic.
rfc819
<domain> ::= <naming-domain> ⎪ <naming-domain> "." <domain><naming-domain> ::= <simple-name> ⎪ <address><simple-name> ::= <a> <ldh-str> <let-dig><ldh-str> ::= <let-dig-hyp> ⎪ <let-dig-hyp> <ldh-str><let-dig> ::= <a> ⎪ <d><let-dig-hyp> ::= <a> ⎪ <d> ⎪ "-"<a> ::= any one of the 52 alphabetic characters A through Z in uppercase and a through z in lower case<d> ::= any one of the ten digits 0 through 9
EXAMPLE
A 'logfile' like e.g.
blaat fkrf 1.2.3.4.in-addr.arpa] [email protected] bla 1 2 3 lj;agas;gagblaat 1.2.3.4 fkrf 3.2.3.4.in-addr.arpa] bla 1 www.hotsex.com 2 3 lj;agas;gag[email protected] agagagblaat fkrf 4.2.3.4.in-addr.arpa] bla [email protected] www.hotsex.com234.34.2.0 [email protected] 4.2.3.4.in-addr.arpa1 2 3 lj;agas;gagblaat fkrf tweede 3.2.3.4.in-addr.arpa] bla 1.2.3.4 1 blablabla.com2 mdcc.cx3 lj;agas;gag
wil get anonimized to
blaat fkrf 1.0.0.10.in-addr.arpa] [email protected] bla 1 2 3 lj;agas;gagblaat 10.0.0.1 fkrf 2.0.0.10.in-addr.arpa] bla 1 1.example.com 2 3 lj;agas;gag[email protected] agagagblaat fkrf 3.0.0.10.in-addr.arpa] bla [email protected] 1.example.com10.0.0.2 [email protected] 3.0.0.10.in-addr.arpa1 2 3 lj;agas;gagblaat fkrf tweede 2.0.0.10.in-addr.arpa] bla 10.0.0.1 1 2.example.com2 3.example.com3 lj;agas;gag
The dumps will represent something like
ip 234.34.2.0 10.0.0.2ip 1.2.3.4 10.0.0.1inaddr 3.2.3.4.in-addr.arpa 2.0.0.10.in-addr.arpainaddr 1.2.3.4.in-addr.arpa 1.0.0.10.in-addr.arpainaddr 4.2.3.4.in-addr.arpa 3.0.0.10.in-addr.arpadomain mdcc.cx 3.example.comdomain blablabla.com 2.example.comdomain www.hotsex.com 1.example.comemail [email protected] [email protected]email [email protected] [email protected]
BUGS
We can't handle files containing hostnames or email addresses in the example.com domain, usernames of the form john.doe.<someletters> or ipnumbers in the rfc 1918 private network 10.0.0.0 - 10.255.255.255 (10/8 prefix).
We don't handle quoted-string's in email addresses. We don't handle domain-literals in email addresses' domain.
We regard 999.999.999.999 as an IP address: we don't mind the 255 limit.
We don't treat network ipaddresses like 100.10.3 as ipaddresses. These will not get anonimized.
SEE ALSO
lr_deanonimize(1), the README.lire-client file in the Lire distribution.
VERSION
$Id: lr_anonimize.in,v 1.14 2001/10/18 19:13:17 flacoste Exp $
COPYRIGHT
Copyright (C) 2000-2001 Stichting LogReport Foundation [email protected]
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program (see COPYING); if not, check with http://www.gnu.org/copyleft/gpl.html or write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
AUTHOR
Joost van Baal <[email protected]>