Jutta-Proto / protocol-cpp

C++ JURA protocol implementation for controlling a Jura coffee maker over a serial (UART) connection.
GNU General Public License v3.0
63 stars 6 forks source link

Protocol for new Machines #2

Open BNoiZe opened 2 years ago

BNoiZe commented 2 years ago

Hallo,

nicht direkt ein Bug, mehr ein Kontaktversuch bzw. Diskussion.

Es sieht aus als wären die Befehle mit neueren Maschinen wieder geändert worden. Selbst besitze ich eine ENA 8 mit Touchdisplay. Ich hab schon einiges aufgefangen vom Bluetooth-Dongle. Befehle wie "TY:" funktionieren noch immer. Auch das Auslesen von Statistiken funktioniert noch gleich.

Geändert hat sich offenbar wie die Zubereitung von Kaffee angestoßen wird. Die Befehle die der Dongle dabei an die Maschine sendet machen für mich absolut keinen Sinn wenn ich sie mit bekannten Befehlen vergleiche.

Hast du den Code schon mit neueren Maschinen probiert?

COM8 commented 2 years ago

Ich habe aktuell nur Zugriff zu einer Jura E6. Es könnte gut sein, dass es daran liegt, dass ich mit 'FA:04' einfach nur den Knopfdruck simuliere. Wenn jetzt die Maschine aber keine Knöpfe hat, ist das vermutlich nicht verfügbar. Wenn du einen Bluetooth Dongle hast, sollten die Befehle immer noch darüber funktionieren, da ich hier einfach alles über die "machinefiles" übersetze, die von JURA „veröffentlicht“ werden.

===

I currently only have access to a Jura E6. It could well be that it is because I simply simulate the button pressure with 'FA:04'. But now if the machine has no buttons, that's probably not available. If you have a Bluetooth dongle, the commands should still work through it, as I'm simply translating everything here via the "machinefiles" that are "published" by JURA.

BNoiZe commented 2 years ago

Die Befehle wie FA:04 habe ich schon probiert und dabei passiert bei der Maschine nichts. Wie du schon sagst, keine Knöpfe und deshalb vermutlich nicht verfügbar. Ich habe beide Dongles. Vom Wi-Fi Dongle konnte ich einen Firmware-Dump anlegen, hatte die Hoffnung daraus das aktuelle Protokoll zu finden. Leider funktioniert der Wi-Fi Dongle nicht mit der ENA 8... Der Wi-Fi Dongle basiert auf einem ESP32, lässt sich also leicht selbst programmieren. Mein Ziel wäre es den Wi-Fi Dongle als Schnittstelle zu verwenden um auch ohne die App Kaffee zubereiten zu können. Vielleicht doch nochmal versuchen die Wi-Fi Firmware zu reversen.

===

I have already tried the commands like FA:04 and nothing happens with the machine. As you say, no buttons and therefore probably not available. I have both dongles. From the Wi-Fi dongle I was able to create a firmware dump, had hope to find from it the current protocol. Unfortunately, the Wi-Fi dongle does not work with the ENA 8.... The Wi-Fi dongle is based on an ESP32, so it is easy to program it yourself. My goal would be to use the Wi-Fi dongle as an interface to make coffee without the app. Maybe another try to reverse engineer the W-Fi firmware.

ralmulle commented 2 years ago

Hallo Zusammen, ich versuche mich auch gerade an dem Serial to Jura Protokoll. Danke erstmal für deine tolle arbeit COM8. Ich habe da nun das gleiche Problem wie BNoiZe. "TY:" und das auslesen der statisiken funktioniert. Nur das zubereiten von Kaffee will nicht (z.b. FA:04). Ich besitze eine Jura E8 und diese hat 6 Tasten! Einen Dongle hab ich mir noch nicht zugelegt, da ich alles über einen ESP8266 machen wollte. @BNoiZe: Könntest Du mit evtl. ein paar Befehle die beim zubereiten von Kaffee von Dongle zur Maschine geschickt werden zur Verfügung stellen? Danke Schön.

COM8 commented 2 years ago

Die Befehle wie FA:04 habe ich schon probiert und dabei passiert bei der Maschine nichts. Wie du schon sagst, keine Knöpfe und deshalb vermutlich nicht verfügbar. Ich habe beide Dongles. Vom Wi-Fi Dongle konnte ich einen Firmware-Dump anlegen, hatte die Hoffnung daraus das aktuelle Protokoll zu finden. Leider funktioniert der Wi-Fi Dongle nicht mit der ENA 8... Der Wi-Fi Dongle basiert auf einem ESP32, lässt sich also leicht selbst programmieren. Mein Ziel wäre es den Wi-Fi Dongle als Schnittstelle zu verwenden um auch ohne die App Kaffee zubereiten zu können. Vielleicht doch nochmal versuchen die Wi-Fi Firmware zu reversen.

===

I have already tried the commands like FA:04 and nothing happens with the machine. As you say, no buttons and therefore probably not available. I have both dongles. From the Wi-Fi dongle I was able to create a firmware dump, had hope to find from it the current protocol. Unfortunately, the Wi-Fi dongle does not work with the ENA 8.... The Wi-Fi dongle is based on an ESP32, so it is easy to program it yourself. My goal would be to use the Wi-Fi dongle as an interface to make coffee without the app. Maybe another try to reverse engineer the W-Fi firmware.

Bekommst du ein ok: als Antwort zurück wenn du z.B. FA:04 an deine Maschiene sendest? Alternativ kannst du auch mal einkleines skript schreiben und nacheinander von FA:00 bis FA:FF alle Befehle an die Maschiene senden und schauen was passiert. So bin ich auf die Befehle gekommen.

Ja, das mit dem ESP32 habe ich auch schon hinbekommen. Hast du hier auch direkt Kabel an den ESP32 gelötet, oder gibt es da einen bessern Weg? Ich habe zwar die Debug-Pads gesehen, konnte sie aber nicht ordentlich zuordnen. wifi_dongle_esp32

Als kleiner Spoiler, im Image steht darüber nichts, da hier der Kaffee über eine zweite ebene "obfuscation" geordert wird nachdem der Dogle sich authentifiziert hat: https://github.com/Jutta-Proto/protocol-cpp/blob/main/protocol_snoops/keyexchange.md

=== Do you get an ok: as response when you send e.g. FA:04 to your machine? Alternatively you can write a small script and send all commands from FA:00 to FA:FF to the machine and see what happens. That's how I got the commands.

Yes, I have already managed that with the ESP32. Did you solder cables directly to the ESP32, or is there a better way? I did see the debug pads, but couldn't map them properly.

As a small spoiler, there is nothing about this in the image, as here the coffee is ordered via a second level "obfuscation" after the dogle has authenticated itself:
BNoiZe commented 2 years ago

@BNoiZe: Könntest Du mit evtl. ein paar Befehle die beim zubereiten von Kaffee von Dongle zur Maschine geschickt werden zur Verfügung stellen? Danke Schön.

Sobald meine Frau die Steckdose bei der Kaffeemaschine wieder frei gibt kann ich gerne ein paar Kaffees zubereiten. Vielleicht finden wir ja doch irgendwie raus wie man den Kaffee direkt starten kann ohne das Drücken von Tasten zu simulieren.

===

As soon as my wife releases the socket at the coffee machine I can prepare a few coffees. Maybe we can somehow figure out how to start the coffee directly without simulating the pressing of buttons.

BNoiZe commented 2 years ago

@COM8 Kann ich tatsächlich aus dem Kopf heraus nicht sagen. Muss ich nochmal austesten ob ein "ok" retour kommt. Soweit ich mich erinnere passiert aber einfach nichts. Auch kein "ok". Ich hab schon eine Befehle als Stichprobe getestet, Kaffee kommt dabei aber keine zustande.

Die Testpads konnte ich zuordnen. Habe den ESP32 über diese auch geflasht.

Wenn im Dongle nochmal eine Obfuscation stattfindet, dann sollte es ja möglich sein auf die Ursprungsbefehle zu schließen? Hast du es geschafft die Firmware vom ESP32 zu reversen?

===

I can not actually tell from memory. I must test again whether an "ok" comes back. As far as I remember nothing happens. No "ok" either. I have already tested random commands, but no coffee.

I was able to assign the test pads. I also flashed the ESP32 using them.

If in the dongle again an obfuscation takes place, then it should be possible to determine the original commands? Did you manage to reverse the firmware of the ESP32?

COM8 commented 2 years ago

Problem ist, der Handshake, den ich hier beschreibe findet nur garantiert beim Bluetooth-Dongle statt. Da meine Maschiene auch kein Support für den WiFi-Dongle hat kann ich da nicht wirklich snoopen (klar ich könnte eine dummy-Maschiene bauen indem ich mit einem ESP das simuliere und dann schauen was passiert). Bisher bin ich aber daran gescheitert aus den Daten irgendeinen Sinn zu machen, was danach kommt. Hier ein paar Snoops: https://github.com/Jutta-Proto/protocol-cpp/tree/main/protocol_snoops

Ja, die ESP32-Firmware ist nicht verschlüsselt und kann somit einfach analysiert werden. Das habe ich auch schon bei den ganzen Strings gemacht, die in der Binary zu finden sind (Binwalk). Weiter bin ich aber bisher noch nicht gegangen, da ich gerade daran Arbeite das dumpen zu dokumentieren.

Darf ich dein Bild von der Platine hier verwenden?

Auch die Firmware von Bluetooth-Dongle kann gedumpt werden, da bin ich aber gerade noch dran mich ein zu lesen, da ich mit diesem Microcontroller noch nie gearbeitet habe.

===

Problem is, the handshake I describe here is only guaranteed to happen with the Bluetooth dongle. Since my machine also has no support for the WiFi dongle I can't really snoop there (sure I could build a dummy machine by simulating it with an ESP and then see what happens). But so far I failed to make any sense out of the data what comes after. Here are a few snoops: https://github.com/Jutta-Proto/protocol-cpp/tree/main/protocol_snoops

Yes, the ESP32 firmware is not encrypted, so it can be easily analyzed. I already did that with all the strings that can be found in the binary (Binwalk). But I haven't gone further yet, because I'm working on documenting the dumping.

May I use your picture of the board here?

Also the firmware of the bluetooth dongle can be dumped, but I am still reading up on it, because I have never worked with this microcontroller.

BNoiZe commented 2 years ago

Ich vermute mal, dass die Kommunikation zwischen Bluetooth- bzw. WiFi-Dongle und Maschine wohl die gleiche sein wird. Die Snoops sehen bei mir auch so aus, auch mir erschließt sich die Logik dahinter noch nicht.

binwalk hab ich auch schon drüber laufen lassen. Sitze im Moment vor Ghidra und versuche zu verstehen was ich da sehe. Bin mir aber nicht sicher ob der dump den ich habe vollständig ist... Muss sagen, dass ich mich vorher noch nie mit Reverse Engineering beschäftigt habe.

Bild gerne verwenden.

Kann man dich irgendwo anders auch noch antreffen? Discord oder dergleichen?

===

I assume that the communication between the Bluetooth or WiFi dongle and the machine will be the same. The snoops seem the same on my machine, but I also don't understand the logic behind it yet.

I have also run binwalk over it. At the moment I'm sitting in front of Ghidra and trying to understand what I see. But I am not sure if the dump I have is complete... Must say that I have never dealt with reverse engineering before.

Feel free to use image.

Is there anywhere else you can be contacted? Discord or something like that?

BNoiZe commented 2 years ago
[D] b'&\x18\xe9\x9e\x8c\xc9\x92\x17\xcd"\xe2\xef\xd3I\xc6Sf\xec\xce\x0fzoo\x1b\xa6\x9ct\xff\xae\xa8#\x89\xc6\x1b\x9biF\xc4\r\n'
[D] b'&X\x1c\x8dB\xe8\xcd\x0f\x19\xba\xd3N\xc6Wf\xec\xe2\xefzgo.\x9cy\xce\x08\xa8#\x89\xc6\x1b\x9bi\xff\xae\xaf \r\n'
[D] b'&~g\xdae\xe5\xde\x92\xfcG\xc9\xb8\x97\x1c*E\x1a\xa8\xe6X\xbbB\xff\x07\xd2T\xf1\xed\xec\x97{ZG|\xcf\xf5\r\n'
[D] b'&\x8a\x9bk\xcb\xd1\xc1\xb7\x9bH\x06r\xa5Wx\x87n\x15\xdd\xa4A\xad\x04Z\x8a\x82q\x0f\x0el\x1a\xf9t\xa6u\xf3\r\n'
[D] b'&\x1f5\x96\x18\xcc\xb8e\x14*\x0b\xd2T\xeeV\xbbB\xffZF|\xf1\xed\xe5\x97{\x8f\xc1\x8e\x17y\x18\x86^\xbaY\r\n'

Five times hot water. Five times a different command sent from the dongle to the machine.

BNoiZe commented 2 years ago

@ralmulle https://github.com/BNoiZe/jura-esp32-connect/blob/main/protocol_snoops/connect_and_hot_water.txt

Connecting is like we know it. Looks like all things after T3 are somehow encrypted. As soon as the device disconnects from bluetooth there is now more output from dongle/machine. One thing all messages have in common is the & at the beginning and \r\n as end.

ralmulle commented 2 years ago

Thank you for the byte sequences. If I only send "FA:xx" nothing comes back from the coffee machine. As soon as I perform a key exanche, the coffee machine responds with an undefinable byte message. I think it's not so easy to decipher the algorithm used by Jura. I also find it strange that different messages were always sent to the coffee machine to make hot water. Tomorrow I would do a "FA:xx" Loop from 00 to FF with and without key exanche.

COM8 commented 2 years ago

I assume that the communication between the Bluetooth or WiFi dongle and the machine will be the same. The snoops seem the same on my machine, but I also don't understand the logic behind it yet.

I have also run binwalk over it. At the moment I'm sitting in front of Ghidra and trying to understand what I see. But I am not sure if the dump I have is complete... Must say that I have never dealt with reverse engineering before.

Feel free to use image.

Is there anywhere else you can be contacted? Discord or something like that?

I have a bit of basic knowledge about the tools used for such jobs, but nothing too fancy here.

Sure we could open a chat room on Matrix (@ga87qip:tum.de) or XMPP (com8@xmpp.uwpx.org). I don't have a discord account right now. Do you have a Matrix or XMPP account?

COM8 commented 2 years ago
[D] b'&\x18\xe9\x9e\x8c\xc9\x92\x17\xcd"\xe2\xef\xd3I\xc6Sf\xec\xce\x0fzoo\x1b\xa6\x9ct\xff\xae\xa8#\x89\xc6\x1b\x9biF\xc4\r\n'
[D] b'&X\x1c\x8dB\xe8\xcd\x0f\x19\xba\xd3N\xc6Wf\xec\xe2\xefzgo.\x9cy\xce\x08\xa8#\x89\xc6\x1b\x9bi\xff\xae\xaf \r\n'
[D] b'&~g\xdae\xe5\xde\x92\xfcG\xc9\xb8\x97\x1c*E\x1a\xa8\xe6X\xbbB\xff\x07\xd2T\xf1\xed\xec\x97{ZG|\xcf\xf5\r\n'
[D] b'&\x8a\x9bk\xcb\xd1\xc1\xb7\x9bH\x06r\xa5Wx\x87n\x15\xdd\xa4A\xad\x04Z\x8a\x82q\x0f\x0el\x1a\xf9t\xa6u\xf3\r\n'
[D] b'&\x1f5\x96\x18\xcc\xb8e\x14*\x0b\xd2T\xeeV\xbbB\xffZF|\xf1\xed\xe5\x97{\x8f\xc1\x8e\x17y\x18\x86^\xbaY\r\n'

Five times hot water. Five times a different command sent from the dongle to the machine.

Yes, that's exactly what I've been scratching my head about for almost half a year so far. Does the handshake look the same for you like described here. Especially the @T2 and @t2 messages.

BNoiZe commented 2 years ago

Currently looking into getting an XMPP account or installing Matrix.

Yes, that's exactly what I've been scratching my head about for almost half a year so far. Does the handshake look the same for you like described here. Especially the @T2 and @t2 messages.

The process for the handshake is the same, but the keys and version are different.

[M] @T2:81C001B228
[D] @t2:8180000000
[M] @T3:3BEBEF1012M V01.02
ralmulle commented 2 years ago

Nearly the same: [M] @T2:01C041B628 [D] @t2:8180000000 [M] @T3:3BE8EF538M V01.08

ralmulle commented 2 years ago

As already expected, was the FA:xx loop from 00 to FF without any result. Without handshake there was no response. With handshake only undifined responses comes back.

p47-6 commented 2 years ago

Has there been any progress on this topic ? I've got an E8 (AB) with bluetooth and wanted switch over to wifi just to figure out that my coffe machine is to old to support wifi. So i also started with dumping firmware and trying to figure out how to get around this issue. The problem is that i'm not somebody who ever did reverse engineering on such kind of things so i'm now sitting in front of Ghidra and have no idea what i'm seeing here.

BNoiZe commented 2 years ago

We have a reversed version of the bluetooth firmware. There is some kind of disc encryption in place. Currently no working communication. Only garbage available.

COM8 commented 2 years ago

That's basically what is happening: https://github.com/Jutta-Proto/protocol-cpp/blob/29823beddc30c0dede352b25dd81aec68d5f77d2/src/test_exec/handshake_test.cpp#L75-L121

But the result does not work. I'd say since the first byte always changes in the encrypted message and in the unencrypted one it's always '@', the handshake has an influence here and acts as a "salt" or some kind of counter.

If you want, I can give you read access to the ghidra repo, so you can have a look at the stuff we already figured out.

p47-6 commented 2 years ago

If you want, I can give you read access to the ghidra repo, so you can have a look at the stuff we already figured out.

That would be nice, just to have a look.

I've lost a little bit track on wich bit of communication this happens. The communication between WIFI <-> Coffe Maker and BLE <-> Coffe Maker should be the same, or do i miss something here ? The communication between App <-> WIFI and BLE <-> Wifi Could be different. So where exactly does this "encryption" happens ? My goal currently is to bring my "old / unsupported" coffe machine up to wifi (mqtt if possible) and the esp32 based wifi stick seems perfect for this. If the app then works also this would be the optimal solution but i rather take one step after the other.

Has somebody ever ask Jura if they can give us any information on this ? Maybe they are happy to see their stuff integrated elsewhere.

COM8 commented 2 years ago

Yes, I was in contact with JURA and this was the reply:

[...]
Thank you for the request.
The commands are secret and therefore encrypted.
No information is given to the outside in this regard.
[...]

The communication between App <--> BT-Dongle is already cracked and can be found here: https://github.com/Jutta-Proto/protocol-bt-cpp

This is for the communication between CoffeeMaker <--> BT-Dongle, basically the UART based connection.

If you want to make your "old" coffee maker WiFi ready, you can use the library provided here if you are happy with the commands in this list: https://github.com/Jutta-Proto/protocol-cpp#available-commands

Here you can find an example implementation: https://github.com/Jutta-Proto/gtk-ui/tree/serial

If you want even more, we have to get around the second level of encryption for advanced commands. That's what we are currently working on.

COM8 commented 2 years ago

@p47-6 Do you have a Matrix account? In case you can contact me there (@ga87qip:tum.de), so I can give you access to it. If not, you can also simply drop me a mail (jutta@uwpx.org).

NicolaiLolansen commented 2 years ago

Just wanted to chime in on this interesting discussion. We have a Jura X9C Pro and have sucessfully "made coffee" using the FA:0X commands. I think on our machine it simulates the "wheel" menu, but it skips the double doses (like 2 espressi). Reading the sensors seems really difficult, and we have not made any progress here.

COM8 commented 2 years ago

This is something I can confirm. For me I can not make 2 espressi. I always defaults back to a regular coffee.

NicolaiLolansen commented 2 years ago

We can make all the drinks, just cycling the FA:XX commands. We also found commands for "infinite milk foam" which doesnt seem super practical. But if you make any progress on the sensor output, that would be really useful knowledge.

rmeekers commented 1 year ago

any updates on this? I have a Z10 with a WiFi Connect dongle and I would like to integrate it to Home Assistant through ESPHome.

bischoffjeremy commented 1 year ago

any progress with wifi?

COM8 commented 1 year ago

Nope, sadly not from my side @bischoffjeremy since I changed my job and now don't have access to a JURA coffee maker any more.

FriedCheese2006 commented 1 year ago

I'm trying to resurrect all this. I've done a full packet capture on the network traffic between the app and wifi dongle; hoping it may help shed some light.

https://github.com/Jutta-Proto/protocol-cpp/discussions/5#discussioncomment-6714572

8818freak commented 11 months ago

@COM8 Was meinst Du mit: "Wenn du einen Bluetooth Dongle hast, sollten die Befehle immer noch darüber funktionieren, da ich hier einfach alles über die "machinefiles" übersetze, die von JURA „veröffentlicht“ werden."

genauer: "machinefiles"?

COM8 commented 11 months ago

Wilkommen @8818freak 🎉 ! Wenn man die Android-App Dekompiliert findet man dort die ominösen "machinefiles". Das sind XML-Dateien, die das Interface zur Kaffeemaschiene für den BT-Dongle definieren. Mehr dazu hier: https://github.com/Jutta-Proto/gtk-ui#machine-files

====

Welcome @8818freak 🎉 ! If you decompile the Android app you will find the ominous "machinefiles". These are XML files that define the interface to the coffee machine for the BT dongle. More about this here: https://github.com/Jutta-Proto/gtk-ui#machine-files

8818freak commented 11 months ago

Ah, ok. Die SW gab es damals noch nicht. Irgendwie hatte ich gehofft, Du hättest mit der Serviceanimation "gespielt". Die enthält sehr viel mehr Informationen zu den Maschinen. Mit ihr lassen sich ALLE Jura-Maschinen reparieren, mit neuen Daten versehen und zum Teil auch programmieren.

COM8 commented 11 months ago

Oh, ja. Dieses Rabbit Hole bin ich auch schon runter gegangen. Aber ich habe da nichts weiteres herausgefunden, wie den Testmode, wo man alle Buttons etc. testen kann.

8818freak commented 11 months ago

Was meinst Du damit?

COM8 commented 11 months ago

AN:20 setzt die Maschiene in einen Testmode, wo ein Techniker alle Buttons, Schalter etc. testen kann und immer ein OK\r\n zurück kommt, sollte etwas erkannt worden sein.

Beim bruteforcen von Kommandos bin ich aber auch schon einmal in einem Menü gelandet, wo auf dem Display stand "Programming...". Das konnte ich aber leider nicht mehr reproduzieren.

====

AN:20 puts the machine into a test mode, where a technician can test all buttons, switches etc. and always gets an OK\r\n back, if something was detected.

When bruteforcing commands, I also ended up in a menu where the display said "Programming...". Unfortunately I could not reproduce this.

8818freak commented 11 months ago

Ah, ok. Es gibt auch einen Display- und und einen LED- Test. Aber Einstellungen werden Ausschließlich im Kundenmenü oder mit der Serviceanimation über die serielle Schnittstelle vorgenommen, ebenso das Laden von Updates oder neuen Parametern, beispielsweise für Anpassungen von Heizkurven, Pumpensteuerung, Trester-Mengen, minimale und maximale Mahlwerkslaufzeiten, Vorbrühen ein, aus, Vorbrühdauer, Funktionen der Tasten bei den Profimaschinen, Kolbenhübe je Taste....

RacoJo commented 10 months ago

Very strange that on my E6 (2023), none of the FA:XX FN:XX is working. Is it other codes for 2023 machines ?

8de2fdb0 commented 4 months ago

@COM8 could i get access to the hidra repo see: https://github.com/Jutta-Proto/protocol-cpp/issues/2#issuecomment-1116959928

I am trying to figure out the disc encryption.

COM8 commented 4 months ago

@8de2fdb0 sure. Please send a mail to jutta (at) uwpx.org