WEBVTT

00:00.000 --> 00:02.140
My name is Aaron or Acorn.

00:02.160 --> 00:05.560
Uh and I'm a security researcher with Grimm.

00:05.820 --> 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.

00:13.800 --> 00:16.020
And let's get moving.

00:16.260 --> 00:17.900
So what is UDS?

00:17.980 --> 00:21.920
Um I'm not gonna go through all this detail because it's really boring and a bunch of standards.

00:21.920 --> 00:26.840
But basically UDS is a higher level protocol that lives on top of CAN.

00:27.000 --> 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.

00:37.220 --> 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.

00:42.820 --> 00:43.140
Right?

00:43.140 --> 00:45.240
So keep that in mind that's basically CAN.

00:45.380 --> 00:48.760
UDS itself is then a higher level protocol living on top of that.

00:49.320 --> 00:53.420
As you may know CAN has a limit of 8 bytes per message.

00:53.720 --> 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.

01:06.360 --> 01:10.280
So ISOTP is a segmentation layer, kind of like IP.

01:10.480 --> 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 .

01:19.300 --> 01:22.280
Like I said the analogy does break down at that point.

01:22.960 --> 01:25.200
But there's the ISO standards if you feel like looking at it.

01:25.200 --> 01:27.160
One quick mention OBD2.

01:27.160 --> 01:29.420
OBD2 is a little bit different standard.

01:29.440 --> 01:31.960
Uh it's not really living on top of these things as well.

01:31.960 --> 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.

01:41.060 --> 01:47.420
So it's not really the same thing but sometimes the ECUs which do talk OBD2 also talk UDS.

01:47.560 --> 01:48.740
Sometimes not.

01:49.060 --> 01:50.200
So CAN.

01:50.360 --> 01:53.360
Um you have a message ID, arbitration ID.

01:53.360 --> 01:56.040
It's what identifies what message is meant to go on the bus.

01:56.120 --> 02:02.760
Uh the if you have standard CAN is 11 bits only for the message ID, arbitration ID.

02:02.760 --> 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.

02:12.140 --> 02:14.040
This will make sense eventually.

02:14.040 --> 02:15.020
I promise.

02:15.200 --> 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.

02:24.220 --> 02:26.180
It makes a little bit more sense.

02:26.640 --> 02:31.580
Uh OBD2 there's a specialized set of uh IDs that are meant for OBD2 only.

02:31.760 --> 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.

02:39.300 --> 02:40.800
We don't have a switch.

02:40.800 --> 02:43.680
We don't have DNS to tell us what's on the bus.

02:43.680 --> 02:46.320
So the thing is we need to figure it out.

02:46.320 --> 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.

02:53.420 --> 02:58.860
It's like a maximum of that's actually a little bit less than 255, 256.

03:02.760 --> 03:06.760
So real quick, ISOTP, there's a couple different frame types.

03:06.760 --> 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.

03:14.600 --> 03:21.440
Since it's a limited subset of values, it can make it really easy to see uh large data transfers.

03:21.440 --> 03:24.660
And which is one of the things that is nice about UDS.

03:24.660 --> 03:28.680
It makes it easy to just visually take a look at it and see that something is happening.

03:30.660 --> 03:32.920
Uh couple different UDS services.

03:32.920 --> 03:35.720
If you take a look at this and you say what do I want to do to a car?

03:35.940 --> 03:40.420
You can say that well downloading and uploading things to the ECUs does sound interesting.

03:40.460 --> 03:42.480
Transferring data, security access.

03:42.480 --> 03:44.440
This is there's a lot more than this.

03:44.440 --> 03:46.380
If you want to know you can go look at the standard.

03:46.380 --> 03:49.580
Actually the Wikipedia page for UDS is pretty good.

03:50.020 --> 03:52.200
Uh and so you can go take a look at that.

03:52.220 --> 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.

04:00.540 --> 04:04.520
You need to either have the design documents or you need to figure it out.

04:04.520 --> 04:06.720
So that's kind of the goal here.

04:08.040 --> 04:11.880
So let's take a look here's a couple different ECU uh UDS responses.

04:11.880 --> 04:14.300
The whole idea is you've got a request.

04:14.320 --> 04:19.380
So in the very first message here we've got a request ID of 74A.

04:19.640 --> 04:22.800
And the response here is 7B4.

04:22.860 --> 04:25.260
And you'll notice that that's not actually what I said earlier.

04:25.260 --> 04:27.380
Earlier I said it should be 8 more than that.

04:27.380 --> 04:29.100
Well that's the standard.

04:29.220 --> 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.

04:37.640 --> 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.

04:45.160 --> 04:47.120
Again it's very obvious what's going on.

04:47.120 --> 04:48.560
Second nibble is the length.

04:48.560 --> 04:52.620
And then after that we see 10, 0, 3.

04:52.620 --> 04:55.980
10 is the uh diagnostic session request.

04:55.980 --> 04:58.240
3 is just a session ID.

04:58.400 --> 05:00.540
What does that session mean?

05:01.400 --> 05:06.360
Well again it means whatever the automaker wants it to mean.

05:06.360 --> 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.

05:18.480 --> 05:21.360
You might have some simple diagnostics in session 2.

05:21.360 --> 05:25.220
You might be able to um reprogram the ECUs in session 2.

05:25.220 --> 05:31.300
Maybe session 3 lets you do things like um disable the brakes or something like that.

05:31.300 --> 05:35.040
You know so maybe it's some uh debugging or implementation.

05:35.040 --> 05:38.800
Something the engineers were doing that's not really meant for general consumption.

05:38.840 --> 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.

05:47.980 --> 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.

05:55.120 --> 05:58.260
Uh so again single frame message 6 bytes.

05:58.260 --> 05:59.120
50.

05:59.260 --> 06:02.560
So the first byte here is isotp.

06:02.560 --> 06:04.840
That's kind of the encapsulation layer.

06:04.840 --> 06:12.160
UDS itself is then the actual uh the remaining bytes right the remaining 7 bytes of this message.

06:12.940 --> 06:17.160
The request is the service ID which was 10.

06:17.160 --> 06:24.020
The response if it's a successful response is then hex 40 more than the request.

06:24.020 --> 06:25.840
These all seem incredibly arbitrary.

06:25.840 --> 06:26.360
I know.

06:26.360 --> 06:30.760
And basically it's because I don't know the people who wrote the standard did it that way.

06:30.760 --> 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.

06:40.300 --> 06:45.340
Which is basically how all technology in computers has ever worked.

06:45.340 --> 06:48.840
Because it's all based on well we did it this way so let's do it this way now.

06:49.280 --> 06:50.340
That's why it's this way.

06:50.340 --> 06:54.320
So you just gotta take a look at it and look at the standard and you eventually figure it out.

06:55.420 --> 06:56.280
So 50.

06:56.280 --> 06:59.360
That means successful because it was 40 more than the request.

06:59.760 --> 07:07.020
And then the next thing is going to be 3 which is the diagnostic session that was requested.

07:07.280 --> 07:10.300
The length is 6 which means there's 3 more bytes of data here.

07:10.680 --> 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.

07:19.520 --> 07:24.460
Uh if you're actually implemented this or doing something with the dealer tools it might be meaningful.

07:24.460 --> 07:25.440
I don't know.

07:27.240 --> 07:31.160
So if it's 40 more that's successful response.

07:31.160 --> 07:33.460
Uh what happens if it's an unsuccessful response?

07:33.460 --> 07:35.280
That's the next example I got here.

07:35.280 --> 07:37.180
Got 0, 2, 10, 4.

07:37.180 --> 07:40.800
So it's slightly different session uh session ID I'm looking for.

07:40.800 --> 07:42.900
The response itself then is 7F.

07:42.900 --> 07:44.680
That means it's a negative response.

07:44.680 --> 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.

07:53.740 --> 07:54.560
10.

07:54.560 --> 07:56.160
And then it's the error code.

07:56.160 --> 07:58.060
Well the error code itself is 12.

07:58.140 --> 08:01.660
Uh that is thankfully a standard thing in this.

08:01.660 --> 08:04.140
And 12 means subfunction not supported.

08:04.940 --> 08:08.780
So that basically is somebody telling us that we don't know what this means.

08:08.780 --> 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.

08:17.900 --> 08:20.440
The last one here is a read did message.

08:20.440 --> 08:23.900
So a did in UDS speak is uh a block of data.

08:23.900 --> 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.

08:31.780 --> 08:33.280
Uh that's part of the standard.

08:33.280 --> 08:36.940
There's a range of these different dids which are standard for the ISO standard.

08:37.320 --> 08:43.700
There's uh then there's a bunch of other stuff which automakers or suppliers do because they feel like it.

08:43.840 --> 08:47.500
Or probably really to put in information that they feel is necessary.

08:47.500 --> 08:49.620
What version of software do we have in here?

08:49.620 --> 08:51.640
Uh what version of the hardware is this?

08:51.640 --> 08:52.960
Who compiled it?

08:52.960 --> 08:53.800
Navy.

08:55.400 --> 09:02.380
So here the response was uh there's a couple two things I wanna point out about this last one.

09:02.400 --> 09:07.160
You can see that the error is we have a 7F which means error.

09:07.740 --> 09:10.260
But the error code is 78.

09:10.320 --> 09:18.540
Error code 78 means that it's a it's a hold on let me look let me read this properly.

09:19.420 --> 09:21.360
Request correctly received.

09:21.360 --> 09:22.640
Response pending.

09:22.800 --> 09:25.080
So basically it means hold on a second .

09:26.000 --> 09:28.260
And this is one that always annoyed me a little bit.

09:28.260 --> 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 .

09:33.140 --> 09:37.120
First nibble is 1 which means it's the first frame of a multi -frame message.

09:37.120 --> 09:40.440
And then again like I said 3 is the flow control .

09:40.520 --> 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?

09:48.620 --> 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?

09:58.560 --> 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.

10:04.360 --> 10:06.300
But then the first frame is 2.

10:06.700 --> 10:08.940
2 means it's a multi-frame message.

10:09.100 --> 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.

10:19.940 --> 10:25.300
It makes it extremely obvious when there's a block of data going to a particular location.

10:25.380 --> 10:30.320
Because it all starts with 2 and the message ID is all 7 something or other.

10:32.360 --> 10:35.040
Uh in this case the actual response doesn't matter too much.

10:35.040 --> 10:37.740
It was just because of those two things I wanted to point out there.

10:39.720 --> 10:40.600
Alright.

10:40.920 --> 10:42.820
So that's the basics of UDS.

10:42.840 --> 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.

10:50.560 --> 10:54.900
Um unless you're a standards nerd, you don't necessarily like looking at standards.

10:54.900 --> 10:57.220
But it's useful to see that raw level of things.

10:57.220 --> 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.

11:07.500 --> 11:10.020
So a couple useful tools I want to point out here.

11:10.020 --> 11:11.400
First one is CanCat .

11:11.400 --> 11:12.880
Um I work with Grimm.

11:12.880 --> 11:14.340
We've uh we like CanCat.

11:14.340 --> 11:15.000
We use it.

11:15.000 --> 11:15.820
It's not.

11:16.100 --> 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.

11:21.860 --> 11:24.700
But we also have uh class in there for UDS.

11:24.700 --> 11:29.220
It allows you to interact with uh ACU uh doing UDS functionality.

11:29.780 --> 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.

11:43.100 --> 11:47.720
There's uh two other ones I'd like to point out here that are capable of doing uh UDS things.

11:47.720 --> 11:51.500
First one is carrying car- carrying caribou which I have a hard time saying.

11:51.960 --> 11:53.400
Um it works pretty well.

11:53.400 --> 11:55.360
It works with standard Python can stuff.

11:55.360 --> 12:00.420
Uh if you have a socket can capabilities like a cantact , uh this will work well with it.

12:00.420 --> 12:02.840
Um it also does UDS scanning.

12:02.840 --> 12:04.540
Scapey can also do this as well.

12:04.540 --> 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.

12:11.640 --> 12:13.200
In this particular case.

12:16.980 --> 12:23.620
So can utils um the raw low-level socket can that if you run in Linux, you've got socket can.

12:23.620 --> 12:24.880
You've got can utils.

12:24.880 --> 12:28.440
They're installed by default, pretty sure, on most distributions.

12:28.680 --> 12:31.980
Uh but the thing is they interact with the raw can messages.

12:31.980 --> 12:34.280
They don't necessarily give you the UDS capabilities.

12:34.600 --> 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.

12:41.280 --> 12:43.600
Uh can sniff is also a really useful tool.

12:44.140 --> 12:48.060
Unfortunately can sniffer isn't actually support 29 bit messages.

12:48.060 --> 12:50.820
There's a pull request that's been open for like a year for it.

12:50.920 --> 12:53.900
Uh you can go and look at the pull request if you want to go and see it.

12:53.900 --> 12:57.260
You can go find a particular patch and download it and compile it.

12:57.440 --> 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.

13:10.220 --> 13:15.120
And here, like I said, you can use the can message uh can utils for doing can injection.

13:15.200 --> 13:16.800
And here's just a simple example.

13:16.860 --> 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.

13:21.200 --> 13:22.040
I started logging.

13:22.040 --> 13:23.300
I hit the unlock button.

13:23.300 --> 13:26.920
And then I can't, I control C to kill the can dump.

13:26.920 --> 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?

13:33.600 --> 13:37.480
So this is again a simple example of message injection with can utils.

13:38.440 --> 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.

13:46.300 --> 13:51.060
You hit the pound sign and then it will slowly shrink the window like notches the messages it's receiving.

13:51.060 --> 13:56.400
And then it highlights, if you give it the dash C flag, it'll highlight the new messages it receives.

13:56.520 --> 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.

14:03.020 --> 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.

14:11.260 --> 14:16.120
Or if you already did, figured it out when you were taking a look at it on our booth.

14:16.260 --> 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.

14:28.500 --> 14:33.100
Can escapee again, so there's the uh, there's the incantation for doing it.

14:33.100 --> 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.

14:41.340 --> 14:44.300
And you know, this is just a simple example.

14:44.300 --> 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.

14:55.420 --> 14:59.760
Caring caribou, again this is uh, doing an ECU scan.

15:00.280 --> 15:03.220
So this is starting to get into more of what I was talking about.

15:03.240 --> 15:07.200
How you can use UDS capabilities to identify what's on the bus.

15:07.520 --> 15:12.780
So this again was looking, I was scanning 3PO and I did UDS discovery.

15:12.840 --> 15:18.480
This is just using uh, the can, cannibal, I was uh, little $10 piece of hardware.

15:18.580 --> 15:23.220
And it's fi- going through all the different ECUs to find out what's present on the bus.

15:23.220 --> 15:25.080
And you can see here it's finding different things.

15:25.080 --> 15:28.560
It's finding some things that are standard, it's finding some things that are not standard.

15:28.760 --> 15:31.260
The particular results in this case don't matter too much.

15:31.260 --> 15:35.040
It's nicer to have something animated on the screen.

15:37.480 --> 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.

15:48.240 --> 15:49.640
They're extremely verbose.

15:49.640 --> 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.

15:53.880 --> 15:57.140
Because they say, well I want to know why this didn't work.

15:58.840 --> 15:59.260
I want to know why this didn't work .

15:59.260 --> 16:02.460
So there's, well, there's a byte for the messages.

16:02.460 --> 16:05.680
So you've got a couple hundred possibilities of what the error code is.

16:05.680 --> 16:08.440
They're not all valid but a lot of them are valid.

16:08.440 --> 16:10.080
And here's some of the common ones.

16:10.180 --> 16:11.200
Service not supported.

16:11.200 --> 16:13.760
Conditions not correct, which is an interesting one.

16:13.760 --> 16:15.100
Security access denied.

16:15.100 --> 16:16.320
Invalid key.

16:16.800 --> 16:18.540
Exceeded number of attempts.

16:18.760 --> 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.

16:31.120 --> 16:33.820
Well, sometimes it happens, sometimes it doesn't.

16:34.760 --> 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.

16:43.620 --> 16:46.740
So then you've got to figure out what those conditions might be.

16:46.740 --> 16:50.740
Again, it lets you start narrowing down the type of functionality you're looking for.

16:50.740 --> 16:55.880
There's also a really verbose section of errors like RPM too high, RPM too low.

16:55.880 --> 16:56.880
Engine is running.

16:56.880 --> 16:58.260
Engine is not running.

16:58.700 --> 17:01.220
Uh, throttle pedal too high, too low.

17:01.220 --> 17:02.840
Transmission not in neutral.

17:02.840 --> 17:04.180
Transmission in gear.

17:04.220 --> 17:09.640
And not all of these different error codes are things that all automakers implement.

17:09.640 --> 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.

17:17.000 --> 17:20.340
All I have to do is change the conditions that the car is in.

17:20.340 --> 17:23.860
So again, this is allowing you to scan the functionality.

17:24.000 --> 17:26.160
You don't have any knowledge of what's going on.

17:26.160 --> 17:28.960
And it's allowing you to figure out what is going on.

17:30.440 --> 17:32.340
So, UDS.

17:32.600 --> 17:36.080
So, because I can't help myself, I named it CanMap.

17:36.100 --> 17:40.300
Because it's based on CanCat and it helps you do end mapping of a car, right?

17:40.760 --> 17:43.800
That's the theory anyway.

17:43.800 --> 17:45.620
So there's, there's my, there's my car.

17:45.660 --> 17:48.160
My own test subject that I tested this on.

17:49.220 --> 17:51.760
Uh, to try and figure out what's going on.

17:51.760 --> 17:56.040
So, again, uh, when you're taking, doing a pen test, right?

17:56.040 --> 17:59.260
If you're doing a pen test, you want to figure out what's on this network.

17:59.260 --> 18:01.620
What services are available on this network?

18:01.740 --> 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.

18:10.100 --> 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.

18:17.040 --> 18:19.680
It can allow you to detect if there's a firewall present.

18:20.220 --> 18:24.540
Um, so Nmap is again a blind tool that lets you go through it and figure out what's going on.

18:24.740 --> 18:27.000
CanMap is pretty much the same thing.

18:27.080 --> 18:29.800
And of course Karen Caribou does similar things as well.

18:29.800 --> 18:33.760
But I had the, I, I, I felt like doing it on my own.

18:33.760 --> 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.

18:42.880 --> 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.

18:48.260 --> 18:49.720
It's written on top of CanCat.

18:49.720 --> 18:54.500
So it's an example of how you can use CanCat's existing API to interact with the bus.

18:54.500 --> 18:58.380
So use it as a way to learn how CanCat stuff works.

18:58.380 --> 19:00.900
Uh, use it as a tool, standalone tool by itself.

19:01.900 --> 19:06.680
Um, whatever you, use this as an example or a chance to explore other new tools.

19:06.680 --> 19:11.160
As long as people are going out and learning new things, that's my goal.

19:12.220 --> 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.

19:21.080 --> 19:24.120
Right here, and it'll start over in a second.

19:24.860 --> 19:28.060
So it allows you to, first thing I'm doing is scanning for ECUs.

19:28.060 --> 19:29.720
There's a couple different ways you can do this.

19:29.720 --> 19:33.500
Any functionality you can send to an EC, any function you can request.

19:33.500 --> 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.

19:47.100 --> 19:51.680
Um, in this particular case, the one of the default modes is just reading a DITS.

19:51.680 --> 19:54.280
So it tries to read the VIN out of a vehicle.

19:55.180 --> 19:57.960
And you can see a bunch of things coming back here.

19:57.960 --> 20:04.760
So it's detecting that, that if there's a nonstandard response, um, and it logs it in different ways.

20:05.180 --> 20:09.820
There's different, this is just the way that I had figured out how I wanted to do it.

20:12.790 --> 20:16.490
I want to, uh, talk a little bit too about how the scanning works.

20:16.490 --> 20:21.410
UDS works, uh, UDS is the basis of all the different functionality that like the dealer tools use.

20:21.410 --> 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.

20:28.750 --> 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.

20:34.530 --> 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.

20:39.610 --> 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.

20:48.130 --> 20:54.010
Which means that you, using the UDS will help you find things, even getting through a gateway.

20:54.010 --> 20:59.090
It's essentially using a firewall's capabilities to allow you to go through it on its own.

20:59.090 --> 21:04.290
You don't have to break through it as long as it lets you through in a nice and friendly manner.

21:06.790 --> 21:11.750
So here's the results, the results of my scan are output into a YAML file.

21:12.630 --> 21:15.390
I'm not a fan of YAML but it does work well.

21:15.510 --> 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.

21:24.470 --> 21:26.990
Now what is the bus speed that I use for this?

21:26.990 --> 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.

21:39.390 --> 21:43.190
It's also got the notes there indicating what the actual command you ran was.

21:43.190 --> 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.

21:54.790 --> 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.

22:00.310 --> 22:02.430
But I wanna point out a couple things here.

22:02.430 --> 22:05.590
Again looking at the ISO TP frame IDs.

22:05.590 --> 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.

22:12.050 --> 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.

22:21.470 --> 22:25.030
And then you can actually see the read DID result there.

22:25.030 --> 22:28.390
In this case it was uh one of the application identifiers.

22:29.930 --> 22:32.250
F182, whatever it is, I don't know.

22:34.780 --> 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.

22:45.120 --> 22:49.780
Once you have extracted the firmware for the ECU, they can act as good sign posts.

22:49.960 --> 22:55.760
Because it allows you to have this particular string, search for that string in the firmware somewhere.

22:55.760 --> 22:58.520
And then once you find it, you can start finding the references.

22:58.540 --> 23:04.740
And you can uh, you know that the references are going to be related to this particular CAN function out.

23:04.740 --> 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.

23:13.300 --> 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.

23:23.540 --> 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.

23:30.340 --> 23:34.780
You've recorded all this information, all these CAN messages have been saved, you've been doing hours of testing.

23:34.780 --> 23:38.100
Well, there's a function called save session to file.

23:38.280 --> 23:41.960
Uh you can just type it interactively on the IPython shell, it's a normal way.

23:42.000 --> 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.

23:49.280 --> 23:52.240
It's just a pickle, a Python pickle if you know how those work.

23:52.240 --> 23:56.160
Yes they're insecure so don't unpickle other people's pickles that they provide.

23:56.500 --> 23:59.500
If that phrase makes, if that sentence makes sense.

24:00.700 --> 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.

24:10.880 --> 24:16.460
So if something has gone weird, then it can allow you to core, find out exactly what's going on here.

24:16.460 --> 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.

24:27.480 --> 24:31.680
The last set of functionality I've gotten it is scan for diagnostic sessions.

24:31.860 --> 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.

24:40.800 --> 24:42.800
I set the immobilizer off on my car.

24:42.860 --> 24:46.080
It did clear as soon as I turned the car on and off again.

24:46.080 --> 24:47.500
Off and on again.

24:47.880 --> 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.

24:54.560 --> 24:59.920
Uh, on the other hand, it can also help you identify which ECU does what on a car.

25:00.160 --> 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.

25:10.960 --> 25:17.020
Because just looking at the raw message IDs, you don't know which ECU those belong to necessarily.

25:17.980 --> 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.

25:25.620 --> 25:27.140
Again, here's some results.

25:27.140 --> 25:29.420
You can see some of the weird errors I started getting.

25:29.420 --> 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.

25:37.420 --> 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.

25:43.880 --> 25:45.460
And again, this is the first version of it.

25:45.460 --> 25:46.260
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:50.560
So, uh, it'll get there eventually.

25:52.820 --> 25:56.000
Uh, the, oh, that must be a later slide.

25:56.140 --> 25:58.320
So, real quick wrap up.

25:58.320 --> 26:01.960
UDS helps you to enumerate the vehicles and taxis.

26:02.000 --> 26:04.160
Let's you figure out what ECUs are present.

26:04.160 --> 26:05.900
It lets you figure out what data is in there.

26:05.900 --> 26:10.180
The data can then be used to more easily reverse engineer what's going on in the thing.

26:10.780 --> 26:16.080
I do want to point out that UDS itself is not necessarily a vulnerability in and of itself.

26:16.220 --> 26:20.080
It's simply a way to discover the functionality that's present on the vehicle.

26:20.080 --> 26:23.740
The functionality itself might be the vulnerability, right?

26:23.740 --> 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 .

26:35.380 --> 26:37.920
Not the fact that I found out I could do it with UDS .

26:38.280 --> 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.

26:46.720 --> 26:49.220
Not the fact that I use a session control to do it.

26:50.720 --> 26:54.000
This is again similar to the way different protocols work.

26:54.020 --> 26:56.840
Uh, in, in, if you're talking, thinking about regular computers.

26:57.060 --> 27:00.420
I could go on forever with these if I had time, which I don't.

27:01.760 --> 27:05.720
Um, again, the more tools, the better.

27:05.720 --> 27:09.020
So I like Canmap, Kirin, Caribou, Scapey, other options out there.

27:09.060 --> 27:14.700
Uh, and lastly, go out there, scan, be curious, play with your own car, uh, and have fun.

27:16.780 --> 27:17.640
That's it.

27:18.120 --> 27:19.620
I know it was really quick.

27:23.870 --> 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.

27:29.590 --> 27:33.830
If you have questions, let me know and I'll answer them or go into more detail if you wish.

27:33.910 --> 27:34.810
A couple links here.

27:34.810 --> 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.

27:41.210 --> 27:42.970
That's very valuable to go and look at.

27:42.970 --> 27:46.110
It talks about reverse engineering those algorithms out of the dealer tools.

27:46.130 --> 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.

27:51.230 --> 27:54.070
Uh, and again, some links to the other different CAN tools here.

27:54.590 --> 27:55.370
That's it.

27:55.810 --> 27:56.370
Yes?

27:58.810 --> 28:01.810
Uh, yeah, question was if I've messed with the Tesla 3.

28:01.810 --> 28:03.730
I've not personally messed with the Tesla 3.

28:04.690 --> 28:07.250
Anyway, I'm pretty sure I'm out of time.

28:11.330 --> 28:14.090
It is in a poll request up on the CANCAT repo.

28:14.090 --> 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.

28:19.110 --> 28:20.750
So it's working on it.

28:20.750 --> 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.

28:38.160 --> 28:41.080
Alright, question was about emulators, so for messing around with this.

28:41.080 --> 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.

28:46.960 --> 28:51.780
Uh, I did, did create a testing CAN interface for CANMAP.

28:51.780 --> 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.

28:56.860 --> 28:59.260
So, short answer is, kind of.

29:03.160 --> 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.

29:13.000 --> 29:16.240
So you can convert from one to the other to play with them if you wanted to.

29:16.620 --> 29:19.320
But, uh, that is functionality I would like to do eventually.

29:19.360 --> 29:22.420
But, I'm now a couple minutes past time.

29:22.420 --> 29:25.280
Whoever's next is gonna need to get up here, so I do need to shut down.

29:25.280 --> 29:27.200
Thank you everybody for being here.

29:28.840 --> 29:30.600
And I'll be hanging around afterwards.

