-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SRP is not implemented (required for Remote Engine Start / HVAC) #404
Comments
After numerous fails I've finally sniffed the traffic from the official MyRenault app on android, and I see that there is POST to ../actions/engine-start endpoint instead of hvac-start, and the payload is also different from hvac-start. It does not have a temperature in it (in my car the temp is always defaulted to 21, that's probably the reason it is not passed to this endpoint) but has some srp hash or smth like that. There is also POST to ../actions/srp-sets before that, and a number of GET requests, mostly for notifications around that time. If I got it right from the source code fragments of the app, the SRP also somehow includes the pin code set during pairing of the app/account to the car. |
The joys of the Renault API May I suggest that you first look at #48 to add some fixtures for the Duster? |
Here is the carGateway response for the new duster car with certain felds obfuscated:
|
Here is the vehicle fixture:
|
Hi @epenet , sorry for late response, but I'm back now. I've shared the carGateway response above, and also the fixture for my car. Also to add details on the communications to start the engine:
These 3 steps happen every time. I also found that SRP support exists in https://github.com/mitchellrj/kamereon-python/blob/146904802301aa0b0008e2bdb3a88ed10ff50acf/kamereon/kamereon.py though not sure if it is finilized. |
Hi @FRSTR did you manage to work out how SRP works? |
Hi @epenet Yes, kinda. The SRP is a special standard protocol that is used to authenticate when the communication channel is not trusted. There are also several implementations in python, e.g. here a random repo I just found - https://github.com/cocagne/pysrp The overall idea of SRP communication is the following:
|
How much effort are you willing to put into this? |
@epenet yeah, I can sniff the stuff and try to test builds on my side, I'm just not really a developer to write python code (at least I still don't really get the OOP structure of the code in this repo). Indeed there is some personal info in the sniffs so we better communicate somewhere else, e.g. email as you said. I also opened the Android app code to try figure our how it works, but again a good architecture instead of spaghetti makes it hard for me to get what's going on there. Though I can share pages from there if you'd like. So as the first step, you'd want the full communication with SRP for the engine start flow, right? The sniffer I used is not friendly so it will take some time to capture full flow, but I'll start work on that today. |
@epenet I've just sent you an email with the sniff |
@FRSTR |
@jumpjack: as I have already requested, can you please stop spamming? You can already run all debug commands within the renault api like this: |
@jumpjack , I don't want to share those traces as they have personal info and it takes quite some time to clear them out. If you have a tool, you can also sniff it with your car as the faulty module in the car does not affect anything in the app communication except for the final result being failure. |
Hi @epenet . Just wanted to double check with you if you plan any work there. I have a daily need to at least lock the car via API or app, and I'm thinking if we proceed here or it may be faster for me to invest time into android app automation on my own. |
I'll try to have a fresh look before the end of the month - but not sure when. |
btw, @epenet I found this library for SRP, and it seems that generating SRP requests could as simple as the example on the readme page - https://github.com/cocagne/pysrp If the SRP part gets implemented, it can also be used to lock the car, from what I remember the process was very similar. |
Before it can be added to HomeAssistant, it needs to be exposed by the RenaultVehicle class:
Is that something you feel you could do? I have been busy these past weeks inside HA, and this week I refactored a few chunks to make way for the Dacia Spring features that @lucviala created PRs for. |
Note: adding the lock status should be much easier than implementating adding SRP as the framework is already there... |
@epenet but it is already there in renault-api/src/renault_api/renault_vehicle.py : Or by expose you mean there should be some other structures? I'm sorry, I'm not fully familiar with the way it works. However if there is an example of another function I can use and just do the same - I can try to replicate it for the lock status |
Ah... the fixture file is empty, and so is the corresponding model. renault-api/src/renault_api/kamereon/models.py Lines 379 to 383 in 680cd5a
If you update the fixture file with real data, and adjust the KamereonVehicleLockStatusData data class it should be straightforward to then add to HA. |
Ok. let me see If I can figure this out. |
And one more file to adjust afterwards: the tests to ensure we parse the data correctly. |
In my tests with my app I get the usual "403 forbidden" response. status": "502", |
@jumpjack you get this error for which request? |
for the last one you are talking about, lock-status. |
')
Where? On android, version 4.26.0 has no pin request for hvac, just a button. |
Different cars apparently make it different. My car basically starts its gasoline engine to do the job, and I guess it requires some level of security. Presumably for e-cars, hvac is considered less severe thing and thus does not require anything like that. Though if I'm not mistaken, the PIN code was required at the step of pairing the app with the EasyLink media in car. |
when I brought my plugin captur to the dealer last week, because preconditioning is no more working since 6 months, during the diagnosis he detected a "missing pin" error, but he was surprises and not able to explain it... so he just ignored it. |
Out of interest, does the hvac-status endpoint work on the Captur? renault-api/src/renault_api/kamereon/models.py Lines 57 to 59 in 933b200
|
@epenet on the main topic of this issue ticket: I created a proof of concept for Engine Start wtih SRP, and it goes throught the entire flow using renault-api cli, but...
So not even sure what can be done there further :( |
It's hard to discuss without seeing the code - maybe you can create a draft PR to show how much you managed to implement. |
Remote activation of HVAC on my captur is broken since August 2021; I brought the car to dealer 6 times and I had SW updated and some HW replaced, but it is still not working. :-( (which is why I started studying unofficial apps and methods to remotely activate HVAC). But I read that several people have broken remote HVAC on their Captur since december 2021, I guess something is going wrong at Renault. I wonder if they messed up and mixed up Dacia/Renault SW, because my dealer recorded a "missing pin" while performing electronic diagnosis on my Captur, but there is no place where to write any pin in app for the Captur! |
No, UserId is different than PersonId and AccountId! Anyway I see also:
|
well, UserId is what I called it. I also thought that it might be the Kamereon ID of the user, which is 5 digits, or smth like that. |
After digging up my old code... JWT response:
personId response:
accountId response:
VIN response:
And don't forget that also VIN is called "id" in the responses: { |
Another clue is that for Dacia users the PIN required to remotely control the HVAC is the one provided by the car at first pairing with the cellphone. |
I just tried wtih kmrUserId, it produced the same result. The reason I tried it is that in the final response it is provided by the server, plus in some other Renault API implementatin I saw they tried to use there. |
@epenet do you happen to know what url we can use for renault to get similar info as in the code below?
this is from https://github.com/wobniarin/HEMS_API/blob/main/HEMS_API/nissanapi.py I think this user id can be used in srp, and my guess is that it is different from those I tried |
@jumpjack isn't it just a root hostname? in that php implementation there does not seem to be a user-adapter available. I tried to run renault-app by adding "/users/current" to couple different paths that came to mind, but it did not work |
Yes, I didn't notice the slightly different url...
We could try some combinations/variants of these:
|
@FRSTR you should use the sniffing tools that you previously used to confirm. |
Well, I'm not sure this username is even sent to server, because the server already knows who we are when we are logged in. In srp-sets the request body included "i" param which is gigya ID, and maybe it is there for this purpose, but not sure. |
Maybe sniffing traffic of this Nissan app can help reversing engineering the SRP protocol? But I don't know if it also works for Leaf.
|
Sniffing won't help, the SRP protocol was created to stand against MITM attacks in the first place. Except for SRP part, other communications with the server are clear, and it is all about the implementation of SRP plus some of its variables. I've looked into the Android app, and all those things are hidden in native library. |
Just in case, I looked into the NIssan's app, and they simply use Renault's implementation and library as is. |
Where you also able to see how it uses endpoints for horns, lights and doors locking? |
I used HttpCanary (this is one of debug proxy apps), though I had to use rooted Android with certain tricks and make the SSL certificate from HttpCanary trusted in Android. Otherwise HTTPS sniffing did not work for me. |
and what did you see? |
I looked into the things related to engine start and door locks. The lock-status endpoint is for doors, and it is already in the source code of this python project. You can take a look into the tests to see its response format. The engine start routine is in the SRP sample I posted to the other PR. |
Originally this issue was posted to Home Assistant integration, but it is also reproduced via renault-api CLI.
On an attempt to start AC in the NEW DUSTER car, the 403 error is returned. At the same time it works ok via MyRenault android app.
At the same time renault-api CLI provides the car status correctly (mileage, fuel, GPS).
Debug log:
Note: MyRenault app requires a PIN code set in the app to start AC, could it be required in the API and thus not working there?
The text was updated successfully, but these errors were encountered: