1 00:00:00,000 --> 00:00:02,140 My name is Aaron or Acorn. 2 00:00:02,160 --> 00:00:05,560 Uh and I'm a security researcher with Grimm. 3 00:00:05,820 --> 00:00:13,560 And I play with cars and I'm gonna tell you about what UDS is and why it can help you hack cars. 4 00:00:13,800 --> 00:00:16,020 And let's get moving. 5 00:00:16,260 --> 00:00:17,900 So what is UDS? 6 00:00:17,980 --> 00:00:21,920 Um I'm not gonna go through all this detail because it's really boring and a bunch of standards. 7 00:00:21,920 --> 00:00:26,840 But basically UDS is a higher level protocol that lives on top of CAN. 8 00:00:27,000 --> 00:00:36,980 CAN itself uh for the for the purposes of this particular talk you can think of CAN as about uh kind of old school 10 100 ethernet. 9 00:00:37,220 --> 00:00:42,820 You can have a bunch of things on the bus and they can talk to each other to use the MAC address to figure out what messages are meant for them. 10 00:00:42,820 --> 00:00:43,140 Right? 11 00:00:43,140 --> 00:00:45,240 So keep that in mind that's basically CAN. 12 00:00:45,380 --> 00:00:48,760 UDS itself is then a higher level protocol living on top of that. 13 00:00:49,320 --> 00:00:53,420 As you may know CAN has a limit of 8 bytes per message. 14 00:00:53,720 --> 00:01:06,200 And so if you want to send anything bigger than 8 bytes, like you want to send firmware to an ECU on a car, you're going to need to use a higher level protocol to segment that up into multiple messages. 15 00:01:06,360 --> 00:01:10,280 So ISOTP is a segmentation layer, kind of like IP. 16 00:01:10,480 --> 00:01:19,300 And then you have UDS itself which you can think of like, I mean the analogies break down at this point but you can go with maybe UDP, TCP, whatever you feel like . 17 00:01:19,300 --> 00:01:22,280 Like I said the analogy does break down at that point. 18 00:01:22,960 --> 00:01:25,200 But there's the ISO standards if you feel like looking at it. 19 00:01:25,200 --> 00:01:27,160 One quick mention OBD2. 20 00:01:27,160 --> 00:01:29,420 OBD2 is a little bit different standard. 21 00:01:29,440 --> 00:01:31,960 Uh it's not really living on top of these things as well. 22 00:01:31,960 --> 00:01:40,940 Uh it but it's meant it's very specifically uh single purpose meant to talk to the uh emissions related equipment for scanning codes. 23 00:01:41,060 --> 00:01:47,420 So it's not really the same thing but sometimes the ECUs which do talk OBD2 also talk UDS. 24 00:01:47,560 --> 00:01:48,740 Sometimes not. 25 00:01:49,060 --> 00:01:50,200 So CAN. 26 00:01:50,360 --> 00:01:53,360 Um you have a message ID, arbitration ID. 27 00:01:53,360 --> 00:01:56,040 It's what identifies what message is meant to go on the bus. 28 00:01:56,120 --> 00:02:02,760 Uh the if you have standard CAN is 11 bits only for the message ID, arbitration ID. 29 00:02:02,760 --> 00:02:11,880 In standard for UDS is 7xx is going to be the request and then 7xx plus 8 is going to be the response ID. 30 00:02:12,140 --> 00:02:14,040 This will make sense eventually. 31 00:02:14,040 --> 00:02:15,020 I promise. 32 00:02:15,200 --> 00:02:24,220 Uh the 29 bit which or the extended CAN is a little bit different where it uses two different uh you know two different bytes as kind of the sender and receiver. 33 00:02:24,220 --> 00:02:26,180 It makes a little bit more sense. 34 00:02:26,640 --> 00:02:31,580 Uh OBD2 there's a specialized set of uh IDs that are meant for OBD2 only. 35 00:02:31,760 --> 00:02:39,300 So you don't know and so going back to the Ethernet and IP example, we don't have uh routers here. 36 00:02:39,300 --> 00:02:40,800 We don't have a switch. 37 00:02:40,800 --> 00:02:43,680 We don't have DNS to tell us what's on the bus. 38 00:02:43,680 --> 00:02:46,320 So the thing is we need to figure it out. 39 00:02:46,320 --> 00:02:53,420 But right here we've got a very it's a pretty limited subset of IDs that we can scan to figure out what's on that bus. 40 00:02:53,420 --> 00:02:58,860 It's like a maximum of that's actually a little bit less than 255, 256. 41 00:03:02,760 --> 00:03:06,760 So real quick, ISOTP, there's a couple different frame types. 42 00:03:06,760 --> 00:03:14,520 It's not really important at this point but basically the first nibble of the CAN data frame indicates what type of message it is. 43 00:03:14,600 --> 00:03:21,440 Since it's a limited subset of values, it can make it really easy to see uh large data transfers. 44 00:03:21,440 --> 00:03:24,660 And which is one of the things that is nice about UDS. 45 00:03:24,660 --> 00:03:28,680 It makes it easy to just visually take a look at it and see that something is happening. 46 00:03:30,660 --> 00:03:32,920 Uh couple different UDS services. 47 00:03:32,920 --> 00:03:35,720 If you take a look at this and you say what do I want to do to a car? 48 00:03:35,940 --> 00:03:40,420 You can say that well downloading and uploading things to the ECUs does sound interesting. 49 00:03:40,460 --> 00:03:42,480 Transferring data, security access. 50 00:03:42,480 --> 00:03:44,440 This is there's a lot more than this. 51 00:03:44,440 --> 00:03:46,380 If you want to know you can go look at the standard. 52 00:03:46,380 --> 00:03:49,580 Actually the Wikipedia page for UDS is pretty good. 53 00:03:50,020 --> 00:03:52,200 Uh and so you can go take a look at that. 54 00:03:52,220 --> 00:04:00,540 There's a lot of things in here that are custom per automaker which means to figure out what uh is actually supported for an ECU. 55 00:04:00,540 --> 00:04:04,520 You need to either have the design documents or you need to figure it out. 56 00:04:04,520 --> 00:04:06,720 So that's kind of the goal here. 57 00:04:08,040 --> 00:04:11,880 So let's take a look here's a couple different ECU uh UDS responses. 58 00:04:11,880 --> 00:04:14,300 The whole idea is you've got a request. 59 00:04:14,320 --> 00:04:19,380 So in the very first message here we've got a request ID of 74A. 60 00:04:19,640 --> 00:04:22,800 And the response here is 7B4. 61 00:04:22,860 --> 00:04:25,260 And you'll notice that that's not actually what I said earlier. 62 00:04:25,260 --> 00:04:27,380 Earlier I said it should be 8 more than that. 63 00:04:27,380 --> 00:04:29,100 Well that's the standard. 64 00:04:29,220 --> 00:04:37,420 Just because it's the standard doesn't mean it's actually what is ever done because nothing's ever actually done standardly on passenger automa- passenger vehicles. 65 00:04:37,640 --> 00:04:45,160 So here we see the message uh the very first you see the first nibble of the data is uh 0 which means it's a single frame message. 66 00:04:45,160 --> 00:04:47,120 Again it's very obvious what's going on. 67 00:04:47,120 --> 00:04:48,560 Second nibble is the length. 68 00:04:48,560 --> 00:04:52,620 And then after that we see 10, 0, 3. 69 00:04:52,620 --> 00:04:55,980 10 is the uh diagnostic session request. 70 00:04:55,980 --> 00:04:58,240 3 is just a session ID. 71 00:04:58,400 --> 00:05:00,540 What does that session mean? 72 00:05:01,400 --> 00:05:06,360 Well again it means whatever the automaker wants it to mean. 73 00:05:06,360 --> 00:05:18,480 So the only way to figure out what it means is if you can start actually taking uh you know querying what functionality is available in that diagnostic session. 74 00:05:18,480 --> 00:05:21,360 You might have some simple diagnostics in session 2. 75 00:05:21,360 --> 00:05:25,220 You might be able to um reprogram the ECUs in session 2. 76 00:05:25,220 --> 00:05:31,300 Maybe session 3 lets you do things like um disable the brakes or something like that. 77 00:05:31,300 --> 00:05:35,040 You know so maybe it's some uh debugging or implementation. 78 00:05:35,040 --> 00:05:38,800 Something the engineers were doing that's not really meant for general consumption. 79 00:05:38,840 --> 00:05:47,600 Well if you can figure out what that is if you can get in there and scan what's going on then it allows you to get access to what that type of functionality is. 80 00:05:47,980 --> 00:05:55,080 So other another one the second UDS request here again we've got 7 oh oh yeah so the response itself so we have 0, 6. 81 00:05:55,120 --> 00:05:58,260 Uh so again single frame message 6 bytes. 82 00:05:58,260 --> 00:05:59,120 50. 83 00:05:59,260 --> 00:06:02,560 So the first byte here is isotp. 84 00:06:02,560 --> 00:06:04,840 That's kind of the encapsulation layer. 85 00:06:04,840 --> 00:06:12,160 UDS itself is then the actual uh the remaining bytes right the remaining 7 bytes of this message. 86 00:06:12,940 --> 00:06:17,160 The request is the service ID which was 10. 87 00:06:17,160 --> 00:06:24,020 The response if it's a successful response is then hex 40 more than the request. 88 00:06:24,020 --> 00:06:25,840 These all seem incredibly arbitrary. 89 00:06:25,840 --> 00:06:26,360 I know. 90 00:06:26,360 --> 00:06:30,760 And basically it's because I don't know the people who wrote the standard did it that way. 91 00:06:30,760 --> 00:06:40,060 It's actually it's similar it's based on of older standards so what you're seeing here is kind of the evolution of a lot of things based on a lot of things based on a lot of things. 92 00:06:40,300 --> 00:06:45,340 Which is basically how all technology in computers has ever worked. 93 00:06:45,340 --> 00:06:48,840 Because it's all based on well we did it this way so let's do it this way now. 94 00:06:49,280 --> 00:06:50,340 That's why it's this way. 95 00:06:50,340 --> 00:06:54,320 So you just gotta take a look at it and look at the standard and you eventually figure it out. 96 00:06:55,420 --> 00:06:56,280 So 50. 97 00:06:56,280 --> 00:06:59,360 That means successful because it was 40 more than the request. 98 00:06:59,760 --> 00:07:07,020 And then the next thing is going to be 3 which is the diagnostic session that was requested. 99 00:07:07,280 --> 00:07:10,300 The length is 6 which means there's 3 more bytes of data here. 100 00:07:10,680 --> 00:07:19,280 I have no idea what they mean but usually it doesn't actually matter much what they mean but they're here in case you wanna refer to it later. 101 00:07:19,520 --> 00:07:24,460 Uh if you're actually implemented this or doing something with the dealer tools it might be meaningful. 102 00:07:24,460 --> 00:07:25,440 I don't know. 103 00:07:27,240 --> 00:07:31,160 So if it's 40 more that's successful response. 104 00:07:31,160 --> 00:07:33,460 Uh what happens if it's an unsuccessful response? 105 00:07:33,460 --> 00:07:35,280 That's the next example I got here. 106 00:07:35,280 --> 00:07:37,180 Got 0, 2, 10, 4. 107 00:07:37,180 --> 00:07:40,800 So it's slightly different session uh session ID I'm looking for. 108 00:07:40,800 --> 00:07:42,900 The response itself then is 7F. 109 00:07:42,900 --> 00:07:44,680 That means it's a negative response. 110 00:07:44,680 --> 00:07:53,740 And then you have the error code here which so it says after the negative response the next byte is the service ID that caused the error. 111 00:07:53,740 --> 00:07:54,560 10. 112 00:07:54,560 --> 00:07:56,160 And then it's the error code. 113 00:07:56,160 --> 00:07:58,060 Well the error code itself is 12. 114 00:07:58,140 --> 00:08:01,660 Uh that is thankfully a standard thing in this. 115 00:08:01,660 --> 00:08:04,140 And 12 means subfunction not supported. 116 00:08:04,940 --> 00:08:08,780 So that basically is somebody telling us that we don't know what this means. 117 00:08:08,780 --> 00:08:16,900 So this is again this is the way that the UDS protocol is allowing us to enumerate what functionality exists on an ECU. 118 00:08:17,900 --> 00:08:20,440 The last one here is a read did message. 119 00:08:20,440 --> 00:08:23,900 So a did in UDS speak is uh a block of data. 120 00:08:23,900 --> 00:08:31,780 If you wanna find out what VIN is in a car you read a particular data identifier and in this case data identifier F190. 121 00:08:31,780 --> 00:08:33,280 Uh that's part of the standard. 122 00:08:33,280 --> 00:08:36,940 There's a range of these different dids which are standard for the ISO standard. 123 00:08:37,320 --> 00:08:43,700 There's uh then there's a bunch of other stuff which automakers or suppliers do because they feel like it. 124 00:08:43,840 --> 00:08:47,500 Or probably really to put in information that they feel is necessary. 125 00:08:47,500 --> 00:08:49,620 What version of software do we have in here? 126 00:08:49,620 --> 00:08:51,640 Uh what version of the hardware is this? 127 00:08:51,640 --> 00:08:52,960 Who compiled it? 128 00:08:52,960 --> 00:08:53,800 Navy. 129 00:08:55,400 --> 00:09:02,380 So here the response was uh there's a couple two things I wanna point out about this last one. 130 00:09:02,400 --> 00:09:07,160 You can see that the error is we have a 7F which means error. 131 00:09:07,740 --> 00:09:10,260 But the error code is 78. 132 00:09:10,320 --> 00:09:18,540 Error code 78 means that it's a it's a hold on let me look let me read this properly. 133 00:09:19,420 --> 00:09:21,360 Request correctly received. 134 00:09:21,360 --> 00:09:22,640 Response pending. 135 00:09:22,800 --> 00:09:25,080 So basically it means hold on a second . 136 00:09:26,000 --> 00:09:28,260 And this is one that always annoyed me a little bit. 137 00:09:28,260 --> 00:09:33,140 Because if you take a look at the timestamps it didn't actually take that much longer for the actual message to come back . 138 00:09:33,140 --> 00:09:37,120 First nibble is 1 which means it's the first frame of a multi -frame message. 139 00:09:37,120 --> 00:09:40,440 And then again like I said 3 is the flow control . 140 00:09:40,520 --> 00:09:48,620 So it's saying here's uh it's the person who's receiving the data telling the other end if it has any restrictions in the block sizes right? 141 00:09:48,620 --> 00:09:58,540 So if you can think of this again in terms of Ethernet this is kind of like uh uh uh handshake working out like MTU sizes or something like that right? 142 00:09:58,560 --> 00:10:04,360 Again these these these analogies are a little bit strained but you know it's it's a way to think about it. 143 00:10:04,360 --> 00:10:06,300 But then the first frame is 2. 144 00:10:06,700 --> 00:10:08,940 2 means it's a multi-frame message. 145 00:10:09,100 --> 00:10:19,940 And this is really good if you're like looking at the dealer tools for taking a look at if you use the dealer tools and look at the canned messages that are happening while the dealer tools are like programming the ECU. 146 00:10:19,940 --> 00:10:25,300 It makes it extremely obvious when there's a block of data going to a particular location. 147 00:10:25,380 --> 00:10:30,320 Because it all starts with 2 and the message ID is all 7 something or other. 148 00:10:32,360 --> 00:10:35,040 Uh in this case the actual response doesn't matter too much. 149 00:10:35,040 --> 00:10:37,740 It was just because of those two things I wanted to point out there. 150 00:10:39,720 --> 00:10:40,600 Alright. 151 00:10:40,920 --> 00:10:42,820 So that's the basics of UDS. 152 00:10:42,840 --> 00:10:50,040 Um I could go in for quite a long time going into detail of UDS which would probably bore everyone more than you're already bored. 153 00:10:50,560 --> 00:10:54,900 Um unless you're a standards nerd, you don't necessarily like looking at standards. 154 00:10:54,900 --> 00:10:57,220 But it's useful to see that raw level of things. 155 00:10:57,220 --> 00:11:07,200 Tools can usually can easily uh abstract what's the important stuff that's going on behind the scenes that helps you have a deeper understanding of what the how the computer is behaving. 156 00:11:07,500 --> 00:11:10,020 So a couple useful tools I want to point out here. 157 00:11:10,020 --> 00:11:11,400 First one is CanCat . 158 00:11:11,400 --> 00:11:12,880 Um I work with Grimm. 159 00:11:12,880 --> 00:11:14,340 We've uh we like CanCat. 160 00:11:14,340 --> 00:11:15,000 We use it. 161 00:11:15,000 --> 00:11:15,820 It's not. 162 00:11:16,100 --> 00:11:21,860 There's a uh it has a lot of libraries for allowing you to do the low level can stuff which is what we demonstrate over at our booth. 163 00:11:21,860 --> 00:11:24,700 But we also have uh class in there for UDS. 164 00:11:24,700 --> 00:11:29,220 It allows you to interact with uh ACU uh doing UDS functionality. 165 00:11:29,780 --> 00:11:42,080 Um and what I'm gonna show here in the second half is taking a look at a tool I wrote on top of the CanCat stuff that allows you to essentially do Nmap style scanning uh on a car. 166 00:11:43,100 --> 00:11:47,720 There's uh two other ones I'd like to point out here that are capable of doing uh UDS things. 167 00:11:47,720 --> 00:11:51,500 First one is carrying car- carrying caribou which I have a hard time saying. 168 00:11:51,960 --> 00:11:53,400 Um it works pretty well. 169 00:11:53,400 --> 00:11:55,360 It works with standard Python can stuff. 170 00:11:55,360 --> 00:12:00,420 Uh if you have a socket can capabilities like a cantact , uh this will work well with it. 171 00:12:00,420 --> 00:12:02,840 Um it also does UDS scanning. 172 00:12:02,840 --> 00:12:04,540 Scapey can also do this as well. 173 00:12:04,540 --> 00:12:11,220 As much as I love Scapey , it's not uh the interface is a little bit harder to use unless you're familiar with how it's working. 174 00:12:11,640 --> 00:12:13,200 In this particular case. 175 00:12:16,980 --> 00:12:23,620 So can utils um the raw low-level socket can that if you run in Linux, you've got socket can. 176 00:12:23,620 --> 00:12:24,880 You've got can utils. 177 00:12:24,880 --> 00:12:28,440 They're installed by default, pretty sure, on most distributions. 178 00:12:28,680 --> 00:12:31,980 Uh but the thing is they interact with the raw can messages. 179 00:12:31,980 --> 00:12:34,280 They don't necessarily give you the UDS capabilities. 180 00:12:34,600 --> 00:12:41,180 Um what we demo over at our booth for just recording and replaying messages, you can do that with can dump and can player. 181 00:12:41,280 --> 00:12:43,600 Uh can sniff is also a really useful tool. 182 00:12:44,140 --> 00:12:48,060 Unfortunately can sniffer isn't actually support 29 bit messages. 183 00:12:48,060 --> 00:12:50,820 There's a pull request that's been open for like a year for it. 184 00:12:50,920 --> 00:12:53,900 Uh you can go and look at the pull request if you want to go and see it. 185 00:12:53,900 --> 00:12:57,260 You can go find a particular patch and download it and compile it. 186 00:12:57,440 --> 00:13:07,240 So it's useful for low-level things but uh once you start getting to higher-level protocols, uh you need to usually need to step outside of something like socket can. 187 00:13:10,220 --> 00:13:15,120 And here, like I said, you can use the can message uh can utils for doing can injection. 188 00:13:15,200 --> 00:13:16,800 And here's just a simple example. 189 00:13:16,860 --> 00:13:21,200 You don't really see it interacting with the vehicle at this point but what I did was I hit can dump. 190 00:13:21,200 --> 00:13:22,040 I started logging. 191 00:13:22,040 --> 00:13:23,300 I hit the unlock button. 192 00:13:23,300 --> 00:13:26,920 And then I can't, I control C to kill the can dump. 193 00:13:26,920 --> 00:13:33,600 Then I take the can dump that was generated and I run it through can player and I watch the car unlock itself, right? 194 00:13:33,600 --> 00:13:37,480 So this is again a simple example of message injection with can utils. 195 00:13:38,440 --> 00:13:46,300 Can sniffer is another useful one um and this allows you to do like an interactive viewing of the messages that are going on the bus. 196 00:13:46,300 --> 00:13:51,060 You hit the pound sign and then it will slowly shrink the window like notches the messages it's receiving. 197 00:13:51,060 --> 00:13:56,400 And then it highlights, if you give it the dash C flag, it'll highlight the new messages it receives. 198 00:13:56,520 --> 00:14:02,880 So in this particular case, what I did was I started can sniffer and then I was periodically hitting the lock, unlock button. 199 00:14:03,020 --> 00:14:10,500 And if you got a sharp eye, you might notice what message ID is actually doing the door unlocking in this case. 200 00:14:11,260 --> 00:14:16,120 Or if you already did, figured it out when you were taking a look at it on our booth. 201 00:14:16,260 --> 00:14:25,760 But anyway, so again, hit the lock, hit the unlock message, unlock button on the key fob and the message popped up, you're highlighted with the changed bytes in red. 202 00:14:28,500 --> 00:14:33,100 Can escapee again, so there's the uh, there's the incantation for doing it. 203 00:14:33,100 --> 00:14:41,060 You can go on the escapees, read the docs page and it will, there's a good lot of, there's a lot of information there about using escapee for automotive testing. 204 00:14:41,340 --> 00:14:44,300 And you know, this is just a simple example. 205 00:14:44,300 --> 00:14:53,580 Again, you can do can sniff, this again records all the messages and you can, it's a python interactive shell and you can interact with them using all the different python tools escapee presents. 206 00:14:55,420 --> 00:14:59,760 Caring caribou, again this is uh, doing an ECU scan. 207 00:15:00,280 --> 00:15:03,220 So this is starting to get into more of what I was talking about. 208 00:15:03,240 --> 00:15:07,200 How you can use UDS capabilities to identify what's on the bus. 209 00:15:07,520 --> 00:15:12,780 So this again was looking, I was scanning 3PO and I did UDS discovery. 210 00:15:12,840 --> 00:15:18,480 This is just using uh, the can, cannibal, I was uh, little $10 piece of hardware. 211 00:15:18,580 --> 00:15:23,220 And it's fi- going through all the different ECUs to find out what's present on the bus. 212 00:15:23,220 --> 00:15:25,080 And you can see here it's finding different things. 213 00:15:25,080 --> 00:15:28,560 It's finding some things that are standard, it's finding some things that are not standard. 214 00:15:28,760 --> 00:15:31,260 The particular results in this case don't matter too much. 215 00:15:31,260 --> 00:15:35,040 It's nicer to have something animated on the screen. 216 00:15:37,480 --> 00:15:48,240 So UDS, uh, one of the nicest, well okay, the functionality of, not the nicest, but one of the nicer things about UDS is the error codes. 217 00:15:48,240 --> 00:15:49,640 They're extremely verbose. 218 00:15:49,640 --> 00:15:53,880 This is one of those things where you take a look at a protocol and you can tell it was written by an engineer. 219 00:15:53,880 --> 00:15:57,140 Because they say, well I want to know why this didn't work. 220 00:15:58,840 --> 00:15:59,260 I want to know why this didn't work . 221 00:15:59,260 --> 00:16:02,460 So there's, well, there's a byte for the messages. 222 00:16:02,460 --> 00:16:05,680 So you've got a couple hundred possibilities of what the error code is. 223 00:16:05,680 --> 00:16:08,440 They're not all valid but a lot of them are valid. 224 00:16:08,440 --> 00:16:10,080 And here's some of the common ones. 225 00:16:10,180 --> 00:16:11,200 Service not supported. 226 00:16:11,200 --> 00:16:13,760 Conditions not correct, which is an interesting one. 227 00:16:13,760 --> 00:16:15,100 Security access denied. 228 00:16:15,100 --> 00:16:16,320 Invalid key. 229 00:16:16,800 --> 00:16:18,540 Exceeded number of attempts. 230 00:16:18,760 --> 00:16:30,620 Uh, so exceeded number of attempts for example is one where if you're trying to do a security access, what should happen if you do it wrong is you're supposed to then get an error message back saying that you ran out of attempts. 231 00:16:31,120 --> 00:16:33,820 Well, sometimes it happens, sometimes it doesn't. 232 00:16:34,760 --> 00:16:43,620 Uh, conditions not correct is a good one because what it's saying is I can't do the thing that you're asking for but I am capable of doing it if the conditions were correct. 233 00:16:43,620 --> 00:16:46,740 So then you've got to figure out what those conditions might be. 234 00:16:46,740 --> 00:16:50,740 Again, it lets you start narrowing down the type of functionality you're looking for. 235 00:16:50,740 --> 00:16:55,880 There's also a really verbose section of errors like RPM too high, RPM too low. 236 00:16:55,880 --> 00:16:56,880 Engine is running. 237 00:16:56,880 --> 00:16:58,260 Engine is not running. 238 00:16:58,700 --> 00:17:01,220 Uh, throttle pedal too high, too low. 239 00:17:01,220 --> 00:17:02,840 Transmission not in neutral. 240 00:17:02,840 --> 00:17:04,180 Transmission in gear. 241 00:17:04,220 --> 00:17:09,640 And not all of these different error codes are things that all automakers implement. 242 00:17:09,640 --> 00:17:16,880 But when you see them, it allows you to know that, well, great, this thing I've almost gotten to the ability to activate this function. 243 00:17:17,000 --> 00:17:20,340 All I have to do is change the conditions that the car is in. 244 00:17:20,340 --> 00:17:23,860 So again, this is allowing you to scan the functionality. 245 00:17:24,000 --> 00:17:26,160 You don't have any knowledge of what's going on. 246 00:17:26,160 --> 00:17:28,960 And it's allowing you to figure out what is going on. 247 00:17:30,440 --> 00:17:32,340 So, UDS. 248 00:17:32,600 --> 00:17:36,080 So, because I can't help myself, I named it CanMap. 249 00:17:36,100 --> 00:17:40,300 Because it's based on CanCat and it helps you do end mapping of a car, right? 250 00:17:40,760 --> 00:17:43,800 That's the theory anyway. 251 00:17:43,800 --> 00:17:45,620 So there's, there's my, there's my car. 252 00:17:45,660 --> 00:17:48,160 My own test subject that I tested this on. 253 00:17:49,220 --> 00:17:51,760 Uh, to try and figure out what's going on. 254 00:17:51,760 --> 00:17:56,040 So, again, uh, when you're taking, doing a pen test, right? 255 00:17:56,040 --> 00:17:59,260 If you're doing a pen test, you want to figure out what's on this network. 256 00:17:59,260 --> 00:18:01,620 What services are available on this network? 257 00:18:01,740 --> 00:18:10,100 You run Nmap with a different range of IP addresses and you come back with, there's a service there that gives you a successful or an error, some error responses. 258 00:18:10,100 --> 00:18:17,040 It allows you to know that that IP address is valid and allows you to know what services may or may not be present on there. 259 00:18:17,040 --> 00:18:19,680 It can allow you to detect if there's a firewall present. 260 00:18:20,220 --> 00:18:24,540 Um, so Nmap is again a blind tool that lets you go through it and figure out what's going on. 261 00:18:24,740 --> 00:18:27,000 CanMap is pretty much the same thing. 262 00:18:27,080 --> 00:18:29,800 And of course Karen Caribou does similar things as well. 263 00:18:29,800 --> 00:18:33,760 But I had the, I, I, I felt like doing it on my own. 264 00:18:33,760 --> 00:18:42,360 I don't really like using tools that I've not wrote because I don't actually ever understand how the tools work until I play with them myself with my own hands. 265 00:18:42,880 --> 00:18:48,260 I might be the only one who ever uses the tool, but the whole point is it's helped me learn about how, how UDS works. 266 00:18:48,260 --> 00:18:49,720 It's written on top of CanCat. 267 00:18:49,720 --> 00:18:54,500 So it's an example of how you can use CanCat's existing API to interact with the bus. 268 00:18:54,500 --> 00:18:58,380 So use it as a way to learn how CanCat stuff works. 269 00:18:58,380 --> 00:19:00,900 Uh, use it as a tool, standalone tool by itself. 270 00:19:01,900 --> 00:19:06,680 Um, whatever you, use this as an example or a chance to explore other new tools. 271 00:19:06,680 --> 00:19:11,160 As long as people are going out and learning new things, that's my goal. 272 00:19:12,220 --> 00:19:20,460 So, first thing the tool has right now, uh, because it's brand new, is it allows you to scan for ECUs. 273 00:19:21,080 --> 00:19:24,120 Right here, and it'll start over in a second. 274 00:19:24,860 --> 00:19:28,060 So it allows you to, first thing I'm doing is scanning for ECUs. 275 00:19:28,060 --> 00:19:29,720 There's a couple different ways you can do this. 276 00:19:29,720 --> 00:19:33,500 Any functionality you can send to an EC, any function you can request. 277 00:19:33,500 --> 00:19:46,780 So the things I pointed out earlier, redid, diagnostic session control, uh, data transfer, ECU reset, there's all these things that you could send that would allow you to check if an address is valid. 278 00:19:47,100 --> 00:19:51,680 Um, in this particular case, the one of the default modes is just reading a DITS. 279 00:19:51,680 --> 00:19:54,280 So it tries to read the VIN out of a vehicle. 280 00:19:55,180 --> 00:19:57,960 And you can see a bunch of things coming back here. 281 00:19:57,960 --> 00:20:04,760 So it's detecting that, that if there's a nonstandard response, um, and it logs it in different ways. 282 00:20:05,180 --> 00:20:09,820 There's different, this is just the way that I had figured out how I wanted to do it. 283 00:20:12,790 --> 00:20:16,490 I want to, uh, talk a little bit too about how the scanning works. 284 00:20:16,490 --> 00:20:21,410 UDS works, uh, UDS is the basis of all the different functionality that like the dealer tools use. 285 00:20:21,410 --> 00:20:28,150 When the dealer goes and interacts with an ECU, if they need to reprogram it, they're going to use the UDS protocol to get this to happen. 286 00:20:28,750 --> 00:20:34,310 Well, one of the things that's being hap- that's happening on newer vehicles is there's a CAN gateway sitting on the OBD2 port. 287 00:20:34,530 --> 00:20:39,390 That's supposed to only let the certain things through that are allowed to go through to the rest of the vehicle. 288 00:20:39,610 --> 00:20:48,130 One of the things that by design it has to allow through is the UDS messages that allow the dealer tool to interact with the ECUs. 289 00:20:48,130 --> 00:20:54,010 Which means that you, using the UDS will help you find things, even getting through a gateway. 290 00:20:54,010 --> 00:20:59,090 It's essentially using a firewall's capabilities to allow you to go through it on its own. 291 00:20:59,090 --> 00:21:04,290 You don't have to break through it as long as it lets you through in a nice and friendly manner. 292 00:21:06,790 --> 00:21:11,750 So here's the results, the results of my scan are output into a YAML file. 293 00:21:12,630 --> 00:21:15,390 I'm not a fan of YAML but it does work well. 294 00:21:15,510 --> 00:21:24,470 And the YAML file has the list of like what are the transmit IDs, what are the response IDs and eventually what are the actual values of different DIDS. 295 00:21:24,470 --> 00:21:26,990 Now what is the bus speed that I use for this? 296 00:21:26,990 --> 00:21:38,790 And then this YAML file can be used in future scans that will allow you to not worry about scanning for the ECUs because you've got them already saved in the file and then you can use those and go on and scan for other things. 297 00:21:39,390 --> 00:21:43,190 It's also got the notes there indicating what the actual command you ran was. 298 00:21:43,190 --> 00:21:52,710 The idea being that it should help you find out how long did the scan take and uh what actually, how did you actually invoke the command that generated the results you see there. 299 00:21:54,790 --> 00:22:00,310 So here again scanning for DIDS, I'm not gonna show you an animated one for that because it's just a ton of output. 300 00:22:00,310 --> 00:22:02,430 But I wanna point out a couple things here. 301 00:22:02,430 --> 00:22:05,590 Again looking at the ISO TP frame IDs. 302 00:22:05,590 --> 00:22:11,830 If you take a look at the bottom one, you'll see you've got the 0, 1, 3 and a bunch of 2s. 303 00:22:12,050 --> 00:22:21,290 Again that's very in, that's very classic, it's an easy way to see looking at the raw CAN messages that you're looking at an ISO TP uh block transfer. 304 00:22:21,470 --> 00:22:25,030 And then you can actually see the read DID result there. 305 00:22:25,030 --> 00:22:28,390 In this case it was uh one of the application identifiers. 306 00:22:29,930 --> 00:22:32,250 F182, whatever it is, I don't know. 307 00:22:34,780 --> 00:22:45,100 One of the things I also wanna point out about how UDS is useful in this case is by taking a look at the contents that you can get out of the different data identifiers on the different ECUs. 308 00:22:45,120 --> 00:22:49,780 Once you have extracted the firmware for the ECU, they can act as good sign posts. 309 00:22:49,960 --> 00:22:55,760 Because it allows you to have this particular string, search for that string in the firmware somewhere. 310 00:22:55,760 --> 00:22:58,520 And then once you find it, you can start finding the references. 311 00:22:58,540 --> 00:23:04,740 And you can uh, you know that the references are going to be related to this particular CAN function out. 312 00:23:04,740 --> 00:23:13,300 So it can allow you to go from a known info set of information in the software that will allow you then figure out how you get back there to the CAN stuff. 313 00:23:13,300 --> 00:23:18,860 And once you take a look at the CAN functions, you can see what other functionality might be available through that CAN interface. 314 00:23:23,540 --> 00:23:30,340 Uh one of the other things that is nice about uh that I like about the tool CANCAT, so it allows you to do a save session file. 315 00:23:30,340 --> 00:23:34,780 You've recorded all this information, all these CAN messages have been saved, you've been doing hours of testing. 316 00:23:34,780 --> 00:23:38,100 Well, there's a function called save session to file. 317 00:23:38,280 --> 00:23:41,960 Uh you can just type it interactively on the IPython shell, it's a normal way. 318 00:23:42,000 --> 00:23:49,280 Or what, and what we can do here is if you pass the dash C flag to CAN map, it'll save the session file for you also. 319 00:23:49,280 --> 00:23:52,240 It's just a pickle, a Python pickle if you know how those work. 320 00:23:52,240 --> 00:23:56,160 Yes they're insecure so don't unpickle other people's pickles that they provide. 321 00:23:56,500 --> 00:23:59,500 If that phrase makes, if that sentence makes sense. 322 00:24:00,700 --> 00:24:10,700 But it's really useful because it allows you to take your logged output that you see, here's the results I see, here's what's going on, and you can take a look at the raw CAN messages themselves. 323 00:24:10,880 --> 00:24:16,460 So if something has gone weird, then it can allow you to core, find out exactly what's going on here. 324 00:24:16,460 --> 00:24:26,940 In my limited testing leading up to this, I didn't have time to go through every scenario to figure out what works, but being able to go through and look at the raw messages helps you figure out what's going weird. 325 00:24:27,480 --> 00:24:31,680 The last set of functionality I've gotten it is scan for diagnostic sessions. 326 00:24:31,860 --> 00:24:40,800 Um, I've got the warning here because when I started doing this, things do start acting weird because it does involve, uh, putting the ECUs into different modes. 327 00:24:40,800 --> 00:24:42,800 I set the immobilizer off on my car. 328 00:24:42,860 --> 00:24:46,080 It did clear as soon as I turned the car on and off again. 329 00:24:46,080 --> 00:24:47,500 Off and on again. 330 00:24:47,880 --> 00:24:54,540 Uh, but again, this is one of those things where once you start messing around with different diagnostic sessions and ECU resets, things can get weird. 331 00:24:54,560 --> 00:24:59,920 Uh, on the other hand, it can also help you identify which ECU does what on a car. 332 00:25:00,160 --> 00:25:10,960 When I was doing this scanning for sessions and I saw, okay, well here's the session ID and then I see my radio start rebooting, I know that that session ID is my radio. 333 00:25:10,960 --> 00:25:17,020 Because just looking at the raw message IDs, you don't know which ECU those belong to necessarily. 334 00:25:17,980 --> 00:25:25,000 But when you start seeing the actual physical effects on the car, then you can start correlating that to what ECU does what function. 335 00:25:25,620 --> 00:25:27,140 Again, here's some results. 336 00:25:27,140 --> 00:25:29,420 You can see some of the weird errors I started getting. 337 00:25:29,420 --> 00:25:36,940 One of them was like, when I go to a particular session, after I start scanning long enough, then it just, it just kind of stopped responding in a friendly manner. 338 00:25:37,420 --> 00:25:43,260 Um, again, I'm not entirely sure why, but looking at the raw messages can help you diagnose what's going on. 339 00:25:43,880 --> 00:25:45,460 And again, this is the first version of it. 340 00:25:45,460 --> 00:25:46,260 It'll get better. 341 00:25:46,260 --> 00:25:48,780 It's still sitting in a pull request up to the main CANCAT. 342 00:25:48,780 --> 00:25:50,560 So, uh, it'll get there eventually. 343 00:25:52,820 --> 00:25:56,000 Uh, the, oh, that must be a later slide. 344 00:25:56,140 --> 00:25:58,320 So, real quick wrap up. 345 00:25:58,320 --> 00:26:01,960 UDS helps you to enumerate the vehicles and taxis. 346 00:26:02,000 --> 00:26:04,160 Let's you figure out what ECUs are present. 347 00:26:04,160 --> 00:26:05,900 It lets you figure out what data is in there. 348 00:26:05,900 --> 00:26:10,180 The data can then be used to more easily reverse engineer what's going on in the thing. 349 00:26:10,780 --> 00:26:16,080 I do want to point out that UDS itself is not necessarily a vulnerability in and of itself. 350 00:26:16,220 --> 00:26:20,080 It's simply a way to discover the functionality that's present on the vehicle. 351 00:26:20,080 --> 00:26:23,740 The functionality itself might be the vulnerability, right? 352 00:26:23,740 --> 00:26:35,380 If I'm alive, if I can do things to a car that are bad, if I can, uh, put my, if I can unlock a vehicle from an external location, that itself is the vulnerability . 353 00:26:35,380 --> 00:26:37,920 Not the fact that I found out I could do it with UDS . 354 00:26:38,280 --> 00:26:46,720 Uh, if I can put an ECU into diagnostics mode while the car is running and then, uh, impact the vehicle dynamics, that is the vulnerability. 355 00:26:46,720 --> 00:26:49,220 Not the fact that I use a session control to do it. 356 00:26:50,720 --> 00:26:54,000 This is again similar to the way different protocols work. 357 00:26:54,020 --> 00:26:56,840 Uh, in, in, if you're talking, thinking about regular computers. 358 00:26:57,060 --> 00:27:00,420 I could go on forever with these if I had time, which I don't. 359 00:27:01,760 --> 00:27:05,720 Um, again, the more tools, the better. 360 00:27:05,720 --> 00:27:09,020 So I like Canmap, Kirin, Caribou, Scapey, other options out there. 361 00:27:09,060 --> 00:27:14,700 Uh, and lastly, go out there, scan, be curious, play with your own car, uh, and have fun. 362 00:27:16,780 --> 00:27:17,640 That's it. 363 00:27:18,120 --> 00:27:19,620 I know it was really quick. 364 00:27:23,870 --> 00:27:29,590 And if you have any questions, uh, we don't have time right now, unfortunately, but please, uh, I'll stand around afterwards. 365 00:27:29,590 --> 00:27:33,830 If you have questions, let me know and I'll answer them or go into more detail if you wish. 366 00:27:33,910 --> 00:27:34,810 A couple links here. 367 00:27:34,810 --> 00:27:41,130 If you haven't yet read Chris and Charlie's paper, it goes a lot into UDS and security access key, uh, uh, the seed key pairs. 368 00:27:41,210 --> 00:27:42,970 That's very valuable to go and look at. 369 00:27:42,970 --> 00:27:46,110 It talks about reverse engineering those algorithms out of the dealer tools. 370 00:27:46,130 --> 00:27:51,030 The dealer tools are always a valuable resource when you're trying to figure out what the capabilities of a vehicle are. 371 00:27:51,230 --> 00:27:54,070 Uh, and again, some links to the other different CAN tools here. 372 00:27:54,590 --> 00:27:55,370 That's it. 373 00:27:55,810 --> 00:27:56,370 Yes? 374 00:27:58,810 --> 00:28:01,810 Uh, yeah, question was if I've messed with the Tesla 3. 375 00:28:01,810 --> 00:28:03,730 I've not personally messed with the Tesla 3. 376 00:28:04,690 --> 00:28:07,250 Anyway, I'm pretty sure I'm out of time. 377 00:28:11,330 --> 00:28:14,090 It is in a poll request up on the CANCAT repo. 378 00:28:14,090 --> 00:28:18,770 So if you go up to CANCAT and you look for pull requests, you'll find one of them that's branch labeled CANMAP. 379 00:28:19,110 --> 00:28:20,750 So it's working on it. 380 00:28:20,750 --> 00:28:29,710 It was a lot of code changes, so it is, uh, it was a lot of code changes, so it's gonna take a little while to review and make, and fix all the stylistic things that I've messed up. 381 00:28:38,160 --> 00:28:41,080 Alright, question was about emulators, so for messing around with this. 382 00:28:41,080 --> 00:28:46,960 If you play with the SocketCAN tools, you can create a virtual CAN device which will allow you to play back pre-recorded data. 383 00:28:46,960 --> 00:28:51,780 Uh, I did, did create a testing CAN interface for CANMAP. 384 00:28:51,780 --> 00:28:56,860 Uh, it's kind of limited at the moment though, but it allows you to kind of fake out the high level stuff, but not the low level ones. 385 00:28:56,860 --> 00:28:59,260 So, short answer is, kind of. 386 00:29:03,160 --> 00:29:13,000 Right, yeah, and there's also tool, we also have a tool in CANCAT now that allows you to go between SocketCAN dumps and, uh, P, or PCAPs and CANCAT sessions files. 387 00:29:13,000 --> 00:29:16,240 So you can convert from one to the other to play with them if you wanted to. 388 00:29:16,620 --> 00:29:19,320 But, uh, that is functionality I would like to do eventually. 389 00:29:19,360 --> 00:29:22,420 But, I'm now a couple minutes past time. 390 00:29:22,420 --> 00:29:25,280 Whoever's next is gonna need to get up here, so I do need to shut down. 391 00:29:25,280 --> 00:29:27,200 Thank you everybody for being here. 392 00:29:28,840 --> 00:29:30,600 And I'll be hanging around afterwards.