Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 104 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,108 +8,178 @@ A simple and efficient tool to automatically change your IP address using Tor ne

- 🔄 Automatic IP rotation at user-defined intervals
- 🛡️ Uses Tor network for secure IP changes
- 🚀 Works on multiple Linux distributions
- 🚀 Works on Linux and macOS
- ⚡ Easy installation and setup
- ⌛️ Run without installation

## Supported Distributions
## Supported Platforms

### Linux
- Arch Linux / Manjaro
- Debian / Ubuntu
- Kali Linux
- Parrot OS
- Fedora
- OpenSUSE

### macOS
- macOS (Apple Silicon and Intel) via [Homebrew](https://brew.sh)

## Prerequisites

- Linux-based operating system
### Linux
- Sudo privileges
- Internet connection
- tor,curl,xxd,fq packages required
- `tor`, `curl`, `xxd`, `jq` packages (installed automatically by the scripts)

### macOS
- [Homebrew](https://brew.sh) installed
- Internet connection
- `tor` and `jq` installed via `brew` (installed automatically by the scripts)

---

## Run without Installation

### Linux
1. Clone the repository:
```bash
git clone https://github.com/techchipnet/ip-changer.git
cd ip-changer
```

2. Make the installation script executable:
2. Make the script executable:
```bash
chmod +x ip-changer.sh
```

3. Run the installation script:
3. Run as root:
```bash
sudo ./ip-changer.sh
```

4. Follow the on-screen instructions to set your desired IP change interval.
## Setup for service
### macOS
1. Clone the repository:
```bash
git clone https://github.com/techchipnet/ip-changer.git
cd ip-changer
```

2. Make the script executable:
```bash
chmod +x ip-changer.sh
```

3. Run (no `sudo` required):
```bash
./ip-changer.sh
```

---

## Setup for Background Service

### Linux (systemd)

1. Clone the repository:
```bash
git clone https://github.com/techchipnet/ip-changer.git
cd ip-changer
```

2. Make the installation script executable:
2. Make the setup script executable:
```bash
chmod +x setup.sh
```

3. Run the installation script:
3. Run the setup script:
```bash
./setup.sh
```

4. Follow the on-screen instructions to set your desired IP change interval.

## Usage

Once installed, the service will automatically start and run in the background. Your IP address will be changed at the interval you specified during installation.

### Checking Status

To check if the service is running:
#### Checking Status
```bash
systemctl status change-tor-ip.service
```

### Stopping the Service

To stop the IP changer:
#### Stopping the Service
```bash
sudo systemctl stop change-tor-ip.service
```

### Starting the Service

To start the IP changer:
#### Starting the Service
```bash
sudo systemctl start change-tor-ip.service
```

### Changing the Interval

To change the IP rotation interval:
1. Stop the service
2. Edit the `change-tor-ip.service` file
3. Restart the service

## Uninstallation

To remove the IP Changer:
#### Uninstall (Linux)
```bash
sudo systemctl stop change-tor-ip.service
sudo systemctl disable change-tor-ip.service
sudo systemctl stop tor
sudo systemctl disable tor
sudo rm /etc/systemd/system/change-tor-ip.service
sudo rm /home/$USER/change_tor_ip.sh
sudo rm ~/change_tor_ip.sh
```

---

### macOS (launchd)

1. Clone the repository:
```bash
git clone https://github.com/techchipnet/ip-changer.git
cd ip-changer
```

2. Make the setup script executable:
```bash
chmod +x setup.sh
```

3. Run the setup script (no `sudo` required):
```bash
./setup.sh
```

4. Follow the on-screen instructions to set your desired IP change interval.

The rotator script is installed to `~/change_tor_ip.sh` and registered as a launchd user agent at `~/Library/LaunchAgents/com.techchip.change-tor-ip.plist`. Logs are written to `~/tor_ip_log.txt`.

#### Checking Status
```bash
launchctl list | grep change-tor-ip
```

#### Stopping the Service
```bash
launchctl unload ~/Library/LaunchAgents/com.techchip.change-tor-ip.plist
```

#### Starting the Service
```bash
launchctl load -w ~/Library/LaunchAgents/com.techchip.change-tor-ip.plist
```

#### Changing the Interval (macOS)
1. Stop the service (see above).
2. Edit `~/Library/LaunchAgents/com.techchip.change-tor-ip.plist` — change the `ThrottleInterval` integer value.
3. Reload the service (see above).

#### Uninstall (macOS)
```bash
launchctl unload ~/Library/LaunchAgents/com.techchip.change-tor-ip.plist
rm ~/Library/LaunchAgents/com.techchip.change-tor-ip.plist
brew services stop tor
rm ~/change_tor_ip.sh ~/tor_ip_log.txt
# Optionally remove packages:
# brew uninstall tor jq
```

---

## Security Note

This tool uses the Tor network to change your IP address. While Tor provides anonymity, please be aware that:
Expand Down
22 changes: 17 additions & 5 deletions change_tor_ip.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
#!/bin/bash

# Read auth cookie as hex string
COOKIE=$(xxd -ps /var/run/tor/control.authcookie | tr -d '\n')
case "$(uname -s)" in
Darwin)
TOR_COOKIE="$HOME/.tor/control_auth_cookie"
LOG_FILE="$HOME/tor_ip_log.txt"
;;
Linux)
TOR_COOKIE="/var/run/tor/control.authcookie"
LOG_FILE="$HOME/tor_ip_log.txt"
;;
*)
echo "Unsupported OS" >&2
exit 1
;;
esac

COOKIE=$(xxd -ps "$TOR_COOKIE" | tr -d '\n')

# Send NEWNYM signal to Tor ControlPort using cookie authentication
printf 'AUTHENTICATE %s\r\nSIGNAL NEWNYM\r\nQUIT\r\n' "$COOKIE" | nc 127.0.0.1 9051 > /dev/null

# Store IP logs
IP=$(curl -s --socks5-hostname 127.0.0.1:9050 https://check.torproject.org/api/ip | jq -r .IP)
echo "$(date '+%Y-%m-%d %H:%M:%S') - New Tor IP: $IP" >> HOME/tor_ip_log.txt
echo "$(date '+%Y-%m-%d %H:%M:%S') - New Tor IP: $IP" >> "$LOG_FILE"
22 changes: 22 additions & 0 deletions com.techchip.change-tor-ip.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.techchip.change-tor-ip</string>
<key>ProgramArguments</key>
<array>
<string>__SCRIPT_PATH__</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ThrottleInterval</key>
<integer>__INTERVAL__</integer>
<key>StandardOutPath</key>
<string>__HOME__/tor_ip_log.txt</string>
<key>StandardErrorPath</key>
<string>__HOME__/tor_ip_log.txt</string>
</dict>
</plist>
87 changes: 78 additions & 9 deletions ip-changer.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,80 @@ echo -e "${NC}"
echo -e "${YELLOW}Author: TechChip. https://www.youtube.com/@techchipnet ${NC}"
echo -e "${YELLOW}=========================================================${NC}\n"

case "$(uname -s)" in
Darwin) OS="macos" ;;
Linux) OS="linux" ;;
*)
echo -e "${RED}❌ Unsupported OS.${NC}"
exit 1
;;
esac

set -e
[[ "$UID" -ne 0 ]] && {
echo -e "${RED}❌ Please run this script as root.${NC}"
exit 1

if [ "$OS" = "linux" ]; then
[[ "$UID" -ne 0 ]] && {
echo -e "${RED}❌ Please run this script as root.${NC}"
exit 1
}
fi

setup_macos() {
if ! command -v brew &>/dev/null; then
echo -e "${RED}❌ Homebrew is required but not installed.${NC}"
echo -e "${YELLOW} Install it from: https://brew.sh${NC}"
exit 1
fi

BREW_PREFIX="$(brew --prefix)"
TORRC_FILE="$BREW_PREFIX/etc/tor/torrc"
TOR_COOKIE="$HOME/.tor/control_auth_cookie"

echo -e "${BLUE}[*] Installing required packages via Homebrew...${NC}"
brew install tor jq

if [ ! -f "$TORRC_FILE" ]; then
if [ -f "${TORRC_FILE}.sample" ]; then
cp "${TORRC_FILE}.sample" "$TORRC_FILE"
else
touch "$TORRC_FILE"
fi
fi

echo -e "${BLUE}[*] Configuring Tor...${NC}"
NEEDS_UPDATE=0
grep -q "^ControlPort 9051" "$TORRC_FILE" || NEEDS_UPDATE=1
grep -q "^CookieAuthentication 1" "$TORRC_FILE" || NEEDS_UPDATE=1
grep -q "^CookieAuthFileGroupReadable 1" "$TORRC_FILE" || NEEDS_UPDATE=1

if [ "$NEEDS_UPDATE" -eq 1 ]; then
echo -e "${BLUE}[*] Updating torrc with required ControlPort settings...${NC}"
{
echo ""
echo "# Added by change-tor-ip automation script"
echo "ControlPort 9051"
echo "CookieAuthentication 1"
echo "CookieAuthFileGroupReadable 1"
} >> "$TORRC_FILE"
brew services restart tor
else
echo -e "${GREEN}[✓] torrc already configured correctly. Skipping update.${NC}"
brew services start tor 2>/dev/null || true
fi

echo -e "${BLUE}[*] Waiting for Tor to be ready...${NC}"
for i in $(seq 1 20); do
[ -f "$TOR_COOKIE" ] && break
sleep 1
done
if [ ! -f "$TOR_COOKIE" ]; then
echo -e "${RED}❌ Tor did not start in time. Check: brew services list${NC}"
exit 1
fi
echo -e "${GREEN}[✓] Tor is ready.${NC}"
}

setup() {
setup_linux() {
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO=$ID
Expand Down Expand Up @@ -74,9 +141,9 @@ setup() {
echo -e "${GREEN}[✓] User '$USER' is already a member of group '$TOR_GROUP'.${NC}"
fi


echo -e "${BLUE}[*] Configuring Tor...${NC}"
TORRC_FILE="/etc/tor/torrc"
TOR_COOKIE="/var/run/tor/control.authcookie"
NEEDS_UPDATE=0

grep -q "^ControlPort 9051" "$TORRC_FILE" || NEEDS_UPDATE=1
Expand All @@ -99,15 +166,17 @@ setup() {
}

ipchanger() {
COOKIE=$(xxd -ps /var/run/tor/control.authcookie | tr -d '\n')

COOKIE=$(xxd -ps "$TOR_COOKIE" | tr -d '\n')
printf 'AUTHENTICATE %s\r\nSIGNAL NEWNYM\r\nQUIT\r\n' "$COOKIE" | nc 127.0.0.1 9051 > /dev/null

IP=$(curl -s --socks5-hostname 127.0.0.1:9050 https://check.torproject.org/api/ip | jq -r .IP)
echo "$(date '+%Y-%m-%d %H:%M:%S') - New Tor IP: $IP"
}

setup
if [ "$OS" = "macos" ]; then
setup_macos
else
setup_linux
fi

read -p "Enter Tor IP change interval in seconds (default 10): " TIME_INTERVAL
TIME_INTERVAL=${TIME_INTERVAL:-10}
Expand Down
Loading