obfuscate.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. # obfuscate.sh
  3. # obfuscate email addresses in XML/HTML
  4. # Script written (and slight perl modification) by Archaic <archaic AT linuxfromscratch D0T org>
  5. # Original Perl expression by Anderson Lizardo <lizardo AT linuxfromscratch D0T org>
  6. # Released under the GNU General Public License
  7. #
  8. # This script currently only seeks out mailto: addresses. If those same
  9. # addresses also appear in plaintext, we need to obfuscate those as well.
  10. #
  11. # This script was made for a very specific purpose so I was a bit lazy in
  12. # writing the regex's.
  13. #
  14. # Please send comments, enhancements, etc. to the above address
  15. #set -e # Bail on all errors
  16. # First, ensure that we are given a file to process
  17. # if [ $# -lt 1 ]; then
  18. # echo -e "\nYou must provide an input file."
  19. # exit 1
  20. # fi
  21. # Nothing like a backup plan!
  22. #cp "$1" "$1".bak
  23. for i in `grep -o '"mailto:.*@.*"' "$1" |sed -e 's|^"mailto:||' -e 's|"$||'`; do
  24. link=`echo $i | perl -pe 's/[^\n]/"\\\&#".ord($&)."\;"/ge'`
  25. plaintext=`echo $i | sed -e 's|@| AT |' -e 's|\.| D0T |g'`
  26. sed -i "s|mailto:$i|mailto:$link|" "$1"
  27. sed -i "s|$i|$plaintext|" "$1"
  28. done
  29. #exit 0