Skip to content

Instantly share code, notes, and snippets.

@wrobelda
Last active June 22, 2024 12:00
Show Gist options
  • Save wrobelda/20d9ba0a9b478b0e75dab8ea57321454 to your computer and use it in GitHub Desktop.
Save wrobelda/20d9ba0a9b478b0e75dab8ea57321454 to your computer and use it in GitHub Desktop.
Update BulletVPN SmartDNS IP address
#!/bin/bash
# Variables
USERNAME=""
PASSWORD=""
URL1="https://www.bulletvpn.com/account/dologin.php"
URL2="https://www.bulletvpn.com/account/smartdns"
URL3="https://www.bulletvpn.com/account/check_ip.php"
# Step 1: Generate a random token
TOKEN=$(openssl rand -hex 20)
# Step 2: Login
RESPONSE=$(curl -s -D - -o /dev/null -X POST $URL1 \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-raw "token=$TOKEN&username=$USERNAME&password=$PASSWORD")
# Step 3: Capture cookies from the response
COOKIES=$(echo "$RESPONSE" | grep -i 'Set-Cookie' | sed 's/Set-Cookie: //I' | tr -d '\r\n')
echo "Captured Cookies: $COOKIES"
# Step 4: Open SmartDNS page
HTML=$(curl -s -X GET $URL2 -H "Cookie: $COOKIES")
# Step 5: Extract token and IP from the HTML response
DNS_TOKEN=$(echo "$HTML" | grep -oi 'var token = "[^"]*' | sed 's/var token = "//i')
IP=$(echo "$HTML" | grep -oi 'var ip = "[^"]*' | sed 's/var ip = "//i')
echo "Extracted Token: $DNS_TOKEN"
echo "Extracted IP: $IP"
# Step 6: Update the IP
FINAL_RESPONSE=$(curl -s -X POST $URL3 \
-H 'X-Requested-With: XMLHttpRequest' \
-H "Cookie: $COOKIES" \
--data "{\"token\":\"$DNS_TOKEN\",\"user_ip\":\"$IP\"}")
# Output the final response
echo "Final Response: $FINAL_RESPONSE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment