Last active
January 15, 2021 09:20
-
-
Save av01d/940a498063427975616d22dc91401cda to your computer and use it in GitHub Desktop.
Commandline Bash script for retrieving connected clients from cable modem/router Compal CH7465LG (Ziggo)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
#-------------------------------------------------------------------- | |
# This script retrieves a list (in XML format) of connected clients | |
# on a Compal CH7465LG modem/router. | |
# This modem is provided by various ISPs, a.o: | |
# - UPC Connect Box (CH) | |
# - Irish Virgin Media Super Hub 3.0 (IE) | |
# - Ziggo Connectbox (NL) | |
# - Unitymedia Connect Box (DE) | |
# | |
#### | |
# License: Freeware | |
# Author: Arjan Haverkamp (arjan at webgear dot nl) | |
# Date: 2021-01-08 | |
#-------------------------------------------------------------------- | |
### | |
### Configuration | |
### | |
host='192.168.1.1' | |
password='Password' | |
cookieFile='/tmp/cookies.txt' | |
### | |
### End of configuration | |
### | |
token='' | |
userAgent='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36' | |
output=$(curl -s \ | |
--head \ | |
--cookie $cookieFile \ | |
--cookie-jar $cookieFile \ | |
"-A '$userAgent'" \ | |
"http://$host/common_page/login.html" | |
) | |
if [[ $output =~ sessionToken=([0-9]+) ]]; then | |
token=${BASH_REMATCH[1]} | |
fi | |
output=$(curl -i -s \ | |
--cookie $cookieFile \ | |
--cookie-jar $cookieFile \ | |
"-A '$userAgent'" \ | |
-d "token=$token&fun=15&Username=NULL&Password=$password" \ | |
"http://$host/xml/setter.xml" | |
) | |
if [[ $output =~ sessionToken=([0-9]+) ]]; then | |
token=${BASH_REMATCH[1]} | |
fi | |
output=$(curl -s \ | |
--cookie $cookieFile \ | |
--cookie-jar $cookieFile \ | |
"-A '$userAgent'" \ | |
-d "token=$token&fun=123" \ | |
"http://$host/xml/getter.xml" | |
) | |
# Finally: logout | |
curl -s \ | |
--cookie $cookieFile \ | |
--cookie-jar $cookieFile \ | |
"-A '$userAgent'" \ | |
-d "token=$token&fun=16" \ | |
"http://$host/xml/setter.xml" | |
/bin/rm -f $cookieFile | |
echo $output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment