tor-hardened-preferences.install 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. pre_install() {
  2. echo "Cleaning any old chroots before installing a new one..."
  3. rm -rf /opt/torchroot
  4. }
  5. post_install() {
  6. echo "Installing a new chroot ... "
  7. /usr/bin/sh -c "/opt/tor-hardened-scripts/torchroot.sh"
  8. wait
  9. echo "Done!"
  10. echo "====="
  11. echo "To use this service please disable tor.service"
  12. echo "then enable/start tor-hardened.service via systemctl."
  13. echo "----"
  14. echo "You may now use stream isolated ports for added security."
  15. echo "Please configure your applications as follows:"
  16. echo "Default Port: 9050"
  17. echo "Mail Client isolated port: 9061"
  18. echo "Browser isolated port: 9150"
  19. echo "Other applications you want isolated: 9062"
  20. echo "----"
  21. echo "To use TOR as your DNS resolver:"
  22. echo "Place ONLY this line into /etc/resolv.conf:"
  23. echo "nameserver 127.0.0.1"
  24. echo "Apply the following firewall rules:"
  25. echo "iptables -t nat -A OUTPUT -p TCP --dport 53 -j DNAT --to-destination 127.0.0.1:9053"
  26. echo "iptables -t nat -A OUTPUT -p UDP --dport 53 -j DNAT --to-destination 127.0.0.1:9053"
  27. echo "----"
  28. echo "To request new IP from TOR:"
  29. echo "killall -HUP tor"
  30. echo "---"
  31. echo "Advanced usage, not recommended:"
  32. echo "To torify ALL TCP traffic, you can use TorTransport without stream isolation:"
  33. echo "iptables -t nat -A OUTPUT -p TCP -m owner ! --uid-owner tor -j DNAT --to-destination 127.0.0.1:9040"
  34. echo "WARNING: UDP traffic may still leak! All traffic goes through single port. Apply additional iptables rules as you see fit."
  35. echo "====="
  36. }
  37. post_upgrade() {
  38. systemctl stop tor-hardened
  39. echo "Cleaning old chroot and putting in a new one..."
  40. rm -rf /opt/torchroot
  41. wait
  42. /usr/bin/sh -c "/opt/tor-hardened-scripts/torchroot.sh"
  43. wait
  44. echo "Done!"
  45. echo "====="
  46. echo "To use this service please disable tor.service"
  47. echo "then enable/start tor-hardened.service via systemctl."
  48. echo "----"
  49. echo "You may now use stream isolated ports for added security."
  50. echo "Please configure your applications as follows:"
  51. echo "Default Port: 9050"
  52. echo "Mail Client isolated port: 9061"
  53. echo "Browser isolated port: 9150"
  54. echo "Other applications you want isolated: 9062"
  55. echo "----"
  56. echo "To use TOR as your DNS resolver:"
  57. echo "Place ONLY this line into /etc/resolv.conf:"
  58. echo "nameserver 127.0.0.1"
  59. echo "Apply the following firewall rules:"
  60. echo "iptables -t nat -A OUTPUT -p TCP --dport 53 -j DNAT --to-destination 127.0.0.1:9053"
  61. echo "iptables -t nat -A OUTPUT -p UDP --dport 53 -j DNAT --to-destination 127.0.0.1:9053"
  62. echo "----"
  63. echo "To request new IP from TOR:"
  64. echo "killall -HUP tor"
  65. echo "---"
  66. echo "Advanced usage, not recommended:"
  67. echo "To torify ALL TCP traffic, you can use TorTransport without stream isolation:"
  68. echo "iptables -t nat -A OUTPUT -p TCP -m owner ! --uid-owner tor -j DNAT --to-destination 127.0.0.1:9040"
  69. echo "WARNING: UDP traffic may still leak! All traffic goes through single port. Apply additional iptables rules as you see fit."
  70. echo "====="
  71. systemctl daemon-reload
  72. }
  73. post_remove() {
  74. echo "Deleting chroot..."
  75. rm -rf /opt/torchroot
  76. wait
  77. echo "Done!"
  78. }