Skip to content

Instantly share code, notes, and snippets.

@paulscode
Created June 8, 2024 20:23
Show Gist options
  • Save paulscode/edf83354ba6da722ffa33b48685731fa to your computer and use it in GitHub Desktop.
Save paulscode/edf83354ba6da722ffa33b48685731fa to your computer and use it in GitHub Desktop.
Changes the Tor identity
#!/bin/bash
# Check for the --help flag
if [[ "$1" == "--help" ]]; then
echo "Creates a new Tor identity. Usage:"
echo "sudo ./tor_new_identity.sh"
exit 0
fi
# Check if the script is run as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
# Path to the control port cookie file
COOKIE_FILE="/var/run/tor/control.authcookie"
# Read the authentication cookie
AUTH_COOKIE=$(cat $COOKIE_FILE | xxd -p)
# Send NEWNYM signal to the Tor control port
echo -e "authenticate \"${AUTH_COOKIE}\"\nsignal newnym\nquit" | nc localhost 9051
echo "Tor identity updated."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment