Skip to content

Instantly share code, notes, and snippets.

@DavidPesticcio
Forked from lethak/tbb_clone.sh
Created January 29, 2026 12:01
Show Gist options
  • Select an option

  • Save DavidPesticcio/1ecbd82aa88955c5de65a0fdd3ead8d7 to your computer and use it in GitHub Desktop.

Select an option

Save DavidPesticcio/1ecbd82aa88955c5de65a0fdd3ead8d7 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment