Skip to content

Instantly share code, notes, and snippets.

@iTrauco
Created August 15, 2024 00:46
Show Gist options
  • Save iTrauco/ed3a03d36e7f995d63f21c33cef62343 to your computer and use it in GitHub Desktop.
Save iTrauco/ed3a03d36e7f995d63f21c33cef62343 to your computer and use it in GitHub Desktop.
debian_hide_all_system_internet_traffic
sudo bash -c '
# Install required packages
apt-get update
apt-get install -y macchanger iproute2 curl iptables ufw
# Create the secure_connection.sh script
cat <<EOF > /usr/local/bin/secure_connection.sh
#!/bin/bash
# Configuration
INTERFACE="eth0" # Change this to your network interface (e.g., eth0, wlan0)
PROXY_IP="127.0.0.1" # IP address of the proxy server
PROXY_PORT="9050" # Port of the proxy server
CHANGE_INTERVAL=240 # Time in seconds between changes (4 minutes)
NOTIFY_BEFORE=300 # Time in seconds to notify before changes (5 minutes)
STATUS_FILE="/tmp/proxy_status" # File to store proxy status
FIREWALL_STATUS_FILE="/tmp/firewall_status" # File to store firewall status
# Function to generate a random MAC address
generate_random_mac() {
echo "00:$(printf '%02x' \$((RANDOM % 256))):$(printf '%02x' \$((RANDOM % 256))):$(printf '%02x' \$((RANDOM % 256))):$(printf '%02x' \$((RANDOM % 256))):$(printf '%02x' \$((RANDOM % 256)))"
}
# Function to generate a random IP address
generate_random_ip() {
echo "\$((RANDOM % 255 + 1)).\$((RANDOM % 255 + 1)).\$((RANDOM % 255 + 1)).\$((RANDOM % 255 + 1))"
}
# Function to change MAC address
change_mac_address() {
NEW_MAC=\$(generate_random_mac)
sudo ifconfig \$INTERFACE down
sudo macchanger -m \$NEW_MAC \$INTERFACE
sudo ifconfig \$INTERFACE up
echo "MAC Address changed to: \$NEW_MAC"
echo "MAC changed: \$NEW_MAC" > \$STATUS_FILE
}
# Function to change IP address
change_ip_address() {
NEW_IP=\$(generate_random_ip)
sudo ifconfig \$INTERFACE \$NEW_IP netmask 255.255.255.0
echo "IP Address changed to: \$NEW_IP"
echo "IP changed: \$NEW_IP" > \$STATUS_FILE
}
# Function to check if proxy is online
check_proxy() {
RESPONSE=\$(curl -s --proxy socks5h://\$PROXY_IP:\$PROXY_PORT http://www.google.com)
if [[ \$RESPONSE == *"Google"* ]]; then
echo "Proxy online" > \$STATUS_FILE
xfce4-notifyd --hint=int:transient:1 --hint=int:importance:1 -t 2000 -a "Proxy Status" -u normal -i "network-wired" "Proxy is online."
return 0
else
echo "Proxy offline" > \$STATUS_FILE
xfce4-notifyd --hint=int:transient:1 --hint=int:importance:1 -t 2000 -a "Proxy Status" -u critical -i "network-error" "Proxy is offline! Internet traffic has been stopped."
stop_traffic
return 1
fi
}
# Function to stop internet traffic
stop_traffic() {
sudo iptables -A OUTPUT -j DROP
echo "Internet traffic stopped." > \$FIREWALL_STATUS_FILE
}
# Main loop
while true; do
echo "Notifying user about upcoming changes in 5 minutes..."
sleep \$NOTIFY_BEFORE
change_mac_address
change_ip_address
check_proxy
sleep \$CHANGE_INTERVAL
done
EOF
# Set the script as executable
chmod +x /usr/local/bin/secure_connection.sh
# Create the systemd service file
cat <<EOF > /etc/systemd/system/secure_connection.service
[Unit]
Description=Secure Connection Service
After=network.target
[Service]
ExecStart=/usr/local/bin/secure_connection.sh
Restart=always
User=root
[Install]
WantedBy=multi-user.target
EOF
# Reload systemd to apply the new service
systemctl daemon-reload
# Enable and start the service
systemctl enable secure_connection.service
systemctl start secure_connection.service
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment