1 00:00:00,000 --> 00:00:05,360 My talk is about flashing ECU firmware updates from a web browser. 2 00:00:05,480 --> 00:00:13,260 More specifically, I did some reverse engineering of the Honda firmware update file format that they put out. 3 00:00:13,460 --> 00:00:15,180 So that's what I'm going to be talking about. 4 00:00:15,820 --> 00:00:16,700 So, who am I? 5 00:00:16,700 --> 00:00:18,220 My name is Greg Hogan. 6 00:00:18,820 --> 00:00:20,800 You can follow me on Twitter. 7 00:00:21,100 --> 00:00:24,640 All the source code for the software that I'm going to show you is open source. 8 00:00:24,640 --> 00:00:27,920 You can find it in one or more of my GitHub repositories. 9 00:00:27,920 --> 00:00:31,540 And I work at Comet AI on infrastructure. 10 00:00:31,540 --> 00:00:34,980 Which, yes, if you're wondering, that has nothing to do with car hacking. 11 00:00:36,400 --> 00:00:41,120 So, a couple days ago, I got an email. 12 00:00:41,180 --> 00:00:43,880 And it said Defcon 27 talk. 13 00:00:43,880 --> 00:00:48,580 And I thought, oh, this is information on my speaking gig here. 14 00:00:48,620 --> 00:00:52,740 I open up the email, and no, it is from Honda. 15 00:00:52,780 --> 00:00:55,460 So apparently they were interested in my talk. 16 00:00:55,460 --> 00:00:57,680 And I'll summarize this for you. 17 00:00:57,680 --> 00:01:01,580 It basically says, don't do something that might kill somebody. 18 00:01:02,140 --> 00:01:03,920 That was never my intention. 19 00:01:04,220 --> 00: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. 20 00:01:16,700 --> 00:01:18,400 That's not the case. 21 00:01:18,400 --> 00:01:21,020 I never planned on talking about anything like that. 22 00:01:21,020 --> 00:01:23,920 So that doesn't change anything that I'm going to be talking about. 23 00:01:23,920 --> 00:01:27,860 Also, this is a completely legitimate thing to ask of someone. 24 00:01:27,900 --> 00:01:31,060 To make sure you don't do something that could injure somebody. 25 00:01:31,060 --> 00: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. 26 00:01:39,340 --> 00:01:45,400 If you screw something up, the best case might be that the steering wheel tries to break your arms. 27 00:01:45,400 --> 00:01:49,560 And the worst case is it'll flip over your car and kill you. 28 00:01:49,560 --> 00:01:52,200 So, please don't do anything stupid. 29 00:01:52,200 --> 00:01:56,940 And I have no intention of enabling you to be able to do such things. 30 00:01:58,140 --> 00:02:02,340 What got me interested in flashing ECU firmware updates? 31 00:02:02,820 --> 00:02:09,660 So, in 2017, George Hotz, he's actually the guy that started the company that I work for. 32 00:02:09,660 --> 00: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. 33 00:02:19,920 --> 00:02:25,380 And I looked at these tools that he was showing and I thought, wow, that software is garbage. 34 00:02:26,200 --> 00:02:31,900 It looks like it runs on Windows XP and why hasn't anyone created anything better? 35 00:02:32,700 --> 00:02:36,500 So, that's kind of what I set out to do. 36 00:02:40,320 --> 00: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. 37 00:02:52,280 --> 00: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. 38 00:03:06,100 --> 00:03:08,340 They've basically done what I'm going to show you. 39 00:03:08,340 --> 00: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. 40 00:03:15,580 --> 00: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. 41 00:03:29,740 --> 00:03:36,400 So, how do you get the software and firmware updates for these vehicles? 42 00:03:36,400 --> 00: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. 43 00:04:00,380 --> 00:04:06,580 So, anyone can sign up for these websites. 44 00:04:06,580 --> 00: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. 45 00:04:24,180 --> 00:04:27,660 If you subscribe for one day, interestingly, you actually get three days. 46 00:04:28,540 --> 00:04:34,280 So, Toyota's a little more expensive and, you know, there's other vehicle manufacturers. 47 00:04:34,280 --> 00: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. 48 00:04:46,680 --> 00: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. 49 00:04:58,260 --> 00:05:02,880 It's horrible, just like from a UI perspective, usability perspective. 50 00:05:02,880 --> 00:05:04,520 It's not great software. 51 00:05:05,520 --> 00:05:08,100 The authentication is over HTTP. 52 00:05:08,160 --> 00:05:12,860 Like, nobody's proud of themselves for like working on this software, I don't think. 53 00:05:12,880 --> 00:05:14,960 This is the new version. 54 00:05:14,960 --> 00:05:20,660 This is new for like, I think like 2017 model year vehicles or something like that. 55 00:05:20,660 --> 00:05:22,980 The old version looked even sadder. 56 00:05:23,140 --> 00:05:24,880 It's called HDS for Honda. 57 00:05:24,880 --> 00:05:26,920 It's Honda Diagnostic System. 58 00:05:26,920 --> 00:05:31,100 In 2017, when this new version came out, they threw an I in the front of it. 59 00:05:31,100 --> 00: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. 60 00:05:37,520 --> 00:05:41,880 But using this software is nothing like using an Apple product. 61 00:05:42,400 --> 00:05:47,200 You also need a piece of hardware to interface with the car through the ODB2 port. 62 00:05:47,200 --> 00:05:57,640 So, that hardware, if you go to the Honda website, there's one like certified hardware package that you can buy. 63 00:05:57,640 --> 00:05:59,880 And it is almost $1500. 64 00:06:01,280 --> 00: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. 65 00:06:12,720 --> 00:06:22,520 So, one of those boxes on like that first window was something called the J2534 rewrite tool. 66 00:06:22,520 --> 00:06:23,520 So, what is that thing? 67 00:06:23,520 --> 00:06:29,700 That's the software that actually does the firmware updates, that actually flashes your ECUs. 68 00:06:30,440 --> 00:06:37,880 So, the company I work for, they actually make an OBD2 dongle that has a USB port called a Panda. 69 00:06:37,880 --> 00:06:42,680 And it's a lot cheaper than the $1500 product that Honda sells. 70 00:06:42,820 --> 00: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. 71 00:06:52,900 --> 00:06:57,260 They defined it so that, you know, to enable right to repair, essentially. 72 00:06:58,520 --> 00:07:03,680 And the driver, like it's not perfect, but it at least works for CAN. 73 00:07:03,680 --> 00:07:09,260 And so, I decided to go down this path since it's so much more cost effective. 74 00:07:09,260 --> 00:07:17,860 And the Panda has, it has a great Python library for interacting with your vehicle over the OBD2 port. 75 00:07:18,160 --> 00:07:22,440 And someone wrote a web USB driver for it. 76 00:07:22,720 --> 00: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. 77 00:07:31,530 --> 00: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. 78 00:07:42,030 --> 00:07:45,290 So, that's how you get the actual firmware update files. 79 00:07:45,470 --> 00:07:49,010 And they're in this folder here that I listed at the bottom. 80 00:07:51,390 --> 00:07:55,870 So, okay, now we've got a flashing tool and we've got firmware updates. 81 00:07:55,870 --> 00: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. 82 00:08:06,350 --> 00:08:13,110 So, the first thing that I found was this software called J2534 Logger. 83 00:08:13,410 --> 00:08:21,490 Basically, what that does is it acts as a proxy to a real J2534 driver. 84 00:08:21,490 --> 00: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. 85 00:08:31,010 --> 00: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. 86 00:08:44,390 --> 00:08:50,910 So, that's another reason that I was interested in creating my own software that flashes this. 87 00:08:50,910 --> 00: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. 88 00:08:58,070 --> 00:09:08,390 So, basically, you can fire up that J2534 rewrite tool that Honda puts out and fire up this, install this logger. 89 00:09:08,390 --> 00: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. 90 00:09:16,590 --> 00: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. 91 00:09:26,530 --> 00: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. 92 00:09:40,750 --> 00:09:44,450 UDS, Unified Diagnostics, that's, like, a big one. 93 00:09:44,450 --> 00: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. 94 00:09:55,270 --> 00:09:58,290 The next layer down is ISOTP. 95 00:09:58,310 --> 00: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. 96 00:10:15,350 --> 00:10:17,270 All right. 97 00:10:17,270 --> 00:10:27,440 So, after recording flashing an ECU from that J2534 rewrite tool that Honda distributes, here's what you come up with. 98 00:10:28,260 --> 00:10:33,360 It's basically more or less an eight-step process here. 99 00:10:34,100 --> 00: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. 100 00:10:44,360 --> 00: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. 101 00:11:00,200 --> 00:11:02,360 Once you get there, you can request a seed. 102 00:11:03,120 --> 00:11:07,860 You'll then see the seed go back to the software. 103 00:11:07,900 --> 00: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. 104 00:11:17,860 --> 00:11:19,200 So, this is what we want to get to, right? 105 00:11:19,200 --> 00: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. 106 00:11:26,320 --> 00: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. 107 00:11:37,900 --> 00: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. 108 00:11:52,280 --> 00:12:00,440 So, it turns out that these Honda firmware update files, the firmware portion of the file, they actually encrypt it. 109 00:12:01,180 --> 00:12:05,980 And the J2534 rewrite tool, it doesn't decrypt it. 110 00:12:05,980 --> 00:12:09,080 It sends it to the ECU, and then the ECU decrypts it. 111 00:12:09,080 --> 00:12:19,120 So, they haven't distributed, per se, any software that you can obtain that actually has the decryption algorithm in it. 112 00:12:19,120 --> 00:12:20,560 It's all in the ECU. 113 00:12:21,840 --> 00:12:28,120 Then you proceed to send the firmware, and then at the very end, it does basically checksum. 114 00:12:28,120 --> 00: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. 115 00:12:35,280 --> 00:12:38,300 The checksums in the Honda firmware are extremely poor. 116 00:12:38,580 --> 00:12:43,700 They're actually just the sum of all the bytes across a few sections. 117 00:12:44,520 --> 00: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. 118 00:12:57,380 --> 00: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. 119 00:13:06,100 --> 00: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, 120 00:13:29,060 --> 00:13:32,540 but without any software written by Honda. 121 00:13:33,320 --> 00:13:38,140 So, the very first byte of the file is what I call the signature. 122 00:13:38,140 --> 00:13:41,240 It basically tells you the format of the rest of the file. 123 00:13:41,240 --> 00:13:42,580 There's a few different formats. 124 00:13:42,580 --> 00:13:46,140 I'm just going to focus on one, because I only care about one, which is CAN. 125 00:13:46,380 --> 00:13:51,140 There's also other formats, I think, where you flash over LIN or other protocols. 126 00:13:51,180 --> 00: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. 127 00:13:59,460 --> 00:14:03,080 So CAN is this hex 5A value. 128 00:14:03,960 --> 00: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. 129 00:14:14,640 --> 00: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, 130 00:14:45,960 --> 00:14:51,340 or if the file is an update for the version of the firmware that's on the ECU. 131 00:14:52,600 --> 00:14:54,320 You only need a few things. 132 00:14:54,320 --> 00: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. 133 00:15:00,200 --> 00:15:02,420 So there's one byte that specifies it. 134 00:15:02,420 --> 00: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. 135 00:15:08,900 --> 00:15:11,020 So they just have that one byte in there. 136 00:15:13,940 --> 00:15:15,880 Then there's a few different values. 137 00:15:15,880 --> 00:15:20,600 They can change these security access keys per firmware update file. 138 00:15:20,600 --> 00:15:27,740 So they put the actual keys in the firmware update file because you have to send them to the ECU. 139 00:15:27,740 --> 00:15:31,000 So when the ECU receives the firmware, it knows how to decrypt it. 140 00:15:32,680 --> 00: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. 141 00:15:43,020 --> 00:15:49,020 So what you need to do to get that ECU into programming mode, essentially. 142 00:15:52,420 --> 00:15:55,860 After the headers is the actual firmware. 143 00:15:55,860 --> 00:15:58,800 This is the encrypted firmware that I talked about before. 144 00:15:59,260 --> 00:16:01,760 There's a start address and a length. 145 00:16:04,360 --> 00: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? 146 00:16:14,940 --> 00:16:19,700 That's part of that UDS sequence of messages that you have to send to the ECU. 147 00:16:20,660 --> 00:16:26,980 The Honda ECUs I've looked at, they actually only allow you to flash one section of the firmware. 148 00:16:26,980 --> 00: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. 149 00:16:37,900 --> 00:16:40,240 So that's good. 150 00:16:41,840 --> 00:16:44,060 But yeah, the state is encrypted. 151 00:16:44,060 --> 00:16:47,020 So we can't really look at the firmware at this point. 152 00:16:48,580 --> 00:16:52,500 And then at the end of the file is a checksum. 153 00:16:52,500 --> 00:16:57,140 And it's just the sum of all the bytes except the checksum itself. 154 00:16:57,740 --> 00:17:05,420 And so that is, that's the entirety of one of these CAN format Honda firmware update files. 155 00:17:06,420 --> 00:17:08,420 Alright, the encryption. 156 00:17:08,480 --> 00:17:16,320 So I mentioned that this firmware is, like the data section of the update file for the firmware is encrypted. 157 00:17:16,680 --> 00:17:20,460 So I thought, okay, well, it'd be interesting to see if we can decrypt that. 158 00:17:21,720 --> 00: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. 159 00:17:33,500 --> 00:17:35,940 And I thought to myself, oh, okay, well, maybe I'm lucky. 160 00:17:35,940 --> 00:17:38,660 Maybe they use the same encryption for every one of these updates. 161 00:17:39,140 --> 00:17:40,800 Turns out that's not the case. 162 00:17:41,580 --> 00:17:47,980 But there's these keys that we already found in the headers of each firmware update file. 163 00:17:47,980 --> 00:17:50,380 So I've got the keys. 164 00:17:50,380 --> 00:17:51,760 I've got an example. 165 00:17:51,760 --> 00:17:52,720 So what should I try? 166 00:17:52,720 --> 00:17:55,360 Okay, well, maybe they just change the operators. 167 00:17:56,600 --> 00:18:00,620 It turns out, at least somewhat common, that's the case. 168 00:18:00,620 --> 00: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. 169 00:18:19,500 --> 00:18:25,760 So utilizing that, I wrote this piece of software that I linked to at the top there called RWD X-Ray. 170 00:18:25,960 --> 00:18:28,780 And that, it does that, exactly. 171 00:18:28,860 --> 00: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. 172 00:18:46,260 --> 00:18:48,760 Yeah, so that's really fast. 173 00:18:48,760 --> 00:18:50,400 Most of these firmware updates are small. 174 00:18:50,400 --> 00:18:57,500 And, yeah, it takes, like, seconds to run this through and find the appropriate operators for a lot of them. 175 00:18:57,500 --> 00: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. 176 00:19:03,020 --> 00: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. 177 00:19:12,840 --> 00:19:17,400 So this is just an example of running that tool. 178 00:19:17,400 --> 00:19:20,740 It just kind of ties everything together that I just talked through. 179 00:19:21,020 --> 00:19:24,960 It basically, you know, parses the file, spits out the headers. 180 00:19:25,820 --> 00: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. 181 00:19:41,960 --> 00:19:51,900 That returns something that looks like a part number for Honda with an extra few numbers at the end. 182 00:19:51,900 --> 00:19:58,140 All of these RWD files have a name that looks like a part number. 183 00:19:58,160 --> 00: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? 184 00:20:15,900 --> 00:20:18,240 And normally there's just one. 185 00:20:18,920 --> 00:20:23,780 Down at the bottom there, all those dots, is it trying every possible set of operators that existed. 186 00:20:23,940 --> 00: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. 187 00:20:38,500 --> 00:20:42,780 And then it spits out the decrypted firmware into a file at the end. 188 00:20:44,100 --> 00: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. 189 00:20:58,620 --> 00:21:04,960 It has everything in it, I guess, except the actual security access key exchange algorithm. 190 00:21:04,960 --> 00: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. 191 00:21:15,680 --> 00: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. 192 00:21:35,360 --> 00:21:37,040 But we don't know what that is. 193 00:21:37,040 --> 00:21:39,780 So, brute force would take a long time. 194 00:21:40,160 --> 00: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. 195 00:21:52,040 --> 00:21:57,500 So, what else would have this security access key exchange that I already have access to? 196 00:21:58,180 --> 00:22:02,200 Well, how about that J2534 reflash tool? 197 00:22:02,200 --> 00:22:08,980 Turns out it's pretty easy to find the security access key exchange algorithm in that tool. 198 00:22:09,240 --> 00: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. 199 00:22:25,340 --> 00: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. 200 00:22:36,340 --> 00:22:38,040 And so, yeah, great. 201 00:22:38,080 --> 00: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. 202 00:22:48,440 --> 00: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? 203 00:22:54,120 --> 00:22:54,620 I don't know. 204 00:22:54,620 --> 00:22:56,600 I guess it's easy to find, though. 205 00:22:56,600 --> 00:22:59,060 So, I guess it makes sense that they would. 206 00:23:01,080 --> 00:23:01,800 All right. 207 00:23:01,800 --> 00:23:07,360 So, I've got everything I want, or I need to know now to build this website. 208 00:23:07,360 --> 00:23:09,040 So I created this website. 209 00:23:09,040 --> 00:23:10,220 It's open source. 210 00:23:11,140 --> 00:23:13,400 Autoecu.io is the URL. 211 00:23:14,000 --> 00:23:18,640 It's the AutoECU GitHub repository that I have. 212 00:23:18,640 --> 00:23:20,900 It's open source. 213 00:23:20,960 --> 00: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. 214 00:23:42,760 --> 00:23:45,060 This website is just static content. 215 00:23:45,060 --> 00:23:47,340 Like, you don't need an internet connection to use it. 216 00:23:47,340 --> 00:23:48,460 There's no API. 217 00:23:48,800 --> 00:23:53,220 You can totally just pull down the GitHub repo and run it locally. 218 00:23:53,780 --> 00:23:57,860 But, you know, for convenience, I just threw it up on AutoECU.io. 219 00:24:01,160 --> 00:24:02,440 There are some problems. 220 00:24:02,440 --> 00:24:03,420 It's not perfect. 221 00:24:03,420 --> 00: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. 222 00:24:10,780 --> 00: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, 223 00:24:31,600 --> 00:24:34,860 or maybe they only give it, like, small time slices or something. 224 00:24:34,860 --> 00: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. 225 00:24:45,980 --> 00:24:48,700 So you really don't want that to happen, you know, in the middle. 226 00:24:50,640 --> 00:24:52,340 Generally, it's, like, it's okay. 227 00:24:52,340 --> 00:24:57,800 Like, if you cancel flashing one of these ECUs in the middle, you've potentially erased the ECU. 228 00:24:57,800 --> 00: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. 229 00:25:07,620 --> 00:25:12,600 But, yeah, it's definitely possible that you'll brick an ECU if you use this. 230 00:25:14,160 --> 00:25:17,680 So, I have a little video here. 231 00:25:17,680 --> 00:25:19,660 I have a 2017 Honda CR-V. 232 00:25:19,660 --> 00:25:23,800 It has ECU updates for several ECUs. 233 00:25:23,800 --> 00:25:25,940 I'll just play this here. 234 00:25:27,040 --> 00:25:30,400 See if I can make it full screen here. 235 00:25:31,800 --> 00:25:36,840 If you watch the dash really close, things look pretty good right now. 236 00:25:36,840 --> 00:25:38,140 It looks normal. 237 00:25:38,240 --> 00:25:41,000 I'm, like, picking the firmware file right now. 238 00:25:42,620 --> 00:25:44,700 It does a little validation. 239 00:25:44,940 --> 00:25:48,040 And then I'm going to start the flashing process here. 240 00:25:48,040 --> 00:25:55,060 And then, holy shit, every error code possible pops up on the dash. 241 00:25:56,200 --> 00:25:57,780 So, I don't know if I, like, missed. 242 00:25:57,780 --> 00:25:58,640 Maybe I missed something. 243 00:25:58,640 --> 00:26:01,220 Maybe there's, like, some way to prevent that from happening. 244 00:26:01,380 --> 00:26:03,180 But it's kind of scary. 245 00:26:03,180 --> 00:26:07,080 I mean, I tested this, like, on a bench before and actually, like, had bugs in my code. 246 00:26:07,080 --> 00: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. 247 00:26:14,820 --> 00: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. 248 00:26:29,640 --> 00:26:32,940 When, you know, the ECUs are throwing messages all over the place all the time. 249 00:26:33,260 --> 00:26:34,800 So, luckily, that was easy to fix. 250 00:26:34,800 --> 00:26:39,580 And now it works better and, like, actually, this successfully flashes the ECU. 251 00:26:40,100 --> 00:26:41,860 Looks like it's flashing right now. 252 00:26:41,860 --> 00:26:43,400 Actually applying the firmware. 253 00:26:43,400 --> 00:26:48,440 I think this is, like, applying the radar firmware update for my car or something like that. 254 00:26:49,120 --> 00:26:53,920 So, I just took, you know, the RWD file. 255 00:26:53,980 --> 00:26:58,900 Honda names these firmware update files with .RWD as the extension. 256 00:26:59,840 --> 00: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. 257 00:27:07,900 --> 00:27:12,840 And then I just power cycled the car and all the errors went away. 258 00:27:13,100 --> 00:27:14,660 So, it's great. 259 00:27:14,660 --> 00:27:15,500 It worked. 260 00:27:20,600 --> 00:27:21,620 Thanks. 261 00:27:21,620 --> 00:27:23,600 So, that was fun. 262 00:27:24,000 --> 00: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. 263 00:27:32,080 --> 00:27:35,540 They reverse engineer this and they generate their own updates, right? 264 00:27:35,540 --> 00: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. 265 00:27:47,060 --> 00:27:49,640 So, you don't need a whole lot of information. 266 00:27:49,640 --> 00:27:52,720 You just need, you know, whatever is in that RWD file. 267 00:27:53,740 --> 00:27:55,440 You can just make up some keys. 268 00:27:55,720 --> 00:27:59,800 You do have to be able to figure out, you know, how to get firmware off of an ECU maybe. 269 00:27:59,800 --> 00: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. 270 00:28:08,200 --> 00:28:11,640 And, but you got to be able to get, you know, the firmware. 271 00:28:11,640 --> 00:28:16,660 You have to be able to encrypt it since it's encrypted in these RWD update files. 272 00:28:16,700 --> 00:28:23,400 But this is actually like a pretty good format for updating an ECU because it's like self-contained. 273 00:28:23,400 --> 00: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. 274 00:28:38,940 --> 00:28:46,700 So , in my RWD X-Ray repo, there is a script that does just that. 275 00:28:46,700 --> 00: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. 276 00:29:05,380 --> 00:29:06,140 All right. 277 00:29:06,140 --> 00:29:07,500 So, let's do that. 278 00:29:07,500 --> 00: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. 279 00:29:16,460 --> 00:29:24,220 And it's, you can get, for example, a lot of ECUs on, you know, like LKQ online for really cheap. 280 00:29:24,220 --> 00:29:31,140 This is specifically an ECU for the electronic power steering for my 2017 Honda CR-V. 281 00:29:31,140 --> 00:29:34,620 I'm just using it because, like, that's what I have out of convenience. 282 00:29:34,920 --> 00:29:37,660 So, let's, so let's do it. 283 00:29:44,020 --> 00:29:44,740 So, yeah. 284 00:29:44,740 --> 00:29:49,140 So, basically, I just, I was, I figured out how to extract the firmware from this ECU. 285 00:29:49,140 --> 00: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. 286 00:29:57,480 --> 00:30:01,240 It literally just is the original firmware on the ECU. 287 00:30:01,620 --> 00:30:02,620 So, that's what we're going to do. 288 00:30:02,620 --> 00:30:04,680 So, this is, this is my web, oh, sorry. 289 00:30:04,680 --> 00:30:07,120 This is my website, autoecu.io. 290 00:30:07,120 --> 00:30:12,000 And, right now, it has a dropdown for manufacturer. 291 00:30:12,580 --> 00:30:17,720 Honda is the only manufacturer that is supported, but, you know, it's open source. 292 00:30:17,720 --> 00:30:26,880 If someone's interested, they could, you know, definitely add formats of other firmware update files distributed by other car manufacturers. 293 00:30:27,240 --> 00: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. 294 00:30:33,600 --> 00:30:36,840 It just has, like, I think it has, like, a header that says the start address and the length. 295 00:30:36,840 --> 00:30:41,220 And then, it's just the firmware, just, you know, not encrypted or anything. 296 00:30:41,240 --> 00:30:45,920 So, you could definitely expand this, you know, if you wanted to. 297 00:30:46,200 --> 00: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. 298 00:30:55,760 --> 00:30:57,580 You can do all kinds of cool stuff with this, too, right? 299 00:30:57,580 --> 00: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. 300 00:31:10,460 --> 00: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. 301 00:31:21,880 --> 00:31:23,880 So, there's all kinds of cool stuff you can do with this. 302 00:31:23,880 --> 00:31:25,940 So, let me power this. 303 00:31:25,940 --> 00:31:27,020 It's powered on here. 304 00:31:27,020 --> 00:31:29,100 I don't know if anyone can really see this here. 305 00:31:29,100 --> 00:31:29,560 Sorry. 306 00:31:29,560 --> 00:31:30,780 We didn't get a table. 307 00:31:31,060 --> 00:31:34,340 So, this chair here is my... what's that? 308 00:31:34,880 --> 00:31:36,040 Oh, hey, I got a table. 309 00:31:36,040 --> 00:31:37,200 Let me go grab the table quick. 310 00:31:37,200 --> 00:31:37,820 Thanks. 311 00:32:11,070 --> 00:32:12,070 All right. 312 00:32:12,070 --> 00:32:14,870 So, maybe this setup deserves a little more explanation here. 313 00:32:14,870 --> 00: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. 314 00:32:24,470 --> 00:32:26,790 Like, they actually put the controller in the motor. 315 00:32:26,790 --> 00:32:29,210 So, that's why it's, like, all tore apart and weird. 316 00:32:30,210 --> 00:32:35,830 I'm using one of those Panda OBD2 dongles that ComAI sells. 317 00:32:37,430 --> 00: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. 318 00:32:43,630 --> 00:32:47,790 It's just in case, like, you brick your OBD2 dongle. 319 00:32:47,910 --> 00: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. 320 00:32:54,570 --> 00:33:00,370 So, that's plugged into another thing that we sell, which you don't need by any means at all. 321 00:33:00,370 --> 00:33:07,730 It's just, like, a development board that breaks out the OBD2 pins really conveniently. 322 00:33:07,930 --> 00: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. 323 00:33:22,570 --> 00:33:23,830 So, yeah. 324 00:33:25,090 --> 00:33:26,870 So, all right. 325 00:33:27,130 --> 00:33:29,490 Let's pull up... 326 00:33:30,090 --> 00:33:36,630 This is my fake firmware update that is just, like, the stock firmware that I generated a file for. 327 00:33:36,630 --> 00:33:39,450 Because there is no firmware update for this ECU. 328 00:33:39,650 --> 00:33:42,650 I pick that firmware update file. 329 00:33:42,950 --> 00:33:44,410 And I say next. 330 00:33:44,870 --> 00:33:48,950 Now, this is where those headers that are in the RWD file come into play. 331 00:33:48,950 --> 00:33:52,290 It just went out. 332 00:33:52,290 --> 00:33:57,590 So, I implemented that UDS protocol in the ISOTP. 333 00:33:57,590 --> 00:33:59,390 I implemented it in JavaScript. 334 00:33:59,570 --> 00:34:04,150 You can see it in the GitHub repo for this website. 335 00:34:04,710 --> 00:34:11,670 So, like, it just went off and it just queried that CAN address, 18DA30F1. 336 00:34:12,090 --> 00:34:17,670 And I think it might have sent, like, tester present or something like that. 337 00:34:17,910 --> 00:34:18,170 Oh, no. 338 00:34:18,170 --> 00:34:18,850 I'm sorry. 339 00:34:18,850 --> 00:34:20,170 It didn't send that off yet. 340 00:34:20,170 --> 00:34:21,790 We still have to connect to the ECU. 341 00:34:23,430 --> 00: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. 342 00:34:35,730 --> 00: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. 343 00:34:56,650 --> 00:34:58,230 So, I pick it. 344 00:34:58,230 --> 00:34:59,270 I say connect. 345 00:34:59,270 --> 00: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? 346 00:35:08,570 --> 00:35:09,710 Are you awake? 347 00:35:09,710 --> 00:35:17,110 And then there's another UDS message called, like, read memory by address. 348 00:35:17,110 --> 00:35:18,870 I think it's read memory by address. 349 00:35:18,870 --> 00: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. 350 00:35:27,570 --> 00:35:30,410 So, I think it's software version. 351 00:35:30,410 --> 00: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. 352 00:35:49,510 --> 00:35:50,530 All right. 353 00:35:50,530 --> 00:35:51,910 So, now we're connected. 354 00:35:52,490 --> 00:35:53,490 Next. 355 00:35:54,210 --> 00:35:54,910 Okay. 356 00:35:54,910 --> 00:35:55,910 This is the danger screen. 357 00:35:55,910 --> 00:35:57,490 Like I said, you can brick an ECU. 358 00:35:57,490 --> 00:36:00,530 So, don't do this with an ECU that you're not willing to pay to replace. 359 00:36:00,530 --> 00:36:02,090 Something could go wrong. 360 00:36:02,110 --> 00:36:03,630 I say I agree. 361 00:36:03,670 --> 00:36:05,750 And flash. 362 00:36:05,750 --> 00:36:07,590 It's erasing the memory. 363 00:36:08,810 --> 00:36:11,090 And now it's flashing the firmware. 364 00:36:11,470 --> 00: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. 365 00:36:18,010 --> 00:36:25,110 So, you can't really see the progress bar there really well, but it's at, like, 25% and moving along. 366 00:36:27,330 --> 00:36:32,150 LEDs are, like, flashing different colors on the table over here. 367 00:36:36,430 --> 00:36:37,370 Yeah. 368 00:36:37,370 --> 00:36:38,850 So, I don't know. 369 00:36:39,990 --> 00:36:43,230 Once you have this, I guess flashing a firmware update is pretty boring. 370 00:36:47,270 --> 00:36:49,310 It'll be done here in a second. 371 00:36:49,610 --> 00:36:51,230 A few seconds. 372 00:36:51,230 --> 00:36:52,710 About 80%. 373 00:36:52,710 --> 00:36:54,610 And then I'll just pull something up. 374 00:36:54,690 --> 00:37:00,270 Like, this ECU just constantly dumps out some messages on the CAN bus. 375 00:37:00,270 --> 00:37:01,330 Okay, it's complete. 376 00:37:01,950 --> 00:37:03,310 So, all right. 377 00:37:03,310 --> 00:37:05,050 Let's talk to this ECU. 378 00:37:05,190 --> 00:37:09,050 I've got to free up the USB device so that the web browser doesn't have a hold of it. 379 00:37:09,810 --> 00:37:10,790 And, all right. 380 00:37:10,790 --> 00:37:11,850 So, let's see if this... 381 00:37:11,850 --> 00:37:12,190 All right. 382 00:37:12,190 --> 00:37:13,310 So, it should be... 383 00:37:13,310 --> 00:37:14,150 Now, if I didn't... 384 00:37:14,150 --> 00:37:16,550 Hopefully, this is where, like, the live demo doesn't go all wrong. 385 00:37:16,950 --> 00: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... 386 00:37:24,210 --> 00:37:25,270 There we go. 387 00:37:25,450 --> 00:37:29,730 So, it's, like, five messages that it just dumps out. 388 00:37:29,730 --> 00:37:33,970 I think it's, like, the torque sensor that's on it and a bunch of other stuff. 389 00:37:33,970 --> 00:37:36,510 So, yeah. 390 00:37:36,850 --> 00:37:38,750 And, I guess that's it. 391 00:37:38,750 --> 00:37:39,790 That's my talk. 392 00:37:39,790 --> 00:37:40,270 Thank you . 393 00:37:46,710 --> 00:37:47,850 What's up? 394 00:38:38,360 --> 00:38:39,820 Yeah, sure. 395 00:38:39,820 --> 00:38:42,480 So, is there any signature on the firmware? 396 00:38:42,600 --> 00:38:43,280 No. 397 00:38:43,280 --> 00:38:44,640 Yeah, there's no signature. 398 00:38:45,100 --> 00:38:46,080 It just... 399 00:38:46,080 --> 00:38:46,640 Like, they just... 400 00:38:46,640 --> 00:38:48,860 There's that last step where they say... 401 00:38:48,860 --> 00:38:52,020 They say, basically, validate the firmware. 402 00:38:52,020 --> 00:38:54,360 There's, like, a routine control message that gets called. 403 00:38:54,360 --> 00:38:55,500 And that validation is just... 404 00:38:56,020 --> 00:38:56,440 Are the checks... 405 00:38:56,440 --> 00:38:57,140 Do the checks... 406 00:38:57,140 --> 00:39:00,820 Do the sum of the bytes add up? 407 00:39:00,820 --> 00:39:01,260 So, yeah. 408 00:39:01,260 --> 00:39:01,620 So, yeah. 409 00:39:01,620 --> 00:39:02,720 There's nothing like that. 410 00:39:03,120 --> 00:39:04,400 And then the other comment was... 411 00:39:04,400 --> 00:39:06,540 I made some assumptions about, like... 412 00:39:06,540 --> 00:39:07,680 I had something. 413 00:39:07,680 --> 00:39:08,820 I wanted to decrypt it. 414 00:39:08,820 --> 00:39:11,860 And I didn't know, you know, what the... 415 00:39:11,860 --> 00:39:13,300 How would I know... 416 00:39:13,300 --> 00:39:17,960 Like, how would I make those assumptions so that I know when it was decrypted completely or properly? 417 00:39:18,400 --> 00:39:19,100 Yeah. 418 00:39:19,100 --> 00:39:20,680 So, I mean, I just guessed, right? 419 00:39:20,680 --> 00:39:29,940 And then, in addition to guessing, though, this ECU here is tore apart because then I have the decrypted firmware. 420 00:39:29,940 --> 00:39:33,340 Like, I figured out how to dump the full firmware. 421 00:39:33,500 --> 00:39:40,040 So, like, these firmware update files, they're, you know, potentially not super useful to modify because they're partial. 422 00:39:40,040 --> 00:39:40,540 Right? 423 00:39:40,540 --> 00: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. 424 00:39:48,840 --> 00:39:49,560 Right? 425 00:39:49,560 --> 00:39:56,100 So, like, what I did was I got an ECU that I was able to dump the firmware off of. 426 00:39:56,100 --> 00: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. 427 00:40:05,760 --> 00:40:07,620 And maybe I, like, I just tried. 428 00:40:07,620 --> 00:40:08,760 Like, okay, well, maybe... 429 00:40:08,760 --> 00:40:09,440 How many times... 430 00:40:09,440 --> 00:40:11,400 I had no idea how many times... 431 00:40:11,400 --> 00:40:18,680 How many sets of, you know, combinations of operators in my brute force decryption would match. 432 00:40:18,680 --> 00:40:22,320 And it turned out, like, 99% of the time there was only one. 433 00:40:22,320 --> 00: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. 434 00:40:35,560 --> 00:40:39,320 This one actually, this specific ECU is simpler than that. 435 00:40:39,320 --> 00:40:40,220 It's UART. 436 00:40:40,220 --> 00:40:41,220 It's serial. 437 00:40:41,220 --> 00:40:44,480 But a lot of them are JTAG that you have to dump them through. 438 00:40:44,480 --> 00:40:45,140 Yep. 439 00:40:45,520 --> 00:40:46,440 Yeah. 440 00:40:53,480 --> 00:40:54,860 No, I don't think so. 441 00:40:54,860 --> 00:40:57,520 I mean, they don't publish any firmware updates. 442 00:40:57,520 --> 00:41:02,780 I think George has, like, said on our Discord multiple times that all firmware modifications are canceled. 443 00:41:03,120 --> 00: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. 444 00:41:09,460 --> 00:41:12,780 So, yeah, this is just my stuff for fun. 445 00:41:12,940 --> 00:41:13,620 So, yeah. 446 00:41:22,080 --> 00:41:22,800 Go ahead. 447 00:41:23,140 --> 00:41:28,320 Yeah , so I haven't had that much time to, like, really work on it and make it awesome. 448 00:41:28,800 --> 00:41:32,140 So, like, I've just tried it on a few ECUs that are actually in my car. 449 00:41:32,140 --> 00: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. 450 00:41:38,840 --> 00:41:42,120 You know, the, where there's a lot more potential. 451 00:41:42,120 --> 00:41:44,540 I mean, they all charge money for that stuff, right? 452 00:41:44,560 --> 00:41:45,280 Well, not all of them. 453 00:41:45,280 --> 00:41:48,260 I think there's some free ones, like ROM Raider or something like that. 454 00:41:49,420 --> 00:41:50,440 But, like, I don't know. 455 00:41:50,440 --> 00:41:51,540 I think this is the future. 456 00:41:51,540 --> 00: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. 457 00:41:58,960 --> 00:42:00,420 And so, like, I don't know. 458 00:42:00,420 --> 00:42:03,960 I feel like I'm showing you the future of what these tools are going to look like someday. 459 00:42:07,420 --> 00:42:08,180 All right. 460 00:42:09,040 --> 00:42:09,680 Cool. 461 00:42:09,700 --> 00:42:10,500 Thanks, guys. 462 00:42:10,500 --> 00:42:14,720 And I think someone gave me this adapter. 463 00:42:14,720 --> 00:42:19,040 Thanks a lot for the adapter so I could actually give my presentation.