Skip to content

Instantly share code, notes, and snippets.

@marcinantkiewicz
Last active January 5, 2022 00:42
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 marcinantkiewicz/72363bf899ad33b322f439537d805497 to your computer and use it in GitHub Desktop.
Save marcinantkiewicz/72363bf899ad33b322f439537d805497 to your computer and use it in GitHub Desktop.
#! /bin/sh
# +---------------------------------
# Enter madtown pw: dd
# Sanity check:
# default iface en0
# mac_addr 0c:e4:41:d9:63:89
# ip_addr 192.168.1.202
#
# Type Y to proceed.
# y
# curl -H X-JNAP-Action: http://cisco.com/jnap/guestnetwork/Authenticate --data {"macAddress":"","ipAddress":"","password":"dd"} -X POST http://192.168.3.1:10080/JNAP/
# + --------------------------------
DEF_IFACE="$(route -n get default | awk '/interface/{print $2}')"
MAC_ADDR="$(ifconfig $DEF_IFACE | awk '/ether/{print $2}')"
IP_ADDR="$(ifconfig $DEF_IFACE | awk '/inet / {print $2}')"
if [ -z "${MADTOWN_PASS}" ]
then
echo -n "Enter madtown pw: "
read MADTOWN_PASS
fi
echo -e "Sanity check:\n\tdefault iface $DEF_IFACE\n\tmac_addr $MAC_ADDR\n\tip_addr $IP_ADDR\n"
echo "Type Y to proceed."
read PROCEED
# https://stackoverflow.com/questions/226703/how-do-i-prompt-for-yes-no-cancel-input-in-a-linux-shell-script/27875395#27875395
if [ "$PROCEED" != "${PROCEED#[yY]}" ]
then
curl -H "X-JNAP-Action: http://cisco.com/jnap/guestnetwork/Authenticate" --data "{\"macAddress\":\"$MAC_ADDR\",\"ipAddress\":\"$IP_ADDR\",\"password\":\"${MADTOWN_PASS}\"}" -X POST http://192.168.3.1:10080/JNAP/
else
echo "aborted"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment