Thread View: alt.os.linux
12 messages
12 total messages
Started by Maria Sophia
Sun, 08 Nov 2026 03:08
Re: PSA: Setting the Windows Firefox Tor browser to use USA exit nodes
Author: Maria Sophia
Date: Sun, 08 Nov 2026 03:08
Date: Sun, 08 Nov 2026 03:08
79 lines
5069 bytes
5069 bytes
Maria Sophia wrote:
> I can write code to ask what web site I'm going to, and then insert
> a given USA exit node into the torrc file, but has anyone done that?
The goal:
1. We need an exit node that isn't on the shit list (e.g., Cloudflare)
2. In my experience, the USA nodes seem to be challenged fewer times
3. Yet, we don't want to associate Account A, B & C with each other
4. And certainly we don't want the website to know our real IP address
To add further value that will be useful to others, let's say we have
three web sites (or one web site with three profiles) and we want each
profile to be not only distinct in terms of IP address, but consistent
and, known to not be contentious in terms of being on the shit list.
Previously we employed two techniques which *manually* stabilized Tor.
A. gvim "C:\app\browser\tor\Tor Browser\Browser\TorBrowser\Data\Tor\torrc"
ExitNodes {us}
StrictNodes 1
B. <https://metrics.torproject.org/rs.html#search/country:us%20flag:exit>
gvim "C:\app\browser\tor\Tor Browser\Browser\TorBrowser\Data\Tor\torrc"
ExitNodes $6886...,$B8FA...,$BD61...,$9C7B...
The question becomes, always, how to improve the efficiency of that action.
There is no built-in mechanism that I know of, so I searched for code.
I found two potential tor-exit-node selection tools right off the bat.
Note both support Windows and Linux (I'm not sure about macOS per se).
1. Tor ExitNode Changer
<https://github.com/gmolop/Tor-ExitNode-changer>
It seems focused on selecting countries though, and not specific nodes.
a. It edits Tor's torrc
b. by changing the exit-node configuration
c. and then closes and relaunches Tor Browser
2. Tor Control Panel
<https://github.com/abysshint/tor-control-panel>
It seems to be a more sophisticated GUI for configuring tor sessions.
a. Choose relays located in a country (e.g., {us})
b. Choose relays based on the fingerprint (e.g., $A1B2C3...)
c. Choose relays by static IP address (e.g., 192.0.2.15)
d. Choose relays by dynamic CIDR mask (e.g., 192.0.2.0/24)
To obtain...
1. The Tor ExitNode Changer
Windows:
<https://github.com/gmolop/Tor-ExitNode-changer/blob/master/dist/tor_exitNode_changer.bat>
Linux:
<https://github.com/gmolop/Tor-ExitNode-changer/blob/master/dist/tor_exitNode_changer.sh>
2. The Tor Control Panel
Windows
<https://github.com/abysshint/tor-control-panel/releases/tag/v2.3.12.20>
<https://github.com/abysshint/tor-control-panel/releases/download/v2.3.12.20/tor-control-panel-2.3.12.20-win64.exe>
Name: tor-control-panel-2.3.12.20-win64.exe
Size: 12134773 bytes (11 MiB)
SHA256: D5A9A05318D6D99F85A6585A12FC324DB7ECBB8AACFC04E96CF56D481E7F076F
Analysis:
Suppose we have three accounts on the same website:
If we restrict each persona to a single tor exit node (or a CIDR set)
a. Account A always appears from IP 1.
b. Account B always appears from IP 2.
c. Account C always appears from IP 3.
This gives each account a consistent network identity.
Disadvantages?
a. The exit-node operator can potentially observe metadata such as
the destination IP address, connection timing, traffic volume, etc.
b. If an adversary can observe both ends of the connection, timing and
traffic-volume patterns can potentially be correlated.
c. Trust is concentrated in a single exit node per website persona
Have you ever used these tools to set the exit nodes on the fly?
Do you know of others that may work out well for most people?
--
Always seeking efficiency on computers, much like physics seeks entropy
Re: PSA: Setting the Windows Firefox Tor browser to use USA exit nodes
Author: Maria Sophia
Date: Sun, 08 Nov 2026 03:58
Date: Sun, 08 Nov 2026 03:58
121 lines
6888 bytes
6888 bytes
Maria Sophia wrote:
> 1. The Tor ExitNode Changer
> Windows:
> <https://github.com/gmolop/Tor-ExitNode-changer/blob/master/dist/tor_exitNode_changer.bat>
> Linux:
> <https://github.com/gmolop/Tor-ExitNode-changer/blob/master/dist/tor_exitNode_changer.sh>
I tested the Windows version of the Tor ExitNode changer, where I was
pleasantly surprised to see this useful "pro tip" in the batch file:
<https://github.com/gmolop/Tor-ExitNode-changer/>
:: Pro Tip to pin a "batch" file shortcut to the Windows taskbar
:: copy the .bat file to a temporary .exe file of the same name
:: drag the exe to the taskbar to pin a shortcut to it on the taskbar
:: rename the taskbar target back to .bat on the now-pinned shorcut
:: delete the temporary exe copy and keep the original bat file
To install, even though I use Linux-style file paths in Windows such as
C:\app\browser\tor\.
all I did was put the tor_exitNode_changer script in the same folder
that already contained the torrc (which the tor shortcut points to).
C:\app\browser\tor\Tor Browser\Browser\TorBrowser\Data\Tor\tor_exitNode_changer.bat
Note: Having learned computers on the UNIX/IBM/PDP/DEC/VAX/SunOS/Solaris/RedHat
side of the house, all my Windows paths are "linux like" in that they're all
lower case, 8 characters or fewer, never do I use plurals unless I must, etc.
Then I tapped the taskbar icon that I created using the "pro tip".
_____________________________________
Starting TOR with ExitNode Changer...
Setting up environment variables.....
done/
Creating a new instance of TOR.......
1 file(s) copied.
New instance of TOR created..........
done/
Searching current ExitNode value.....
done/
Creating support files...............
done/
Requesting new ExitNode value........
Then, an "ExitNodes" popup asked:
Enter ISO3166 country code:
https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
Default: us
[OK][Cancel]
When the Tor browser popped up, it had a USA exit node.
It was that easy to set the country code. I'm surprised.
I'm sure it works similarly on Linux using the shell script.
I looked for a Linux version of the more sophisticated GUI but
I didn't see one, but I did just now test the Windows GUI.
Windows
<https://github.com/abysshint/tor-control-panel/releases/tag/v2.3.12.20>
<https://github.com/abysshint/tor-control-panel/releases/download/v2.3.12.20/tor-control-panel-2.3.12.20-win64.exe>
Name: tor-control-panel-2.3.12.20-win64.exe
Size: 12134773 bytes (11 MiB)
SHA256: D5A9A05318D6D99F85A6585A12FC324DB7ECBB8AACFC04E96CF56D481E7F076F
After extracting to C:\tmp\TorControlPanel, I belatedly realized it's
just a simple self-extracting archive (so I didn't need c:\tmp).
12/20/2023 01:32 AM 40,007 Changelog.txt
11/07/2026 11:34 PM <DIR> Data
12/20/2023 02:10 AM 7,132 Defaults.ini
11/07/2026 11:34 PM <DIR> Licenses
11/07/2026 11:34 PM <DIR> Skins
11/07/2026 11:34 PM <DIR> Tor
12/20/2023 04:03 AM 6,081,536 TorControlPanel.exe
12/09/2023 09:06 AM 45,636 Translations.ini
Realizing that's what it was, I moved it into my linux-like program files
C:\app\browser\tor\
Tor Browser\
Browser\
TorBrowser\
Data\
Tor\
torrc
tor_exitNode_changer.bat
TorControlPanel\
TorControlPanel.exe
Defaults.ini
Changelog.txt
Data\
Licenses\
Skins\
Tor\
Translations.ini
Note that the crazy naming (case-specific & long with spaces) is not in
my control as all the files/folders I create are linux-like in simplicity.
And I put a shortcut to it in my C:\menu\browser\tor accordion menu.
C:\app\browser\tor\Tor Browser\Browser\TorBrowser\Data\Tor\TorControlPanel\TorControlPanel.exe
And, of course, I pinned a shortcut to the exe on my taskbar
(where I add a custom comment in that pinned shortcut for the future me).
Tapping that black-shield icon, up popped "Tor Control Panel".
It comes up with a "Change Circuit" button and a "Start" button.
And a few others {Settings,Log,Status,Circuits,Relays,etc.}
The Settings are extensive, so this may take a while to configure.
General,Network,Filter,Server,Hidden Service,Lists,Other
Each of which is an entire page onto itself of various settings.
I clicked Start, since it was overwhelming the setup options.
It found an exit node, in Germany, which wasn't my intent.
So my assessment is this will likely work for the job, but it will
take some getting used to as the goal is the following from the start:
1. Have 3 accounts (either on one social media site, or multiple)
2. Find a reliable Tor exit node that isn't on the shit list
3. Since that's usually in the USA (IMHO), restrict to USA nodes
4. But, since we need to prevent overlap, let's pick specific USA nodes
Best is a set of nodes for profile1, another set for profile 2, etc.
That way, it looks "normal" to the social (or throwaway email) web site.
--
Every working example is someone paying forward a hard-learned lesson.
Re: PSA: Setting the Windows Firefox Tor browser to use USA exit nodes
Author: Simon
Date: Sun, 08 Nov 2026 04:00
Date: Sun, 08 Nov 2026 04:00
24 lines
1698 bytes
1698 bytes
On 08/11/2026 03:08, Maria Sophia wrote: > 1. We need an exit node that isn't on the shit list (e.g., Cloudflare) CloudFlare user here so not on my shit list. What do you think of this guy called Donald 'Duck' Trump? Do you like oven baked crisps? I eat them a lot with a 1/2 litre of coke per day and I never put on any weight either. How's life treating you Maria? What flavour of crisps do you eat when fucking around with Android phone? You spend all of your time on phone so how's Windows or Linux helping you? Are you still flashing your boobs in public with your Android phone in one hand? Your mate Russel Brand rapist is going for a very long prison sentence.
Re: PSA: Setting the Windows Firefox Tor browser to use USA exit nodes
Author: Maria Sophia
Date: Sun, 08 Nov 2026 06:13
Date: Sun, 08 Nov 2026 06:13
188 lines
9866 bytes
9866 bytes
Maria Sophia wrote:
> So my assessment is this will likely work for the job, but it will
> take some getting used to as the goal is the following from the start:
UPDATE
My initial assessment is that those prior utilities, basically, suck.
1. "TOR with ExitNode Changer" is too simple (it only sets the country)
2. But the "TCP GUI" is far too complex (it has hundreds of settings!)
All I want is what I would think almost everyone would want, right?
a. When I log into Profile 1, use USA Tor exit node 192.0.2.10
b. When I log into Profile 1, use USA Tor exit node 192.0.2.20
c. When I log into Profile 1, use USA Tor exit node 192.0.2.30
As long as that exit node isn't on the cloudflare shit list,
it will seem normal to the web site (although they know exit nodes).
All we really need to do is change the fingerprint from A to B to C.
SETCONF ExitNodes=$FINGERPRINT_{A,B,C}
StrictExitNodes=1
SIGNAL NEWNYM
Looking to see if Tor Browser already exposes its ControlPort
A. I started the Tor browser
B. powershell Test-NetConnection 127.0.0.1 -Port 9151
C. That concluded Tor Browser was listening on TCP port 9151.
Then I checked for "control_auth_cookie", which was found in:
C:\app\browser\tor\Tor Browser\Browser\TorBrowser\Data\Tor\.
Let's check that the OS can successfully read the cookie file
and that the OS can successfully calculate its SHA256 hash.
certutil -hashfile "control_auth_cookie" SHA256
=> SHA256 hash of control_auth_cookie:
=> 643REDACTEDe0a218f0
=> CertUtil: -hashfile command completed successfully.
Let's test ControlPort authentication using torset.bat
(See below for the torset.bat which can be converted to sh.)
torset.bat
=> Authentication: 250 OK
=> Exit configuration: 250 ExitNodes={US}
=> Bootstrap status: 250-status/bootstrap-phase=NOTICE BOOTSTRAP PROGRESS=100 TAG=done SUMMARY="Done"
=> Press any key to continue . . .
This means we can control & query Tor from the command line to find
a. v1p0 Authentication: 250 OK (authenticated successfully)
b. v1p1 Exit configuration: {US} (the existing US exit restriction is active)
c. v1p2 Bootstrap: PROGRESS=100 (Tor is fully connected to the network)
We can now check whether Tor is connected before choosing exit nodes.
Let's re-use {us} fingerprints that we already found in this thread:
<https://metrics.torproject.org/>
<https://metrics.torproject.org/rs.html#search>
<https://metrics.torproject.org/rs.html#search/country:us%20flag:exit>
Profile1 $688604204AF0C0473DFFA8CD2E186D1EEAEE6916
Profile1 $B8FA90A8B7DA9B90A09AA04CD2E81E263AA8DA4C
Profile2 $BD610AAEAE179EC259B022A178A75C70042407FB
Profile3 $9C7B1DB2C5520B21E181EB945A01E9ABA42654A2
OK. Long story short, after an hour or two, this is a working script.
Note it can be ported to Linux using Python so the concept works for all.
:: ---------------------------------------------------------------------
:: torset.bat
:: Manually set known-good Tor exit nodes for specific web-login profiles
:: ---------------------------------------------------------------------
:: Usage notes:
:: 1. Manually obtain a set of desired known-good US Tor exit relays:
:: https://metrics.torproject.org/rs.html#search/country:us%20flag:exit
:: 2. Enter the desired fingerprints in the profile definitions below
:: 3. Start Tor Browser, and click the [Connect] button if necessary
:: 4. Run this script and select the desired profile
:: 5. Wait for Tor to establish new circuits before browsing
:: 6. Verify the actual exit relay and exit IP before logging in
:: Later I will remove the need to start the Tor browser first
:: ---------------------------------------------------------------------
:: v1p6 20261108 Display multi-line Tor circuit status via GETINFO
:: v1p5 20261108 Request new Tor circuits after profile selection
:: v1p4 20261108 Added multi-profile exit-node selection menu
:: v1p3 20261108 Set Profile 1 ExitNodes (two fingerprints) via SETCONF
:: v1p2 20261108 Added GETINFO status/bootstrap-phase
:: v1p1 20261108 Retrieve current ExitNodes configuration via GETCONF
:: v1p0 20261108 Tested Tor ControlPort via TCP cookie authentication
:: ---------------------------------------------------------------------
:: Summary of what this script does
:: 1. CONNECT
:: Open a TCP connection to Tor's local ControlPort (9151).
:: 2. AUTHENTICATE
:: Read Tor's control_auth_cookie and authenticate with Tor.
:: 3. INSPECT CONFIGURATION
:: Retrieve the currently configured ExitNodes fingerprints.
:: 4. APPLY PROFILE
:: Set ExitNodes to the fingerprints assigned to the selected
:: web-login profile.
:: 5. REQUEST NEW CIRCUITS
:: Send SIGNAL NEWNYM to request fresh Tor circuits.
:: 6. VERIFY CONFIGURATION
:: Read ExitNodes again to confirm the selected configuration.
:: 7. CHECK BOOTSTRAP
:: Retrieve Tor's bootstrap status.
:: 8. INSPECT CIRCUITS
:: Retrieve Tor's circuit-status information.
:: 9. IDENTIFY GENERAL-PURPOSE EXITS
:: Examine BUILT GENERAL circuits and identify their final relay.
:: 10. REPORT RESULTS
:: Compare the reported exit fingerprints with the selected
:: profile's permitted exit fingerprints.
::
:: ExitNodes configuration does not prove that a particular website
:: connection is using a particular exit relay. That will be added.
:: ---------------------------------------------------------------------
@echo off
:: Begin selection menu
echo ----------------------------------------
echo TOR EXIT NODE SELECTOR
echo ----------------------------------------
echo.
echo 1 for Profile 1 (two possible exit nodes)
echo 2 for Profile 2 (one exit node)
echo 3 for Profile 3 (one exit node)
echo.
choice /c 123Q /n /m "Select profile [1,2,3] or Q to quit: "
if errorlevel 4 exit /b
if errorlevel 3 goto profile3
if errorlevel 2 goto profile2
goto profile1
:profile1
set "PROFILE=Profile 1"
set "EXITNODES=$688604204AF0C0473DFFA8CD2E186D1EEAEE6916,$B8FA90A8B7DA9B90A09AA04CD2E81E263AA8DA4C"
goto run
:profile2
set "PROFILE=Profile 2"
set "EXITNODES=$BD610AAEAE179EC259B022A178A75C70042407FB"
goto run
:profile3
set "PROFILE=Profile 3"
set "EXITNODES=$9C7B1DB2C5520B21E181EB945A01E9ABA42654A2"
goto run
:run
echo.
echo Setting %PROFILE%...
:: End selection menu
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"$path = 'C:\app\browser\tbb\Tor Browser\Browser\TorBrowser\Data\Tor\control_auth_cookie'; ^
$cookie = [BitConverter]::ToString([IO.File]::ReadAllBytes($path)).Replace('-', ''); ^
$tcp = New-Object System.Net.Sockets.TcpClient; ^
$tcp.Connect('127.0.0.1', 9151); ^
$stream = $tcp.GetStream(); ^
$writer = New-Object System.IO.StreamWriter($stream); ^
$reader = New-Object System.IO.StreamReader($stream); ^
$writer.NewLine = [char]13 + [char]10; ^
$writer.AutoFlush = $true; ^
$writer.WriteLine('AUTHENTICATE ' + $cookie); ^
$auth = $reader.ReadLine(); ^
Write-Host ('Authentication: ' + $auth); ^
$writer.WriteLine('GETCONF ExitNodes'); ^
$config = $reader.ReadLine(); ^
Write-Host ('Exit configuration: ' + $config); ^
$writer.WriteLine('SETCONF ExitNodes=' + $env:EXITNODES); ^
$setconf = $reader.ReadLine(); ^
Write-Host ('SETCONF response: ' + $setconf); ^
$writer.WriteLine('SIGNAL NEWNYM'); ^
$newnym = $reader.ReadLine(); ^
Write-Host ('NEWNYM response: ' + $newnym); ^
$writer.WriteLine('GETCONF ExitNodes'); ^
$config = $reader.ReadLine(); ^
Write-Host ('New exit configuration: ' + $config); ^
$writer.WriteLine('GETINFO status/bootstrap-phase'); ^
do { $bootstrap = $reader.ReadLine(); ^
if ($bootstrap -ne '250 OK') { Write-Host ('Bootstrap status: ' + $bootstrap) } ^
} while ($bootstrap -ne '250 OK'); ^
$writer.WriteLine('GETINFO circuit-status'); ^
do { $circuit = $reader.ReadLine(); ^
if ($circuit -ne '250 OK') { Write-Host ('Circuit: ' + $circuit) } ^
} while ($circuit -ne '250 OK'); ^
$tcp.Close()"
pause
:: ---------------------------------------------------------------------
:: end of torset.bat
:: ---------------------------------------------------------------------
--
Posted out of the goodness of my heart to kindly help others do what I can.
Re: PSA: Setting the Windows Firefox Tor browser to use USA exit nodes
Author: Maria Sophia
Date: Sun, 08 Nov 2026 07:45
Date: Sun, 08 Nov 2026 07:45
338 lines
15652 bytes
15652 bytes
Maria Sophia wrote:
> Best is a set of nodes for profile1, another set for profile 2, etc.
> That way, it looks "normal" to the social (or throwaway email) web site.
I'm getting tired after investing a few hours fixing the problems with the
Firefox Tor browser when it comes to choosing exit nodes on the fly.
The code I hacked out below works on my Windows system, but if we want to
port it to Linux, we likely will have to port it to Python first.
The only reason it was written first in Powershell was that the initial
tests (version 1.0) used Powershell, and then it just grew from there.
Anyway, if the Firefox Tor browser is running, this will kill it and then
pop up a query for us to choose which exit nodes we want and then the
script will run the Firefox Tor browser using the selected exit nodes.
As far as I'm aware, this functionality doesn't exist on the net anywhere
but in this post as I didn't want to write it but I couldn't find it.
=== cut here for typical output ===
torset.bat
----------------------------------------
Tor exit node selector
----------------------------------------
1 for Profile 1 (two possible exit nodes)
2 for Profile 2 (one exit node)
3 for Profile 3 (one exit node)
Select profile [1,2,3] or Q to quit: 1
Setting Profile 1...
Ensuring clean state by stopping any existing Tor instances...
Tor Browser is not running. Starting Tor Browser automatically...
Waiting for Tor Browser to initialize and open ControlPort (9151)...
Tor Browser port is open.
Authentication: 250 OK
Waiting for Tor bootstrap to complete...
Tor bootstrap complete (100).
Exit configuration: 250 ExitNodes={US}
SETCONF response: 250 OK
NEWNYM response: 250 OK
New exit configuration: 250 ExitNodes=$688604204AF0C0473DFFA8CD2E186D1EEAEE6916,$B8FA90A8B7DA9B90A09AA04CD2E81E263AA8DA4C
ExitNodes verification: Match
General-purpose circuits
-------------------------
Circuit: 8
Exit fingerprint: 634B891DAF74FB17C94C4AA73CB394CE6B2531F1
Profile comparison: Not in profile
Circuit: 18
Exit fingerprint: 688604204AF0C0473DFFA8CD2E186D1EEAEE6916
Profile comparison: Match
Circuit inspection complete.
Tor control session completed successfully.
torset completed successfully.
Press any key to continue . . .
=== cut here for typical output ===
:: ---------------------------------------------------------------------
:: torset.bat
:: Manually set known-good Tor exit nodes for specific web-login profiles
:: Should be ported to python so that it can be ported to Linux as needed
:: ---------------------------------------------------------------------
:: Usage notes:
:: 1. Obtain desired US Tor exit relays:
:: https://metrics.torproject.org/rs.html#search/country:us%20flag:exit
:: 2. Enter their fingerprints in the profile definitions below.
:: 3. Run this script. It cleans up stale sessions, starts Tor, and sets nodes.
:: 4. Allow Tor a bit of time to establish new circuits.
:: 5. Verify the exit relay and exit IP before logging in.
:: ---------------------------------------------------------------------
:: v2p4 20261108 Handled stale process cleanup cleanly in native batch
:: v2p3 20261108 Added automated cleanup of stale Tor/Firefox instances
:: v2p2 20261108 Added full bootstrap completion polling on cold start
:: v2p1 20261108 Fixed $tcp variable scope in try/finally block
:: v2p0 20261108 Added automated Tor Browser startup and port polling
:: v1p9 20261108 Added ControlPort error handling and response validation
:: v1p8 20261108 Cleaned up comments and clarified explanations
:: v1p7 20261108 Identify general-purpose ckts and compare exit fingerprints
:: v1p6 20261108 Display multi-line Tor circuit status via GETINFO
:: v1p5 20261108 Request new Tor circuits after profile selection
:: v1p4 20261108 Added multi-profile exit-node selection menu
:: v1p3 20261108 Set Profile 1 ExitNodes (two fingerprints) via SETCONF
:: v1p2 20261108 Added GETINFO status/bootstrap-phase
:: v1p1 20261108 Retrieve current ExitNodes configuration via GETCONF
:: v1p0 20261108 Tested Tor ControlPort via TCP cookie authentication
:: ---------------------------------------------------------------------
:: Summary:
:: 1. Stop any stale Tor Browser/Firefox instances for a clean start.
:: 2. Launch Tor Browser automatically if not running.
:: 3. Wait for Tor's ControlPort (9151) and 100% bootstrap completion.
:: 4. Connect to Tor's local ControlPort (9151).
:: 5. Authenticate using Tor's control_auth_cookie.
:: 6. Read the current ExitNodes configuration.
:: 7. Apply the selected profile's permitted exit fingerprints.
:: 8. Request new circuits using SIGNAL NEWNYM.
:: 9. Confirm the selected ExitNodes configuration.
:: 10. Check Tor's bootstrap status and inspect circuits.
::
:: Stop and report an error if a required operation fails.
:: This does not prove which circuit a particular website uses.
:: ---------------------------------------------------------------------
@echo off
:: Profile selection
echo ----------------------------------------
echo Tor exit node selector
echo ----------------------------------------
echo.
echo 1 for Profile 1 (two possible exit nodes)
echo 2 for Profile 2 (one exit node)
echo 3 for Profile 3 (one exit node)
echo.
choice /c 123Q /n /m "Select profile [1,2,3] or Q to quit: "
if errorlevel 4 exit /b
if errorlevel 3 goto profile3
if errorlevel 2 goto profile2
goto profile1
:profile1
set "PROFILE=Profile 1"
set "EXITNODES=$688604204AF0C0473DFFA8CD2E186D1EEAEE6916,$B8FA90A8B7DA9B90A09AA04CD2E81E263AA8DA4C"
goto run
:profile2
set "PROFILE=Profile 2"
set "EXITNODES=$BD610AAEAE179EC259B022A178A75C70042407FB"
goto run
:profile3
set "PROFILE=Profile 3"
set "EXITNODES=$9C7B1DB2C5520B21E181EB945A01E9ABA42654A2"
goto run
:run
echo.
echo Setting %PROFILE%...
:: Clean up any existing stale Tor/Firefox instances first
echo Ensuring clean state by stopping any existing Tor instances...
taskkill /f /im firefox.exe >nul 2>&1
timeout /t 2 /nobreak >nul
:: begin powershell block, later to be converted to python
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"$ErrorActionPreference = 'Stop'; ^
$tcp = $null; ^
try { ^
$path = 'C:\app\browser\tbb\Tor Browser\Browser\TorBrowser\Data\Tor\control_auth_cookie'; ^
$torExe = 'C:\app\browser\tbb\Tor Browser\Browser\firefox.exe'; ^
^
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { ^
Write-Host 'Tor Browser is not running. Starting Tor Browser automatically...'; ^
if (-not (Test-Path -LiteralPath $torExe)) { throw 'Tor Browser executable not found at: ' + $torExe }; ^
Start-Process -FilePath $torExe; ^
Write-Host 'Waiting for Tor Browser to initialize and open ControlPort (9151)...'; ^
$sw = [Diagnostics.Stopwatch]::StartNew(); ^
$ready = $false; ^
while ($sw.ElapsedMilliseconds -lt 45000) { ^
if (Test-Path -LiteralPath $path) { ^
try { ^
$testTcp = New-Object System.Net.Sockets.TcpClient; ^
$testTcp.Connect('127.0.0.1', 9151); ^
$testTcp.Close(); ^
$ready = $true; ^
break; ^
} catch { } ^
}; ^
Start-Sleep -Seconds 2; ^
}; ^
$sw.Stop(); ^
if (-not $ready) { throw 'Timed out waiting for Tor Browser to start and open ControlPort 9151.' }; ^
Write-Host 'Tor Browser port is open.'; ^
}; ^
^
if ([string]::IsNullOrWhiteSpace($env:EXITNODES)) { throw 'No exit nodes defined for this profile.' }; ^
$cookie = [BitConverter]::ToString([IO.File]::ReadAllBytes($path)).Replace('-', ''); ^
$tcp = New-Object System.Net.Sockets.TcpClient; ^
$tcp.ReceiveTimeout = 15000; ^
$tcp.SendTimeout = 15000; ^
$tcp.Connect('127.0.0.1', 9151); ^
$stream = $tcp.GetStream(); ^
$stream.ReadTimeout = 15000; ^
$writer = New-Object System.IO.StreamWriter($stream); ^
$reader = New-Object System.IO.StreamReader($stream); ^
$writer.NewLine = [char]13 + [char]10; ^
$writer.AutoFlush = $true; ^
^
function Read-TorReply { ^
$lines = New-Object 'System.Collections.Generic.List[string]'; ^
while ($true) { ^
$line = $reader.ReadLine(); ^
if ($null -eq $line) { throw 'Tor closed the ControlPort connection unexpectedly.' }; ^
[void]$lines.Add($line); ^
if ($line -match '^250\+') { ^
do { ^
$dataLine = $reader.ReadLine(); ^
if ($null -eq $dataLine) { throw 'Tor closed the connection during a data response.' }; ^
[void]$lines.Add($dataLine); ^
} while ($dataLine -ne '.'); ^
continue ^
}; ^
if ($line -match '^\d{3}-') { continue }; ^
break ^
}; ^
return $lines.ToArray() ^
}; ^
^
function Send-TorCommand($command) { ^
$writer.WriteLine($command); ^
$reply = @(Read-TorReply); ^
if ($reply.Count -eq 0 -or $reply[0] -notmatch '^250[ +\-]') { ^
throw ('Tor rejected command: ' + $command + ' -- ' + ($reply -join ' ')) ^
}; ^
return ,$reply ^
}; ^
^
$auth = Send-TorCommand ('AUTHENTICATE ' + $cookie); ^
Write-Host ('Authentication: ' + $auth[0]); ^
^
Write-Host 'Waiting for Tor bootstrap to complete...'; ^
$bootstrapComplete = $false; ^
$bSw = [Diagnostics.Stopwatch]::StartNew(); ^
while ($bSw.ElapsedMilliseconds -lt 60000) { ^
try { ^
$bootstrap = Send-TorCommand 'GETINFO status/bootstrap-phase'; ^
foreach ($line in $bootstrap) { ^
if ($line -match 'PROGRESS=100') { ^
$bootstrapComplete = $true; ^
break; ^
} ^
}; ^
if ($bootstrapComplete) { break }; ^
} catch { } ^
Start-Sleep -Seconds 2; ^
}; ^
$bSw.Stop(); ^
if (-not $bootstrapComplete) { throw 'Timed out waiting for Tor to finish bootstrapping.' }; ^
Write-Host 'Tor bootstrap complete (100%).'; ^
^
$config = Send-TorCommand 'GETCONF ExitNodes'; ^
Write-Host ('Exit configuration: ' + ($config -join ' ')); ^
$setconf = Send-TorCommand ('SETCONF ExitNodes=' + $env:EXITNODES); ^
Write-Host ('SETCONF response: ' + $setconf[-1]); ^
$newnym = Send-TorCommand 'SIGNAL NEWNYM'; ^
Write-Host ('NEWNYM response: ' + $newnym[-1]); ^
Start-Sleep -Seconds 3; ^
^
$config = Send-TorCommand 'GETCONF ExitNodes'; ^
Write-Host ('New exit configuration: ' + ($config -join ' ')); ^
$actualLine = $null; ^
foreach ($item in $config) { ^
if ($item -match '^250 ExitNodes=') { $actualLine = $item; break } ^
}; ^
if (-not $actualLine) { throw 'Could not verify the new ExitNodes configuration.' }; ^
^
$actualNodes = @(); ^
$actualText = $actualLine -replace '^250 ExitNodes=', ''; ^
foreach ($fp in ($actualText -split ',')) { ^
$actualNodes += $fp.Trim().TrimStart('$').ToUpperInvariant() ^
}; ^
^
$expectedNodes = @(); ^
foreach ($fp in ($env:EXITNODES -split ',')) { ^
$expectedNodes += $fp.Trim().TrimStart('$').ToUpperInvariant() ^
}; ^
if ($actualNodes.Count -ne $expectedNodes.Count) { throw 'ExitNodes verification failed: fingerprint count differs.' }; ^
foreach ($fp in $expectedNodes) { ^
if (-not ($actualNodes -contains $fp)) { throw ('ExitNodes verification failed: missing fingerprint ' + $fp) } ^
}; ^
Write-Host 'ExitNodes verification: Match'; ^
^
$allowed = @{}; ^
foreach ($fp in $expectedNodes) { ^
$allowed[$fp] = $true ^
}; ^
^
$circuitReply = Send-TorCommand 'GETINFO circuit-status'; ^
Write-Host ''; ^
Write-Host 'General-purpose circuits'; ^
Write-Host '-------------------------'; ^
$found = $false; ^
foreach ($line in $circuitReply) { ^
if ($line -notmatch '^\d+\s+BUILT\s+') { continue }; ^
if ($line -notmatch 'PURPOSE=GENERAL') { continue }; ^
$fields = $line -split '\s+'; ^
if ($fields.Count -lt 3) { continue }; ^
$hops = $fields[2] -split ','; ^
$last = ($hops[-1] -split '~')[0].TrimStart('$').ToUpperInvariant(); ^
$found = $true; ^
Write-Host ''; ^
Write-Host ('Circuit: ' + $fields[0]); ^
Write-Host ('Exit fingerprint: ' + $last); ^
if ($allowed.ContainsKey($last)) { ^
Write-Host 'Profile comparison: Match' ^
} else { ^
Write-Host 'Profile comparison: Not in profile' ^
}; ^
}; ^
if (-not $found) { ^
Write-Host 'No built general-purpose circuits found.' ^
}; ^
Write-Host ''; ^
Write-Host 'Circuit inspection complete.'; ^
Write-Host 'Tor control session completed successfully.'; ^
} catch { ^
Write-Host ''; ^
Write-Host ('Error: ' + $_.Exception.Message) -ForegroundColor Red; ^
exit 1 ^
} finally { ^
if ($tcp) { $tcp.Close() } ^
}"
:: end of powershell block
if errorlevel 1 (
echo.
echo torset did not complete successfully.
) else (
echo.
echo torset completed successfully.
)
pause
:: ---------------------------------------------------------------------
:: end of torset.bat
:: ---------------------------------------------------------------------
--
Usenet should be a discussion where everyone adds value to the topic.
Re: PSA: Setting the Windows Firefox Tor browser to use USA exit nodes
Author: Paul
Date: Sun, 08 Nov 2026 09:22
Date: Sun, 08 Nov 2026 09:22
37 lines
2905 bytes
2905 bytes
On Sat, 11/7/2026 11:00 PM, Simon wrote:
> On 08/11/2026 03:08, Maria Sophia wrote:
>> 1. We need an exit node that isn't on the shit list (e.g., Cloudflare)
>
> Do you like oven baked crisps? I eat them a lot with a 1/2 litre of coke
> per day and I never put on any weight either.
I have a Python script that will optimize those crisps
so they are golden brown. Do you apply the catsup to
the crisps ? Or is this an occasion for some gravy ?
We have the gravy when it is poutine. If you want to
put some weight on, try poutine. It's addictive stuff.
You'll have to find someone who knows how to make
it properly, as an amateur job renders it as mush,
and it doesn't have to be like that. The person promoting
this at work, liked unpasturized cheese curds with his.
You can see in this picture, it's well defined, the
elements are separate. If you get it at a place
that doesn't care, it arrives as so much mush. If you
use a national fast food shop version of it, it's mush.
https://en.wikipedia.org/wiki/Poutine
"Others that followed used inferior cheese and the dish's reputation declined.
Poutine was largely perceived as an unsophisticated backwoods creation or
unhealthy junk food[16][10] to be consumed after a night of drinking."
On the contrary, we was sober.
I'm sure the saturated and trans fat in that, is off the charts :-)
When you put on weight, the blame is squarely on the coke.
It couldn't be the gravy.
Paul
Re: PSA: Setting the Windows Firefox Tor browser to use USA exit nodes
Author: Carlos E.R.
Date: Sun, 08 Nov 2026 14:14
Date: Sun, 08 Nov 2026 14:14
18 lines
1934 bytes
1934 bytes
On 2026-11-08 07:13, Maria Sophia wrote: > Maria Sophia wrote: >> So my assessment is this will likely work for the job, but it will >> take some getting used to as the goal is the following from the start: > > UPDATE > > My initial assessment is that those prior utilities, basically, suck. > 1. "TOR with ExitNode Changer" is too simple (it only sets the country) > 2. But the "TCP GUI" is far too complex (it has hundreds of settings!) Arlen, please don't post a serious reply to what is a trolling or humorous post by somebody else. Reason be, that it is possible that we have killed the subthread and will not see your post. -- Cheers, Carlos. ESπͺπΈ, EUπͺπΊ;
Re: PSA: Setting the Windows Firefox Tor browser to use USA exit nodes
Author: Carlos E.R.
Date: Sun, 08 Nov 2026 14:19
Date: Sun, 08 Nov 2026 14:19
28 lines
2156 bytes
2156 bytes
On 2026-11-08 04:08, Maria Sophia wrote: > Maria Sophia wrote: >> I can write code to ask what web site I'm going to, and then insert >> a given USA exit node into the torrc file, but has anyone done that? > > The goal: > 1. We need an exit node that isn't on the shit list (e.g., Cloudflare) > 2. In my experience, the USA nodes seem to be challenged fewer times > 3. Yet, we don't want to associate Account A, B & C with each other > 4. And certainly we don't want the website to know our real IP address I have, manually, set the exit country to one of my liking (or a list of countries). I have not used any script. Reason? I am visiting a site that will only reply properly if they see me coming from their own country or their own language zone. I could just as well use a VPN, I have no reason to hide my tracks. It works. I have no desire to choose a certain exit node. -- Cheers, Carlos. ESπͺπΈ, EUπͺπΊ;
Re: PSA: Setting the Windows Firefox Tor browser to use USA exit nodes
Author: Maria Sophia
Date: Sun, 08 Nov 2026 17:06
Date: Sun, 08 Nov 2026 17:06
81 lines
5047 bytes
5047 bytes
Carlos E.R. wrote: >> The goal: >> 1. We need an exit node that isn't on the shit list (e.g., Cloudflare) >> 2. In my experience, the USA nodes seem to be challenged fewer times >> 3. Yet, we don't want to associate Account A, B & C with each other >> 4. And certainly we don't want the website to know our real IP address > > I have, manually, set the exit country to one of my liking (or a list of > countries). I have not used any script. > > Reason? > > I am visiting a site that will only reply properly if they see me coming > from their own country or their own language zone. I could just as well > use a VPN, I have no reason to hide my tracks. > > It works. > > I have no desire to choose a certain exit node. Hi Carlos, Thank you for adding useful value & perspicuity to this FF Tor thread. Like you, until now, I also had no desire to set even a country, let alone an exit node, but when the web site doesn't like it, we have to fix that. We're all adding value to the newsgroup, which, in this thread is we're adding value to the tribal knowledge on setting Tor Browser exit nodes. a. by country b. by fingerprint In my almost two decades of using the Tor browser (e.g., to log into Protonmail accounts), I let the browser pick and choose exit nodes. Only recently have I run into the kind of exit-node-specific challenges that you seem to be also running into where the country code solved it. In my case, the country code *also* solved the problem, so we're both claiming the same solution seems to work for us in our use models. I started off, in a sophomoric attempt, of setting the country code in th Firefox Tor browser torrc file, but, unfortunately, manual setup sucks. If people don't know why it sucks, fundamentally the torrc file is overwritten every time, so it can't keep any comments that you make. And I add comments since I was trained as a programmer in the 1960s. As you know, in this thread, I sought out software that will *more easily* set the country code (and exit nodes) than editing the torrc file does. I found it for the team! For country codes anyway. Works on Linux/Windows. Windows: <https://github.com/gmolop/Tor-ExitNode-changer/blob/master/dist/tor_exitNode_changer.bat> Linux: <https://github.com/gmolop/Tor-ExitNode-changer/blob/master/dist/tor_exitNode_changer.sh> Since you're on Linux, it would be great if you can test that for the team. As for me, it worked fine in my test, but I wanted even more functionality. I wanted to be able to choose a set of static exit nodes, and use only that static set of exit nodes, and I couldn't find software to do that. You'd think it would be easy to find software that does that, but I gave up after only a few searches so that functionality may already exist. I think the best way to port it to Linux would be to first port it to Python, and then to port that to Linux, but I can't test it out. PS: The classic Snowden response to someone claiming "I have no reason to hide my tracks" so why should anyone else, probably might be simply to ask you to publish your email password, which will lend veracity to your claim. If you truly have no reason to "hide your tracks", then certainly you will tell us, without apprehension, your daily drive email address & password. However, if you do not immediately publish your email address and password, we will accept that as tacit admission some things should stay private. -- We all strive to add privacy that marketing doesn't want us to have.
Re: PSA: Setting the Windows Firefox Tor browser to use USA exit nodes
Author: Maria Sophia
Date: Sun, 08 Nov 2026 17:14
Date: Sun, 08 Nov 2026 17:14
37 lines
3262 bytes
3262 bytes
Paul wrote: > On the contrary, we was sober. Hi Paul, You recently mentioned one reason I have so many files on my circa 2009 desktop was because of all the python files, but I think it's because of the versions more so than the actual final files, since I save them all. Directory of C:\data\sys\bat\ff\tor 11/08/2026 03:45 AM 11,236 torset.bat 11/08/2026 12:39 AM 1,302 torset.bat_v1p0.txt 11/08/2026 12:47 AM 1,497 torset.bat_v1p1.txt 11/08/2026 12:58 AM 1,695 torset.bat_v1p2.txt 11/08/2026 01:09 AM 2,120 torset.bat_v1p3.txt 11/08/2026 01:19 AM 2,952 torset.bat_v1p4.txt 11/08/2026 01:23 AM 3,138 torset.bat_v1p5.txt 11/08/2026 02:23 AM 5,480 torset.bat_v1p6.txt 11/08/2026 02:47 AM 5,958 torset.bat_v1p7.txt 11/08/2026 02:52 AM 6,002 torset.bat_v1p8.txt 11/08/2026 03:12 AM 8,339 torset.bat_v1p9.txt 11/08/2026 03:18 AM 9,109 torset.bat_v2p0.txt 11/08/2026 03:25 AM 9,200 torset.bat_v2p1.txt 11/08/2026 03:30 AM 9,170 torset.bat_v2p2.txt 11/08/2026 03:32 AM 11,452 torset.bat_v2p3.txt 11/08/2026 03:44 AM 11,372 torset.bat_v2p4.txt 11/08/2026 04:21 AM 12,216 torset.bat_v2p5.txt Looking at the time stamps, it seems I invested about 4 hours fixing the Firefox Tor browser inability to easily set exits. I always wonder if it would have been more fruitful to have invested the same 4 hours in finding software that works. But one advantage of DIY is I learned too much that I didn't even want to know, about how complicated the FF Tor browser is. -- On Usenet, we improve our knowledge by sharing & discussing solutions.
Re: PSA: Setting the Windows Firefox Tor browser to use USA exit nodes
Author: Maria Sophia
Date: Sun, 08 Nov 2026 17:42
Date: Sun, 08 Nov 2026 17:42
107 lines
6199 bytes
6199 bytes
Carlos E.R. wrote:
> please don't post a serious reply to what is a trolling or
> humorous post by somebody else. Reason be, that it is possible that we
> have killed the subthread and will not see your post.
Hi Carlos,
That's an interesting point where my home-baked newsreader (which we
started on the linux newsgroups with Marek Novotny, decades ago) doesn't
have the capability of "killing a subthread", so that's good to know.
I started with Larry Wall's rn and Kim Storm's nn and Wayne Davison's trn
before I decided to write my own newsreader, which is currently mojibake.
As for a "serious reply" to the trolls, I invest many hours in my posts,
e.g., it took about four hours of concentrated work to solve this issue.
When the uneducated trolls infest a serious thread, it bothers me, perhaps
more than it bothers most people who invest only a few seconds per article.
Anyway, your point is well taken, where I will seriously note that what we
solved in this thread is we fixed a few huge gaping holes in the Firefox
Tor setup ease of use, which, AFAIK, doesn't exist anywhere else but here.
What I did was take Firefox Tor flaws into my own hands, resulting in
a tested "torset.bat" script, which does the following that is useful:
:: ---------------------------------------------------------------------
:: Summary:
:: 1. Present a multi-profile selection menu allowing the user to choose
:: between predefined exit-node configurations (or quit with Q).
:: 2. Terminate any stale or running instances of Firefox Tor Browser
:: to ensure a clean starting environment.
:: 3. Launch the Firefox Tor Browser executable automatically if it is
:: not currently running on the system.
:: 4. Poll local TCP port 9151 and monitor for the existence of Tor's
:: control authentication cookie file.
:: 5. Open a local TCP socket connection to Tor's ControlPort
:: (127.0.0.1:9151) once it becomes available.
:: 6. Authenticate the control session securely using the binary bytes
:: read from Tor's local control_auth_cookie.
:: 7. Poll Tor's bootstrap status via GETINFO until the bootstrap-phase
:: reports 100% completion.
:: 8. Apply the user's selected profile fingerprints to Tor's configuration
:: using the SETCONF ExitNodes command.
:: 9. Issue a SIGNAL NEWNYM command to force Tor to discard old circuits
:: and build new ones using the designated exit nodes.
:: 10. Verify that the active ExitNodes configuration matches the expected
:: profile fingerprints.
:: 11. Query active circuits (GETINFO circuit-status), parse their exit node
:: fingerprints and compare them against the profile whitelist.
:: 12. Output clear verification results to the user console and pause
:: before exiting, leaving the configured browser ready for secure use.
:: ---------------------------------------------------------------------
:: Sample output:
::
:: ----------------------------------------
:: Tor exit node selector
:: ----------------------------------------
::
:: 1 for Profile 1
:: 2 for Profile 2
:: 3 for Profile 3
::
:: Select profile [1,2,3] or Q to quit: 3
::
:: Setting Profile 3...
:: Ensuring clean state by stopping any existing Tor instances...
:: Tor Browser is not running. Starting Tor Browser automatically...
:: Waiting for Tor Browser to initialize and open ControlPort (9151)...
:: Tor Browser port is open.
:: Authentication: 250 OK
:: Waiting for Tor bootstrap to complete...
:: Tor bootstrap complete (100).
:: Exit configuration: 250 ExitNodes={US}
:: SETCONF response: 250 OK
:: NEWNYM response: 250 OK
:: New exit configuration: 250 ExitNodes=$4FA9...,$29A4...
:: ExitNodes verification: Match
::
:: General-purpose circuits
:: -------------------------
::
:: Circuit: 23
:: Exit fingerprint: 4FA9...
:: Profile comparison: Match
::
:: Circuit: 22
:: Exit fingerprint: 29A4...
:: Profile comparison: Match
::
:: Circuit: 7
:: Exit fingerprint: 1B30...
:: Profile comparison: Not in profile
::
:: Circuit: 8
:: Exit fingerprint: C5B5...
:: Profile comparison: Not in profile
::
:: Circuit inspection complete.
:: Tor control session completed successfully.
::
:: torset completed successfully.
:: Press any key to continue . . .
:: --------------------------------------------------------------------
--
On Usenet, we improve our knowledge by sharing & discussing solutions.
Re: PSA: Setting the Windows Firefox Tor browser to use USA exit nodes
Author: Maria Sophia
Date: Mon, 09 Nov 2026 14:57
Date: Mon, 09 Nov 2026 14:57
396 lines
18489 bytes
18489 bytes
Maria Sophia wrote:
> Since you're on Linux, it would be great if you can test that for the team.
> As for me, it worked fine in my test, but I wanted even more functionality.
Below is portable code that should work on all the major platforms
(Linux/macOS/Windows) to choose per-profile FF Tor browser exit nodes.
I started this project five effort-hours ago assuming it would only
take a few minutes, so I used PowerShell at first, but to leverage
the effort to as many people as possible, which I am won't to do,
I expended another hour to port to Python and then to all platforms.
I tested the code below ONLY on Windows 10, so if someone can test
it on macOS and/or Linux, that would be very useful for the community.
Everything we do, is for everyone to benefit from.
That's how we're wired.
#!/usr/bin/env python3
# ---------------------------------------------------------------------
# torset.py
# Manually set known-good Tor exit nodes for specific web-login profiles
# ---------------------------------------------------------------------
# Usage notes:
# 1. Obtain a set of desired known-to-be-working US Tor exit relays:
# https://metrics.torproject.org/rs.html#search/country:us%20flag:exit
# For example:
# "$688604204AF0C0473DFFA8CD2E186D1EEAEE6916"
# "$B8FA90A8B7DA9B90A09AA04CD2E81E263AA8DA4C"
# "$BD610AAEAE179EC259B022A178A75C70042407FB"
# "$9C7B1DB2C5520B21E181EB945A01E9ABA42654A2"
# 2. Enter their fingerprints in the profile definitions, e.g.,
# Profile 1 (gmail)
# "$688604204AF0C0473DFFA8CD2E186D1EEAEE6916"
# "$B8FA90A8B7DA9B90A09AA04CD2E81E263AA8DA4C"
# Profile 2 (protonmail)
# "$BD610AAEAE179EC259B022A178A75C70042407FB"
# Profile 3 (facebook)
# "$9C7B1DB2C5520B21E181EB945A01E9ABA42654A2"
# 3. Run this script, which cleans stale sessions before starting
# Tor and then provides a choice of pre-selected exit nodes
# Note: Due to Firefox Tor browser complexities, allow Tor a bit of
# time to establish new circuits and then make sure to manually
# verify the exit relay and exit IP before logging in
# ---------------------------------------------------------------------
# v2p9 20261109 Added sys.platform support for macOS and Linux paths
# v2p8 20261109 Reverted profile exit nodes back to original configurations
# v2p7 20261108 Converted native batch/PowerShell implementation to Python
# v2p6 20261108 Improved documentation in terms of technical accuracy
# v2p5 20261108 Added new exit nodes and a profile configuration check
# v2p4 20261108 Handled stale process cleanup cleanly in native batch
# v2p3 20261108 Added automated cleanup of stale Tor/Firefox instances
# v2p2 20261108 Added full bootstrap completion polling on cold start
# v2p1 20261108 Fixed $tcp variable scope in try/finally block
# v2p0 20261108 Added automated Tor Browser startup and port polling
# v1p9 20261108 Added ControlPort error handling and response validation
# v1p8 20261108 Cleaned up comments and clarified explanations
# v1p7 20261108 Identify general-purpose ckts and compare exit fingerprints
# v1p6 20261108 Display multi-line Tor circuit status via GETINFO
# v1p5 20261108 Request new Tor circuits after profile selection
# v1p4 20261108 Added multi-profile exit-node selection menu
# v1p3 20261108 Set Profile 1 ExitNodes (two fingerprints) via SETCONF
# v1p2 20261108 Added GETINFO status/bootstrap-phase
# v1p1 20261108 Retrieve current ExitNodes configuration via GETCONF
# v1p0 20261108 Tested Tor ControlPort via TCP cookie authentication
# ---------------------------------------------------------------------
# See also... Forces a new working Tor exit node:
# <https://github.com/gmolop/Tor-ExitNode-changer/>
# <https://github.com/hevnsnt/IPChanger>
# <https://gist.github.com/kirelagin/9667900>
# Interacts with Tor using the Python stem library:
# <https://pypi.org/project/stem/> <https://stem.torproject.org/>
# <https://github.com/torproject/stem>
# Command-line Tor interaction and Nyx monitor:
# <https://nyx.torproject.org/> <https://github.com/torproject/nyx>
# Configures Tor using a GUI (Windows only):
# <https://github.com/abysshint/tor-control-panel/>
# ---------------------------------------------------------------------
# Summary:
# 1. Present a multi-profile selection menu allowing the user to choose
# between predefined exit-node configurations (or quit with Q).
# 2. Terminate any stale or running instances of Firefox Tor Browser
# to ensure a clean starting environment.
# 3. Launch the Firefox Tor Browser executable automatically if it is
# not currently running on the system.
# 4. Poll local TCP port 9151 and monitor for the existence of Tor's
# control authentication cookie file.
# 5. Open a local TCP socket connection to Tor's ControlPort
# (127.0.0.1:9151) once it becomes available.
# 6. Authenticate the control session securely using the binary bytes
# read from Tor's local control_auth_cookie.
# 7. Poll Tor's bootstrap status via GETINFO until the bootstrap-phase
# reports 100% completion.
# 8. Apply the user's selected profile fingerprints to Tor's configuration
# using the SETCONF ExitNodes command.
# 9. Issue a SIGNAL NEWNYM command to force Tor to discard old circuits
# and build new ones using the designated exit nodes.
# 10. Verify that the active ExitNodes configuration matches the expected
# profile fingerprints.
# 11. Query active circuits (GETINFO circuit-status), parse their exit node
# fingerprints and compare them against the profile whitelist.
# 12. Output clear verification results to the user console and pause
# before exiting, leaving the configured browser ready for secure use.
# ---------------------------------------------------------------------
import os
import socket
import subprocess
import sys
import time
from pathlib import Path
# --- Configuration & Cross-Platform Paths ---
if sys.platform == "win32":
COOKIE_PATH = Path(
r"C:\app\browser\tor\Tor Browser\Browser\TorBrowser\Data\Tor\control_auth_cookie"
)
TOR_EXE = Path(r"C:\app\browser\tor\Tor Browser\Browser\firefox.exe")
KILL_CMD = ["taskkill", "/f", "/im", "firefox.exe"]
elif sys.platform == "darwin": # macOS
TOR_EXE = Path.home() / "Applications" / "TorBrowser.app" / "Contents" / "MacOS" / "firefox"
if not TOR_EXE.is_file():
TOR_EXE = Path("/Applications/TorBrowser.app/Contents/MacOS/firefox")
COOKIE_PATH = Path.home() / "Library" / "Application Support" / "TorBrowser-Data" / "Tor" / "control_auth_cookie"
KILL_CMD = ["pkill", "-f", "torbrowser"]
else: # Linux and other Unix-likes
base_linux = Path.home() / ".local" / "share" / "torbrowser" / "tor" / "x86_64" / "tor-browser"
TOR_EXE = base_linux / "Browser" / "firefox"
COOKIE_PATH = base_linux / "Browser" / "TorBrowser" / "Data" / "Tor" / "control_auth_cookie"
KILL_CMD = ["pkill", "-f", "tor-browser"]
CONTROL_PORT = 9151
# Define selectable profiles with your original exit node fingerprints
PROFILES = {
"1": {
"name": "Profile 1",
"exit_nodes": (
"$688604204AF0C0473DFFA8CD2E186D1EEAEE6916,"
"$B8FA90A8B7DA9B90A09AA04CD2E81E263AA8DA4C"
),
},
"2": {
"name": "Profile 2",
"exit_nodes": "$BD610AAEAE179EC259B022A178A75C70042407FB",
},
"3": {
"name": "Profile 3",
"exit_nodes": "$9C7B1DB2C5520B21E181EB945A01E9ABA42654A2",
},
}
def main():
# Step 1: Profile Selection Menu
print("----------------------------------------")
print(" Tor exit node selector ")
print("----------------------------------------")
print()
print(" 1 for Profile 1")
print(" 2 for Profile 2")
print(" 3 for Profile 3")
print(" Q to Quit")
print()
choice = input("Select profile [1,2,3] or Q to quit: ").strip().upper()
if choice == "Q" or choice not in PROFILES:
print("Exiting.")
sys.exit(0)
profile = PROFILES[choice]
print(f"\nSetting {profile['name']}...")
# Step 2: Clean up any stale or running Tor/Firefox instances
print("Ensuring clean state by stopping any existing Tor instances...")
try:
subprocess.run(
KILL_CMD,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
except Exception:
pass
time.sleep(2)
# Steps 3 & 4: Launch browser if needed and wait for ControlPort & cookie
if not COOKIE_PATH.is_file():
print("Tor Browser is not running. Starting Tor Browser automatically...")
if not TOR_EXE.is_file():
print(f"ERROR: Tor Browser executable not found at: {TOR_EXE}")
sys.exit(1)
subprocess.Popen([str(TOR_EXE)])
print("Waiting for Tor Browser to initialize and open ControlPort (9151)...")
start_time = time.time()
ready = False
while time.time() - start_time < 45:
if COOKIE_PATH.is_file():
try:
test_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
test_sock.settimeout(2)
test_sock.connect(("127.0.0.1", CONTROL_PORT))
test_sock.close()
ready = True
break
except (socket.error, OSError):
pass
time.sleep(2)
if not ready:
print(
"ERROR: Timed out waiting for Tor Browser to start and open ControlPort"
" 9151."
)
sys.exit(1)
print("Tor Browser port is open.")
# Step 6: Read authentication cookie bytes
try:
cookie_bytes = COOKIE_PATH.read_bytes()
cookie_hex = cookie_bytes.hex().upper()
except Exception as e:
print(f"ERROR: Failed to read control authentication cookie: {e}")
sys.exit(1)
# Helper functions for Tor Control Protocol
def read_tor_reply(sock_file):
lines = []
while True:
line = sock_file.readline()
if not line:
raise RuntimeError("Tor closed the ControlPort connection unexpectedly.")
decoded = line.decode("utf-8", errors="ignore").rstrip("\r\n")
lines.append(decoded)
if decoded.startswith("250+"):
while True:
data_line = sock_file.readline()
if not data_line:
raise RuntimeError(
"Tor closed the connection during a data response."
)
d_decoded = data_line.decode("utf-8", errors="ignore").rstrip(
"\r\n"
)
lines.append(d_decoded)
if d_decoded == ".":
break
continue
if len(decoded) >= 4 and decoded[3] == "-":
continue
break
return lines
def send_command(sock_file, command):
sock_file.write((command + "\r\n").encode("utf-8"))
sock_file.flush()
reply = read_tor_reply(sock_file)
if not reply or not reply[0].startswith("250"):
raise RuntimeError(f"Tor rejected command: {command} -- {' '.join(reply)}")
return reply
# Step 5: Connect to ControlPort
stream = None
s = None
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(15)
s.connect(("127.0.0.1", CONTROL_PORT))
stream = s.makefile("rwb")
# Authenticate session
auth_reply = send_command(stream, f"AUTHENTICATE {cookie_hex}")
print(f"Authentication: {auth_reply[0]}")
# Step 7: Wait for Tor bootstrap completion (100%)
print("Waiting for Tor bootstrap to complete...")
bootstrap_complete = False
b_start = time.time()
while time.time() - b_start < 60:
try:
bootstrap_reply = send_command(stream, "GETINFO status/bootstrap-phase")
for line in bootstrap_reply:
if "PROGRESS=100" in line:
bootstrap_complete = True
break
if bootstrap_complete:
break
except Exception:
pass
time.sleep(2)
if not bootstrap_complete:
raise RuntimeError("Timed out waiting for Tor to finish bootstrapping.")
print("Tor bootstrap complete (100%).")
# Step 8: Apply selected profile ExitNodes via SETCONF
config_reply = send_command(stream, "GETCONF ExitNodes")
print(f"Exit configuration: {' '.join(config_reply)}")
setconf_reply = send_command(
stream, f"SETCONF ExitNodes={profile['exit_nodes']}"
)
print(f"SETCONF response: {setconf_reply[-1]}")
# Step 9: Signal NEWNYM to clear circuits and build new ones
newnym_reply = send_command(stream, "SIGNAL NEWNYM")
print(f"NEWNYM response: {newnym_reply[-1]}")
time.sleep(3)
# Step 10: Verify new ExitNodes configuration matches expected
config_reply = send_command(stream, "GETCONF ExitNodes")
print(f"New exit configuration: {' '.join(config_reply)}")
actual_line = None
for item in config_reply:
if item.startswith("250 ExitNodes="):
actual_line = item
break
if not actual_line:
raise RuntimeError("Could not verify the new ExitNodes configuration.")
actual_text = actual_line.replace("250 ExitNodes=", "")
actual_nodes = [
fp.strip().lstrip("$").upper() for fp in actual_text.split(",") if fp
]
expected_nodes = [
fp.strip().lstrip("$").upper()
for fp in profile["exit_nodes"].split(",")
if fp
]
if set(actual_nodes) != set(expected_nodes):
raise RuntimeError("ExitNodes verification failed: fingerprint mismatch.")
print("ExitNodes verification: Match")
allowed = {fp: True for fp in expected_nodes}
# Step 11: Inspect circuit-status and compare exit fingerprints
circuit_reply = send_command(stream, "GETINFO circuit-status")
print("\nGeneral-purpose circuits")
print("-------------------------")
found = False
for line in circuit_reply:
if "BUILT" not in line or "PURPOSE=GENERAL" not in line:
continue
fields = line.split()
if len(fields) < 3:
continue
circuit_id = fields[0]
hops = fields[2].split(",")
last_hop = hops[-1].split("~")[0].lstrip("$").upper()
found = True
print(f"\nCircuit: {circuit_id}")
print(f"Exit fingerprint: {last_hop}")
if last_hop in allowed:
print("Profile comparison: Match")
else:
print("Profile comparison: Not in profile")
if not found:
print("No built general-purpose circuits found.")
print("\nCircuit inspection complete.")
print("Tor control session completed successfully.")
except Exception as e:
print(f"\nError: {e}", file=sys.stderr)
sys.exit(1)
finally:
if stream:
try:
stream.close()
except Exception:
pass
if s:
try:
s.close()
except Exception:
pass
# Step 12: Output final success message and pause before exit
print("\ntorset completed successfully.")
input("Press Enter to continue . . . ")
if __name__ == "__main__":
main()
# ---------------------------------------------------------------------
# end of torset.py
# ---------------------------------------------------------------------
--
On Usenet, a good suggestion can make everyone's solution a little better.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads