torchroot.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. # torchroot generate script
  3. export TORCHROOT=/opt/torchroot
  4. mkdir -p $TORCHROOT
  5. mkdir -p $TORCHROOT/etc/tor
  6. mkdir -p $TORCHROOT/dev
  7. mkdir -p $TORCHROOT/usr/bin
  8. mkdir -p $TORCHROOT/usr/lib
  9. mkdir -p $TORCHROOT/usr/share/tor
  10. mkdir -p $TORCHROOT/var/lib
  11. ln -s /usr/lib $TORCHROOT/lib
  12. # Replace this line if you want to copy your own torrc instead of the one provided by hardened script.
  13. cp /opt/tor-hardened-scripts/torrc $TORCHROOT/etc/tor/
  14. cp /usr/bin/tor $TORCHROOT/usr/bin/
  15. cp /usr/share/tor/geoip* $TORCHROOT/usr/share/tor/
  16. cp /lib/libnss* /lib/libnsl* /lib/ld-linux-*.so* /lib/libresolv* /lib/libgcc_s.so* $TORCHROOT/usr/lib/
  17. cp $(ldd /usr/bin/tor | awk '{print $3}'|grep --color=never "^/") $TORCHROOT/usr/lib/
  18. cp -r /var/lib/tor $TORCHROOT/var/lib/
  19. chown -R tor:tor $TORCHROOT/var/lib/tor
  20. sh -c "grep --color=never ^tor /etc/passwd > $TORCHROOT/etc/passwd"
  21. sh -c "grep --color=never ^tor /etc/group > $TORCHROOT/etc/group"
  22. mknod -m 644 $TORCHROOT/dev/random c 1 8
  23. mknod -m 644 $TORCHROOT/dev/urandom c 1 9
  24. mknod -m 666 $TORCHROOT/dev/null c 1 3
  25. if [[ "$(uname -m)" == "x86_64" ]]; then
  26. cp /usr/lib/ld-linux-x86-64.so* $TORCHROOT/usr/lib/.
  27. ln -sr /usr/lib64 $TORCHROOT/lib64
  28. ln -s $TORCHROOT/usr/lib ${TORCHROOT}/usr/lib64
  29. fi