blabbermouth 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. #
  3. # BLABBERMOUTH: a text-obfuscation script that takes a legitimate stream of
  4. # text and masks it with random words sourced from the unix dictionary file,
  5. # making it much harder for a human operator to read it.
  6. #
  7. # USAGE: blabbermouth [-d] [FILE]
  8. #
  9. # With no FILE specified, blabbermouth reads text from stdin, obfuscates it,
  10. # and prints the obfuscated text to stdout. Otherwise, it will attempt to read
  11. # the cleartext from the given FILE.
  12. #
  13. # Pass the `-d' flag to indicate that blabbermouth should deobfuscate a
  14. # previously obfuscated text.
  15. #
  16. # this is where the file is located, at least in debian:
  17. WORDS=/etc/dictionaries-common/words
  18. # obfuscation logic:
  19. encrypt() {
  20. # the "chaff" is sourced from the words file, but we should rotate it:
  21. chaff=$(shuf "$WORDS" | head -1)
  22. for word in $1
  23. do
  24. printf "$word $chaff "
  25. chaff=$(shuf "$WORDS" | head -1)
  26. done
  27. echo
  28. }
  29. # deobfuscation script:
  30. decrypt() {
  31. index=1
  32. for word in $1
  33. do
  34. rem=$(( $index % 2 ))
  35. if [[ ${rem} -ne 0 ]]
  36. then
  37. printf "$word "
  38. fi
  39. index=$(($index + 1))
  40. done
  41. echo
  42. }
  43. if [[ "$1" == "-d" ]]
  44. then
  45. echo "Enter some text to be deobfuscated: "
  46. read token
  47. decrypt "$token"
  48. else
  49. echo "Enter some text to be obfuscated: "
  50. read token
  51. encrypt "$token"
  52. fi