Sending SMS messages via bash script using a Huawei E8372 hilink

大城市里の小女人 提交于 2019-12-06 05:02:05

Got it! You have to pass the SESSION_ID cookie to /api/webserver/sesTokInfo to get a new TOKEN (TokInfo) - this replaces the /api/webserver/token call from previous versions of the firmware. So once logged in,

the below gets a new token, stored as ADM_TOKEN

curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" \
 -H "Cookie: $SESSION_ID" > ses_tok2.xml
ADM_TOKEN=`grep "TokInfo" ses_tok2.xml | cut -b 10-41`

and you can then use that ADM_TOKEN to run the next command

curl -v http://192.168.8.1/api/sms/send-sms \
 -H "Cookie: $SESSION_ID" \
 -H "__RequestVerificationToken: $ADM_TOKEN" \
 -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" \
 -H "Accept: */*" \
 -H "Referer: http://192.168.8.1/html/smsinbox.html" \
 -H 'X-Requested-With: XMLHttpRequest' \
 -H "Connection: keep-alive" \
 -H "Origin: http://192.168.8.1" \
 --data $message_data \
 --dump-header send_result.txt

it looks like every command you want to run you have to first get a new token

If you want to log to your modem you have to manipulate your code a little bit more than a simple base64. this is what I found : usually the password is "admin" so I'll start with this.

psd = sha256("admin");
psd = b64(psd);
psd = name + psd + token;
psd = sha256(psd);
psd = b64(psd); 

I took a lot of time to find this on my own project. And now you can log correctly to your E8372.
I hope that will be helpful for someone else.

PS: name is usually "admin" too. And sha256 is an hash method you can find this really easily.

Edit: this answer is not for all type of password, I saw it after you use the type 3 in your question. this response is for the type 4. I think that can still help someone else.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!