diff --git a/README.md b/README.md
index d58fc6b..eee5ecc 100644
--- a/README.md
+++ b/README.md
@@ -8,12 +8,13 @@ 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
@@ -21,32 +22,64 @@ A simple and efficient tool to automatically change your IP address using Tor ne
- 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
@@ -54,62 +87,99 @@ 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:
diff --git a/change_tor_ip.sh b/change_tor_ip.sh
index 5c1ad72..c5033b2 100644
--- a/change_tor_ip.sh
+++ b/change_tor_ip.sh
@@ -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"
diff --git a/com.techchip.change-tor-ip.plist b/com.techchip.change-tor-ip.plist
new file mode 100644
index 0000000..085efe6
--- /dev/null
+++ b/com.techchip.change-tor-ip.plist
@@ -0,0 +1,22 @@
+
+
+
+
+ Label
+ com.techchip.change-tor-ip
+ ProgramArguments
+
+ __SCRIPT_PATH__
+
+ RunAtLoad
+
+ KeepAlive
+
+ ThrottleInterval
+ __INTERVAL__
+ StandardOutPath
+ __HOME__/tor_ip_log.txt
+ StandardErrorPath
+ __HOME__/tor_ip_log.txt
+
+
diff --git a/ip-changer.sh b/ip-changer.sh
old mode 100644
new mode 100755
index 6563bfb..1b36cb1
--- a/ip-changer.sh
+++ b/ip-changer.sh
@@ -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
@@ -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
@@ -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}
diff --git a/setup.sh b/setup.sh
index 8e59361..d23b961 100644
--- a/setup.sh
+++ b/setup.sh
@@ -22,56 +22,115 @@ echo -e "${YELLOW}=========================================================${NC}
set -e
-if [ -f /etc/os-release ]; then
- . /etc/os-release
- DISTRO=$ID
-else
- echo -e "${RED}❌ Unsupported Linux distribution!${NC}"
- exit 1
-fi
-
-echo -e "${BLUE}[*] Detected Linux Distro: $DISTRO${NC}"
-
-echo -e "${BLUE}[*] Installing required packages...${NC}"
-case "$DISTRO" in
- arch|manjaro|blackarch)
- sudo pacman -Syu --noconfirm curl tor jq xxd
- TOR_GROUP="tor"
- ;;
- debian|ubuntu|kali|parrot)
- sudo apt update && sudo apt install -y curl tor jq xxd
- TOR_GROUP="debian-tor"
- ;;
- fedora)
- sudo dnf install -y curl tor jq xxd
- TOR_GROUP="tor"
- ;;
- opensuse*)
- sudo zypper install -y curl tor jq xxd
- TOR_GROUP="tor"
- ;;
+case "$(uname -s)" in
+ Darwin) OS="macos" ;;
+ Linux) OS="linux" ;;
*)
- echo -e "${RED}❌ Unsupported distro. Please install curl, tor, jq, xxd manually.${NC}"
+ echo -e "${RED}❌ Unsupported OS.${NC}"
exit 1
;;
esac
-if ! getent group "$TOR_GROUP" >/dev/null; then
- echo -e "${BLUE}[*] Group '$TOR_GROUP' not found, creating it...${NC}"
- sudo groupadd "$TOR_GROUP"
-fi
+# BSD sed (macOS) requires an explicit empty string after -i; GNU sed does not.
+sed_inplace() {
+ if [ "$OS" = "macos" ]; then
+ sed -i '' "$@"
+ else
+ sed -i "$@"
+ fi
+}
-if ! groups "$USER" | grep -q " $TOR_GROUP"; then
- echo -e "${BLUE}[*] Adding user '$USER' to group '$TOR_GROUP'...${NC}"
- sudo usermod -aG "$TOR_GROUP" "$USER"
-else
- echo -e "${GREEN}[✓] User '$USER' is already a member of group '$TOR_GROUP'.${NC}"
-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"
-echo -e "${BLUE}[*] Configuring Tor...${NC}"
-TORRC_FILE="/etc/tor/torrc"
+ 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}"
+ fi
+}
+
+setup_linux() {
+ if [ -f /etc/os-release ]; then
+ . /etc/os-release
+ DISTRO=$ID
+ else
+ echo -e "${RED}❌ Unsupported Linux distribution!${NC}"
+ exit 1
+ fi
+
+ echo -e "${BLUE}[*] Detected Linux Distro: $DISTRO${NC}"
+ echo -e "${BLUE}[*] Installing required packages...${NC}"
+ case "$DISTRO" in
+ arch|manjaro|blackarch)
+ sudo pacman -Syu --noconfirm curl tor jq xxd
+ TOR_GROUP="tor"
+ ;;
+ debian|ubuntu|kali|parrot)
+ sudo apt update && sudo apt install -y curl tor jq xxd
+ TOR_GROUP="debian-tor"
+ ;;
+ fedora)
+ sudo dnf install -y curl tor jq xxd
+ TOR_GROUP="tor"
+ ;;
+ opensuse*)
+ sudo zypper install -y curl tor jq xxd
+ TOR_GROUP="tor"
+ ;;
+ *)
+ echo -e "${RED}❌ Unsupported distro. Please install curl, tor, jq, xxd manually.${NC}"
+ exit 1
+ ;;
+ esac
+
+ if ! getent group "$TOR_GROUP" >/dev/null; then
+ echo -e "${BLUE}[*] Group '$TOR_GROUP' not found, creating it...${NC}"
+ sudo groupadd "$TOR_GROUP"
+ fi
+
+ if ! groups "$USER" | grep -q " $TOR_GROUP"; then
+ echo -e "${BLUE}[*] Adding user '$USER' to group '$TOR_GROUP'...${NC}"
+ sudo usermod -aG "$TOR_GROUP" "$USER"
+ else
+ echo -e "${GREEN}[✓] User '$USER' is already a member of group '$TOR_GROUP'.${NC}"
+ fi
+
+ TORRC_FILE="/etc/tor/torrc"
+ 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
@@ -89,23 +148,66 @@ TORRC_FILE="/etc/tor/torrc"
else
echo -e "${GREEN}[✓] torrc already configured correctly. Skipping update.${NC}"
fi
-
+}
+
+deploy_macos() {
+ INSTALL_DIR="$HOME"
+ PLIST_LABEL="com.techchip.change-tor-ip"
+ PLIST_DEST="$HOME/Library/LaunchAgents/${PLIST_LABEL}.plist"
+ PLIST_SRC="$(dirname "$0")/com.techchip.change-tor-ip.plist"
+
+ echo -e "${BLUE}[*] Deploying files to $INSTALL_DIR...${NC}"
+ cp change_tor_ip.sh "$INSTALL_DIR/"
+ chmod +x "$INSTALL_DIR/change_tor_ip.sh"
+
+ mkdir -p "$HOME/Library/LaunchAgents"
+ cp "$PLIST_SRC" "$PLIST_DEST"
+ sed_inplace "s|__SCRIPT_PATH__|${INSTALL_DIR}/change_tor_ip.sh|g" "$PLIST_DEST"
+ sed_inplace "s|__HOME__|${INSTALL_DIR}|g" "$PLIST_DEST"
+ sed_inplace "s|__INTERVAL__|${TIME_INTERVAL}|g" "$PLIST_DEST"
+
+ echo -e "${BLUE}[*] Loading launchd agent...${NC}"
+ launchctl unload "$PLIST_DEST" 2>/dev/null || true
+ launchctl load -w "$PLIST_DEST"
+
+ echo -e "${BLUE}[*] Ensuring Tor starts at login...${NC}"
+ brew services start tor
+
+ echo -e "${GREEN}[✔] Deployment complete! Tor IP will change every $TIME_INTERVAL seconds.${NC}"
+ echo -e "${GREEN}[✔] Logs: $INSTALL_DIR/tor_ip_log.txt${NC}"
+}
+
+deploy_linux() {
+ echo -e "${BLUE}[*] Setting up systemd service with interval: $TIME_INTERVAL sec...${NC}"
+ sed_inplace "s/RestartSec=.*/RestartSec=$TIME_INTERVAL/" change-tor-ip.service
+
+ echo -e "${BLUE}[*] Deploying files...${NC}"
+ INSTALL_DIR="/home/$USER"
+ sudo cp change_tor_ip.sh "$INSTALL_DIR/"
+ sudo chmod +x "$INSTALL_DIR/change_tor_ip.sh"
+ sed_inplace "s|^ExecStart=.*|ExecStart=${INSTALL_DIR}/change_tor_ip.sh|" change-tor-ip.service
+ sudo cp change-tor-ip.service /etc/systemd/system/
+
+ echo -e "${BLUE}[*] Enabling and starting service...${NC}"
+ sudo systemctl daemon-reload
+ sudo systemctl enable --now change-tor-ip.service
+ sudo systemctl enable --now tor.service
+ echo -e "${GREEN}[✔] Deployment complete! Tor IP will change every $TIME_INTERVAL seconds.${NC}"
+}
+
+if [ "$OS" = "macos" ]; then
+ setup_macos
+else
+ setup_linux
+fi
+
+echo -e "${BLUE}[*] Configuring Tor (done above)${NC}"
+
read -p "Enter Tor IP change interval (seconds, default 10): " TIME_INTERVAL
TIME_INTERVAL=${TIME_INTERVAL:-10}
-echo -e "${BLUE}[*] Setting up systemd service with interval: $TIME_INTERVAL sec...${NC}"
-sed -i "s/RestartSec=.*/RestartSec=$TIME_INTERVAL/" change-tor-ip.service
-
-echo -e "${BLUE}[*] Deploying files...${NC}"
-INSTALL_DIR="/home/$USER"
-sudo cp change_tor_ip.sh "$INSTALL_DIR/"
-sed -i "s#HOME#$INSTALL_DIR#g" "$INSTALL_DIR/change_tor_ip.sh"
-sudo chmod +x "$INSTALL_DIR/change_tor_ip.sh"
-sed -i "s|^ExecStart=.*|ExecStart=${INSTALL_DIR}/change_tor_ip.sh|" change-tor-ip.service
-sudo cp change-tor-ip.service /etc/systemd/system/
-
-echo -e "${BLUE}[*] Enabling and starting service...${NC}"
-sudo systemctl daemon-reload
-sudo systemctl enable --now change-tor-ip.service
-sudo systemctl enable --now tor.service
-echo -e "${GREEN}[✔] Deployment complete! Tor IP will change every $TIME_INTERVAL seconds.${NC}"
+if [ "$OS" = "macos" ]; then
+ deploy_macos
+else
+ deploy_linux
+fi