ysard / mi_remote_database

Proof of concept aiming to reproduce and query the infrared code database (IRDB) used by the Xiaomi *Mi Remote* application.
GNU Affero General Public License v3.0
47 stars 8 forks source link

Could not pull Set-top box devices data #1

Closed shamin closed 1 year ago

shamin commented 2 years ago

First of all, Thanks for the amazing project.

I was trying to pull Set-top box devices data using your dump_database function. But it is always giving me an empty data

'{"status":0,"encoding":"UTF-8","language":"zh_CN","data":[]}'

Then I went through your code and found out the TODO you have added at https://github.com/ysard/mi_remote_database/blob/master/src/xiaomi_query.py#L212

I would like to know if there is anyway I can pull in the Set-top box devices data from the mi api. Any help would be much appreciated.

ysard commented 1 year ago

Hello, sorry for the response time. From what I remember, the program uses a different branch of code for this type of device. For lack of time, because this type of device was in the minority and because it was not my goal at the time, I was not interested in it.

There should be at least an example of the URL used to start a reversing of this part of the program.

In the meantime I will add a line to inform the user that this type is not supported, so others won't be unpleasantly surprised like you were.

shamin commented 1 year ago

@ysard Thanks for the update. Actually I was able to fetch the STB data from the mi api, forgot to update it here.

I followed your tutorial, and with some help with Wireshark, I was able to pull the data. Your code was helpful in decoding the IR data.

There are the API's I used to pull the STB data. Might be useful for someone else trying to do the same.

https://i2-urc.io.mi.com/controller/device/1?version=6329&country=IN&ts=1667318141899&nonce=-1171209548&opaque=ee48b71c1b3d5d866a1586ca0fc56823f54a7d9f

https://i2-urc.io.mi.com/controller/stb/lineup/match/1?version=6329&country=IN&ts=1667318148341&nonce=871222104&opaque=c9f3ffc28ac586207772e11bcd909ead2b339f3a

https://i2-urc.io.mi.com/controller/code/1?version=6329&country=IN&ts=1667318737889&nonce=-573423170&matchid=xm_2_1489&vendor=mi&opaque=3c1350bce46e508ef5fa3fe96a0a6a8bdd5ee78e

https://i2-urc.io.mi.com/controller/report/1?version=6329&country=IN&ts=1667318740316&nonce=-756289397&opaque=80b68462fd59142c4e884d524e9060ccc89950a6

https://i2-urc.io.mi.com/controller/match/tree/1?version=6329&country=IN&ts=1667318152151&nonce=-20782770&devid=2&miyk=1&spid=in100&power=1&opaque=5a31c79439f2314a2ff935fd852eb5172c9316ed

Thanks for the project again. Feel free to close the issue.

ysard commented 1 year ago

Ok, thank you, I have an error with the opaque param for the /controller/report/ url. Maybe it is not a very important url...

I suppose that the main urls are match, code & device.

shamin commented 1 year ago

Yeah, You don't need the report. I think it was just to check the status of api. It is not working for me also now.

These is the flow.

ysard commented 1 year ago

Thanks, so spid replaces brandid in the match url, and stb url replaces the brand url used for all the other devices.

I will try to update the code for that when I will have the time :p

ysard commented 1 year ago

Ok it's done; 117 more unique patterns. I will add dumped files later in the release page. These devices are only for India, no data for the other countries :o

shamin commented 1 year ago

That is a great news. Thanks for doing it. You have an amazing project. :)

MasterKia commented 1 year ago

It's indeed an amazing project. As Richard Stallman has always said, reverse engineering is the biggest contribution in the Free Software community.

Only if I had the knowledge to turn this into a free/libre Android application ...

Biswa96 commented 11 months ago

The set-top box links got simpler in newer version.

https://us-urc.io.mi.com/app/public/get_stb_brand?data={"country":"ID"}
https://us-urc.io.mi.com/app/public/get_stb_match?data={"country":"US","brandid":12}
https://us-urc.io.mi.com/app/public/get_stb_keyset?data={"id":"kk_2_12_114"}