Created
May 9, 2021 18:44
-
-
Save castironclay/7db9c53347e001785592069c87caf528 to your computer and use it in GitHub Desktop.
Check SMS messages, validate phone number, then run command
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/bash | |
APPROVED_SOURCES=(+18008675309) | |
SOURCE=$(curl -X $'GET' -H $'Host: 192.168.0.1' -H $'Referer: http://192.168.0.1/index.html' -H $'Connection: close' $'http://192.168.0.1/goform/goform_get_cmd_process?isTest=false&cmd=sms_data_total&page=0&data_per_page=500&mem_store=1&tags=10&order_by=order+by+id+desc&_=1620342672308' | jq -r .messages[0].number) | |
COMMAND=$(curl -X $'GET' -H $'Host: 192.168.0.1' -H $'Referer: http://192.168.0.1/index.html' -H $'Connection: close' $'http://192.168.0.1/goform/goform_get_cmd_process?isTest=false&cmd=sms_data_total&page=0&data_per_page=500&mem_store=1&tags=10&order_by=order+by+id+desc&_=1620342672308' | jq -r .messages[0].content | awk -F "" '{print $4}') | |
#SOURCE CHECK | |
if [[ "${APPROVED_SOURCES[@]}" =~ "${SOURCE}" ]]; then | |
if [[ "${COMMAND}" =~ "1" ]]; then | |
systemctl start wg-quick@wg0 | |
fi | |
if [[ "${COMMAND}" =~ "2" ]]; then | |
systemctl stop wg-quick@wg0 | |
fi | |
fi | |
if [[ ! "${APPROVED_SOURCES[@]}" =~ "${SOURCE}" ]]; then | |
exit 1 | |
fi | |
#MESSAGE CLEANUP COMMANDS | |
until curl -X $'GET' -H $'Host: 192.168.0.1' -H $'Referer: http://192.168.0.1/index.html' -H $'Connection: close' $'http://192.168.0.1/goform/goform_get_cmd_process?isTest=false&cmd=sms_data_total&page=0&data_per_page=500&mem_store=1&tags=10&order_by=order+by+id+desc&_=1620342672308' | grep id > /dev/null 2>&1; do sleep 1; done | |
sleep 3 | |
MESSAGEID=$(curl -X $'GET' -H $'Host: 192.168.0.1' -H $'Referer: http://192.168.0.1/index.html' -H $'Connection: close' $'http://192.168.0.1/goform/goform_get_cmd_process?isTest=false&cmd=sms_data_total&page=0&data_per_page=500&mem_store=1&tags=10&order_by=order+by+id+desc&_=1620342672308' | jq -r .messages[0].id)"%3B" | |
sleep 3 | |
# Delete messages | |
curl -i -s -k -X $'POST' \ | |
-H $'Host: 192.168.0.1' \ | |
-H $'Origin: http://192.168.0.1' \ | |
-H $'Referer: http://192.168.0.1/index.html' \ | |
-H $'Connection: close' \ | |
--data-binary $'isTest=false&goformId=DELETE_SMS¬Callback=true' \ | |
--data-binary msg_id=$MESSAGEID \ | |
$'http://192.168.0.1/goform/goform_set_cmd_process' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modify APPROVED_SOURCES to be an array of any approved cell numbers.