| 1 |
#!/usr/bin/awk -f |
| 2 |
# |
| 3 |
# $Id$ |
| 4 |
# |
| 5 |
# Copyright (c) 2006 Nicholas Marriott <[email protected]> |
| 6 |
# |
| 7 |
# Permission to use, copy, modify, and distribute this software for any |
| 8 |
# purpose with or without fee is hereby granted, provided that the above |
| 9 |
# copyright notice and this permission notice appear in all copies. |
| 10 |
# |
| 11 |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 12 |
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 13 |
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 14 |
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 15 |
# WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER |
| 16 |
# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING |
| 17 |
# OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 18 |
# |
| 19 |
# |
| 20 |
# If the output of fdm -vvvv is piped to this script, it will remove usernames |
| 21 |
# and passwords from IMAP/POP3 output, for example: |
| 22 |
# |
| 23 |
# fdm -vvvv f 2>&1|fdm-sanitize|tee saved-output |
| 24 |
# |
| 25 |
|
| 26 |
BEGIN { |
| 27 |
imap_user = 0; |
| 28 |
imap_pass = 0; |
| 29 |
} |
| 30 |
|
| 31 |
/> [0-9]+ LOGIN \{[0-9]+\}/ { |
| 32 |
imap_user = 1; |
| 33 |
print ($1 " " $2 " " $3 " {*}"); |
| 34 |
fflush(); |
| 35 |
next; |
| 36 |
} |
| 37 |
|
| 38 |
/> .+ ?\{[0-9]+\}/ { |
| 39 |
if (imap_user) { |
| 40 |
print ("> * {*}"); |
| 41 |
fflush(); |
| 42 |
imap_user = 0; |
| 43 |
imap_pass = 1; |
| 44 |
next; |
| 45 |
} |
| 46 |
print ($0); |
| 47 |
fflush(); |
| 48 |
next; |
| 49 |
} |
| 50 |
|
| 51 |
/> APOP .+/ { |
| 52 |
print ("> APOP * *"); |
| 53 |
fflush(); |
| 54 |
next; |
| 55 |
} |
| 56 |
|
| 57 |
/> USER .+/ { |
| 58 |
print ("> USER *"); |
| 59 |
fflush(); |
| 60 |
next; |
| 61 |
} |
| 62 |
|
| 63 |
/> PASS .+/ { |
| 64 |
print ("> PASS *"); |
| 65 |
fflush(); |
| 66 |
next; |
| 67 |
} |
| 68 |
|
| 69 |
/> .+/ { |
| 70 |
if (imap_pass) { |
| 71 |
print ("> *"); |
| 72 |
fflush(); |
| 73 |
imap_pass = 0; |
| 74 |
next; |
| 75 |
} |
| 76 |
print ($0); |
| 77 |
fflush(); |
| 78 |
next; |
| 79 |
} |
| 80 |
|
| 81 |
/.*/ { |
| 82 |
print ($0); |
| 83 |
fflush(); |
| 84 |
} |