Skip to content

Instantly share code, notes, and snippets.

@dburger
Created January 17, 2011 20:23
Show Gist options
  • Save dburger/783405 to your computer and use it in GitHub Desktop.
Save dburger/783405 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
USER=$1
PASSWD=$2
AGENT="Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.45 Safari/534.13"
function bail {
echo $1
exit $2
}
ticket=$(curl -s \
--user-agent "${AGENT}" \
--cookie-jar cjar \
--location \
--referer ";auto" \
-d "user=${USER}&passwd=${PASSWD}&rm=2&deviceAuthn=false" \
-d "forceAuthn=true&s=ccentral-cima&r=comcast.net" \
-d "continue=https://customer.comcast.com/Secure/Home.aspx" \
https://login.comcast.net/login | tee one.html | \
grep cima\.ticket | \
sed -e 's/.*cima.ticket" value="\([^"]*\).*$/\1/')
[ $? -eq 0 ] || bail "could not login and grab the ticket" $?
curl -s \
--user-agent "${AGENT}" \
--cookie-jar cjar \
--cookie cjar \
--location \
--referer "https://customer.comcast.com/Secure/Home.aspx;auto" \
--data-urlencode "cima.ticket=${ticket}" \
"https://customer.comcast.com/Secure/Home.aspx" > /dev/null
[ $? -eq 0 ] || bail "could not post the ticket" $?
usage=$(curl -s \
--user-agent "${AGENT}" \
--cookie-jar cjar \
--cookie cjar \
--location \
--referer "https://customer.comcast.com/Secure/Home.aspx;auto" \
https://customer.comcast.com/Secure/Users.aspx | \
grep "GB of" | sed 's/^[^>]*>\([^<]*\)<.*$/\1/')
[ $? -eq 0 ] || bail "could not find the usage" $?
echo "usage: ${usage}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment