Skip to content

Instantly share code, notes, and snippets.

@xyntrix
Last active February 9, 2021 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xyntrix/0168179789615537a337fca06da53fe8 to your computer and use it in GitHub Desktop.
Save xyntrix/0168179789615537a337fca06da53fe8 to your computer and use it in GitHub Desktop.
#!/bin/sh
# cmcurl: curl shell wrapper to access Arris cable modems on Cox's network
# author: Jan-30-2021, xyntrix@bitz.org
# license: Apache License, Version 2.0
# license-text: https://www.apache.org/licenses/LICENSE-2.0
# intent: Cox Communications installed new firmware on my CPE without notice
# (as usual). This broke my automated modem status gathering. Wrote
# this simple shell script to process curl GETS to my cable modem
# requires: curl (and the right password)
# other-notes: arris cert is very expired/invalid.. why even bother with tls?
HASCURL=$(which curl 2>&1 > /dev/null)
if [ ${?} -ne 0 ]; then
echo "Please install curl."
exit 1
fi
# cox arris sb8200 cable modem login script
# set following vars to override
# CMLOGIN: always(?) admin
# CMPASS: last 8 digits of serial number (case-sensitive) on modem
# sticker (NOT mac address)
# CMIP: always(?) 192.168.100.1
# CMURI: uri to access. usually:
# cm(connectionstatus,eventlog,configuration,
# address,swinfo,statushelp).html
# CMAUTHURI: uri that provides cred response.. seems to only be this
# page that parses the auth
# CMPORT: incase this ever changes? otherwise always tcp/443 (disabled for now)
# ;append to $CMURL
[ -z "${CMLOGIN}" ] && CMLOGIN="admin"
[ -z "${CMPASS}" ] && CMPASS="OMGSECRET111ONE!!1one1!"
[ -z "${CMIP}" ] && CMIP="192.168.100.1"
[ -z "${CMURI}" ] && CMURI="cmconnectionstatus.html"
[ -z "${CMAUTHURI}" ] && CMAUTHURI="cmconnectionstatus.html"
[ ! -z "${CMPORT}" ] && CMIP="${CMIP}:${CMPORT}"
CMURL="https://${CMIP}"
# Create basic auth base64 string of user:pass
AUTH=$(echo -n ${CMLOGIN}:${CMPASS}|base64 -w0)
# send auth as header and as part of uri (weird scheme.. but ok), must go through $CMAUTHURI page
CREDS=$(curl -sk -H "Authorization: Basic ${AUTH}" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" ${CMURL}/${CMAUTHURI}?${AUTH})
if [ $? -ne 0 ] || [ ${#CREDS} -gt 40 ]; then
echo "Error getting creds cookie from: https://${CMIP}/${CMAUTHURI} (${CMLOGIN})"
exit 1
fi
# now pass creds cookie we received along to GET
# note: this redirects stderr to stdout because i parse it from stdout
curl -sk --cookie "credential=${CREDS}" ${CMURL}/${CMURI} 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment