Skip to content

Instantly share code, notes, and snippets.

@Geczy
Last active September 11, 2024 16:55
Show Gist options
  • Save Geczy/a7a3fc87daf7d9d8f5d98ee3d4c967ef to your computer and use it in GitHub Desktop.
Save Geczy/a7a3fc87daf7d9d8f5d98ee3d4c967ef to your computer and use it in GitHub Desktop.
free american airlines wifi
#!/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://www.aainflight.com/api/v1/connectivity/viasat/device?random=$TIMESTAMP" \
-H 'accept: application/json' \
-H 'cache-control: no-cache' \
-H 'referer: https://aainflight.com/' \
-H "user-agent: $AGENT" \
--compressed | jq .deviceGuid -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 | jq ".sessionData.timeRemaining")
OFFER_ID=$(curl -s "https://$PRIMARY_DOMAIN/engage-advertising-service/vas/api/v1/advertisements" \
-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","eventTypes":["VIEWABLE_IMPRESSION","VIDEO_START","VIDEO_COMPLETE","VIDEO_MUTE","VIDEO_UNMUTE","VIDEO_PAUSE","VIDEO_RESUME","VIDEO_PROGRESS","ACTIVATION_EVENT","UI_CUSTOM_EVENT"],"adTypes":[18],"vsatType":"WATCH"}]}' \
--compressed | jq ".adDataMap.items.ads[0].offerInteractionId" -r)
curl -s "https://$PRIMARY_DOMAIN/engage-advertising-service/vas/api/v1/advertisements/$OFFER_ID/click" \
-X 'GET' \
-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
curl -s "https://$PRIMARY_DOMAIN/engage-advertising-service/vas/api/v1/advertisements/$OFFER_ID/recordInteraction/VIDEO_START" \
-X 'GET' \
-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
curl -s "https://$PRIMARY_DOMAIN/engage-advertising-service/vas/api/v1/advertisements/$OFFER_ID/recordInteraction/ACTIVATION_EVENT" \
-X 'GET' \
-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
curl -s "https://$PRIMARY_DOMAIN/engage-advertising-service/vas/api/v1/advertisements/$OFFER_ID/recordInteraction/VIDEO_COMPLETE" \
-X 'GET' \
-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
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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment