kkDav1337

Automatic Tor Duplication

Dec 5th, 2019
14,351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.45 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. usage() { echo "Usage: $0 [-n <number of copies>] [-p <path to default TBB>]" 1>&2; exit 1; }
  4.  
  5. print_userjs(){
  6.   local socksport=${1}
  7.   local controlport=${2}
  8.   local dest=${3}
  9.   echo "user_pref(\"extensions.torlauncher.control_port\",$controlport);" > $dest
  10.   echo "user_pref(\"extensions.torbutton.custom.socks_port\",$socksport);" >> $dest
  11.   echo "user_pref(\"extensions.torbutton.custom.socks_host\",\"127.0.0.1\");" >> $dest
  12.   echo "user_pref(\"extensions.torbutton.proxies_applied\",false);" >> $dest
  13.   echo "user_pref(\"extensions.torbutton.use_privoxy\",false);" >> $dest
  14.   echo "user_pref(\"network.proxy.socks_port\",$socksport);" >> $dest
  15. }
  16.  
  17. while getopts ":n:p:" o; do
  18.   case "${o}" in
  19.     n)
  20.       n=${OPTARG}
  21.       ;;
  22.     p)
  23.       p=${OPTARG}
  24.       ;;
  25.     *)
  26.       usage
  27.       exit 0
  28.      ;;
  29.   esac
  30. done
  31. if [ -z "$n" ] || [ -z "$p" ];
  32. then
  33.   usage
  34.   exit 0
  35. fi
  36. for i in `seq 1 $n`;
  37. do
  38.   CONTROL_PORT=$((9151+$i*2))
  39.   SOCKS_PORT=$((9150+$i*2))
  40.   echo "$i) Copying $p to TBB$i"
  41.   cp -r $p TBB$i
  42.   echo "$i) Creating user.js with SocksPort $SOCKS_PORT and ControlPort $CONTROL_PORT"
  43.   print_userjs $SOCKS_PORT $CONTROL_PORT "./TBB$i/Browser/TorBrowser/Data/Browser/profile.default/user.js"
  44.   echo "$i) Modifying torrc-default"
  45.   TORRC="./TBB$i/Browser/TorBrowser/Data/Tor/torrc-defaults"
  46.   sed -i "s/SocksPort 9150/SocksPort $SOCKS_PORT/g" $TORRC
  47.   sed -i "s/ControlPort 9151/ControlPort $CONTROL_PORT/g" $TORRC
  48. done
Add Comment
Please, Sign In to add comment