How to edit Tor circuit in shell

Hello, can i use some commands to edit my connection how i want?
I need to do this in shell, exist some method for edit my circuit like choose how many nodes to use like just one or more than 3?
Can i choose my exit node on the same command?
Is extremely important that i don’t use some software, i must use shell(terminal)

1 Like

Information taken from here: Tor Project: manual

There are ways to manipulate or steer your paths via torrc, you can specify explicit nodes, countries or an IP/IP-Ranges:

ExitNodes node , node ,

MiddleNodes node , node ,

EntryNodes node , node ,

StrictNodes 0 | 1

For playing around it might be fine, when you need anonymity it is not recommended, because you look completely different from the other network…


building a Tor-binary will let you choose how many hops are used when modifying ‘#define DEFAULT_ROUTE_LEN 3’ in ‘src/core/or/or.h

on Debian/Ubuntu:

sudo apt-get install build-essential libevent-dev libssl-dev zlib1g zlib1g-dev
mkdir ~/tortest
cd ~/tortest
wget https://dist.torproject.org/tor-0.4.7.2-alpha.tar.gz
tar xfz tor-0.4.7.2-alpha.tar.gz
sed -i 's/DEFAULT_ROUTE_LEN\ 3/DEFAULT_ROUTE_LEN\ 6/' tor-0.4.7.2-alpha/src/core/or/or.h | where 6 is your wanted hop number
./configure --prefix=~/tortest
make
make install
cp etc/torrc.sample etc/torrc
—> adjust your torrc to provide debug.log

mkdir -p ~/tortest/var/lib/tor
mkdir -p ~/tortest/var/log/tor
~/tortest/bin/tor -f ~/tortest/etc/torrc
curl --socks5-hostname localhost:9050 https://check.torproject.org/

—> see ~/tortest/var/log/tor/debug.log for ‘exit circ (length

3 Likes

Thanks for the reply, i think that you have understand correctly what i need but i have some problems with your solution.
I have created a directory with mkdir and downloaded the Tor Project dist, but after make install command nothing else works.

When i run cp tor/torrc.sample tor/torrc i have No such file or directory however i found this guide How to install tor frome source code that i tried to follow but without success, it however doesn’t work because if i send just tor in Shell (after make install command) it doesn’t find nothing and if i run tor from src/app/tor it doesn’t even work…

What i wrong?

And an another important thing is that i must can change this config file when tor is installed on the machine whenever i want.

For example…
Now i install Tor and i have 3 default node
I edit this setting with 6 node circuit
I run Tor and now i have 6 node circuit
I edit this setting with 2 node circuit
I run Tor and now i have 2 node circuit
And more…

sorry - edited this one - there was a typo and that one

then it should work

probably this won’t work so easy - you could compile different versions for different hop-settings - maybe there is a more clever approach, but can’t provide you with…

in ~/tortest/etc/ i have just tor directory, i don’t have torrc file and i seen in else directories and i haven’t found torrc file anywhere, except for etc/tor/torrc.sample that i found correctly…

However, if i understand you do you mean, do you think that can i change this option on torrc file?

In case of yes what i must write inside?

Because if exist some command like ExitNodes {ca} StrictNodes 1 (it is just for an example) where i can declare something like Route_Len 6 everything is done… but i didn’t find nothing like this on the manual page

cp ~/tortest/etc/torrc.sample ~/tortest/etc/torrc

Add
ExitNodes {ca}
StrictNodes 1
and you will exit in Canada…

As far as I know you can’t change hops from config - you have to compile a corresponding binary with the specific DEFAULT_ROUTE_LEN

ok i discard this idea

i found online*1 that the only one torrc command enable you to have a different number of circuit nodes is HiddenServiceSingleHopMode 1 that need to have HiddenServiceNonAnonymousMode 1

that change default tor circuit with 3 nodes in an another with just 1 node but when i write it on torrc my tor browser doesn’t start because it have an error in loading tor circuit, do you have some idea how can i solve it?

source*1: What's new in Tor 0.2.9.8? | The Tor Project

Can I ask what exactly are you trying to do?

Sure i’m trying to change circuit nodes number on Tor Browser that it can change in 1 or 2 or more of 3 nodes.
I know that this is not a good idea for anonymity but i’m trying to do it however for a study project and i don’t understand if it is possible or not…
I found 2 methods for do it…

  1. Change source code before installing tor, but it is not good for what i want to do because i need to can change nodes number when tor browser is installed.
  2. Change, with torrc file, hop number(so nodes number) to one and yes, it is a good command but i don’t have what i want because i can’t change nodes number to 2 or to more of 3

Forgive me if my English is not good.
I know that 3 nodes is the perfect circuit for the anonymity online but i need(i don’t know if “need” is the correct word to understand my necessity) do it for my study project

  1. You can use the downloaded Tor Browser and start it from command-line.

  2. From a second command-line you can kill the tor process e.g. killall tor, when something like psmisc is installed.

  3. Afterwards you start your compiled version of Tor with the specific hop settings. Make sure 9150 is set as socks port in torrc.

  4. Repeat from 2. to change your hops…

After putting this in an interactive script/application using dialog / ncurses you will probably get you better grades than just the 1.-4. PoC…

I don’t want to change my hops, i want to change hops number from 3 to N

Probably then your only option is to modify the source code to accept changes to new_route_len() at runtime…

1 Like

Ok, and how can i do what did you say?
What i must to do, when tor is installed on my computer, to change route len with new_route_len() method?

An another question is, is necessary use tor source code or can i use TorBrowser?
If i need tor source code, how can i install correctly to do what i need?

Thanks for the help

If you want a software to behave different from default, you need to modify it.
Like you do, when changing the DEFAULT_ROUTE_LEN in the source and compile it → This change is static and the binary will have the specified route-length baked in.

To make this length dynamic you need to modify way more things in the source → Read the corresponding source, adapt it according to your needs and compile it…

In other words, there is no easy way →

Compile

different versions or learn a little C…

2 Likes

Ok atari, thanks for your amazing help.

1 Like