Last active
April 17, 2017 19:02
-
-
Save vsivsi/fbaf31106ce82c73456c97b0c10b7e34 to your computer and use it in GitHub Desktop.
Grab event and log data from a Cyperpower UPS with RMCARD205 installed
This file contains 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/sh | |
# Note that this script may fail if there are multiple copies running at the same time | |
# Or if a person is logged into the device Web Management UI | |
# It should recover on future runs once the contention is released | |
# Default read only user/pass | |
export CPWUSER=device | |
export CPWPASS=cyber | |
# Default IP address | |
export UPSIP=129.168.10.134 | |
# All HTTP headers are dumped, omit "-D -" to suppress | |
curl -D - "http://$UPSIP/login_pass.cgi?username=$CPWUSER&password=$CPWPASS&action=LOGIN" | |
curl -D - -c cookiejar.txt "http://$UPSIP/login_pass.html" | |
curl -b cookiejar.txt -D - "http://$UPSIP/login_counter.html?stap=1" | |
curl -b cookiejar.txt -D - "http://$UPSIP/login_counter.html?stap=2" | |
sleep 1 # This seems to occasionally help | |
curl -b cookiejar.txt -D - "http://$UPSIP/login_counter.html?stap=2" | |
curl -b cookiejar.txt -D - "http://$UPSIP/login.cgi?action=LOGIN" | |
# HTTP headers are written to the top of these files, omit "-D -" to suppress | |
curl -b cookiejar.txt -D - "http://$UPSIP/get_eventLog.cgi" > eventLog.txt | |
curl -b cookiejar.txt -D - "http://$UPSIP/get_dataRec.cgi" > dataLog.txt | |
# This is necessary or future auth attempts will be locked out until some timeout | |
curl -b cookiejar.txt -D - "http://$UPSIP/logout.html" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment