[00:00.000 --> 00:04.800] My name is Aaron or Acorn. Uh and I'm a security researcher with [00:04.800 --> 00:10.120] Grimm. And I play with cars and I'm gonna tell you about what [00:10.120 --> 00:15.240] UDS is and why it can help you hack cars. And let's get [00:15.240 --> 00:19.380] moving. So what is UDS? Um I'm not gonna go through all this [00:19.380 --> 00:21.920] detail because it's really boring and a bunch of standards. [00:21.920 --> 00:26.060] But basically UDS is a higher level protocol that lives on top [00:26.060 --> 00:31.100] of CAN. CAN itself uh for the for the purposes of this [00:31.100 --> 00:35.120] particular talk you can think of CAN as about uh kind of old [00:35.120 --> 00:38.660] school 10 100 ethernet. You can have a bunch of things on the [00:38.660 --> 00:41.160] bus and they can talk to each other to use the MAC address to [00:41.160 --> 00:43.460] figure out what messages are meant for them. Right? So keep [00:43.460 --> 00:46.860] that in mind that's basically CAN. UDS itself is then a higher [00:46.860 --> 00:51.940] level protocol living on top of that. As you may know CAN has a [00:51.940 --> 00:55.560] limit of 8 bytes per message. And so if you want to send [00:55.560 --> 00:59.480] anything bigger than 8 bytes, like you want to send firmware [00:59.480 --> 01:02.840] to an ECU on a car, you're going to need to use a higher level [01:02.840 --> 01:08.600] protocol to segment that up into multiple messages. So ISOTP is a [01:08.600 --> 01:12.420] segmentation layer, kind of like IP. And then you have UDS itself [01:12.420 --> 01:16.280] which you can think of like, I mean the analogies break down at [01:16.280 --> 01:19.000] this point but you can go with maybe UDP, TCP, whatever you [01:19.000 --> 01:22.280] feel like. Like I said the analogy does break down at that [01:22.960 --> 01:24.520] point. But there's the ISO standards if you feel like [01:24.520 --> 01:28.120] looking at it. One quick mention OBD2. OBD2 is a little bit [01:28.120 --> 01:31.180] different standard. Uh it's not really living on top of these [01:31.180 --> 01:34.980] things as well. Uh it but it's meant it's very specifically uh [01:34.980 --> 01:38.980] single purpose meant to talk to the uh emissions related [01:38.980 --> 01:42.780] equipment for scanning codes. So it's not really the same thing [01:42.780 --> 01:47.420] but sometimes the ECUs which do talk OBD2 also talk UDS. [01:47.560 --> 01:52.920] Sometimes not. So CAN. Um you have a message ID, arbitration [01:52.920 --> 01:55.300] ID. It's what identifies what message is meant to go on the [01:55.300 --> 02:00.780] bus. Uh the if you have standard CAN is 11 bits only for the [02:00.780 --> 02:06.360] message ID, arbitration ID. In standard for UDS is 7xx is going [02:06.360 --> 02:10.700] to be the request and then 7xx plus 8 is going to be the [02:10.700 --> 02:15.480] response ID. This will make sense eventually. I promise. Uh [02:15.480 --> 02:18.860] the 29 bit which or the extended CAN is a little bit different [02:18.860 --> 02:22.580] where it uses two different uh you know two different bytes as [02:22.580 --> 02:25.200] kind of the sender and receiver. It makes a little bit more [02:25.200 --> 02:29.660] sense. Uh OBD2 there's a specialized set of uh IDs that [02:29.660 --> 02:35.120] are meant for OBD2 only. So you don't know and so going back to [02:35.120 --> 02:39.400] the Ethernet and IP example, we don't have uh routers here. We [02:39.400 --> 02:42.840] don't have a switch. We don't have DNS to tell us what's on [02:42.840 --> 02:47.000] the bus. So the thing is we need to figure it out. But right here [02:47.000 --> 02:51.100] we've got a very it's a pretty limited subset of IDs that we [02:51.100 --> 02:54.300] can scan to figure out what's on that bus. It's like a maximum [02:54.300 --> 03:03.800] of that's actually a little bit less than 255, 256. So real [03:03.800 --> 03:07.100] quick, ISOTP, there's a couple different frame types. It's not [03:07.100 --> 03:10.240] really important at this point but basically the first nibble [03:10.240 --> 03:14.520] of the CAN data frame indicates what type of message it is. [03:14.600 --> 03:17.740] Since it's a limited subset of values, it can make it really [03:17.740 --> 03:22.520] easy to see uh large data transfers. And which is one of [03:22.520 --> 03:25.480] the things that is nice about UDS. It makes it easy to just [03:25.480 --> 03:28.680] visually take a look at it and see that something is happening. [03:30.660 --> 03:33.540] Uh couple different UDS services. If you take a look at [03:33.540 --> 03:36.720] this and you say what do I want to do to a car? You can say that [03:36.720 --> 03:39.620] well downloading and uploading things to the ECUs does sound [03:39.620 --> 03:43.400] interesting. Transferring data, security access. This is there's [03:43.500 --> 03:45.680] a lot more than this. If you want to know you can go look at [03:45.680 --> 03:48.840] the standard. Actually the Wikipedia page for UDS is pretty [03:48.840 --> 03:52.820] good. Uh and so you can go take a look at that. There's a lot of [03:52.820 --> 03:57.140] things in here that are custom per automaker which means to [03:57.140 --> 04:00.720] figure out what uh is actually supported for an ECU. You need [04:00.720 --> 04:03.660] to either have the design documents or you need to figure [04:03.660 --> 04:09.020] it out. So that's kind of the goal here. So let's take a look [04:09.020 --> 04:12.740] here's a couple different ECU uh UDS responses. The whole idea [04:12.740 --> 04:15.640] is you've got a request. So in the very first message here [04:15.640 --> 04:23.140] we've got a request ID of 74A. And the response here is 7B4. And [04:23.140 --> 04:25.260] you'll notice that that's not actually what I said earlier. [04:25.260 --> 04:28.300] Earlier I said it should be 8 more than that. Well that's the [04:28.300 --> 04:30.900] standard. Just because it's the standard doesn't mean it's [04:30.900 --> 04:33.580] actually what is ever done because nothing's ever actually [04:33.580 --> 04:38.120] done standardly on passenger automa- passenger vehicles. So [04:38.120 --> 04:41.240] here we see the message uh the very first you see the first [04:41.240 --> 04:44.280] nibble of the data is uh 0 which means it's a single frame [04:44.280 --> 04:47.720] message. Again it's very obvious what's going on. Second nibble [04:47.720 --> 04:53.920] is the length. And then after that we see 10, 0, 3. 10 is the [04:53.920 --> 04:58.720] uh diagnostic session request. 3 is just a session ID. What does [04:58.720 --> 05:04.760] that session mean? Well again it means whatever the automaker [05:04.760 --> 05:09.060] wants it to mean. So the only way to figure out what it means [05:09.060 --> 05:14.480] is if you can start actually taking uh you know querying what [05:14.480 --> 05:18.820] functionality is available in that diagnostic session. You [05:18.820 --> 05:21.660] might have some simple diagnostics in session 2. You [05:21.660 --> 05:25.420] might be able to um reprogram the ECUs in session 2. Maybe [05:25.420 --> 05:30.440] session 3 lets you do things like um disable the brakes or [05:30.440 --> 05:34.140] something like that. You know so maybe it's some uh debugging or [05:34.140 --> 05:36.780] implementation. Something the engineers were doing that's not [05:36.780 --> 05:39.840] really meant for general consumption. Well if you can [05:39.840 --> 05:42.940] figure out what that is if you can get in there and scan what's [05:42.940 --> 05:46.340] going on then it allows you to get access to what that type of [05:46.340 --> 05:49.980] functionality is. So other another one the second UDS [05:49.980 --> 05:53.560] request here again we've got 7 oh oh yeah so the response [05:53.560 --> 05:57.620] itself so we have 0, 6. Uh so again single frame message 6 [05:57.620 --> 06:03.120] bytes. 50. So the first byte here is isotp. That's kind of [06:03.120 --> 06:08.500] the encapsulation layer. UDS itself is then the actual uh the [06:08.500 --> 06:11.120] remaining bytes right the remaining 7 bytes of this [06:11.120 --> 06:17.400] message. The request is the service ID which was 10. The [06:17.400 --> 06:22.660] response if it's a successful response is then hex 40 more [06:22.660 --> 06:26.360] than the request. These all seem incredibly arbitrary. I know. [06:26.360 --> 06:29.360] And basically it's because I don't know the people who wrote [06:29.360 --> 06:32.580] the standard did it that way. It's actually it's similar it's [06:32.580 --> 06:35.880] based on of older standards so what you're seeing here is kind [06:35.880 --> 06:38.900] of the evolution of a lot of things based on a lot of things [06:38.900 --> 06:42.480] based on a lot of things. Which is basically how all technology [06:42.480 --> 06:46.420] in computers has ever worked. Because it's all based on well [06:46.420 --> 06:49.920] we did it this way so let's do it this way now. That's why it's [06:49.920 --> 06:52.140] this way. So you just gotta take a look at it and look at the [06:52.140 --> 06:56.480] standard and you eventually figure it out. So 50. That means [06:56.480 --> 07:00.100] successful because it was 40 more than the request. And then [07:01.540 --> 07:05.800] the next thing is going to be 3 which is the diagnostic session [07:05.800 --> 07:08.940] that was requested. The length is 6 which means there's 3 more [07:08.940 --> 07:13.220] bytes of data here. I have no idea what they mean but usually [07:13.220 --> 07:16.200] it doesn't actually matter much what they mean but they're here [07:16.200 --> 07:20.560] in case you wanna refer to it later. Uh if you're actually [07:20.560 --> 07:23.020] implemented this or doing something with the dealer tools [07:23.020 --> 07:29.820] it might be meaningful. I don't know. So if it's 40 more that's [07:29.820 --> 07:32.560] successful response. Uh what happens if it's an unsuccessful [07:32.560 --> 07:36.520] response? That's the next example I got here. Got 0, 2, 10, [07:36.520 --> 07:39.900] 4. So it's slightly different session uh session ID I'm [07:39.900 --> 07:43.620] looking for. The response itself then is 7F. That means it's a [07:43.620 --> 07:47.080] negative response. And then you have the error code here which [07:47.080 --> 07:52.400] so it says after the negative response the next byte is the [07:52.400 --> 07:55.360] service ID that caused the error. 10. And then it's the [07:55.360 --> 07:59.500] error code. Well the error code itself is 12. Uh that is [07:59.500 --> 08:02.980] thankfully a standard thing in this. And 12 means subfunction [08:02.980 --> 08:06.900] not supported. So that basically is somebody telling us [08:06.900 --> 08:10.040] that we don't know what this means. So this is again this is [08:10.040 --> 08:14.000] the way that the UDS protocol is allowing us to enumerate what [08:14.000 --> 08:19.620] functionality exists on an ECU. The last one here is a read did [08:19.620 --> 08:24.180] message. So a did in UDS speak is uh a block of data. If you [08:24.180 --> 08:27.920] wanna find out what VIN is in a car you read a particular data [08:27.920 --> 08:32.620] identifier and in this case data identifier F190. Uh that's part [08:32.620 --> 08:35.060] of the standard. There's a range of these different dids which [08:35.060 --> 08:38.500] are standard for the ISO standard. There's uh then [08:38.500 --> 08:41.740] there's a bunch of other stuff which automakers or suppliers do [08:42.280 --> 08:45.580] because they feel like it. Or probably really to put in [08:45.580 --> 08:48.120] information that they feel is necessary. What version of [08:48.120 --> 08:51.140] software do we have in here? Uh what version of the hardware is [08:51.140 --> 08:59.220] this? Who compiled it? Navy. So here the response was uh there's [08:59.320 --> 09:02.380] a couple two things I wanna point out about this last one. [09:02.400 --> 09:08.300] You can see that the error is we have a 7F which means error. But [09:08.300 --> 09:16.420] the error code is 78. Error code 78 means that it's a it's a hold [09:16.420 --> 09:20.340] on let me look let me read this properly. Request correctly [09:20.340 --> 09:24.640] received. Response pending. So basically it means hold on a [09:24.640 --> 09:28.560] second. And this is one that always annoyed me a little bit. [09:28.560 --> 09:30.260] Because if you take a look at the timestamps it didn't [09:30.260 --> 09:32.740] actually take that much longer for the actual message to come [09:32.740 --> 09:35.940] back. First nibble is 1 which means it's the first frame of a [09:35.940 --> 09:40.000] multi-frame message. And then again like I said 3 is the flow [09:40.000 --> 09:43.900] control. So it's saying here's uh it's the person who's [09:43.900 --> 09:47.180] receiving the data telling the other end if it has any [09:47.180 --> 09:49.280] restrictions in the block sizes right? So if you can think of [09:49.280 --> 09:54.460] this again in terms of Ethernet this is kind of like uh uh uh [09:54.460 --> 09:57.840] handshake working out like MTU sizes or something like that [09:57.840 --> 10:01.120] right? Again these these these analogies are a little bit [10:01.120 --> 10:04.740] strained but you know it's it's a way to think about it. But [10:04.740 --> 10:08.020] then the first frame is 2. 2 means it's a multi-frame [10:08.020 --> 10:11.360] message. And this is really good if you're like looking at the [10:11.360 --> 10:15.040] dealer tools for taking a look at if you use the dealer tools [10:15.040 --> 10:17.440] and look at the canned messages that are happening while the [10:17.440 --> 10:20.460] dealer tools are like programming the ECU. It makes it [10:20.460 --> 10:24.460] extremely obvious when there's a block of data going to a [10:24.460 --> 10:28.380] particular location. Because it all starts with 2 and the [10:28.380 --> 10:33.660] message ID is all 7 something or other. Uh in this case the [10:33.660 --> 10:35.860] actual response doesn't matter too much. It was just because of [10:35.860 --> 10:41.440] those two things I wanted to point out there. Alright. So [10:41.440 --> 10:45.400] that's the basics of UDS. Um I could go in for quite a long [10:45.400 --> 10:47.500] time going into detail of UDS which would probably bore [10:47.500 --> 10:51.660] everyone more than you're already bored. Um unless you're [10:51.780 --> 10:54.340] a standards nerd, you don't necessarily like looking at [10:54.340 --> 10:57.220] standards. But it's useful to see that raw level of things. [10:57.220 --> 11:01.460] Tools can usually can easily uh abstract what's the important [11:01.460 --> 11:04.360] stuff that's going on behind the scenes that helps you have a [11:04.360 --> 11:07.940] deeper understanding of what the how the computer is behaving. [11:08.100 --> 11:11.020] So a couple useful tools I want to point out here. First one is [11:11.020 --> 11:14.600] CanCat. Um I work with Grimm. We've uh we like CanCat. We use [11:14.600 --> 11:18.340] it. It's not. There's a uh it has a lot of libraries for [11:18.340 --> 11:20.400] allowing you to do the low level can stuff which is what we [11:20.400 --> 11:23.660] demonstrate over at our booth. But we also have uh class in [11:23.660 --> 11:27.820] there for UDS. It allows you to interact with uh ACU uh doing [11:27.820 --> 11:32.240] UDS functionality. Um and what I'm gonna show here in the [11:32.240 --> 11:35.740] second half is taking a look at a tool I wrote on top of the [11:35.740 --> 11:39.460] CanCat stuff that allows you to essentially do Nmap style [11:39.460 --> 11:44.460] scanning uh on a car. There's uh two other ones I'd like to [11:44.460 --> 11:47.920] point out here that are capable of doing uh UDS things. First [11:47.920 --> 11:50.780] one is carrying car- carrying caribou which I have a hard [11:50.780 --> 11:54.000] time saying. Um it works pretty well. It works with standard [11:54.000 --> 11:58.200] Python can stuff. Uh if you have a socket can capabilities like a [11:58.200 --> 12:02.840] cantact, uh this will work well with it. Um it also does UDS [12:02.840 --> 12:05.660] scanning. Scapey can also do this as well. As much as I love [12:05.660 --> 12:09.580] Scapey, it's not uh the interface is a little bit harder [12:09.580 --> 12:11.960] to use unless you're familiar with how it's working. In this [12:11.960 --> 12:21.300] particular case. So can utils um the raw low-level socket can [12:21.300 --> 12:24.280] that if you run in Linux, you've got socket can. You've got can [12:24.280 --> 12:27.420] utils. They're installed by default, pretty sure, on most [12:27.420 --> 12:31.260] distributions. Uh but the thing is they interact with the raw [12:31.260 --> 12:33.180] can messages. They don't necessarily give you the UDS [12:33.180 --> 12:37.100] capabilities. Um what we demo over at our booth for just [12:37.100 --> 12:39.640] recording and replaying messages, you can do that with [12:39.640 --> 12:42.900] can dump and can player. Uh can sniff is also a really useful [12:42.900 --> 12:47.320] tool. Unfortunately can sniffer isn't actually support 29 bit [12:47.320 --> 12:49.980] messages. There's a pull request that's been open for like a year [12:49.980 --> 12:53.220] for it. Uh you can go and look at the pull request if you want [12:53.220 --> 12:55.520] to go and see it. You can go find a particular patch and [12:55.520 --> 12:58.720] download it and compile it. So it's useful for low-level [12:58.720 --> 13:02.400] things but uh once you start getting to higher-level [13:02.400 --> 13:05.860] protocols, uh you need to usually need to step outside of [13:05.860 --> 13:12.200] something like socket can. And here, like I said, you can use [13:12.200 --> 13:15.300] the can message uh can utils for doing can injection. And [13:15.300 --> 13:17.700] here's just a simple example. You don't really see it [13:17.700 --> 13:20.420] interacting with the vehicle at this point but what I did was I [13:20.420 --> 13:23.680] hit can dump. I started logging. I hit the unlock button. And [13:23.680 --> 13:27.440] then I can't, I control C to kill the can dump. Then I take [13:27.440 --> 13:30.320] the can dump that was generated and I run it through can player [13:30.840 --> 13:34.180] and I watch the car unlock itself, right? So this is again [13:34.260 --> 13:38.620] a simple example of message injection with can utils. Can [13:38.620 --> 13:42.280] sniffer is another useful one um and this allows you to do [13:42.280 --> 13:45.520] like an interactive viewing of the messages that are going on [13:45.520 --> 13:48.680] the bus. You hit the pound sign and then it will slowly shrink [13:48.680 --> 13:51.360] the window like notches the messages it's receiving. And [13:51.360 --> 13:54.260] then it highlights, if you give it the dash C flag, it'll [13:54.260 --> 13:57.560] highlight the new messages it receives. So in this particular [13:57.560 --> 14:00.440] case, what I did was I started can sniffer and then I was [14:00.440 --> 14:03.920] periodically hitting the lock, unlock button. And if you got a [14:03.920 --> 14:08.180] sharp eye, you might notice what message ID is actually doing the [14:08.180 --> 14:13.100] door unlocking in this case. Or if you already did, figured it [14:13.100 --> 14:16.780] out when you were taking a look at it on our booth. But anyway, [14:16.780 --> 14:20.760] so again, hit the lock, hit the unlock message, unlock button on [14:20.760 --> 14:23.260] the key fob and the message popped up, you're highlighted [14:23.260 --> 14:30.800] with the changed bytes in red. Can escapee again, so there's [14:30.800 --> 14:33.940] the uh, there's the incantation for doing it. You can go on the [14:33.940 --> 14:37.760] escapees, read the docs page and it will, there's a good lot of, [14:37.760 --> 14:39.900] there's a lot of information there about using escapee for [14:39.900 --> 14:43.580] automotive testing. And you know, this is just a simple [14:43.580 --> 14:46.640] example. Again, you can do can sniff, this again records all [14:46.640 --> 14:49.520] the messages and you can, it's a python interactive shell and you [14:49.520 --> 14:52.320] can interact with them using all the different python tools [14:52.320 --> 14:58.400] escapee presents. Caring caribou, again this is uh, doing [14:58.400 --> 15:02.180] an ECU scan. So this is starting to get into more of what I was [15:02.180 --> 15:05.820] talking about. How you can use UDS capabilities to identify [15:05.820 --> 15:09.840] what's on the bus. So this again was looking, I was scanning [15:09.840 --> 15:15.320] 3PO and I did UDS discovery. This is just using uh, the can, [15:15.320 --> 15:19.380] cannibal, I was uh, little $10 piece of hardware. And it's fi- [15:19.380 --> 15:22.240] going through all the different ECUs to find out what's present [15:22.240 --> 15:25.080] on the bus. And you can see here it's finding different things. [15:25.080 --> 15:27.000] It's finding some things that are standard, it's finding some [15:27.000 --> 15:30.040] things that are not standard. The particular results in this [15:30.040 --> 15:34.120] case don't matter too much. It's nicer to have something animated [15:34.120 --> 15:42.840] on the screen. So UDS, uh, one of the nicest, well okay, the [15:42.840 --> 15:45.660] functionality of, not the nicest, but one of the nicer [15:45.660 --> 15:48.940] things about UDS is the error codes. They're extremely [15:48.940 --> 15:51.040] verbose. This is one of those things where you take a look at [15:51.140 --> 15:53.880] a protocol and you can tell it was written by an engineer. [15:53.880 --> 15:59.240] Because they say, well I want to know why this didn't work. I [15:59.240 --> 16:01.420] want to know why this didn't work. So there's, well, there's [16:01.520 --> 16:03.520] a byte for the messages. So you've got a couple hundred [16:03.520 --> 16:06.880] possibilities of what the error code is. They're not all valid [16:06.880 --> 16:10.080] but a lot of them are valid. And here's some of the common ones. [16:10.180 --> 16:12.620] Service not supported. Conditions not correct, which is [16:12.620 --> 16:16.320] an interesting one. Security access denied. Invalid key. [16:16.800 --> 16:20.400] Exceeded number of attempts. Uh, so exceeded number of attempts [16:20.400 --> 16:23.300] for example is one where if you're trying to do a security [16:23.300 --> 16:26.800] access, what should happen if you do it wrong is you're [16:26.800 --> 16:29.320] supposed to then get an error message back saying that you [16:29.320 --> 16:32.880] ran out of attempts. Well, sometimes it happens, sometimes [16:32.880 --> 16:36.480] it doesn't. Uh, conditions not correct is a good one because [16:36.480 --> 16:39.460] what it's saying is I can't do the thing that you're asking [16:39.460 --> 16:43.620] for but I am capable of doing it if the conditions were correct. [16:43.620 --> 16:46.740] So then you've got to figure out what those conditions might be. [16:46.740 --> 16:49.340] Again, it lets you start narrowing down the type of [16:49.340 --> 16:51.920] functionality you're looking for. There's also a really [16:51.920 --> 16:55.880] verbose section of errors like RPM too high, RPM too low. [16:55.880 --> 16:59.660] Engine is running. Engine is not running. Uh, throttle pedal [16:59.660 --> 17:03.420] too high, too low. Transmission not in neutral. Transmission in [17:03.420 --> 17:07.700] gear. And not all of these different error codes are things [17:07.700 --> 17:11.320] that all automakers implement. But when you see them, it allows [17:11.320 --> 17:14.520] you to know that, well, great, this thing I've almost gotten [17:14.520 --> 17:18.060] to the ability to activate this function. All I have to do is [17:18.060 --> 17:21.640] change the conditions that the car is in. So again, this is [17:21.640 --> 17:24.640] allowing you to scan the functionality. You don't have [17:24.640 --> 17:27.040] any knowledge of what's going on. And it's allowing you to [17:27.040 --> 17:33.920] figure out what is going on. So, UDS. So, because I can't help [17:33.920 --> 17:37.600] myself, I named it CanMap. Because it's based on CanCat and [17:37.600 --> 17:43.180] it helps you do end mapping of a car, right? That's the theory [17:43.180 --> 17:46.340] anyway. So there's, there's my, there's my car. My own test [17:46.340 --> 17:51.160] subject that I tested this on. Uh, to try and figure out what's [17:51.160 --> 17:55.540] going on. So, again, uh, when you're taking, doing a pen test, [17:55.540 --> 17:57.820] right? If you're doing a pen test, you want to figure out [17:57.820 --> 18:00.920] what's on this network. What services are available on this [18:00.920 --> 18:04.500] network? You run Nmap with a different range of IP addresses [18:04.500 --> 18:07.920] and you come back with, there's a service there that gives you a [18:07.920 --> 18:10.980] successful or an error, some error responses. It allows you [18:10.980 --> 18:14.420] to know that that IP address is valid and allows you to know [18:14.420 --> 18:17.500] what services may or may not be present on there. It can allow [18:17.500 --> 18:21.500] you to detect if there's a firewall present. Um, so Nmap is [18:21.500 --> 18:23.540] again a blind tool that lets you go through it and figure out [18:23.540 --> 18:27.140] what's going on. CanMap is pretty much the same thing. And [18:27.140 --> 18:31.440] of course Karen Caribou does similar things as well. But I [18:31.440 --> 18:34.360] had the, I, I, I felt like doing it on my own. I don't really [18:34.360 --> 18:37.560] like using tools that I've not wrote because I don't actually [18:37.560 --> 18:40.720] ever understand how the tools work until I play with them [18:40.720 --> 18:44.060] myself with my own hands. I might be the only one who ever [18:44.060 --> 18:46.460] uses the tool, but the whole point is it's helped me learn [18:46.460 --> 18:49.880] about how, how UDS works. It's written on top of CanCat. So [18:49.880 --> 18:53.340] it's an example of how you can use CanCat's existing API to [18:53.340 --> 18:57.500] interact with the bus. So use it as a way to learn how CanCat [18:57.500 --> 19:00.100] stuff works. Uh, use it as a tool, standalone tool by [19:00.100 --> 19:05.120] itself. Um, whatever you, use this as an example or a chance [19:05.120 --> 19:08.120] to explore other new tools. As long as people are going out and [19:08.120 --> 19:14.320] learning new things, that's my goal. So, first thing the tool [19:14.320 --> 19:19.200] has right now, uh, because it's brand new, is it allows you to [19:19.200 --> 19:25.280] scan for ECUs. Right here, and it'll start over in a second. So [19:25.280 --> 19:28.060] it allows you to, first thing I'm doing is scanning for ECUs. [19:28.060 --> 19:29.920] There's a couple different ways you can do this. Any [19:29.920 --> 19:32.940] functionality you can send to an EC, any function you can [19:32.940 --> 19:36.640] request. So the things I pointed out earlier, redid, diagnostic [19:36.640 --> 19:41.880] session control, uh, data transfer, ECU reset, there's all [19:41.880 --> 19:45.060] these things that you could send that would allow you to check if [19:45.060 --> 19:49.400] an address is valid. Um, in this particular case, the one of the [19:49.720 --> 19:52.820] default modes is just reading a DITS. So it tries to read the [19:52.820 --> 19:57.200] VIN out of a vehicle. And you can see a bunch of things coming [19:57.200 --> 20:00.360] back here. So it's detecting that, that if there's a [20:00.360 --> 20:06.500] nonstandard response, um, and it logs it in different ways. There's [20:06.500 --> 20:08.820] different, this is just the way that I had figured out how I [20:08.820 --> 20:15.230] wanted to do it. I want to, uh, talk a little bit too about how [20:15.230 --> 20:19.030] the scanning works. UDS works, uh, UDS is the basis of all the [20:19.030 --> 20:21.730] different functionality that like the dealer tools use. When [20:21.730 --> 20:24.370] the dealer goes and interacts with an ECU, if they need to [20:24.370 --> 20:27.270] reprogram it, they're going to use the UDS protocol to get this [20:27.270 --> 20:30.710] to happen. Well, one of the things that's being hap- that's [20:30.710 --> 20:33.290] happening on newer vehicles is there's a CAN gateway sitting on [20:33.290 --> 20:36.410] the OBD2 port. That's supposed to only let the certain things [20:36.410 --> 20:38.570] through that are allowed to go through to the rest of the [20:38.570 --> 20:42.090] vehicle. One of the things that by design it has to allow [20:42.090 --> 20:46.490] through is the UDS messages that allow the dealer tool to interact [20:46.490 --> 20:50.970] with the ECUs. Which means that you, using the UDS will help you [20:50.970 --> 20:54.090] find things, even getting through a gateway. It's [20:54.090 --> 20:58.130] essentially using a firewall's capabilities to allow you to go [20:58.130 --> 21:00.510] through it on its own. You don't have to break through it as long [21:00.510 --> 21:07.550] as it lets you through in a nice and friendly manner. So here's [21:07.550 --> 21:11.750] the results, the results of my scan are output into a YAML file. [21:12.630 --> 21:16.590] I'm not a fan of YAML but it does work well. And the YAML file [21:16.590 --> 21:19.510] has the list of like what are the transmit IDs, what are the [21:19.510 --> 21:23.410] response IDs and eventually what are the actual values of [21:23.410 --> 21:26.990] different DIDS. Now what is the bus speed that I use for this? [21:26.990 --> 21:30.630] And then this YAML file can be used in future scans that will [21:30.630 --> 21:33.330] allow you to not worry about scanning for the ECUs because [21:33.330 --> 21:36.110] you've got them already saved in the file and then you can use [21:36.110 --> 21:40.250] those and go on and scan for other things. It's also got the [21:40.250 --> 21:43.550] notes there indicating what the actual command you ran was. The [21:43.550 --> 21:46.330] idea being that it should help you find out how long did the [21:46.330 --> 21:50.170] scan take and uh what actually, how did you actually invoke the [21:50.170 --> 21:55.510] command that generated the results you see there. So here [21:55.510 --> 21:58.210] again scanning for DIDS, I'm not gonna show you an animated one [21:58.210 --> 22:01.190] for that because it's just a ton of output. But I wanna point out [22:01.310 --> 22:05.590] a couple things here. Again looking at the ISO TP frame IDs. [22:05.590 --> 22:08.070] If you take a look at the bottom one, you'll see you've got the [22:08.070 --> 22:13.950] 0, 1, 3 and a bunch of 2s. Again that's very in, that's very [22:13.950 --> 22:17.610] classic, it's an easy way to see looking at the raw CAN messages [22:17.610 --> 22:21.910] that you're looking at an ISO TP uh block transfer. And then you [22:21.910 --> 22:25.710] can actually see the read DID result there. In this case it [22:25.710 --> 22:31.130] was uh one of the application identifiers. F182, whatever it [22:31.130 --> 22:36.860] is, I don't know. One of the things I also wanna point out [22:36.860 --> 22:41.160] about how UDS is useful in this case is by taking a look at the [22:41.160 --> 22:43.860] contents that you can get out of the different data identifiers [22:43.860 --> 22:47.100] on the different ECUs. Once you have extracted the firmware for [22:47.100 --> 22:50.820] the ECU, they can act as good sign posts. Because it allows [22:50.820 --> 22:54.040] you to have this particular string, search for that string [22:54.040 --> 22:57.140] in the firmware somewhere. And then once you find it, you can [22:57.140 --> 22:59.660] start finding the references. And you can uh, you know that [22:59.660 --> 23:03.780] the references are going to be related to this particular CAN [23:03.780 --> 23:07.840] function out. So it can allow you to go from a known info set [23:07.840 --> 23:10.920] of information in the software that will allow you then figure [23:10.920 --> 23:13.760] out how you get back there to the CAN stuff. And once you take [23:13.840 --> 23:15.560] a look at the CAN functions, you can see what other [23:15.560 --> 23:23.940] functionality might be available through that CAN interface. Uh [23:23.940 --> 23:26.520] one of the other things that is nice about uh that I like about [23:26.520 --> 23:30.340] the tool CANCAT, so it allows you to do a save session file. [23:30.340 --> 23:32.240] You've recorded all this information, all these CAN [23:32.240 --> 23:34.780] messages have been saved, you've been doing hours of testing. [23:34.780 --> 23:38.500] Well, there's a function called save session to file. Uh you can [23:38.500 --> 23:41.260] just type it interactively on the IPython shell, it's a normal [23:41.260 --> 23:45.020] way. Or what, and what we can do here is if you pass the dash C [23:45.020 --> 23:49.460] flag to CAN map, it'll save the session file for you also. It's [23:49.460 --> 23:52.460] just a pickle, a Python pickle if you know how those work. Yes [23:52.460 --> 23:55.300] they're insecure so don't unpickle other people's pickles [23:55.300 --> 23:58.520] that they provide. If that phrase makes, if that sentence [23:58.520 --> 24:03.240] makes sense. But it's really useful because it allows you to [24:03.240 --> 24:06.160] take your logged output that you see, here's the results I [24:06.160 --> 24:09.220] see, here's what's going on, and you can take a look at the raw [24:09.220 --> 24:13.540] CAN messages themselves. So if something has gone weird, then [24:13.540 --> 24:15.940] it can allow you to core, find out exactly what's going on [24:15.940 --> 24:19.100] here. In my limited testing leading up to this, I didn't [24:19.100 --> 24:22.240] have time to go through every scenario to figure out what [24:22.240 --> 24:24.680] works, but being able to go through and look at the raw [24:24.680 --> 24:28.100] messages helps you figure out what's going weird. The last [24:28.100 --> 24:30.900] set of functionality I've gotten it is scan for diagnostic [24:30.900 --> 24:34.700] sessions. Um, I've got the warning here because when I [24:34.700 --> 24:37.740] started doing this, things do start acting weird because it [24:37.740 --> 24:41.020] does involve, uh, putting the ECUs into different modes. I set [24:41.020 --> 24:44.640] the immobilizer off on my car. It did clear as soon as I turned [24:44.640 --> 24:49.260] the car on and off again. Off and on again. Uh, but again, this [24:49.260 --> 24:50.820] is one of those things where once you start messing around [24:50.820 --> 24:53.580] with different diagnostic sessions and ECU resets, things [24:53.580 --> 24:56.660] can get weird. Uh, on the other hand, it can also help you [24:56.660 --> 25:00.820] identify which ECU does what on a car. When I was doing this [25:00.820 --> 25:04.320] scanning for sessions and I saw, okay, well here's the [25:04.320 --> 25:08.500] session ID and then I see my radio start rebooting, I know [25:08.500 --> 25:12.040] that that session ID is my radio. Because just looking at [25:12.040 --> 25:15.420] the raw message IDs, you don't know which ECU those belong to [25:16.060 --> 25:19.580] necessarily. But when you start seeing the actual physical [25:19.580 --> 25:22.820] effects on the car, then you can start correlating that to what [25:22.820 --> 25:27.540] ECU does what function. Again, here's some results. You can see [25:27.540 --> 25:29.840] some of the weird errors I started getting. One of them was [25:29.840 --> 25:32.680] like, when I go to a particular session, after I start scanning [25:32.680 --> 25:35.660] long enough, then it just, it just kind of stopped responding [25:35.660 --> 25:39.960] in a friendly manner. Um, again, I'm not entirely sure why, but [25:39.960 --> 25:42.520] looking at the raw messages can help you diagnose what's going [25:42.520 --> 25:46.260] on. And again, this is the first version of it. It'll get better. [25:46.260 --> 25:48.780] It's still sitting in a pull request up to the main CANCAT. [25:48.780 --> 25:54.940] So, uh, it'll get there eventually. Uh, the, oh, that [25:54.940 --> 25:59.700] must be a later slide. So, real quick wrap up. UDS helps you to [25:59.700 --> 26:03.100] enumerate the vehicles and taxis. Let's you figure out what [26:03.100 --> 26:05.700] ECUs are present. It lets you figure out what data is in [26:05.700 --> 26:08.520] there. The data can then be used to more easily reverse engineer [26:08.520 --> 26:12.040] what's going on in the thing. I do want to point out that UDS [26:12.040 --> 26:16.080] itself is not necessarily a vulnerability in and of itself. [26:16.220 --> 26:19.040] It's simply a way to discover the functionality that's present [26:19.040 --> 26:22.400] on the vehicle. The functionality itself might be [26:22.400 --> 26:25.700] the vulnerability, right? If I'm alive, if I can do things to a [26:25.700 --> 26:32.120] car that are bad, if I can, uh, put my, if I can unlock a [26:32.120 --> 26:35.140] vehicle from an external location, that itself is the [26:35.140 --> 26:37.520] vulnerability. Not the fact that I found out I could do it with [26:37.520 --> 26:41.840] UDS. Uh, if I can put an ECU into diagnostics mode while the [26:41.840 --> 26:46.060] car is running and then, uh, impact the vehicle dynamics, [26:46.060 --> 26:48.500] that is the vulnerability. Not the fact that I use a session [26:48.500 --> 26:52.820] control to do it. This is again similar to the way different [26:52.820 --> 26:55.740] protocols work. Uh, in, in, if you're talking, thinking about [26:55.740 --> 26:58.680] regular computers. I could go on forever with these if I had [26:58.680 --> 27:05.980] time, which I don't. Um, again, the more tools, the better. So I [27:05.980 --> 27:09.020] like Canmap, Kirin, Caribou, Scapey, other options out there. [27:09.060 --> 27:12.580] Uh, and lastly, go out there, scan, be curious, play with your [27:12.580 --> 27:18.920] own car, uh, and have fun. That's it. I know it was really [27:18.920 --> 27:26.190] quick. And if you have any questions, uh, we don't have [27:26.190 --> 27:28.850] time right now, unfortunately, but please, uh, I'll stand [27:28.850 --> 27:31.250] around afterwards. If you have questions, let me know and I'll [27:31.250 --> 27:34.270] answer them or go into more detail if you wish. A couple [27:34.270 --> 27:36.470] links here. If you haven't yet read Chris and Charlie's paper, [27:36.470 --> 27:39.870] it goes a lot into UDS and security access key, uh, uh, [27:39.870 --> 27:43.030] the seed key pairs. That's very valuable to go and look at. It [27:43.030 --> 27:45.110] talks about reverse engineering those algorithms out of the [27:45.110 --> 27:48.090] dealer tools. The dealer tools are always a valuable resource [27:48.090 --> 27:50.110] when you're trying to figure out what the capabilities of a [27:50.110 --> 27:52.990] vehicle are. Uh, and again, some links to the other different [27:52.990 --> 28:00.870] CAN tools here. That's it. Yes? Uh, yeah, question was if I've [28:00.870 --> 28:02.950] messed with the Tesla 3. I've not personally messed with the [28:02.950 --> 28:12.290] Tesla 3. Anyway, I'm pretty sure I'm out of time. It is in a poll [28:12.290 --> 28:15.230] request up on the CANCAT repo. So if you go up to CANCAT and [28:15.230 --> 28:17.070] you look for pull requests, you'll find one of them that's [28:17.070 --> 28:21.350] branch labeled CANMAP. So it's working on it. It was a lot of [28:21.350 --> 28:25.050] code changes, so it is, uh, it was a lot of code changes, so [28:25.050 --> 28:27.530] it's gonna take a little while to review and make, and fix all [28:27.530 --> 28:39.000] the stylistic things that I've messed up. Alright, question was [28:39.000 --> 28:41.560] about emulators, so for messing around with this. If you play [28:41.560 --> 28:44.300] with the SocketCAN tools, you can create a virtual CAN device [28:44.300 --> 28:47.480] which will allow you to play back pre-recorded data. Uh, I [28:47.480 --> 28:52.260] did, did create a testing CAN interface for CANMAP. Uh, it's [28:52.260 --> 28:54.060] kind of limited at the moment though, but it allows you to [28:54.060 --> 28:56.280] kind of fake out the high level stuff, but not the low level [28:56.280 --> 29:04.180] ones. So, short answer is, kind of. Right, yeah, and there's [29:04.180 --> 29:06.840] also tool, we also have a tool in CANCAT now that allows you to [29:06.840 --> 29:12.060] go between SocketCAN dumps and, uh, P, or PCAPs and CANCAT [29:12.060 --> 29:14.960] sessions files. So you can convert from one to the other to [29:14.960 --> 29:17.840] play with them if you wanted to. But, uh, that is functionality [29:17.840 --> 29:21.700] I would like to do eventually. But, I'm now a couple minutes [29:21.700 --> 29:24.180] past time. Whoever's next is gonna need to get up here, so I [29:24.180 --> 29:29.200] do need to shut down. Thank you everybody for being here. And [29:29.200 --> 29:30.600] I'll be hanging around afterwards.