Salamek / huawei-lte-api-ts

API For huawei LAN/WAN LTE Modems written in TypeScript
GNU Lesser General Public License v3.0
48 stars 19 forks source link

3372h-320 (send-sms) seems like it needs encryption?? #15

Closed grawsom closed 2 years ago

grawsom commented 2 years ago

Why I'm writing here is because I wanted to use the 3372 in Node-red, and this one have made a Node-red package that uses you API - but.

Seems like the 3372h-320 need some encryption when doing some sms stuff, for me it's send-sms.

Maybe this one could help, because the send-sms works with this package, and what I can see is that in the source is some <nonce>${encrpt}</nonce> after date in the URL when calling the API.

If I can help some way in testing with my device I'm here :-)

Salamek commented 2 years ago

@grawsom well we do support encrypted requests for some endpoints, see:

https://github.com/Salamek/huawei-lte-api/blob/214ddbf4f756f45ca6e9a1e8226de3be879d0ed1/huawei_lte_api/api/DialUp.py#L41-L46

So you may try to modify https://github.com/Salamek/huawei-lte-api/blob/214ddbf4f756f45ca6e9a1e8226de3be879d0ed1/huawei_lte_api/api/Sms.py#L85 to use is_encrypted=True and try if that changes anything...

And looks like this is related to https://github.com/Salamek/huawei-lte-api-ts ? i did not implement encryption there yet, so pls try it with this library, and if it works i will port it to TS version.

grawsom commented 2 years ago

I'm not that well in i py (not a programmer), but I will try to see if I can get some stuff running. :-)

grawsom commented 2 years ago

SUCCES :-) I did this in windows, but are going to try this on my pi, hopefully tomorrow, as I said I'm no programmer, but Google is my friend. Installed python 3, did the pip install as described in Readme, then used the send_sms from examples with correct data, and I got "SMS was send succesfully" - and of cause also received on phone. And did not change anything in the files regarding is_encrypted=True

Don't know yet if I can use the py API with modules in Node-Red, but else will I be waiting for the port to TS/js. So now I can continue my project, and also maybe "zinen" that made the node-red package will happy to.

Salamek commented 2 years ago

@grawsom so this library works for you without any mods?

grawsom commented 2 years ago

@Salamek Yes, and I have also just tested on a clean Raspberry installed with (bullseye v. 11) - did test it with the send_sms.py, and device_info.py and working just fine - so looking forward to the TS update :-)

Salamek commented 2 years ago

@grawsom ok, that is great and weird since huawei-lte-api-ts should be working for you too (sms code logic should be identical just written in different language)

grawsom commented 2 years ago

@Salamek do we have examples in the TS package as in the Python package, maybe I could start there and not what I get from the other - maybe my script was wrong.

Salamek commented 2 years ago

@grawsom i have added some examples to TS version just for you see https://github.com/Salamek/huawei-lte-api-ts/tree/master/examples

grawsom commented 2 years ago

@Salamek Device_info.js is working fine, but still get an error with the send_sms.js I did put in some console.log for argument [2], [3] and [4], so I was sure of the parsing. Here is log output Ready http://admin:admin@192.168.8.1/ +45XXXXXXXX (replaced my phonenumber with XX) Hello world ResponseErrorException: 100005: Unknown at new ResponseErrorException (/home/pi/.node-red/node_modules/huawei-lte-api/dist/exceptions.js:20:28) at Connection.checkResponseStatus (/home/pi/.node-red/node_modules/huawei-lte-api/dist/Connection.js:157:19) at /home/pi/.node-red/node_modules/huawei-lte-api/dist/Connection.js:296:54 at processTicksAndRejections (internal/process/task_queues.js:95:5) { code: 100005

Salamek commented 2 years ago

@grawsom hmm there must be something different in request data that your router does no like...

I have tested what is the difference between Python and TypeScript version:

TypeScript

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<request>
  <Index>-1</Index>
  <Phones>
    <Phone>+420XXXXXXXXX</Phone>
  </Phones>
  <Sca/>
  <Content>Ahoj2</Content>
  <Length>5</Length>
  <Reserved>1</Reserved>
  <Date>2021-12-20 16:25:22</Date>
</request>

Python

<?xml version="1.0" encoding="utf-8"?>
<request>
  <Index>-1</Index>
  <Phones>
    <Phone>+420XXXXXXXXX</Phone>
  </Phones>
  <Sca></Sca>
  <Content>Ahoj2</Content>
  <Length>5</Length>
  <Reserved>1</Reserved>
  <Date>2021-12-20 19:01:33</Date>
</request>

So, as you can see there is difference in how Sca is handled and some data added in XML header... since Huawei XML parser is shitty AF, it is possible that this is our issue... so lets try to first change Sca

So pls, update to huawei-lte-api-ts 0.0.8 and try again

grawsom commented 2 years ago

@Salamek I have now tested on windows and raspberry - with no luck. I also played with wireshark to see differences, and I don't think it's the xml header, more to belive the way with credintials.

I have saved files from wireshark, maybe you can get some out of them.

CENSORED URL

I also found an script that works, see if can help someway.

script.zip

Salamek commented 2 years ago

@grawsom try 0.0.9 pls

grawsom commented 2 years ago

@Salamek Sorry - No change. Here is the output Ready ResponseErrorException: 100005: Unknown at new ResponseErrorException (C:\Users\ivans\.node-red\node_modules\huawei-lte-api\dist\exceptions.js:22:28) at Connection.checkResponseStatus (C:\Users\ivans\.node-red\node_modules\huawei-lte-api\dist\Connection.js:168:19) at C:\Users\ivans\.node-red\node_modules\huawei-lte-api\dist\Connection.js:308:54 at processTicksAndRejections (node:internal/process/task_queues:96:5) { code: 100005 }

I have again made some wireshark saves, (send_sms.js, device_info.js) and the working sh script (script.sh) 0.0.9.zip

Salamek commented 2 years ago

@grawsom #17 by @icetee fixes this issue, just tested on my 3372h-320 (i remembered i have like a week ago lol) So pls install 0.0.10 to test