|
#!/bin/bash |
|
|
|
# If not running via sudo, exit |
|
if [ "$EUID" -ne 0 ]; then |
|
echo "Please run as root" |
|
exit |
|
fi |
|
|
|
# quit if jq is not installed |
|
if ! command -v jq &>/dev/null; then |
|
echo "jq could not be found, install using brew install jq" |
|
exit |
|
fi |
|
|
|
# Function to generate a valid MAC address |
|
generate_valid_mac() { |
|
echo $(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//') |
|
} |
|
|
|
# Display current MAC and IP |
|
current_mac=$(ifconfig en0 | awk '/ether/{print $2}') |
|
echo "Current MAC address: $current_mac" |
|
|
|
networksetup -setairportpower en0 off && sleep 0.5 |
|
networksetup -setairportpower en0 on && sleep 0.5 |
|
|
|
# Wait until we are disconnected from the network |
|
printf "Disconnecting from network..." |
|
while ifconfig en0 | grep -q "status: active"; do |
|
printf "." |
|
sleep 1 |
|
done |
|
echo "" |
|
|
|
# Keep trying new MAC addresses until successful |
|
while true; do |
|
new_mac=$(generate_valid_mac) |
|
if ifconfig en0 ether "$new_mac" >/dev/null 2>&1; then |
|
echo "MAC address rolled successfully" |
|
break |
|
fi |
|
sleep 0.2 |
|
done |
|
|
|
# Check if new mac is different from old mac, exit if not |
|
if [ "$current_mac" = "$(ifconfig en0 | awk '/ether/{print $2}')" ]; then |
|
echo "Failed. New MAC address is the same as the old MAC address? This should never happen." |
|
exit |
|
fi |
|
|
|
networksetup -detectnewhardware &>/dev/null |
|
networksetup -addpreferredwirelessnetworkatindex en0 aainflight.com 0 OPEN &>/dev/null |
|
|
|
# Display new MAC and IP |
|
echo "New MAC address: $(ifconfig en0 | awk '/ether/{print $2}')" |
|
|
|
# while loop to wait until we have conection |
|
printf "Connecting to network..." |
|
while ! ifconfig en0 | grep -q "status: active"; do |
|
printf "." |
|
sleep 1 |
|
done |
|
echo "" |
|
|
|
TIMESTAMP=$(date +%s) |
|
DEVICE_ID="" |
|
AGENT="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" |
|
|
|
printf "Waiting to be assigned a device from AA..." |
|
while [ -z "$DEVICE_ID" ]; do |
|
printf "." |
|
DEVICE_ID=$(curl -s "https://aainflight.com/device?random=$TIMESTAMP" \ |
|
-H 'accept: application/json' \ |
|
-H 'cache-control: no-cache' \ |
|
-H 'referer: https://aainflight.com/' \ |
|
-H "user-agent: $AGENT" \ |
|
--compressed | jq .guid -r) |
|
sleep 1 |
|
done |
|
echo "" |
|
|
|
PRIMARY_DOMAIN="sponsoredaccess.viasat.com" |
|
DEVICE_INFO=$(curl -s "https://$PRIMARY_DOMAIN/engage-advertising-service/api/v1/device" \ |
|
-H 'cookie: aal-termsAcceptance=1703259881243;' \ |
|
-H "deviceid: $DEVICE_ID" \ |
|
-H "referer: https://$PRIMARY_DOMAIN/americanairlines/" \ |
|
-H "user-agent: $AGENT" \ |
|
-H 'venuecode: aal' \ |
|
--compressed) |
|
|
|
OFFER_ID=$(curl -s "https://$PRIMARY_DOMAIN/engage-advertising-service/api/v1/offers" \ |
|
-H 'content-type: application/json' \ |
|
-H 'cookie: aal-termsAcceptance=1703259881243;' \ |
|
-H "deviceid: $DEVICE_ID" \ |
|
-H "origin: https://$PRIMARY_DOMAIN" \ |
|
-H "referer: https://$PRIMARY_DOMAIN/americanairlines/" \ |
|
-H "user-agent: $AGENT" \ |
|
-H 'venuecode: aal' \ |
|
--data-raw '{"placements":[{"divName":"items","count":5,"siteName":"aal_connect","eventIds":[40,900],"adTypes":[18]}]}' \ |
|
--compressed | jq ".decisions.items[0].offerInteractionId" -r) |
|
|
|
ACTIVATE_RESPONSE=$(curl -s "https://$PRIMARY_DOMAIN/engage-advertising-service/api/v1/offers/$OFFER_ID/activate" \ |
|
-X 'POST' \ |
|
-H 'content-type: application/json' \ |
|
-H 'cookie: aal-termsAcceptance=1703259881243;' \ |
|
-H "deviceid: $DEVICE_ID" \ |
|
-H "origin: https://$PRIMARY_DOMAIN" \ |
|
-H "referer: https://$PRIMARY_DOMAIN/americanairlines/" \ |
|
-H "user-agent: $AGENT" \ |
|
-H 'venuecode: aal' \ |
|
--compressed) |
|
|
|
status_value=$(echo "$ACTIVATE_RESPONSE" | jq -r '.status') |
|
|
|
if [ "$status_value" = "SUCCESS" ]; then |
|
future_time=$(date -v+19M '+%I:%M:%S %p') |
|
current_time=$(date '+%I:%M:%S %p') |
|
|
|
echo "Successfully activated at $current_time" |
|
echo "Keep this window open, this script will automatically run again in 19 minutes at $future_time..." |
|
sleep 1140 # 19 minutes in seconds |
|
bash "$0" |
|
else |
|
echo "Activation failed." |
|
echo "$ACTIVATE_RESPONSE" |
|
fi |