Skip to content

Instantly share code, notes, and snippets.

@lethak
Last active December 28, 2021 21:31
Show Gist options
  • Save lethak/9a17a6e235e58013a644c6b20d8495b1 to your computer and use it in GitHub Desktop.
Save lethak/9a17a6e235e58013a644c6b20d8495b1 to your computer and use it in GitHub Desktop.
Clone a default TOR browser instance to allow the clones to be ran as multiple TOR Browser instances with different IPs. If you want the same effect without the Browser, head over https://github.com/lethak-docker/tor-clients
#!/bin/bash
# HOWTO MAKE IT WORK ?
#
# Required for windows user: you may want to have linux friendly shell already installed (Git-Bash is doing a fine job and easy to install)
# Then,
# Go to Tor Browser install directory ex: "C:\Programs\Tor Browser"
# Create and or copy this script there under the name "tbb_clone.sh" (name and path not important if you know what you are doing)
# Run the script ex: "bash ./tbb_clone.sh -n 4 -p ./Browser"
# This will create 4 copies of the "Browser" folder named "TBB1" to "TBB4"
# In each instance, start firefox.exe and test your ips ! http://ip-check.info
# Enjoy; thanks to https://tor.stackexchange.com/questions/2006/how-to-run-multiple-tor-browsers-with-different-ips/6401#6401
usage() { echo "Usage: $0 [-n <number of copies>] [-p <path to default TBB>]" 1>&2; exit 1; }
print_userjs(){
local socksport=${1}
local controlport=${2}
local dest=${3}
echo "user_pref(\"extensions.torlauncher.control_port\",$controlport);" > $dest
#echo "user_pref(\"extensions.torbutton.custom.socks_port\",$socksport);" >> $dest
#echo "user_pref(\"extensions.torbutton.custom.socks_host\",\"127.0.0.1\");" >> $dest
#echo "user_pref(\"extensions.torbutton.proxies_applied\",false);" >> $dest
#echo "user_pref(\"extensions.torbutton.use_privoxy\",false);" >> $dest
echo "user_pref(\"network.proxy.socks_port\",$socksport);" >> $dest
echo "user_pref(\"network.proxy.socks\",\"127.0.0.1\");" >> $dest
}
while getopts ":n:p:" o; do
case "${o}" in
n)
n=${OPTARG}
;;
p)
p=${OPTARG}
;;
*)
usage
exit 0
;;
esac
done
if [ -z "$n" ] || [ -z "$p" ];
then
usage
exit 0
fi
for i in `seq 1 $n`;
do
MAXCIRCUITDIRTINESS=86400
CONTROL_PORT=$((9151+$i*2))
SOCKS_PORT=$((9150+$i*2))
echo "$i) Copying $p to TBB$i"
cp -r $p TBB$i
echo "$i) Creating user.js with SocksPort $SOCKS_PORT and ControlPort $CONTROL_PORT"
print_userjs $SOCKS_PORT $CONTROL_PORT "./TBB$i/TorBrowser/Data/Browser/profile.default/user.js"
echo "$i) Modifying torrc-default"
TORRC="./TBB$i/TorBrowser/Data/Tor/torrc-defaults"
sed -i "s/SocksPort 9150/SocksPort $SOCKS_PORT/g" $TORRC
sed -i "s/ControlPort 9151/ControlPort $CONTROL_PORT/g" $TORRC
sed -i "s/MaxCircuitDirtiness 600/ControlPort $MAXCIRCUITDIRTINESS/g" $TORRC
done
@lethak
Copy link
Author

lethak commented Dec 23, 2020

Sorry to say its not working on windows.

Hi, to be frank its been awhile since this was made and maybe tor browser is not working the same way now ?

I've just updated to TB v10.0.7 (32-bit) and it seems to be still working fine (Win 10)

tbbclone

Also, make sure you follow this

In each instance, start firefox.exe

and not launching the same firefox.exe multiple times.

so you must start

  • TBB1/firefox.exe
  • TBB2/firefox.exe
  • ...

also could be a problem with the ports

CONTROL_PORT=$((9151+$i2))
SOCKS_PORT=$((9150+$i
2))

make sure this range is available on your machine or change those values

@falirezam
Copy link

Hi bro
here is a problem which I can't understand. I did everything you said on windows, yet when I run the bash script nothing happens. no browser comes up. can you help me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment