iptorch is a Bash CLI tool that automates IP rotation through the Tor network using the ControlPort protocol. The script sends the SIGNAL NEWNYM command to Tor to request a new circuit, and consequently a new IP, at user-configurable intervals.
Communication with ControlPort is done via netcat (nc) or socat, with automatic fallback to service reload if authentication fails. The script supports authentication via password (HashedControlPassword) or via cookie (control.authcookie), detecting the default paths used by Tor.
The tool exposes a classic command line interface via getopts, allowing you to specify:
| Flag | Function |
|---|---|
-s |
SECONDS - Interval between IP changes |
-c |
COUNT - Number of rotations (0 = infinite) |
-p |
CONTROL_PORT - Tor ControlPort port (default: 9051) |
-P |
PASSWORD - Password set in torrc |
-t |
SOCKS_PORT - Tor SOCKS port (default: 9050) |
-S |
SERVICE STAND MODE - Does not terminate the Tor service when exiting |
-C / -w |
Displays COPYRIGHT and WARRANTY information (GPLv2) |
During execution, the script:
- Checks root privileges (required to manipulate services).
- Detects the active service manager (
systemd,sysvinit,openrc,runit,s6) and starts Tor. - Attempts to authenticate on ControlPort, prioritising
AUTHENTICATEwith password or cookie. - Repeatedly sends SIGNAL NEWNYM, respecting the configured interval.
- Optionally, displays the current IP and geolocation via
curl + jqusing Tor's SOCKS proxy.
The script uses trap to capture shutdowns (SIGINT, SIGTERM) and ensure a clean shutdown of the Tor service, except when the -S flag is used.
To ensure the script works properly, the following dependencies are recommended:
| Dependency | Reason |
|---|---|
tor |
Tor service for IP rotation |
curl |
IP query via Tor proxy |
jq |
JSON parser for geolocation |
nc (netcat) or socat |
Communication with ControlPort |
xxd or od |
Conversion of authentication cookie to HEX |
systemctl / service / rc-service / sv / s6-rc |
Tor service control |
NOTE: Without
ncorsocat, the script enters fallback mode, attempting toreloadTor instead ofSIGNAL NEWNYM.
Clone the repository and grant execution permission:
git clone https://github.com/letterfenceglasses/iptorch.git
cd iptorch
chmod +x src/iptorch
sudo cp src/iptorch /usr/local/bin/iptorch
Distributed under GNU GPLv2. Free to modify and redistribute, without warranty, see iptorch -C and iptorch -w to display the licence and warranty notices directly via the CLI.
