scripts/sms_sender.sh

43 lines
1.1 KiB
Bash
Raw Normal View History

2024-02-05 10:02:13 +01:00
#!/bin/sh
num=${1:-"+33614495846"}
msg="${2}"
tim=$(date "+%Y,%m,%d,%H,%M,%S")
nonce=$(curl -s 'http://192.168.0.1/cgi-bin/qcmap_auth' \
--data '{"module":"authenticator","action":0}'|jq '.nonce'|tr -d '\"')
digest=$(printf 'admin:admin:%s' $nonce|md5sum|cut -d' ' -f1)
json=$(printf '{"module":"authenticator","action":1,"digest":"%s"}' $digest);
token=$(curl -s 'http://192.168.0.1/cgi-bin/qcmap_auth' \
--data "${json}"|jq '.token'|tr -d '"')
num=${1:-"+33614495846"}
msg="${2:-"Hello, World!"}"
tim=$(date "+%Y,%m,%d,%H,%M,%S")
tmp=$(mktemp)
cat << EOF > $tmp
{"token":"${token}", \
"module":"message", \
"action":3, \
"sendMessage":{"to":"${num}", \
"textContent":"$(cat ${msg})", \
"sendTime":"${tim}"}}
EOF
curl -qs 'http://192.168.0.1/cgi-bin/qcmap_web_cgi' \
-H "Cookie: tpweb_token=${token}" \
--data @$tmp && echo "Trying to send message"
RES=-1
read json << EOF
{"token":"${token}","module":"message","action":7}
EOF
while [ "$RES" -lt 0 ];
do
RES=$(curl -s 'http://192.168.0.1/cgi-bin/qcmap_web_cgi' \
-H "Cookie: tpweb_token=${token}" \
--data "$json" \
| jq '.result')
sleep 2;
done;
rm $tmp;
exit 0;