WEBVTT

00:00.000 --> 00:05.360
My talk is about flashing ECU firmware updates from a web browser.

00:05.480 --> 00:13.260
More specifically, I did some reverse engineering of the Honda firmware update file format that they put out.

00:13.460 --> 00:15.180
So that's what I'm going to be talking about.

00:15.820 --> 00:16.700
So, who am I?

00:16.700 --> 00:18.220
My name is Greg Hogan.

00:18.820 --> 00:20.800
You can follow me on Twitter.

00:21.100 --> 00:24.640
All the source code for the software that I'm going to show you is open source.

00:24.640 --> 00:27.920
You can find it in one or more of my GitHub repositories.

00:27.920 --> 00:31.540
And I work at Comet AI on infrastructure.

00:31.540 --> 00:34.980
Which, yes, if you're wondering, that has nothing to do with car hacking.

00:36.400 --> 00:41.120
So, a couple days ago, I got an email.

00:41.180 --> 00:43.880
And it said Defcon 27 talk.

00:43.880 --> 00:48.580
And I thought, oh, this is information on my speaking gig here.

00:48.620 --> 00:52.740
I open up the email, and no, it is from Honda.

00:52.780 --> 00:55.460
So apparently they were interested in my talk.

00:55.460 --> 00:57.680
And I'll summarize this for you.

00:57.680 --> 01:01.580
It basically says, don't do something that might kill somebody.

01:02.140 --> 01:03.920
That was never my intention.

01:04.220 --> 01:16.700
I won't be... for some reason they thought that I was probably going to be releasing specific modifications about making firmware modifications to power steering controllers of Honda vehicles.

01:16.700 --> 01:18.400
That's not the case.

01:18.400 --> 01:21.020
I never planned on talking about anything like that.

01:21.020 --> 01:23.920
So that doesn't change anything that I'm going to be talking about.

01:23.920 --> 01:27.860
Also, this is a completely legitimate thing to ask of someone.

01:27.900 --> 01:31.060
To make sure you don't do something that could injure somebody.

01:31.060 --> 01:39.060
And I agree completely that trying to make changes to your electronic power steering firmware of your car could be very dangerous.

01:39.340 --> 01:45.400
If you screw something up, the best case might be that the steering wheel tries to break your arms.

01:45.400 --> 01:49.560
And the worst case is it'll flip over your car and kill you.

01:49.560 --> 01:52.200
So, please don't do anything stupid.

01:52.200 --> 01:56.940
And I have no intention of enabling you to be able to do such things.

01:58.140 --> 02:02.340
What got me interested in flashing ECU firmware updates?

02:02.820 --> 02:09.660
So, in 2017, George Hotz, he's actually the guy that started the company that I work for.

02:09.660 --> 02:19.920
He gave a talk at Code Blue at a conference where he kind of showed some information about how you can get these firmware updates from different vehicle manufacturers.

02:19.920 --> 02:25.380
And I looked at these tools that he was showing and I thought, wow, that software is garbage.

02:26.200 --> 02:31.900
It looks like it runs on Windows XP and why hasn't anyone created anything better?

02:32.700 --> 02:36.500
So, that's kind of what I set out to do.

02:40.320 --> 02:51.040
And I guess to do that, to enable that in a modern web development stack, that's why I decided to see if I could make this work where I could flash ECUs from web browsers.

02:52.280 --> 03:05.760
It's basically, what I'm going to show you how to do is basically similar to what like, there's a whole community of people who go out there and they make changes to do like engine tuning for their ECUs, change like gas fuel mixtures and stuff like that.

03:06.100 --> 03:08.340
They've basically done what I'm going to show you.

03:08.340 --> 03:15.480
They've figured out, you know, how the firmware updates work for, in what I'm going to show you here, Honda vehicles.

03:15.580 --> 03:23.520
And then they figure out how to flash their own firmware updates, essentially, without using the Honda software to do so that they distribute.

03:29.740 --> 03:36.400
So, how do you get the software and firmware updates for these vehicles?

03:36.400 --> 04:00.380
So, thanks to Right to Repair, vehicle manufacturers are basically required to provide, at a reasonable cost, the firmware updates for the tools basically that enable any maintenance shop to be able to do repair work so that you're not like locked into going to a Honda dealership and then like charging you an arm and a leg to do this kind of stuff.

04:00.380 --> 04:06.580
So, anyone can sign up for these websites.

04:06.580 --> 04:24.060
Honda is really cheap, $10 for one day to download the software that they provide to their repair shops and anyone who's like, you know, a repair shop that repairs Honda vehicles, they'll subscribe to this also.

04:24.180 --> 04:27.660
If you subscribe for one day, interestingly, you actually get three days.

04:28.540 --> 04:34.280
So, Toyota's a little more expensive and, you know, there's other vehicle manufacturers.

04:34.280 --> 04:44.660
Well, I guess just one that does like over-the-air updates and you don't have, you know, if you have the right access to your car, the firmware updates are actually pushed to your vehicle so you don't have to like pay to get them.

04:46.680 --> 04:57.640
So, I signed up and I downloaded the software and I wish I could get that four hours of my life back that it took to install it.

04:58.260 --> 05:02.880
It's horrible, just like from a UI perspective, usability perspective.

05:02.880 --> 05:04.520
It's not great software.

05:05.520 --> 05:08.100
The authentication is over HTTP.

05:08.160 --> 05:12.860
Like, nobody's proud of themselves for like working on this software, I don't think.

05:12.880 --> 05:14.960
This is the new version.

05:14.960 --> 05:20.660
This is new for like, I think like 2017 model year vehicles or something like that.

05:20.660 --> 05:22.980
The old version looked even sadder.

05:23.140 --> 05:24.880
It's called HDS for Honda.

05:24.880 --> 05:26.920
It's Honda Diagnostic System.

05:26.920 --> 05:31.100
In 2017, when this new version came out, they threw an I in the front of it.

05:31.100 --> 05:37.520
My guess is they're like trying to ride the Apple train, you know, bandwagon or something like iOS and so forth.

05:37.520 --> 05:41.880
But using this software is nothing like using an Apple product.

05:42.400 --> 05:47.200
You also need a piece of hardware to interface with the car through the ODB2 port.

05:47.200 --> 05:57.640
So, that hardware, if you go to the Honda website, there's one like certified hardware package that you can buy.

05:57.640 --> 05:59.880
And it is almost $1500.

06:01.280 --> 06:10.600
That's sad because it just does like stuff that follows specifications that are open, you know, that anyone can implement because of right to repair, basically.

06:12.720 --> 06:22.520
So, one of those boxes on like that first window was something called the J2534 rewrite tool.

06:22.520 --> 06:23.520
So, what is that thing?

06:23.520 --> 06:29.700
That's the software that actually does the firmware updates, that actually flashes your ECUs.

06:30.440 --> 06:37.880
So, the company I work for, they actually make an OBD2 dongle that has a USB port called a Panda.

06:37.880 --> 06:42.680
And it's a lot cheaper than the $1500 product that Honda sells.

06:42.820 --> 06:52.900
It has an open source J2534 driver, which is basically the API that like the whatever for like emissions testing and so forth.

06:52.900 --> 06:57.260
They defined it so that, you know, to enable right to repair, essentially.

06:58.520 --> 07:03.680
And the driver, like it's not perfect, but it at least works for CAN.

07:03.680 --> 07:09.260
And so, I decided to go down this path since it's so much more cost effective.

07:09.260 --> 07:17.860
And the Panda has, it has a great Python library for interacting with your vehicle over the OBD2 port.

07:18.160 --> 07:22.440
And someone wrote a web USB driver for it.

07:22.720 --> 07:29.910
So, I'll get into that a little bit more, but that's a big part of what enables me being able to flash an ECU from a web browser.

07:31.530 --> 07:41.790
So, that four hours that I spent installing the software on a really fast machine, another thing that it drops alongside this executable is the actual firmware updates.

07:42.030 --> 07:45.290
So, that's how you get the actual firmware update files.

07:45.470 --> 07:49.010
And they're in this folder here that I listed at the bottom.

07:51.390 --> 07:55.870
So, okay, now we've got a flashing tool and we've got firmware updates.

07:55.870 --> 08:06.350
So, now what we want to do is we want to reverse engineer, you know, whatever the process is, so that I can replicate it and build my own software that actually does this.

08:06.350 --> 08:13.110
So, the first thing that I found was this software called J2534 Logger.

08:13.410 --> 08:21.490
Basically, what that does is it acts as a proxy to a real J2534 driver.

08:21.490 --> 08:30.930
The J2534 spec, so part of the reason that this software, I guess I didn't mention this, this Honda software, it only runs on Windows.

08:31.010 --> 08:44.390
And the reason that it only runs on Windows is because the J2534 API specifies things like, use these registry keys to find a DLL and load it.

08:44.390 --> 08:50.910
So, that's another reason that I was interested in creating my own software that flashes this.

08:50.910 --> 08:57.030
Because, you know, if you break out of that, you can, you know, make something that's like cross-platform that runs on a web browser, which would be cool.

08:58.070 --> 09:08.390
So, basically, you can fire up that J2534 rewrite tool that Honda puts out and fire up this, install this logger.

09:08.390 --> 09:16.570
And if you have a vehicle that has an ECU that has an update, you can apply it yourself with this software and you can record it.

09:16.590 --> 09:26.530
And it'll dump out this big log file that has all the J2534 API calls, as well as, like, the raw data that was sent and received back and forth.

09:26.530 --> 09:39.770
So, then, to, you know, kind of dig deeper into what the actual steps are that happen when you flash a Honda ECU firmware update, we need to start understanding some of these other specs.

09:40.750 --> 09:44.450
UDS, Unified Diagnostics, that's, like, a big one.

09:44.450 --> 09:55.270
It has all the, like, commands that J2534 uses to actually communicate with the ECU, make it through, like, security access key exchange and all these things, and send the firmware.

09:55.270 --> 09:58.290
The next layer down is ISOTP.

09:58.310 --> 10:12.190
I'm basically just mentioning these things because this is what I have to implement if I'm going to implement my own in a web browser because, as far as I know, no one has written one in JavaScript.

10:15.350 --> 10:17.270
All right.

10:17.270 --> 10:27.440
So, after recording flashing an ECU from that J2534 rewrite tool that Honda distributes, here's what you come up with.

10:28.260 --> 10:33.360
It's basically more or less an eight-step process here.

10:34.100 --> 10:43.360
The first thing that you have to do is you have to... these are all... the names on the right are the UDS message types, essentially, that you have to send to communicate with your car.

10:44.360 --> 11:00.200
So, basically, you need to enter... you need to send a session control message because you can't request a security access seed until you've gotten into that specific diagnostic session mode.

11:00.200 --> 11:02.360
Once you get there, you can request a seed.

11:03.120 --> 11:07.860
You'll then see the seed go back to the software.

11:07.900 --> 11:17.660
Software then does a manipulation to that seed, sends back a key, and that key is what allows you to do the next step, which is enter a programming session.

11:17.860 --> 11:19.200
So, this is what we want to get to, right?

11:19.200 --> 11:24.440
We want to be able to... we want to get the ECU to the state where we can actually send and change the firmware on it.

11:26.320 --> 11:37.300
Then things get dangerous, like from a, oh, crap, I might brick my ECU perspective, because the next thing that you do is you erase the memory that you want to write.

11:37.900 --> 11:52.280
After you erase it, you have to send this message that is... it turns out what it is is you're sending it some keys that go to the firmware so that it can decrypt the firmware that you're going to send it.

11:52.280 --> 12:00.440
So, it turns out that these Honda firmware update files, the firmware portion of the file, they actually encrypt it.

12:01.180 --> 12:05.980
And the J2534 rewrite tool, it doesn't decrypt it.

12:05.980 --> 12:09.080
It sends it to the ECU, and then the ECU decrypts it.

12:09.080 --> 12:19.120
So, they haven't distributed, per se, any software that you can obtain that actually has the decryption algorithm in it.

12:19.120 --> 12:20.560
It's all in the ECU.

12:21.840 --> 12:28.120
Then you proceed to send the firmware, and then at the very end, it does basically checksum.

12:28.120 --> 12:34.920
You send a message that performs this validation, which I believe what it does is validates that the checksums in the firmware are correct.

12:35.280 --> 12:38.300
The checksums in the Honda firmware are extremely poor.

12:38.580 --> 12:43.700
They're actually just the sum of all the bytes across a few sections.

12:44.520 --> 12:53.800
So, I don't know, it's kind of crappy, a couple bit flips, and you might not have what you thought you had there.

12:57.380 --> 13:06.100
So, this firmware update file, I mentioned earlier on that there's a folder that gets dropped that has all these firmware update files in it.

13:06.100 --> 13:29.060
And those firmware update files have a certain format that I'm now going to go through and explain what the different pieces are, because my ultimate goal here is to create a website that I choose one of these firmware update files, and I then flash it to an ECU as if I was that J2534 rewrite tool,

13:29.060 --> 13:32.540
but without any software written by Honda.

13:33.320 --> 13:38.140
So, the very first byte of the file is what I call the signature.

13:38.140 --> 13:41.240
It basically tells you the format of the rest of the file.

13:41.240 --> 13:42.580
There's a few different formats.

13:42.580 --> 13:46.140
I'm just going to focus on one, because I only care about one, which is CAN.

13:46.380 --> 13:51.140
There's also other formats, I think, where you flash over LIN or other protocols.

13:51.180 --> 13:58.020
But I'm just going to focus on CAN, because that's probably the future, at least for any vehicle that I'm going to own.

13:59.460 --> 14:03.080
So CAN is this hex 5A value.

14:03.960 --> 14:14.640
Alright, so now the next section, after that first byte, now we're in the CAN-specific format of the firmware update, and there's six header fields.

14:14.640 --> 14:45.960
These six header fields, they basically have everything that you need to be able to look at one of these firmware update files, determine if the car that you're plugged into has an ECU that a specific firmware update file applies to, and if it's running a version of firmware that is supported as an update,

14:45.960 --> 14:51.340
or if the file is an update for the version of the firmware that's on the ECU.

14:52.600 --> 14:54.320
You only need a few things.

14:54.320 --> 15:00.200
You need the CAN address of the ECU that you want to know if you can update with the specific firmware file.

15:00.200 --> 15:02.420
So there's one byte that specifies it.

15:02.420 --> 15:08.100
The reason it's a single byte is because, if you look at the spec, 29-bit addresses, there's only one significant byte.

15:08.900 --> 15:11.020
So they just have that one byte in there.

15:13.940 --> 15:15.880
Then there's a few different values.

15:15.880 --> 15:20.600
They can change these security access keys per firmware update file.

15:20.600 --> 15:27.740
So they put the actual keys in the firmware update file because you have to send them to the ECU.

15:27.740 --> 15:31.000
So when the ECU receives the firmware, it knows how to decrypt it.

15:32.680 --> 15:43.020
And then there's also a key that I'll get into in a minute here that is an input to the security access key exchange.

15:43.020 --> 15:49.020
So what you need to do to get that ECU into programming mode, essentially.

15:52.420 --> 15:55.860
After the headers is the actual firmware.

15:55.860 --> 15:58.800
This is the encrypted firmware that I talked about before.

15:59.260 --> 16:01.760
There's a start address and a length.

16:04.360 --> 16:14.940
That sequence that I laid out, a couple of the steps were saying, okay, what section of firmware do I want to flash on the ECU and how much data am I now going to send?

16:14.940 --> 16:19.700
That's part of that UDS sequence of messages that you have to send to the ECU.

16:20.660 --> 16:26.980
The Honda ECUs I've looked at, they actually only allow you to flash one section of the firmware.

16:26.980 --> 16:37.840
They did a pretty good job in terms of making it kind of hard to brick the device because the bootloader is outside of the area that they allow you to flash.

16:37.900 --> 16:40.240
So that's good.

16:41.840 --> 16:44.060
But yeah, the state is encrypted.

16:44.060 --> 16:47.020
So we can't really look at the firmware at this point.

16:48.580 --> 16:52.500
And then at the end of the file is a checksum.

16:52.500 --> 16:57.140
And it's just the sum of all the bytes except the checksum itself.

16:57.740 --> 17:05.420
And so that is, that's the entirety of one of these CAN format Honda firmware update files.

17:06.420 --> 17:08.420
Alright, the encryption.

17:08.480 --> 17:16.320
So I mentioned that this firmware is, like the data section of the update file for the firmware is encrypted.

17:16.680 --> 17:20.460
So I thought, okay, well, it'd be interesting to see if we can decrypt that.

17:21.720 --> 17:33.220
And the talk that I mentioned at the beginning that got me kind of interested in this, George's CodeBlue talk, he shows one algorithm that they used for encryption.

17:33.500 --> 17:35.940
And I thought to myself, oh, okay, well, maybe I'm lucky.

17:35.940 --> 17:38.660
Maybe they use the same encryption for every one of these updates.

17:39.140 --> 17:40.800
Turns out that's not the case.

17:41.580 --> 17:47.980
But there's these keys that we already found in the headers of each firmware update file.

17:47.980 --> 17:50.380
So I've got the keys.

17:50.380 --> 17:51.760
I've got an example.

17:51.760 --> 17:52.720
So what should I try?

17:52.720 --> 17:55.360
Okay, well, maybe they just change the operators.

17:56.600 --> 18:00.620
It turns out, at least somewhat common, that's the case.

18:00.620 --> 18:18.840
And it's not too hard to write a piece of software in Python that just brute force tries every combination of operators that results in a full 256-value lookup table, where every value is, you know, the input is unique to the output.

18:19.500 --> 18:25.760
So utilizing that, I wrote this piece of software that I linked to at the top there called RWD X-Ray.

18:25.960 --> 18:28.780
And that, it does that, exactly.

18:28.860 --> 18:41.940
You give it a firmware update file, and it will try to find a set of operators based on the keys in the RWD file to be able to decrypt the firmware.

18:46.260 --> 18:48.760
Yeah, so that's really fast.

18:48.760 --> 18:50.400
Most of these firmware updates are small.

18:50.400 --> 18:57.500
And, yeah, it takes, like, seconds to run this through and find the appropriate operators for a lot of them.

18:57.500 --> 19:03.020
It doesn't seem to work on all of them, which makes me think that maybe they actually use, like, a different algorithm for some firmware updates.

19:03.020 --> 19:08.520
But it seems like there's a number of them that they actually use the same basic algorithm with just different operators.

19:12.840 --> 19:17.400
So this is just an example of running that tool.

19:17.400 --> 19:20.740
It just kind of ties everything together that I just talked through.

19:21.020 --> 19:24.960
It basically, you know, parses the file, spits out the headers.

19:25.820 --> 19:41.620
The way that it figures out if it has successfully decrypted the firmware is that there's a UDS message that you can send to request the software version of an ECU, to get the firmware version of an ECU.

19:41.960 --> 19:51.900
That returns something that looks like a part number for Honda with an extra few numbers at the end.

19:51.900 --> 19:58.140
All of these RWD files have a name that looks like a part number.

19:58.160 --> 20:15.900
So, what I do is I take the beginning portion of the RWD file, and I say every time I try a set of operators, do I find in the decrypted firmware a string that matches that?

20:15.900 --> 20:18.240
And normally there's just one.

20:18.920 --> 20:23.780
Down at the bottom there, all those dots, is it trying every possible set of operators that existed.

20:23.940 --> 20:35.780
And the X means it hit, and it actually found the string that it was looking for in this brute force way of going through the different possibilities of all the algorithms.

20:38.500 --> 20:42.780
And then it spits out the decrypted firmware into a file at the end.

20:44.100 --> 20:58.620
Okay, so, my goal here is to flash an ECU from a web browser, and I now completely understand this firmware update file that Honda publishes that anyone can get a hold of.

20:58.620 --> 21:04.960
It has everything in it, I guess, except the actual security access key exchange algorithm.

21:04.960 --> 21:14.920
So, now I figured out everything I need to figure out to flash an ECU myself, you know, write my own software that does it, but I don't know how to make it through the security access key exchange.

21:15.680 --> 21:35.300
The security access key exchange is okay, it generates a random two byte number, and then you have to manipulate it and send back the corresponding response that is the correct response, going, you know, after you manipulate it with the security access key exchange algorithm.

21:35.360 --> 21:37.040
But we don't know what that is.

21:37.040 --> 21:39.780
So, brute force would take a long time.

21:40.160 --> 21:52.000
It's probably actually maybe doable, but if you do it, you've now figured it out for one ECU for potentially one single firmware revision of that ECU.

21:52.040 --> 21:57.500
So, what else would have this security access key exchange that I already have access to?

21:58.180 --> 22:02.200
Well, how about that J2534 reflash tool?

22:02.200 --> 22:08.980
Turns out it's pretty easy to find the security access key exchange algorithm in that tool.

22:09.240 --> 22:25.340
And it looks like, as far as I can tell, they basically use the same algorithm to a similarly simple algorithm, just, you know, addition, multiplication, and modulo.

22:25.340 --> 22:34.540
So, basically the same algorithm, there's just, like, one variation, whether the key that's in the file is, what, four bytes or six bytes.

22:36.340 --> 22:38.040
And so, yeah, great.

22:38.080 --> 22:47.540
Now we've found how to get through the security access key exchange for probably any Honda ECU, at least that is flashed over CAN, most likely.

22:48.440 --> 22:54.120
And I guess, like, all the people that do, like, the engine tuning, the ECU tuning, I guess they all know this?

22:54.120 --> 22:54.620
I don't know.

22:54.620 --> 22:56.600
I guess it's easy to find, though.

22:56.600 --> 22:59.060
So, I guess it makes sense that they would.

23:01.080 --> 23:01.800
All right.

23:01.800 --> 23:07.360
So, I've got everything I want, or I need to know now to build this website.

23:07.360 --> 23:09.040
So I created this website.

23:09.040 --> 23:10.220
It's open source.

23:11.140 --> 23:13.400
Autoecu.io is the URL.

23:14.000 --> 23:18.640
It's the AutoECU GitHub repository that I have.

23:18.640 --> 23:20.900
It's open source.

23:20.960 --> 23:42.760
It only supports this Panda ODB2 dongle that I'm using here because I don't know any other ODB2 dongle that supports the web USB driver that Chrome has, so that you can interact with a USB device directly from a web browser.

23:42.760 --> 23:45.060
This website is just static content.

23:45.060 --> 23:47.340
Like, you don't need an internet connection to use it.

23:47.340 --> 23:48.460
There's no API.

23:48.800 --> 23:53.220
You can totally just pull down the GitHub repo and run it locally.

23:53.780 --> 23:57.860
But, you know, for convenience, I just threw it up on AutoECU.io.

24:01.160 --> 24:02.440
There are some problems.

24:02.440 --> 24:03.420
It's not perfect.

24:03.420 --> 24:10.780
This isn't, like, productionized code, so don't use it on something that you're not willing to replace if you end up bricking your ECU.

24:10.780 --> 24:31.600
I actually opened a Chrome issue because in their effort to curb people doing crypto mining in your web browsers, like through ads and so forth, they don't let tabs that are, like, in the background or don't have focus keep executing code indefinitely,

24:31.600 --> 24:34.860
or maybe they only give it, like, small time slices or something.

24:34.860 --> 24:45.840
So, like, for example, when you use this, you really want to keep the browser focused because, like, you switch tabs and then basically the flashing process pauses.

24:45.980 --> 24:48.700
So you really don't want that to happen, you know, in the middle.

24:50.640 --> 24:52.340
Generally, it's, like, it's okay.

24:52.340 --> 24:57.800
Like, if you cancel flashing one of these ECUs in the middle, you've potentially erased the ECU.

24:57.800 --> 25:07.160
But since the bootloader is at the beginning, if you haven't done anything really dumb and if you're not really unlucky, you can just cycle the power and start over and flash again.

25:07.620 --> 25:12.600
But, yeah, it's definitely possible that you'll brick an ECU if you use this.

25:14.160 --> 25:17.680
So, I have a little video here.

25:17.680 --> 25:19.660
I have a 2017 Honda CR-V.

25:19.660 --> 25:23.800
It has ECU updates for several ECUs.

25:23.800 --> 25:25.940
I'll just play this here.

25:27.040 --> 25:30.400
See if I can make it full screen here.

25:31.800 --> 25:36.840
If you watch the dash really close, things look pretty good right now.

25:36.840 --> 25:38.140
It looks normal.

25:38.240 --> 25:41.000
I'm, like, picking the firmware file right now.

25:42.620 --> 25:44.700
It does a little validation.

25:44.940 --> 25:48.040
And then I'm going to start the flashing process here.

25:48.040 --> 25:55.060
And then, holy shit, every error code possible pops up on the dash.

25:56.200 --> 25:57.780
So, I don't know if I, like, missed.

25:57.780 --> 25:58.640
Maybe I missed something.

25:58.640 --> 26:01.220
Maybe there's, like, some way to prevent that from happening.

26:01.380 --> 26:03.180
But it's kind of scary.

26:03.180 --> 26:07.080
I mean, I tested this, like, on a bench before and actually, like, had bugs in my code.

26:07.080 --> 26:14.820
Like, for example, when you plug into one ECU sitting on a bench, there's no other ECUs on the CAN bus.

26:14.820 --> 26:29.640
So, like, you can make a mistake where your software assumes accidentally that every message that's coming is intended for, you know, your software.

26:29.640 --> 26:32.940
When, you know, the ECUs are throwing messages all over the place all the time.

26:33.260 --> 26:34.800
So, luckily, that was easy to fix.

26:34.800 --> 26:39.580
And now it works better and, like, actually, this successfully flashes the ECU.

26:40.100 --> 26:41.860
Looks like it's flashing right now.

26:41.860 --> 26:43.400
Actually applying the firmware.

26:43.400 --> 26:48.440
I think this is, like, applying the radar firmware update for my car or something like that.

26:49.120 --> 26:53.920
So, I just took, you know, the RWD file.

26:53.980 --> 26:58.900
Honda names these firmware update files with .RWD as the extension.

26:59.840 --> 27:07.900
I just took that, you know, selected it in the software that I'll show you a live demo here in a minute of an ECU on a bench and picked it and flashed it.

27:07.900 --> 27:12.840
And then I just power cycled the car and all the errors went away.

27:13.100 --> 27:14.660
So, it's great.

27:14.660 --> 27:15.500
It worked.

27:20.600 --> 27:21.620
Thanks.

27:21.620 --> 27:23.600
So, that was fun.

27:24.000 --> 27:32.080
But, you know, these ECU engine tuner guys, they don't just flash the updates that they, you know, get from Honda.

27:32.080 --> 27:35.540
They reverse engineer this and they generate their own updates, right?

27:35.540 --> 27:45.600
So, wouldn't that be more fun if we, you know, we could, you know, figure out how to generate an update maybe for an ECU that doesn't even have an update and then flash that.

27:47.060 --> 27:49.640
So, you don't need a whole lot of information.

27:49.640 --> 27:52.720
You just need, you know, whatever is in that RWD file.

27:53.740 --> 27:55.440
You can just make up some keys.

27:55.720 --> 27:59.800
You do have to be able to figure out, you know, how to get firmware off of an ECU maybe.

27:59.800 --> 28:06.180
Or you could like, I guess, start with one of those RWD files if you wanted to just to play around with generating your own.

28:08.200 --> 28:11.640
And, but you got to be able to get, you know, the firmware.

28:11.640 --> 28:16.660
You have to be able to encrypt it since it's encrypted in these RWD update files.

28:16.700 --> 28:23.400
But this is actually like a pretty good format for updating an ECU because it's like self-contained.

28:23.400 --> 28:38.940
It's a self-contained file and it has everything in it you need to be able to flash an ECU, validate that, you know, the ECU that you're going to flash is running, you know, an expected version of firmware before you flash it and so forth.

28:38.940 --> 28:46.700
So , in my RWD X-Ray repo, there is a script that does just that.

28:46.700 --> 29:04.760
If you supply an encrypted firmware file like what you would find in one of the RWD files in the firmware section and the appropriate headers, then it will kick out for you an RWD file that you can flash using my website.

29:05.380 --> 29:06.140
All right.

29:06.140 --> 29:07.500
So, let's do that.

29:07.500 --> 29:16.460
I have, I just, just because out of convenience, I have an ECU here that I tore apart to play around with.

29:16.460 --> 29:24.220
And it's, you can get, for example, a lot of ECUs on, you know, like LKQ online for really cheap.

29:24.220 --> 29:31.140
This is specifically an ECU for the electronic power steering for my 2017 Honda CR-V.

29:31.140 --> 29:34.620
I'm just using it because, like, that's what I have out of convenience.

29:34.920 --> 29:37.660
So, let's, so let's do it.

29:44.020 --> 29:44.740
So, yeah.

29:44.740 --> 29:49.140
So, basically, I just, I was, I figured out how to extract the firmware from this ECU.

29:49.140 --> 29:57.480
I used that RWD builder to, what I did was just build, you know, for proof of concept, I built a firmware update that does nothing.

29:57.480 --> 30:01.240
It literally just is the original firmware on the ECU.

30:01.620 --> 30:02.620
So, that's what we're going to do.

30:02.620 --> 30:04.680
So, this is, this is my web, oh, sorry.

30:04.680 --> 30:07.120
This is my website, autoecu.io.

30:07.120 --> 30:12.000
And, right now, it has a dropdown for manufacturer.

30:12.580 --> 30:17.720
Honda is the only manufacturer that is supported, but, you know, it's open source.

30:17.720 --> 30:26.880
If someone's interested, they could, you know, definitely add formats of other firmware update files distributed by other car manufacturers.

30:27.240 --> 30:33.600
I've looked a little bit at, like, Tesla's firmware update file format, and it's, like, so much simpler than the Honda, for example.

30:33.600 --> 30:36.840
It just has, like, I think it has, like, a header that says the start address and the length.

30:36.840 --> 30:41.220
And then, it's just the firmware, just, you know, not encrypted or anything.

30:41.240 --> 30:45.920
So, you could definitely expand this, you know, if you wanted to.

30:46.200 --> 30:55.600
The other thing, too, is, like, you know, like I mentioned at the beginning, that Honda diagnostic software is so hard to use and slow and a pain to install.

30:55.760 --> 30:57.580
You can do all kinds of cool stuff with this, too, right?

30:57.580 --> 31:10.460
One of the great things about the Honda software is, like, you can get deep introspection into, if you get, like, check engine lights and so forth, what those things, you know, what are those check engine lights and being able to clear them and so forth.

31:10.460 --> 31:21.880
So, like, you could easily, you know, take this and, for example, build your own HDS that enabled you to, you know, more easily maybe clear check engine codes from a web browser.

31:21.880 --> 31:23.880
So, there's all kinds of cool stuff you can do with this.

31:23.880 --> 31:25.940
So, let me power this.

31:25.940 --> 31:27.020
It's powered on here.

31:27.020 --> 31:29.100
I don't know if anyone can really see this here.

31:29.100 --> 31:29.560
Sorry.

31:29.560 --> 31:30.780
We didn't get a table.

31:31.060 --> 31:34.340
So, this chair here is my... what's that?

31:34.880 --> 31:36.040
Oh, hey, I got a table.

31:36.040 --> 31:37.200
Let me go grab the table quick.

31:37.200 --> 31:37.820
Thanks.

32:11.070 --> 32:12.070
All right.

32:12.070 --> 32:14.870
So, maybe this setup deserves a little more explanation here.

32:14.870 --> 32:24.470
So, this doesn't really look like electronic power steering unless because it's, like, all tore apart and, like, the controller in this situation is not separate from the motor.

32:24.470 --> 32:26.790
Like, they actually put the controller in the motor.

32:26.790 --> 32:29.210
So, that's why it's, like, all tore apart and weird.

32:30.210 --> 32:35.830
I'm using one of those Panda OBD2 dongles that ComAI sells.

32:37.430 --> 32:43.630
And the red thing plugged in is just so that I have a long USB, a long enough USB cord that's called a Panda Paw.

32:43.630 --> 32:47.790
It's just in case, like, you brick your OBD2 dongle.

32:47.910 --> 32:54.570
You can actually... you actually can't really brick it because you can use this Panda Paw to get it into DFU boot mode.

32:54.570 --> 33:00.370
So, that's plugged into another thing that we sell, which you don't need by any means at all.

33:00.370 --> 33:07.730
It's just, like, a development board that breaks out the OBD2 pins really conveniently.

33:07.930 --> 33:21.490
So, I just use that to build an adapter to go from the ECU, from, like, the real ECU connector to the Panda OBD2 connector or device.

33:22.570 --> 33:23.830
So, yeah.

33:25.090 --> 33:26.870
So, all right.

33:27.130 --> 33:29.490
Let's pull up...

33:30.090 --> 33:36.630
This is my fake firmware update that is just, like, the stock firmware that I generated a file for.

33:36.630 --> 33:39.450
Because there is no firmware update for this ECU.

33:39.650 --> 33:42.650
I pick that firmware update file.

33:42.950 --> 33:44.410
And I say next.

33:44.870 --> 33:48.950
Now, this is where those headers that are in the RWD file come into play.

33:48.950 --> 33:52.290
It just went out.

33:52.290 --> 33:57.590
So, I implemented that UDS protocol in the ISOTP.

33:57.590 --> 33:59.390
I implemented it in JavaScript.

33:59.570 --> 34:04.150
You can see it in the GitHub repo for this website.

34:04.710 --> 34:11.670
So, like, it just went off and it just queried that CAN address, 18DA30F1.

34:12.090 --> 34:17.670
And I think it might have sent, like, tester present or something like that.

34:17.910 --> 34:18.170
Oh, no.

34:18.170 --> 34:18.850
I'm sorry.

34:18.850 --> 34:20.170
It didn't send that off yet.

34:20.170 --> 34:21.790
We still have to connect to the ECU.

34:23.430 --> 34:35.650
So, the way WebUSB works, for, like, security reasons, is if you have a device that implements the WebUSB protocol, when you plug it into your computer, it doesn't just, like, get access to things.

34:35.730 --> 34:54.470
So, Chrome has this specification where there is a JavaScript call you can make to say, you know, go talk to this USB device, and then it prompts the user to actually say, yes, you're allowed to talk to this USB device from a web browser.

34:56.650 --> 34:58.230
So, I pick it.

34:58.230 --> 34:59.270
I say connect.

34:59.270 --> 35:08.570
Okay, now it actually went out and it actually, like, sent, like, tester present to the ECU and said, like, are you there?

35:08.570 --> 35:09.710
Are you awake?

35:09.710 --> 35:17.110
And then there's another UDS message called, like, read memory by address.

35:17.110 --> 35:18.870
I think it's read memory by address.

35:18.870 --> 35:27.570
And there's a specific code that's defined that, there's, like, four of them that are, like, bootloader version, software version, application version.

35:27.570 --> 35:30.410
So, I think it's software version.

35:30.410 --> 35:48.290
It goes off and it queries the software version, and it checks, does the software version that the ECU returned match what my RWD headers, excuse me, what my RWD headers say are the supported software versions for this firmware update file.

35:49.510 --> 35:50.530
All right.

35:50.530 --> 35:51.910
So, now we're connected.

35:52.490 --> 35:53.490
Next.

35:54.210 --> 35:54.910
Okay.

35:54.910 --> 35:55.910
This is the danger screen.

35:55.910 --> 35:57.490
Like I said, you can brick an ECU.

35:57.490 --> 36:00.530
So, don't do this with an ECU that you're not willing to pay to replace.

36:00.530 --> 36:02.090
Something could go wrong.

36:02.110 --> 36:03.630
I say I agree.

36:03.670 --> 36:05.750
And flash.

36:05.750 --> 36:07.590
It's erasing the memory.

36:08.810 --> 36:11.090
And now it's flashing the firmware.

36:11.470 --> 36:17.630
So, it's basically just going through that sequence that I laid out at the very beginning to actually send the firmware update.

36:18.010 --> 36:25.110
So, you can't really see the progress bar there really well, but it's at, like, 25% and moving along.

36:27.330 --> 36:32.150
LEDs are, like, flashing different colors on the table over here.

36:36.430 --> 36:37.370
Yeah.

36:37.370 --> 36:38.850
So, I don't know.

36:39.990 --> 36:43.230
Once you have this, I guess flashing a firmware update is pretty boring.

36:47.270 --> 36:49.310
It'll be done here in a second.

36:49.610 --> 36:51.230
A few seconds.

36:51.230 --> 36:52.710
About 80%.

36:52.710 --> 36:54.610
And then I'll just pull something up.

36:54.690 --> 37:00.270
Like, this ECU just constantly dumps out some messages on the CAN bus.

37:00.270 --> 37:01.330
Okay, it's complete.

37:01.950 --> 37:03.310
So, all right.

37:03.310 --> 37:05.050
Let's talk to this ECU.

37:05.190 --> 37:09.050
I've got to free up the USB device so that the web browser doesn't have a hold of it.

37:09.810 --> 37:10.790
And, all right.

37:10.790 --> 37:11.850
So, let's see if this...

37:11.850 --> 37:12.190
All right.

37:12.190 --> 37:13.310
So, it should be...

37:13.310 --> 37:14.150
Now, if I didn't...

37:14.150 --> 37:16.550
Hopefully, this is where, like, the live demo doesn't go all wrong.

37:16.950 --> 37:21.650
If I try to connect to this ECU and read all the messages that it's dumping out on the CAN bus...

37:24.210 --> 37:25.270
There we go.

37:25.450 --> 37:29.730
So, it's, like, five messages that it just dumps out.

37:29.730 --> 37:33.970
I think it's, like, the torque sensor that's on it and a bunch of other stuff.

37:33.970 --> 37:36.510
So, yeah.

37:36.850 --> 37:38.750
And, I guess that's it.

37:38.750 --> 37:39.790
That's my talk.

37:39.790 --> 37:40.270
Thank you .

37:46.710 --> 37:47.850
What's up?

38:38.360 --> 38:39.820
Yeah, sure.

38:39.820 --> 38:42.480
So, is there any signature on the firmware?

38:42.600 --> 38:43.280
No.

38:43.280 --> 38:44.640
Yeah, there's no signature.

38:45.100 --> 38:46.080
It just...

38:46.080 --> 38:46.640
Like, they just...

38:46.640 --> 38:48.860
There's that last step where they say...

38:48.860 --> 38:52.020
They say, basically, validate the firmware.

38:52.020 --> 38:54.360
There's, like, a routine control message that gets called.

38:54.360 --> 38:55.500
And that validation is just...

38:56.020 --> 38:56.440
Are the checks...

38:56.440 --> 38:57.140
Do the checks...

38:57.140 --> 39:00.820
Do the sum of the bytes add up?

39:00.820 --> 39:01.260
So, yeah.

39:01.260 --> 39:01.620
So, yeah.

39:01.620 --> 39:02.720
There's nothing like that.

39:03.120 --> 39:04.400
And then the other comment was...

39:04.400 --> 39:06.540
I made some assumptions about, like...

39:06.540 --> 39:07.680
I had something.

39:07.680 --> 39:08.820
I wanted to decrypt it.

39:08.820 --> 39:11.860
And I didn't know, you know, what the...

39:11.860 --> 39:13.300
How would I know...

39:13.300 --> 39:17.960
Like, how would I make those assumptions so that I know when it was decrypted completely or properly?

39:18.400 --> 39:19.100
Yeah.

39:19.100 --> 39:20.680
So, I mean, I just guessed, right?

39:20.680 --> 39:29.940
And then, in addition to guessing, though, this ECU here is tore apart because then I have the decrypted firmware.

39:29.940 --> 39:33.340
Like, I figured out how to dump the full firmware.

39:33.500 --> 39:40.040
So, like, these firmware update files, they're, you know, potentially not super useful to modify because they're partial.

39:40.040 --> 39:40.540
Right?

39:40.540 --> 39:48.840
Like, important things that you want to modify or you need to, like, reverse engineer out of them, they might not even be in the update section.

39:48.840 --> 39:49.560
Right?

39:49.560 --> 39:56.100
So, like, what I did was I got an ECU that I was able to dump the firmware off of.

39:56.100 --> 40:05.100
And then I just had these ideas, like, okay, well, I should be able to find this software version that you can request through read memory by address.

40:05.760 --> 40:07.620
And maybe I, like, I just tried.

40:07.620 --> 40:08.760
Like, okay, well, maybe...

40:08.760 --> 40:09.440
How many times...

40:09.440 --> 40:11.400
I had no idea how many times...

40:11.400 --> 40:18.680
How many sets of, you know, combinations of operators in my brute force decryption would match.

40:18.680 --> 40:22.320
And it turned out, like, 99% of the time there was only one.

40:22.320 --> 40:32.720
And I had the real firmware from an ECU to compare it to to then make 100% certain that at least sometimes I was decrypting it successfully.

40:35.560 --> 40:39.320
This one actually, this specific ECU is simpler than that.

40:39.320 --> 40:40.220
It's UART.

40:40.220 --> 40:41.220
It's serial.

40:41.220 --> 40:44.480
But a lot of them are JTAG that you have to dump them through.

40:44.480 --> 40:45.140
Yep.

40:45.520 --> 40:46.440
Yeah.

40:53.480 --> 40:54.860
No, I don't think so.

40:54.860 --> 40:57.520
I mean, they don't publish any firmware updates.

40:57.520 --> 41:02.780
I think George has, like, said on our Discord multiple times that all firmware modifications are canceled.

41:03.120 --> 41:09.420
So, yeah, I mean, this is just, you know, this is just me working on this stuff in my free time, basically.

41:09.460 --> 41:12.780
So, yeah, this is just my stuff for fun.

41:12.940 --> 41:13.620
So, yeah.

41:22.080 --> 41:22.800
Go ahead.

41:23.140 --> 41:28.320
Yeah , so I haven't had that much time to, like, really work on it and make it awesome.

41:28.800 --> 41:32.140
So, like, I've just tried it on a few ECUs that are actually in my car.

41:32.140 --> 41:38.840
But I haven't, like, I haven't specifically tested it out on, like, what, like, the engine tuning ECU guys do.

41:38.840 --> 41:42.120
You know, the, where there's a lot more potential.

41:42.120 --> 41:44.540
I mean, they all charge money for that stuff, right?

41:44.560 --> 41:45.280
Well, not all of them.

41:45.280 --> 41:48.260
I think there's some free ones, like ROM Raider or something like that.

41:49.420 --> 41:50.440
But, like, I don't know.

41:50.440 --> 41:51.540
I think this is the future.

41:51.540 --> 41:58.940
I think, you know, it seems like web browsers are going to be the, you know, the platform for building modern applications in the future.

41:58.960 --> 42:00.420
And so, like, I don't know.

42:00.420 --> 42:03.960
I feel like I'm showing you the future of what these tools are going to look like someday.

42:07.420 --> 42:08.180
All right.

42:09.040 --> 42:09.680
Cool.

42:09.700 --> 42:10.500
Thanks, guys.

42:10.500 --> 42:14.720
And I think someone gave me this adapter.

42:14.720 --> 42:19.040
Thanks a lot for the adapter so I could actually give my presentation.

