Skip to content

Instantly share code, notes, and snippets.

@castironclay
Last active August 26, 2021 21:26
Show Gist options
  • Save castironclay/2dbab92454a6545dc91e7dbe77c323fb to your computer and use it in GitHub Desktop.
Save castironclay/2dbab92454a6545dc91e7dbe77c323fb to your computer and use it in GitHub Desktop.
GL-MiFi commands
# Get admin token
SERVER_IP=X.X.X.X
PASS=root_password
TARGET_NUMBER=number_without_country_code
WIREGUARD_SERVER=Home
TOKEN=$(curl -s -k -X POST --data-binary pwd=${PASS} "https://${SERVER_IP}/cgi-bin/api/router/login" | jq -r .token)
echo $TOKEN
# List messages
curl -s -k -X POST -H "Authorization: ${TOKEN}" -b "Admin-Token=${TOKEN}" --data-binary modem_id=3 "https://${SERVER_IP}/cgi-bin/api/modem/sms/list" | jq -r '.messages[0]' > message.json
FROM=$(cat message.json | jq -r .from)
ID=$(cat message.json | jq -r .name)
BODY=$(cat message.json | jq -r .body)
echo $FROM $ID $BODY
# Delete all messages
curl -s -k -X POST -H "Authorization: ${TOKEN}" -b "Admin-Token=${TOKEN}" --data-binary "modem_id" "https://${SERVER_IP}/cgi-bin/api/modem/sms/delete_all"
# Send a message
MSG="bofa"
curl -s -k -X POST -H "Authorization: ${TOKEN}" -b "Admin-Token=${TOKEN}" --data-binary "modem_id=3&number=%2B1${TARGET_NUMBER}&message=${MSG}" "https://${SERVER_IP}/cgi-bin/api/modem/sms/send"
# Start wireguard
curl -s -k -X POST -H "Authorization: ${TOKEN}" -b "Admin-Token=${TOKEN}" --data-binary "name=${WIREGUARD_SERVER}&restart=false" "https://${SERVER_IP}/cgi-bin/api/wireguard/client/start" | jq -r .
# Stop wireguard?
curl -s -k -X GET -H "Authorization: ${TOKEN}" -b "Admin-Token=${TOKEN}" "https://${SERVER_IP}/cgi-bin/api/wireguard/client/stop" | jq -r .
# Wireguard Status
curl -s -k -X GET -H "Authorization: ${TOKEN}" -b "Admin-Token=${TOKEN}" "https://${SERVER_IP}/cgi-bin/api/wireguard/client/status" | jq -r .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment