start	end	text
0	5360	My talk is about flashing ECU firmware updates from a web browser.
5480	13260	More specifically, I did some reverse engineering of the Honda firmware update file format that they put out.
13460	15180	So that's what I'm going to be talking about.
15820	18220	So, who am I? My name is Greg Hogan.
18820	20800	You can follow me on Twitter.
21100	24640	All the source code for the software that I'm going to show you is open source.
24640	27920	You can find it in one or more of my GitHub repositories.
27920	31540	And I work at Comet AI on infrastructure.
31540	34980	Which, yes, if you're wondering, that has nothing to do with car hacking.
36400	41120	So, a couple days ago, I got an email.
41180	43880	And it said Defcon 27 talk.
43880	48580	And I thought, oh, this is information on my speaking gig here.
48620	52740	I open up the email, and no, it is from Honda.
52780	55460	So apparently they were interested in my talk.
55460	57680	And I'll summarize this for you.
57680	61580	It basically says, don't do something that might kill somebody.
62140	63920	That was never my intention.
64220	70900	I won't be... for some reason they thought that I was probably going to be releasing specific modifications
70900	76700	about making firmware modifications to power steering controllers of Honda vehicles.
76700	78400	That's not the case.
78400	81020	I never planned on talking about anything like that.
81020	83920	So that doesn't change anything that I'm going to be talking about.
83920	87860	Also, this is a completely legitimate thing to ask of someone.
87900	91060	To make sure you don't do something that could injure somebody.
91060	99060	And I agree completely that trying to make changes to your electronic power steering firmware of your car could be very dangerous.
99340	105400	If you screw something up, the best case might be that the steering wheel tries to break your arms.
105400	109560	And the worst case is it'll flip over your car and kill you.
109560	112200	So, please don't do anything stupid.
112200	116940	And I have no intention of enabling you to be able to do such things.
118140	122340	What got me interested in flashing ECU firmware updates?
122820	129660	So, in 2017, George Hotz, he's actually the guy that started the company that I work for.
129660	139920	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.
139920	145380	And I looked at these tools that he was showing and I thought, wow, that software is garbage.
146200	151900	It looks like it runs on Windows XP and why hasn't anyone created anything better?
152700	156500	So, that's kind of what I set out to do.
160320	164860	And I guess to do that, to enable that in a modern web development stack,
164860	171040	that's why I decided to see if I could make this work where I could flash ECUs from web browsers.
172280	176740	It's basically, what I'm going to show you how to do is basically similar to what like,
176740	183260	there's a whole community of people who go out there and they make changes to do like engine tuning for their ECUs,
183260	185760	change like gas fuel mixtures and stuff like that.
186100	188340	They've basically done what I'm going to show you.
188340	195480	They've figured out, you know, how the firmware updates work for, in what I'm going to show you here, Honda vehicles.
195580	203520	And then they figure out how to flash their own firmware updates, essentially, without using the Honda software to do so that they distribute.
209740	216400	So, how do you get the software and firmware updates for these vehicles?
216400	225100	So, thanks to Right to Repair, vehicle manufacturers are basically required to provide, at a reasonable cost,
225100	233660	the firmware updates for the tools basically that enable any maintenance shop to be able to do repair work
233660	240380	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.
240380	257180	So, anyone can sign up for these websites. Honda is really cheap, $10 for one day to download the software that they provide to their repair shops
257180	264060	and anyone who's like, you know, a repair shop that repairs Honda vehicles, they'll subscribe to this also.
264180	267660	If you subscribe for one day, interestingly, you actually get three days.
268540	274280	So, Toyota's a little more expensive and, you know, there's other vehicle manufacturers.
274280	279620	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,
279620	284660	the firmware updates are actually pushed to your vehicle so you don't have to like pay to get them.
286680	297640	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.
298260	304520	It's horrible, just like from a UI perspective, usability perspective. It's not great software.
305520	312860	The authentication is over HTTP. Like, nobody's proud of themselves for like working on this software, I don't think.
312880	320660	This is the new version. This is new for like, I think like 2017 model year vehicles or something like that.
320660	326920	The old version looked even sadder. It's called HDS for Honda. It's Honda Diagnostic System.
326920	331100	In 2017, when this new version came out, they threw an I in the front of it.
331100	337520	My guess is they're like trying to ride the Apple train, you know, bandwagon or something like iOS and so forth.
337520	341880	But using this software is nothing like using an Apple product.
342400	347200	You also need a piece of hardware to interface with the car through the ODB2 port.
347200	357640	So, that hardware, if you go to the Honda website, there's one like certified hardware package that you can buy.
357640	359880	And it is almost $1500.
361280	370600	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.
372720	382520	So, one of those boxes on like that first window was something called the J2534 rewrite tool.
382520	389700	So, what is that thing? That's the software that actually does the firmware updates, that actually flashes your ECUs.
390440	397880	So, the company I work for, they actually make an OBD2 dongle that has a USB port called a Panda.
397880	402680	And it's a lot cheaper than the $1500 product that Honda sells.
402820	412900	It has an open source J2534 driver, which is basically the API that like the whatever for like emissions testing and so forth.
412900	417260	They defined it so that, you know, to enable right to repair, essentially.
418520	423680	And the driver, like it's not perfect, but it at least works for CAN.
423680	429260	And so, I decided to go down this path since it's so much more cost effective.
429260	437860	And the Panda has, it has a great Python library for interacting with your vehicle over the OBD2 port.
438160	442440	And someone wrote a web USB driver for it.
442720	449910	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.
451530	461790	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.
462030	465290	So, that's how you get the actual firmware update files.
465470	469010	And they're in this folder here that I listed at the bottom.
471390	475870	So, okay, now we've got a flashing tool and we've got firmware updates.
475870	486350	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.
486350	493110	So, the first thing that I found was this software called J2534 Logger.
493410	501490	Basically, what that does is it acts as a proxy to a real J2534 driver.
501490	510930	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.
511010	524390	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.
524390	530910	So, that's another reason that I was interested in creating my own software that flashes this.
530910	537030	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.
538070	548390	So, basically, you can fire up that J2534 rewrite tool that Honda puts out and fire up this, install this logger.
548390	556570	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.
556590	566530	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.
566530	579770	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.
580750	595270	UDS, Unified Diagnostics, that's, like, a big one. 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.
595270	612190	The next layer down is ISOTP. 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.
615350	627440	All right. So, after recording flashing an ECU from that J2534 rewrite tool that Honda distributes, here's what you come up with.
628260	643360	It's basically more or less an eight-step process here. 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.
644360	660200	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.
660200	677660	Once you get there, you can request a seed. You'll then see the seed go back to the software. 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.
677860	684440	So, this is what we want to get to, right? 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.
686320	697300	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.
697900	712280	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.
712280	720440	So, it turns out that these Honda firmware update files, the firmware portion of the file, they actually encrypt it.
721180	729080	And the J2534 rewrite tool, it doesn't decrypt it. It sends it to the ECU, and then the ECU decrypts it.
729080	740560	So, they haven't distributed, per se, any software that you can obtain that actually has the decryption algorithm in it. It's all in the ECU.
741840	748120	Then you proceed to send the firmware, and then at the very end, it does basically checksum.
748120	754920	You send a message that performs this validation, which I believe what it does is validates that the checksums in the firmware are correct.
755280	763700	The checksums in the Honda firmware are extremely poor. They're actually just the sum of all the bytes across a few sections.
764520	773800	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.
777380	786100	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.
786100	794360	And those firmware update files have a certain format that I'm now going to go through and explain what the different pieces are,
794360	801760	because my ultimate goal here is to create a website that I choose one of these firmware update files,
801760	812540	and I then flash it to an ECU as if I was that J2534 rewrite tool, but without any software written by Honda.
813320	821240	So, the very first byte of the file is what I call the signature. It basically tells you the format of the rest of the file.
821240	826140	There's a few different formats. I'm just going to focus on one, because I only care about one, which is CAN.
826380	831140	There's also other formats, I think, where you flash over LIN or other protocols.
831180	838020	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.
839460	843080	So CAN is this hex 5A value.
843960	852900	Alright, so now the next section, after that first byte, now we're in the CAN-specific format of the firmware update,
852900	854640	and there's six header fields.
854640	867060	These six header fields, they basically have everything that you need to be able to look at one of these firmware update files,
867060	876080	determine if the car that you're plugged into has an ECU that a specific firmware update file applies to,
876080	891340	and if it's running a version of firmware that is supported as an update, or if the file is an update for the version of the firmware that's on the ECU.
892600	894320	You only need a few things.
894320	900200	You need the CAN address of the ECU that you want to know if you can update with the specific firmware file.
900200	902420	So there's one byte that specifies it.
902420	908100	The reason it's a single byte is because, if you look at the spec, 29-bit addresses, there's only one significant byte.
908900	911020	So they just have that one byte in there.
913940	915880	Then there's a few different values.
915880	920600	They can change these security access keys per firmware update file.
920600	927740	So they put the actual keys in the firmware update file because you have to send them to the ECU.
927740	931000	So when the ECU receives the firmware, it knows how to decrypt it.
932680	943020	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.
943020	949020	So what you need to do to get that ECU into programming mode, essentially.
952420	955860	After the headers is the actual firmware.
955860	958800	This is the encrypted firmware that I talked about before.
959260	961760	There's a start address and a length.
964360	967580	That sequence that I laid out, a couple of the steps were saying,
967580	974940	okay, what section of firmware do I want to flash on the ECU and how much data am I now going to send?
974940	979700	That's part of that UDS sequence of messages that you have to send to the ECU.
980660	986980	The Honda ECUs I've looked at, they actually only allow you to flash one section of the firmware.
986980	992880	They did a pretty good job in terms of making it kind of hard to brick the device
992880	997840	because the bootloader is outside of the area that they allow you to flash.
997900	1000240	So that's good.
1001840	1004060	But yeah, the state is encrypted.
1004060	1007020	So we can't really look at the firmware at this point.
1008580	1012500	And then at the end of the file is a checksum.
1012500	1017140	And it's just the sum of all the bytes except the checksum itself.
1017740	1025420	And so that is, that's the entirety of one of these CAN format Honda firmware update files.
1026420	1028420	Alright, the encryption.
1028480	1036320	So I mentioned that this firmware is, like the data section of the update file for the firmware is encrypted.
1036680	1040460	So I thought, okay, well, it'd be interesting to see if we can decrypt that.
1041720	1046900	And the talk that I mentioned at the beginning that got me kind of interested in this, George's CodeBlue talk,
1046900	1053220	he shows one algorithm that they used for encryption.
1053500	1055940	And I thought to myself, oh, okay, well, maybe I'm lucky.
1055940	1058660	Maybe they use the same encryption for every one of these updates.
1059140	1060800	Turns out that's not the case.
1061580	1067980	But there's these keys that we already found in the headers of each firmware update file.
1067980	1072720	So I've got the keys. I've got an example. So what should I try?
1072720	1075360	Okay, well, maybe they just change the operators.
1076600	1080620	It turns out, at least somewhat common, that's the case.
1080620	1089600	And it's not too hard to write a piece of software in Python that just brute force tries every combination of operators
1089600	1098840	that results in a full 256-value lookup table, where every value is, you know, the input is unique to the output.
1099500	1105760	So utilizing that, I wrote this piece of software that I linked to at the top there called RWD X-Ray.
1105960	1108780	And that, it does that, exactly.
1108860	1118960	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
1118960	1121940	to be able to decrypt the firmware.
1126260	1130400	Yeah, so that's really fast. Most of these firmware updates are small.
1130400	1137500	And, yeah, it takes, like, seconds to run this through and find the appropriate operators for a lot of them.
1137500	1143020	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.
1143020	1148520	But it seems like there's a number of them that they actually use the same basic algorithm with just different operators.
1152840	1157400	So this is just an example of running that tool.
1157400	1160740	It just kind of ties everything together that I just talked through.
1161020	1164960	It basically, you know, parses the file, spits out the headers.
1165820	1179500	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,
1179500	1181620	to get the firmware version of an ECU.
1181960	1191900	That returns something that looks like a part number for Honda with an extra few numbers at the end.
1191900	1198140	All of these RWD files have a name that looks like a part number.
1198160	1215900	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?
1215900	1218240	And normally there's just one.
1218920	1223780	Down at the bottom there, all those dots, is it trying every possible set of operators that existed.
1223940	1235780	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.
1238500	1242780	And then it spits out the decrypted firmware into a file at the end.
1244100	1258620	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.
1258620	1264960	It has everything in it, I guess, except the actual security access key exchange algorithm.
1264960	1274920	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.
1275680	1290700	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,
1290700	1295300	going, you know, after you manipulate it with the security access key exchange algorithm.
1295360	1297040	But we don't know what that is.
1297040	1312000	So, brute force would take a long time. 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.
1312040	1317500	So, what else would have this security access key exchange that I already have access to?
1318180	1322200	Well, how about that J2534 reflash tool?
1322200	1328980	Turns out it's pretty easy to find the security access key exchange algorithm in that tool.
1329240	1345340	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.
1345340	1354540	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.
1356340	1367540	And so, yeah, great. 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.
1368440	1374620	And I guess, like, all the people that do, like, the engine tuning, the ECU tuning, I guess they all know this? I don't know.
1374620	1379060	I guess it's easy to find, though. So, I guess it makes sense that they would.
1381080	1387360	All right. So, I've got everything I want, or I need to know now to build this website.
1387360	1398640	So I created this website. It's open source. Autoecu.io is the URL. It's the AutoECU GitHub repository that I have.
1398640	1417740	It's open source. 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,
1417740	1422760	so that you can interact with a USB device directly from a web browser.
1422760	1433220	This website is just static content. Like, you don't need an internet connection to use it. There's no API. You can totally just pull down the GitHub repo and run it locally.
1433780	1437860	But, you know, for convenience, I just threw it up on AutoECU.io.
1441160	1450780	There are some problems. It's not perfect. 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.
1450780	1464000	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,
1464000	1474860	they don't let tabs that are, like, in the background or don't have focus keep executing code indefinitely, or maybe they only give it, like, small time slices or something.
1474860	1485840	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.
1485980	1488700	So you really don't want that to happen, you know, in the middle.
1490640	1497800	Generally, it's, like, it's okay. Like, if you cancel flashing one of these ECUs in the middle, you've potentially erased the ECU.
1497800	1507160	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.
1507620	1512600	But, yeah, it's definitely possible that you'll brick an ECU if you use this.
1514160	1523800	So, I have a little video here. I have a 2017 Honda CR-V. It has ECU updates for several ECUs.
1523800	1530400	I'll just play this here. See if I can make it full screen here.
1531800	1538140	If you watch the dash really close, things look pretty good right now. It looks normal.
1538240	1541000	I'm, like, picking the firmware file right now.
1542620	1544700	It does a little validation.
1544940	1548040	And then I'm going to start the flashing process here.
1548040	1555060	And then, holy shit, every error code possible pops up on the dash.
1556200	1561220	So, I don't know if I, like, missed. Maybe I missed something. Maybe there's, like, some way to prevent that from happening.
1561380	1567080	But it's kind of scary. I mean, I tested this, like, on a bench before and actually, like, had bugs in my code.
1567080	1574820	Like, for example, when you plug into one ECU sitting on a bench, there's no other ECUs on the CAN bus.
1574820	1589640	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.
1589640	1592940	When, you know, the ECUs are throwing messages all over the place all the time.
1593260	1594800	So, luckily, that was easy to fix.
1594800	1599580	And now it works better and, like, actually, this successfully flashes the ECU.
1600100	1601860	Looks like it's flashing right now.
1601860	1608440	Actually applying the firmware. I think this is, like, applying the radar firmware update for my car or something like that.
1609120	1618900	So, I just took, you know, the RWD file. Honda names these firmware update files with .RWD as the extension.
1619840	1627900	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.
1627900	1632840	And then I just power cycled the car and all the errors went away.
1633100	1635500	So, it's great. It worked.
1640600	1641620	Thanks.
1641620	1643600	So, that was fun.
1644000	1652080	But, you know, these ECU engine tuner guys, they don't just flash the updates that they, you know, get from Honda.
1652080	1655540	They reverse engineer this and they generate their own updates, right?
1655540	1665600	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.
1667060	1669640	So, you don't need a whole lot of information.
1669640	1672720	You just need, you know, whatever is in that RWD file.
1673740	1675440	You can just make up some keys.
1675720	1679800	You do have to be able to figure out, you know, how to get firmware off of an ECU maybe.
1679800	1686180	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.
1688200	1691640	And, but you got to be able to get, you know, the firmware.
1691640	1696660	You have to be able to encrypt it since it's encrypted in these RWD update files.
1696700	1703400	But this is actually like a pretty good format for updating an ECU because it's like self-contained.
1703400	1709620	It's a self-contained file and it has everything in it you need to be able to flash an ECU,
1709620	1718940	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.
1718940	1726700	So, in my RWD X-Ray repo, there is a script that does just that.
1726700	1734620	If you supply an encrypted firmware file like what you would find in one of the RWD files in the firmware section
1734620	1744760	and the appropriate headers, then it will kick out for you an RWD file that you can flash using my website.
1745380	1756460	All right. So, let's do that. I have, I just, just because out of convenience, I have an ECU here that I tore apart to play around with.
1756460	1764220	And it's, you can get, for example, a lot of ECUs on, you know, like LKQ online for really cheap.
1764220	1771140	This is specifically an ECU for the electronic power steering for my 2017 Honda CR-V.
1771140	1777660	I'm just using it because, like, that's what I have out of convenience. So, let's, so let's do it.
1784020	1789140	So, yeah. So, basically, I just, I was, I figured out how to extract the firmware from this ECU.
1789140	1797480	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.
1797480	1802620	It literally just is the original firmware on the ECU. So, that's what we're going to do.
1802620	1807120	So, this is, this is my web, oh, sorry. This is my website, autoecu.io.
1807120	1817720	And, right now, it has a dropdown for manufacturer. Honda is the only manufacturer that is supported, but, you know, it's open source.
1817720	1826880	If someone's interested, they could, you know, definitely add formats of other firmware update files distributed by other car manufacturers.
1827240	1833600	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.
1833600	1836840	It just has, like, I think it has, like, a header that says the start address and the length.
1836840	1841220	And then, it's just the firmware, just, you know, not encrypted or anything.
1841240	1845920	So, you could definitely expand this, you know, if you wanted to.
1846200	1855600	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.
1855760	1857580	You can do all kinds of cool stuff with this, too, right?
1857580	1870460	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.
1870460	1881880	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.
1881880	1883880	So, there's all kinds of cool stuff you can do with this.
1883880	1890780	So, let me power this. It's powered on here. I don't know if anyone can really see this here. Sorry. We didn't get a table.
1891060	1897820	So, this chair here is my... what's that? Oh, hey, I got a table. Let me go grab the table quick. Thanks.
1931070	1934870	All right. So, maybe this setup deserves a little more explanation here.
1934870	1944470	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.
1944470	1946790	Like, they actually put the controller in the motor.
1946790	1949210	So, that's why it's, like, all tore apart and weird.
1950210	1955830	I'm using one of those Panda OBD2 dongles that ComAI sells.
1957430	1963630	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.
1963630	1967790	It's just in case, like, you brick your OBD2 dongle.
1967910	1974570	You can actually... you actually can't really brick it because you can use this Panda Paw to get it into DFU boot mode.
1974570	1980370	So, that's plugged into another thing that we sell, which you don't need by any means at all.
1980370	1987730	It's just, like, a development board that breaks out the OBD2 pins really conveniently.
1987930	2001490	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.
2002570	2003830	So, yeah.
2005090	2009490	So, all right. Let's pull up...
2010090	2016630	This is my fake firmware update that is just, like, the stock firmware that I generated a file for.
2016630	2019450	Because there is no firmware update for this ECU.
2019650	2022650	I pick that firmware update file.
2022950	2024410	And I say next.
2024870	2028950	Now, this is where those headers that are in the RWD file come into play.
2028950	2032290	It just went out.
2032290	2037590	So, I implemented that UDS protocol in the ISOTP.
2037590	2039390	I implemented it in JavaScript.
2039570	2044150	You can see it in the GitHub repo for this website.
2044710	2051670	So, like, it just went off and it just queried that CAN address, 18DA30F1.
2052090	2057670	And I think it might have sent, like, tester present or something like that.
2057910	2058850	Oh, no. I'm sorry.
2058850	2060170	It didn't send that off yet.
2060170	2061790	We still have to connect to the ECU.
2063430	2071970	So, the way WebUSB works, for, like, security reasons, is if you have a device that implements the WebUSB protocol,
2071970	2075650	when you plug it into your computer, it doesn't just, like, get access to things.
2075730	2081710	So, Chrome has this specification where there is a JavaScript call you can make to say,
2081710	2090070	you know, go talk to this USB device, and then it prompts the user to actually say,
2090070	2094470	yes, you're allowed to talk to this USB device from a web browser.
2096650	2099270	So, I pick it. I say connect.
2099270	2107890	Okay, now it actually went out and it actually, like, sent, like, tester present to the ECU and said, like,
2107890	2109710	are you there? Are you awake?
2109710	2117110	And then there's another UDS message called, like, read memory by address.
2117110	2118870	I think it's read memory by address.
2118870	2125250	And there's a specific code that's defined that, there's, like, four of them that are, like, bootloader version,
2125250	2127570	software version, application version.
2127570	2130410	So, I think it's software version.
2130410	2136630	It goes off and it queries the software version, and it checks, does the software version that the ECU returned
2137490	2148290	match what my RWD headers, excuse me, what my RWD headers say are the supported software versions for this firmware update file.
2149510	2150530	All right.
2150530	2151910	So, now we're connected.
2152490	2153490	Next.
2154210	2154910	Okay.
2154910	2155910	This is the danger screen.
2155910	2157490	Like I said, you can brick an ECU.
2157490	2160530	So, don't do this with an ECU that you're not willing to pay to replace.
2160530	2162090	Something could go wrong.
2162110	2163630	I say I agree.
2163670	2165750	And flash.
2165750	2167590	It's erasing the memory.
2168810	2171090	And now it's flashing the firmware.
2171470	2177630	So, it's basically just going through that sequence that I laid out at the very beginning to actually send the firmware update.
2178010	2185110	So, you can't really see the progress bar there really well, but it's at, like, 25% and moving along.
2187330	2192150	LEDs are, like, flashing different colors on the table over here.
2196430	2197370	Yeah.
2197370	2198850	So, I don't know.
2199990	2203230	Once you have this, I guess flashing a firmware update is pretty boring.
2207270	2209310	It'll be done here in a second.
2209610	2211230	A few seconds.
2211230	2212710	About 80%.
2212710	2214610	And then I'll just pull something up.
2214690	2220270	Like, this ECU just constantly dumps out some messages on the CAN bus.
2220270	2221330	Okay, it's complete.
2221950	2223310	So, all right.
2223310	2225050	Let's talk to this ECU.
2225190	2229050	I've got to free up the USB device so that the web browser doesn't have a hold of it.
2229810	2230790	And, all right.
2230790	2231850	So, let's see if this...
2231850	2232190	All right.
2232190	2233310	So, it should be...
2233310	2234150	Now, if I didn't...
2234150	2236550	Hopefully, this is where, like, the live demo doesn't go all wrong.
2236950	2241650	If I try to connect to this ECU and read all the messages that it's dumping out on the CAN bus...
2244210	2245270	There we go.
2245450	2249730	So, it's, like, five messages that it just dumps out.
2249730	2253970	I think it's, like, the torque sensor that's on it and a bunch of other stuff.
2253970	2256510	So, yeah.
2256850	2258750	And, I guess that's it.
2258750	2259790	That's my talk.
2259790	2260270	Thank you.
2266710	2267850	What's up?
2318360	2319820	Yeah, sure.
2319820	2322480	So, is there any signature on the firmware?
2322600	2323280	No.
2323280	2324640	Yeah, there's no signature.
2325100	2326080	It just...
2326080	2326640	Like, they just...
2326640	2328860	There's that last step where they say...
2328860	2332020	They say, basically, validate the firmware.
2332020	2334360	There's, like, a routine control message that gets called.
2334360	2335500	And that validation is just...
2336020	2336440	Are the checks...
2336440	2337140	Do the checks...
2337140	2340820	Do the sum of the bytes add up?
2340820	2341260	So, yeah.
2341260	2341620	So, yeah.
2341620	2342720	There's nothing like that.
2343120	2344400	And then the other comment was...
2344400	2346540	I made some assumptions about, like...
2346540	2347680	I had something.
2347680	2348820	I wanted to decrypt it.
2348820	2351860	And I didn't know, you know, what the...
2351860	2353300	How would I know...
2353300	2357960	Like, how would I make those assumptions so that I know when it was decrypted completely or properly?
2358400	2359100	Yeah.
2359100	2360680	So, I mean, I just guessed, right?
2360680	2369940	And then, in addition to guessing, though, this ECU here is tore apart because then I have the decrypted firmware.
2369940	2373340	Like, I figured out how to dump the full firmware.
2373500	2380040	So, like, these firmware update files, they're, you know, potentially not super useful to modify because they're partial.
2380040	2380540	Right?
2380540	2388840	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.
2388840	2389560	Right?
2389560	2396100	So, like, what I did was I got an ECU that I was able to dump the firmware off of.
2396100	2405100	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.
2405760	2407620	And maybe I, like, I just tried.
2407620	2408760	Like, okay, well, maybe...
2408760	2409440	How many times...
2409440	2411400	I had no idea how many times...
2411400	2418680	How many sets of, you know, combinations of operators in my brute force decryption would match.
2418680	2422320	And it turned out, like, 99% of the time there was only one.
2422320	2432720	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.
2435560	2439320	This one actually, this specific ECU is simpler than that.
2439320	2440220	It's UART.
2440220	2441220	It's serial.
2441220	2444480	But a lot of them are JTAG that you have to dump them through.
2444480	2445140	Yep.
2445520	2446440	Yeah.
2453480	2454860	No, I don't think so.
2454860	2457520	I mean, they don't publish any firmware updates.
2457520	2462780	I think George has, like, said on our Discord multiple times that all firmware modifications are canceled.
2463120	2469420	So, yeah, I mean, this is just, you know, this is just me working on this stuff in my free time, basically.
2469460	2472780	So, yeah, this is just my stuff for fun.
2472940	2473620	So, yeah.
2482080	2482800	Go ahead.
2483140	2488320	Yeah, so I haven't had that much time to, like, really work on it and make it awesome.
2488800	2492140	So, like, I've just tried it on a few ECUs that are actually in my car.
2492140	2498840	But I haven't, like, I haven't specifically tested it out on, like, what, like, the engine tuning ECU guys do.
2498840	2502120	You know, the, where there's a lot more potential.
2502120	2504540	I mean, they all charge money for that stuff, right?
2504560	2505280	Well, not all of them.
2505280	2508260	I think there's some free ones, like ROM Raider or something like that.
2509420	2510440	But, like, I don't know.
2510440	2511540	I think this is the future.
2511540	2518940	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.
2518960	2520420	And so, like, I don't know.
2520420	2523960	I feel like I'm showing you the future of what these tools are going to look like someday.
2527420	2528180	All right.
2529040	2529680	Cool.
2529700	2530500	Thanks, guys.
2530500	2534720	And I think someone gave me this adapter.
2534720	2539040	Thanks a lot for the adapter so I could actually give my presentation.
