[00:01.180 --> 00:03.000] Hello DEF CON! [00:03.000 --> 00:04.200] Hi! [00:10.500 --> 00:14.140] I hope you enjoy your time here, we definitely do. [00:14.140 --> 00:16.860] It's actually our first time here at DEF CON [00:16.860 --> 00:21.900] and thus we are very proud and excited to present to you our talk [00:22.700 --> 00:26.670] Redefining V2G, how to use your vehicle as a game controller. [00:27.760 --> 00:32.240] So, why do we need to redefine the acronym V2G? [00:37.370 --> 00:39.870] Well, let me tell you a story. [00:39.870 --> 00:45.430] Once upon a time, our professor told us we should do some research about V2G. [00:46.010 --> 00:51.310] And what he means by that is that we look at vehicle-to-grid communication, [00:51.310 --> 00:54.990] the communication between the car and the charge point, [00:54.990 --> 01:01.750] and also the back-end and even the power grid for bi-directional charging, for example. [01:02.250 --> 01:05.310] Well, that's actually a pretty cool research topic, [01:05.310 --> 01:08.250] but do you know what's even cooler? [01:09.570 --> 01:12.090] Using your car as a game controller. [01:12.090 --> 01:17.690] So, that's why we developed this little project called Vehicle-to-Game. [01:18.270 --> 01:22.870] But before we get started with that, a short introduction of ourselves. [01:22.870 --> 01:28.590] My name is Tim, I'm a PhD student at Darmstadt University of Applied Sciences in Germany, [01:28.590 --> 01:32.430] and I mainly do automotive security, [01:32.430 --> 01:34.650] so also a lot of theoretical stuff. [01:34.650 --> 01:39.990] I look at protocols and standards and do a formal analysis of these standards [01:39.990 --> 01:45.610] to see if they meet certain security goals. [01:45.730 --> 01:48.050] Yeah, hello from my side too. [01:48.050 --> 01:53.210] I'm Janis, I'm also a PhD student at our small automotive research group [01:53.210 --> 01:58.550] called ACSD, Automotive Cyber Security Darmstadt. [01:58.550 --> 02:00.810] It's located in Germany. [02:00.810 --> 02:05.090] I finished my master's at the end of the last year, [02:05.090 --> 02:09.930] and now I'm a PhD student about resilience in the automotive topic, [02:09.930 --> 02:12.630] but also for IoT systems. [02:12.630 --> 02:18.710] It means what happens if an ECU in a car breaks or is going to be compromised, [02:18.710 --> 02:21.810] how you can migrate functionality to another ECU [02:21.810 --> 02:27.850] and strengthen the safety inside the car by such a resilient concept. [02:28.830 --> 02:33.350] Our research group is also very focused on teaching. [02:33.350 --> 02:36.150] We have a lecture called Automotive Security, [02:36.150 --> 02:39.850] and therefore we have to motivate students, of course, [02:39.850 --> 02:44.810] and that's why we have created this motivating and beginner-friendly talk [02:45.650 --> 02:52.190] and our project V2G to get students excited and motivated [02:52.190 --> 02:54.910] about the topic of automotive research. [02:55.730 --> 03:00.290] Maybe the most important member of our research group is our research car. [03:00.290 --> 03:04.010] It's a Volkswagen ID.3. It's an electric vehicle. [03:04.290 --> 03:08.210] And since, of course, we are Germans, we have to do research on the Volkswagen. [03:13.740 --> 03:18.020] Usually, the initial step of the automotive research, [03:18.020 --> 03:23.300] but also other security research, is considering attack vectors. [03:23.300 --> 03:26.620] And that's what we have to do also for the automotive context. [03:26.620 --> 03:32.320] You can see there are various attack... it's a huge attack surface. [03:32.320 --> 03:35.200] First of all, you have long-range attacks, you have short-range attacks, [03:35.200 --> 03:38.700] but you have also physical attack possibilities. [03:38.720 --> 03:42.100] For the long-range attacks, for example, the cellular communication [03:42.100 --> 03:46.960] between the car and the back-end of the OEM, [03:46.960 --> 03:49.220] for example, for over-the-air updates. [03:49.560 --> 03:55.000] In newly upcoming cars, you have also the V2X communication, [03:55.000 --> 03:59.400] cars communicating to each other about their location, about their speed. [03:59.400 --> 04:02.180] You have cars communicating with road signs [04:02.860 --> 04:09.900] to get a status about allowed speed, for example, of this street section. [04:10.420 --> 04:14.920] You have short-range attacks, that's more or less classical cyber security, [04:14.920 --> 04:18.780] considering Bluetooth, Wi-Fi connection for your infotainment system [04:20.020 --> 04:24.000] between the smartphone, for example, for playing via Apple CarPlay, [04:24.000 --> 04:27.180] for example, the music on your car. [04:27.860 --> 04:32.720] And the maybe most interesting and car-specific attack vectors [04:32.720 --> 04:39.140] are these physical attacks, that's the bus systems inside the car, [04:39.140 --> 04:43.540] there are several of them, but we want to focus on two, [04:43.540 --> 04:47.040] and we go into them a little bit later in detail, [04:47.040 --> 04:49.760] because we need them for our V2G project, [04:49.760 --> 04:54.640] for getting all information required for our game controller out of this car. [04:57.960 --> 05:02.180] So, here you can see our two main research cars. [05:02.180 --> 05:06.920] We are focused on electric vehicles, so on the left side you can see our Volkswagen ID.3, [05:06.920 --> 05:09.900] on the right side you can see the Tesla Model 3. [05:11.000 --> 05:14.140] We use them for practical research, [05:14.440 --> 05:17.080] Tim also introduced them as theoretical research, [05:17.080 --> 05:19.140] I'm also more theoretical part, [05:19.140 --> 05:22.020] but you cannot do the whole time theoretical research, [05:22.020 --> 05:26.740] so you have to do tinkering around with the car, it's also good for the motivation. [05:27.260 --> 05:30.860] There's a lot of information you just get when you look at the actual car, [05:30.860 --> 05:32.860] because the manufacturers won't tell you, [05:32.860 --> 05:39.480] and also for students it's quite cool to do research on the actual cars and projects. [05:40.880 --> 05:46.820] So, we have equipped our cars with lots of techniques to get information about them, [05:46.820 --> 05:51.560] and we show you in the following how we have done this. [05:51.860 --> 05:54.420] That's the back of the Volkswagen ID.3, [05:54.420 --> 05:57.320] we've equipped this with lots of measurement techniques, [05:57.320 --> 06:00.540] on the right you can see so-called vector boxes, [06:00.540 --> 06:03.000] they're from a German company called Vector, [06:03.000 --> 06:05.180] that's why we call them vector boxes, [06:05.180 --> 06:09.740] they're for capturing different buses inside the car, [06:09.740 --> 06:14.880] and we have equipped the car in a way that we can get a holistic view [06:14.880 --> 06:18.200] of all relevant buses in this car. [06:18.380 --> 06:22.960] On the left side you can also see some interesting parts, [06:22.960 --> 06:24.900] more for the electrical engineers, [06:24.900 --> 06:28.860] we have equipped the car with so-called LEM sensors, [06:28.860 --> 06:31.580] they are current measuring sensors via induction, [06:31.580 --> 06:38.220] you can clip them on the high voltage system wires to measure the current. [06:38.220 --> 06:45.360] The idea behind this holistic view between physical and messages inside the car [06:45.360 --> 06:54.800] is that we can compare those data and get correlations between the actual physical measurements [06:54.800 --> 07:00.120] and the recorded, for example, canvas data. [07:02.260 --> 07:06.300] As I've already introduced, from a theoretical way, [07:06.300 --> 07:09.120] there's also a practical attack surface, of course. [07:09.120 --> 07:16.120] On the left side you can see classical key fob attacks using an SDR, [07:17.060 --> 07:19.740] maybe all of you have heard about the roll jam attack, [07:19.740 --> 07:24.940] you jam the signal of the key fob because it's using a rolling code, [07:24.940 --> 07:28.160] and the owner of the car will press a second time, [07:28.160 --> 07:32.200] and you have recorded both signals, [07:32.200 --> 07:36.600] and you re-send the older one because the car hasn't heard this already, [07:36.600 --> 07:39.500] and so you have a newer one for the car, [07:39.500 --> 07:43.500] unlocking this in the future without the owner getting any notice about this. [07:44.340 --> 07:49.620] In the middle you can see, for automotive and classical attack surfaces also, [07:49.620 --> 07:54.600] unsoldering the chips where the firmware is located on, [07:54.600 --> 07:56.400] because you have physical access to your car. [07:56.400 --> 08:00.400] If you own the car, you can do anything you like with it, more or less. [08:01.080 --> 08:05.080] So that's why we have unsoldered the EMMC chip, [08:05.080 --> 08:08.760] to get in contact with the firmware. [08:09.220 --> 08:12.700] That's the same we've done with the key fob, [08:12.700 --> 08:16.080] you can see here there was the memory chip. [08:16.920 --> 08:23.520] And maybe another interesting part is that you can directly connect, [08:23.520 --> 08:25.620] here you can see such a vector box, [08:25.620 --> 08:27.840] to the internal buses of the car. [08:27.840 --> 08:31.220] Here you can see one such an ECU, [08:31.220 --> 08:37.160] and we have connected this box with the CAN bus of the ECU, [08:37.160 --> 08:38.980] controlling messages. [08:39.680 --> 08:43.400] But before we go there for a little bit in detail, [08:43.400 --> 08:45.500] how these messages look like, [08:45.500 --> 08:49.080] first we have to understand what this CAN bus actually is, [08:49.080 --> 08:53.150] how can we talk to those cars. [08:53.150 --> 09:00.730] For a game controller, we require, as I've already mentioned, [09:00.730 --> 09:05.010] information about specific actuators of the car, [09:05.010 --> 09:06.230] for example the steering wheel. [09:06.230 --> 09:09.570] We later want to transfer the angle of the steering wheel, [09:09.570 --> 09:11.610] to our virtual game controller. [09:11.610 --> 09:14.810] So we have to get this information out of the car. [09:14.830 --> 09:18.210] And this information is transferred via the CAN bus. [09:22.050 --> 09:27.250] The topology of such a car looks like follows, [09:27.250 --> 09:29.570] it's a very condensed view, [09:29.570 --> 09:32.930] it's a very simplified view of our Volkswagen ID.3, [09:32.930 --> 09:36.450] where you can see there's a main gateway ECU, [09:36.450 --> 09:39.350] and several domains. [09:39.450 --> 09:43.470] Each domain consists of several other ECUs, [09:43.470 --> 09:46.390] and each of those domains is separated in a way, [09:47.210 --> 09:51.270] based on criticality of those functionality and the ECUs. [09:51.270 --> 09:53.890] For example, in the middle domain you can see, [09:53.890 --> 09:55.410] in the drive domain you can see, [09:55.410 --> 09:58.930] there's located the engine ECU, but also the brake ECU, [09:58.930 --> 10:00.350] they're all safety relevant, [10:00.350 --> 10:03.490] so they're very critical for the safety behavior of the car. [10:03.490 --> 10:06.550] On the left side you can see a separated domain, [10:06.550 --> 10:09.450] with less criticality for, for example, [10:09.450 --> 10:12.490] the light controlling inside the car. [10:13.990 --> 10:17.750] The special thing in this topology is, [10:17.750 --> 10:20.330] that those domains are separated, [10:21.150 --> 10:23.490] based on this gateway ECU. [10:23.490 --> 10:26.450] The gateway ECU is responsible for, [10:28.410 --> 10:32.510] for shielding the inside of the car against the outside, [10:32.510 --> 10:37.690] because, you know, maybe you know this from combustion engine, [10:37.690 --> 10:41.330] the outside of the car is connected with so-called OBD2 port. [10:41.330 --> 10:45.290] It's for diagnosis, if you bring your car to a garage, [10:45.290 --> 10:46.890] they will plug there in. [10:46.890 --> 10:50.090] And you want to prevent that via the OBD2 port, [10:50.090 --> 10:52.710] everyone can read everything of the car. [10:52.710 --> 10:57.770] So that's why such a gateway ECU is introduced into this topology. [10:57.970 --> 11:01.630] But this strongly depends on the actual car you want to consider. [11:01.630 --> 11:03.890] That's just for the Volkswagen ID.3 [11:03.890 --> 11:07.410] and the group of vehicles from Volkswagen. [11:11.230 --> 11:14.570] Now we get a little bit into detail about this CAN bus. [11:14.570 --> 11:17.770] The CAN bus was developed by Bosch in 1986. [11:18.070 --> 11:21.090] It's a dual wire twisted pair cable, [11:21.090 --> 11:23.870] and as I said before, it's a bus topology. [11:23.870 --> 11:26.210] What does it mean? [11:26.210 --> 11:31.130] A bus topology means that the ECUs are connected to the same wire, [11:31.130 --> 11:33.690] or wire pair, [11:33.690 --> 11:39.010] and all ECUs get the same state of information in the respective time frame. [11:39.010 --> 11:41.710] We have a frequency in this CAN bus, [11:41.710 --> 11:45.890] and all this information is distributed in this time frame [11:45.890 --> 11:51.310] to all ECUs connected to this CAN bus. [11:51.310 --> 11:53.690] It's also a multi-master protocol. [11:53.690 --> 11:58.540] It means that all ECUs can send and receive on demand, [11:58.950 --> 12:02.710] and there's no master required to control them. [12:06.570 --> 12:10.590] Now we have the foundations how this CAN bus works. [12:10.590 --> 12:15.790] Now we get to gain access to this physical CAN bus inside the car. [12:16.510 --> 12:19.950] Maybe the most convenient way is to find just a repair manual [12:19.950 --> 12:22.090] or a wiring diagram of the car. [12:22.090 --> 12:24.830] They're usually available for garages. [12:24.850 --> 12:27.310] For Volkswagen, you can get them online. [12:27.310 --> 12:31.370] If you claim you have a garage, then you can buy it. [12:32.790 --> 12:35.030] Otherwise, you have to find it out by yourself, [12:35.030 --> 12:37.370] but this can become very, very hard. [12:37.370 --> 12:40.810] So we recommend having such a wiring diagram. [12:41.270 --> 12:42.890] Based on this wiring diagram, [12:42.890 --> 12:48.370] you can find a good exposed position of an interesting CAN bus [12:49.090 --> 12:51.190] where you can connect to. [12:51.190 --> 12:54.370] For example, here you can see the Tesla Model 3, [12:54.370 --> 12:57.270] which is in the mid console of the car. [12:57.530 --> 12:59.950] There's one of three CAN buses, [12:59.950 --> 13:06.330] which you can easily open and connect to ready-to-buy adapter. [13:06.330 --> 13:09.590] You can buy those adapters easily on eBay, for example. [13:09.810 --> 13:13.650] And then you can gain access to this CAN bus. [13:14.270 --> 13:18.250] If you don't want to destroy your car or altering this, [13:18.250 --> 13:21.170] there are also less intrusive techniques. [13:21.170 --> 13:24.050] These are called contactless CAN readers. [13:24.050 --> 13:28.390] They read CAN messages based on induction of the signal. [13:28.850 --> 13:31.290] And that's more or less... it looks like a crocodile. [13:31.290 --> 13:34.170] That's why some products are called CAN crocodile. [13:34.170 --> 13:39.210] You clamp the CAN wires high and low, those dual wires, [13:39.210 --> 13:44.310] between the clamp of the contactless CAN reader, [13:44.310 --> 13:46.690] and you can read those messages. [13:47.430 --> 13:51.090] So, you have gained access to the physical layer, [13:51.090 --> 13:55.790] you have read those physical signals of the CAN bus. [13:55.790 --> 13:58.930] Now you have to transfer them into software, [13:58.930 --> 14:01.170] and therefore you need such... [14:01.690 --> 14:05.110] for the Raspberry Pi, for example, a CAN head, [14:05.110 --> 14:08.010] where those physical CAN signals are interpreted [14:08.010 --> 14:11.970] and transferred to the kernel of the Raspberry Pi. [14:12.190 --> 14:14.710] There are also other options available, [14:14.710 --> 14:18.390] which can conveniently be used, [14:18.390 --> 14:22.630] where you can connect your CAN bus directly via USB to your PC. [14:22.630 --> 14:23.870] This also works for Windows, [14:23.870 --> 14:26.850] so maybe it's for part of you interesting. [14:27.330 --> 14:29.670] So, now we have transferred the message [14:29.670 --> 14:32.910] to the software part of our project, [14:32.910 --> 14:35.290] and that's where Tim continues. [14:35.290 --> 14:38.730] Alright, so very conveniently in the Linux kernel, [14:38.730 --> 14:41.350] there's already a CAN driver built in. [14:41.350 --> 14:43.770] And if you want to work with that, [14:43.770 --> 14:48.690] there's CANutils, which has all the basic tools to use that. [14:48.890 --> 14:52.270] Also, if you want to do more advanced stuff for scripting, [14:52.270 --> 14:55.590] you can use, for example, PythonCAN as a really good library. [14:55.590 --> 14:57.350] That's what we use for our project. [14:57.830 --> 15:01.050] There's also CANtools for more advanced command-line tools. [15:01.350 --> 15:03.630] If you're into GUIs, there's SavvyCAN, [15:03.630 --> 15:06.670] which is a really good open-source GUI tool. [15:07.110 --> 15:09.430] And, of course, there are a lot of commercial tools. [15:09.430 --> 15:11.790] We talked about all this vector stuff before. [15:12.750 --> 15:14.830] But let's stick with the very basics. [15:14.830 --> 15:20.070] So you install CANutils, and then there's this CANdump command, [15:20.070 --> 15:23.710] which will just print out all of the CAN messages on the bus. [15:23.710 --> 15:26.730] It looks somehow like this, but probably a lot faster [15:26.730 --> 15:28.170] if you're on a real car. [15:28.810 --> 15:31.370] For Tesla, for example, it might be on one bus, [15:31.370 --> 15:34.450] I think, like 3,000 messages a second, [15:34.450 --> 15:36.430] so it can be quite a lot. [15:37.070 --> 15:40.490] One step back, even, if you connect to this, [15:42.310 --> 15:47.270] for Linux, the CAN interface is like any other network interface [15:47.270 --> 15:51.410] if your adapter is compatible with SocketCAN. [15:52.410 --> 15:56.390] The only difference is that you don't have a network manager [15:56.390 --> 16:01.190] to directly get your interface up and running, [16:01.190 --> 16:03.510] and you also need a bitrate. [16:03.890 --> 16:09.740] So you have to tell the computer how fast the bus operates. [16:09.740 --> 16:14.260] You can measure that by using an oscilloscope, of course. [16:14.800 --> 16:18.880] Luckily for automotive, it's usually 500 kilobits per second, [16:18.880 --> 16:20.780] so you can also try that. [16:20.900 --> 16:22.860] And just as a disclaimer, [16:22.860 --> 16:29.920] there are also more modern standards, [16:29.920 --> 16:31.460] like improvements on the CAN standards, [16:31.460 --> 16:33.960] for example, CAN FD, [16:33.960 --> 16:37.680] and there you will also need to have the data rate, for example. [16:38.280 --> 16:41.320] But let's assume standard CAN for now. [16:41.880 --> 16:44.540] And then we've already seen the candab command. [16:44.660 --> 16:49.040] I just want to walk very quickly through what you can see here. [16:49.040 --> 16:51.900] That's one single message picked out. [16:51.900 --> 16:55.140] You see the interface in the front, [16:55.140 --> 16:58.920] if you have multiple CAN interfaces connected, [16:58.920 --> 16:59.860] that's important. [16:59.860 --> 17:04.620] Then the CAN ID, and the data length, and the data. [17:04.620 --> 17:07.700] The thing is, this CAN ID, [17:07.700 --> 17:11.300] if you're used to IP, you're usually used to having a source [17:11.300 --> 17:14.560] and a destination address. [17:14.640 --> 17:17.300] The CAN ID is actually neither. [17:17.300 --> 17:20.040] Think of it more like a publish-subscribe topic. [17:20.040 --> 17:22.600] So it will tell you how to define [17:22.600 --> 17:28.500] or how to interpret the bits in the data part. [17:29.040 --> 17:31.180] Also, it's the priority of the message. [17:31.180 --> 17:33.560] So the lower the ID, the higher the priority. [17:35.240 --> 17:40.940] And this data, it can be really arbitrarily defined. [17:40.980 --> 17:43.840] The information in there is called signals, [17:43.840 --> 17:46.220] and it can be like 1-bit, it can be 5-bit, [17:46.220 --> 17:49.160] it can be all 8-bytes. [17:49.820 --> 17:53.400] So that's up to the manufacturer to define that, [17:53.400 --> 17:57.040] and that's why we usually need some reverse engineering [17:57.040 --> 17:59.700] to make sense of this information. [18:00.680 --> 18:06.500] Okay, so you might want to get started, [18:06.500 --> 18:09.920] but maybe you do not want to remove all the plating of your car. [18:10.100 --> 18:16.520] It sounds like a lot of work to figure out all the wiring and stuff. [18:17.480 --> 18:20.000] So that's actually how we started, [18:20.000 --> 18:21.780] but if you don't want to do that, [18:21.780 --> 18:24.600] there's also the way the garages do that. [18:24.600 --> 18:27.420] So Janice already spoilered it, [18:27.420 --> 18:30.520] that you have this OBD2 connector, [18:30.520 --> 18:33.080] and for vehicle diagnostics. [18:33.720 --> 18:37.000] And this connector is usually very conveniently located [18:37.000 --> 18:40.940] somewhere in the driver area of your vehicle in front, [18:40.940 --> 18:45.540] and you can just plug in a diagnostic connector there. [18:45.540 --> 18:47.680] It's usually an OBD2 dongle, [18:47.680 --> 18:50.980] which connects via Bluetooth to a diagnostic device, [18:50.980 --> 18:54.640] and will read out data like that. [18:54.740 --> 18:56.920] And the protocol to do this is called UDS, [18:56.920 --> 18:59.140] Unified Diagnostic Services, [18:59.140 --> 19:02.540] and it's basically a request-response protocol. [19:02.760 --> 19:05.340] The diagnostic tester will, for example, [19:05.340 --> 19:07.460] in our case, we want the steering wheel angle, [19:07.460 --> 19:10.680] so it will ask, is you responsible for that? [19:10.680 --> 19:12.320] Can you give me the steering wheel angle? [19:12.320 --> 19:14.620] And it will respond with the correct value. [19:15.000 --> 19:19.300] So that's on top of the CAN protocol. [19:19.300 --> 19:23.680] It can also be IP, but usually CAN, or both. [19:23.700 --> 19:26.980] And in between, there's actually another protocol, [19:26.980 --> 19:28.760] which is called ISOTP, [19:28.760 --> 19:31.460] and which allows to basically combine multiple CAN measures. [19:31.460 --> 19:34.140] They are limited to 8-byte, [19:34.140 --> 19:36.740] to one message in UDS, [19:36.740 --> 19:39.700] so you can send longer data. [19:41.040 --> 19:46.520] But that comes with the difference that now we also... [19:46.520 --> 19:51.000] I told you before that this is not like source and destination address to CAN ID, [19:51.000 --> 19:54.980] but for UDS, it's actually the destination address now. [19:55.100 --> 19:57.360] So there's also, if you want to read data, [19:57.360 --> 19:59.200] there's also a data identifier, [19:59.200 --> 20:01.780] which identifies which data it is. [20:01.780 --> 20:06.080] So you can have now multiple different interpretations for data [20:06.080 --> 20:07.560] with the same CAN ID, [20:07.560 --> 20:10.620] and data can be split over multiple CAN frames. [20:10.620 --> 20:11.980] Just watch out for that. [20:11.980 --> 20:16.860] All right, and with that, I think we should have everything ready to go. [20:16.960 --> 20:19.460] Yeah, I think so. We have considered the physical layer, [20:19.460 --> 20:22.600] we have considered the transfer to the software, [20:22.600 --> 20:26.040] we have considered how we can interpret those CAN messages, [20:26.040 --> 20:28.920] so we have all together to create our game. [20:29.120 --> 20:32.780] And as a small in-between motivation, [20:32.780 --> 20:34.360] that's the actual result. [20:34.360 --> 20:37.920] Here you can see Tim sitting in our Volkswagen ID.3. [20:38.020 --> 20:40.060] In front, we have placed a big monitor, [20:40.060 --> 20:43.760] playing Need for Speed Most Wanted from 2008, [20:43.760 --> 20:45.440] with the actual car. [20:48.690 --> 20:49.790] Thank you. [20:54.690 --> 20:58.630] Here you can see a little bit more of our V2G experience. [20:58.630 --> 21:00.830] On the left side, you can see our setup, [21:01.010 --> 21:03.770] a laptop where the game is actually running. [21:03.770 --> 21:05.790] In front of the car, we have placed a huge monitor [21:05.790 --> 21:09.070] for a very immersive experience for the driver, [21:09.070 --> 21:12.210] but also for all other people inside the car. [21:12.210 --> 21:15.290] On the right side, you can see me playing, again, [21:15.290 --> 21:16.870] Need for Speed Most Wanted. [21:16.930 --> 21:19.930] And you can see I'm very focused on this game. [21:19.930 --> 21:22.110] So, as I said, it's very immersive, [21:22.110 --> 21:26.210] and it's a very cool experience sitting in such an equipped car. [21:28.290 --> 21:34.770] But how can we now connect the laptop, the game, with the car? [21:34.770 --> 21:37.410] You can see on the right, the topology again. [21:38.050 --> 21:40.130] Therefore, we have several possibilities [21:40.130 --> 21:42.490] to connect the car. [21:42.490 --> 21:44.490] First, we can use wires. [21:44.490 --> 21:49.690] We can use the USB-based P-CAN Pro, for example, [21:49.690 --> 21:55.030] connecting, as one possibility, to the internal CAN bus. [21:55.230 --> 21:56.570] Therefore, we have to figure out [21:56.570 --> 22:00.310] which CAN bus relevant messages are located on. [22:00.630 --> 22:04.010] We have to find the relevant messages, [22:04.010 --> 22:10.110] figuring out the relevant signals of the CAN messages, [22:10.110 --> 22:13.430] and there's an overwhelming number of CAN messages [22:13.430 --> 22:15.070] on this internal bus. [22:15.070 --> 22:18.330] As Tim said, several thousands per second. [22:18.330 --> 22:22.590] So it's quite difficult to figure this stuff out. [22:22.730 --> 22:25.890] Also, the whole breakout box stuff we've shown to you [22:25.890 --> 22:29.370] is required to get access to those internal buses, [22:29.370 --> 22:31.230] so the more convenient solution [22:31.230 --> 22:34.370] is connecting directly to the OBD2 port [22:34.370 --> 22:39.050] and use the diagnostic services for pulling those informations [22:39.050 --> 22:43.790] and getting conveniently just the requested information. [22:44.210 --> 22:46.650] But since we live in 2024, [22:46.650 --> 22:48.470] wires are a little bit outdated. [22:48.470 --> 22:50.750] We have created a Raspberry Pi head, [22:50.750 --> 22:57.810] which allows us to emulate an Xbox 360 controller [22:57.810 --> 22:59.650] with a Raspberry Pi Zero, [22:59.650 --> 23:02.650] connecting directly to the OBD2 port of the car. [23:02.650 --> 23:07.250] And this Raspberry Pi connects via Bluetooth to the laptop, [23:07.250 --> 23:08.770] emulates this controller, [23:08.770 --> 23:10.490] and the laptop can stand outside the car [23:10.490 --> 23:12.990] and runs the game. [23:13.470 --> 23:16.650] For this setup, we use UDS. [23:18.650 --> 23:23.790] Now, a little bit into detail of the actual hardware we use for it. [23:24.190 --> 23:26.530] The lower layer of this, [23:26.530 --> 23:28.850] you can see it's a classical Raspberry Pi Zero [23:28.850 --> 23:30.490] with no modifications. [23:30.490 --> 23:35.750] Above that, we have located the Raspberry Pi CAN head, [23:35.750 --> 23:39.710] which is responsible for converting those physical CAN signals [23:39.710 --> 23:43.230] to a software-readable CAN message. [23:43.370 --> 23:45.130] And the top layer, [23:45.130 --> 23:49.030] we have created a self-designed PCB [23:49.030 --> 23:57.370] for connecting to this OBD2 port of the car. [23:57.370 --> 24:00.750] From this OBD2 port, [24:00.750 --> 24:03.090] we only use four connections. [24:03.090 --> 24:05.150] The 12V, the ground, [24:05.150 --> 24:07.670] the CAN high and CAN low connection. [24:07.910 --> 24:09.270] The CAN high and CAN low connection [24:09.270 --> 24:11.130] is directly transferred via this PCB [24:11.130 --> 24:15.750] to the lower CAN head, [24:15.750 --> 24:18.690] which converts this message. [24:19.050 --> 24:21.730] But the more interesting part of this PCB [24:21.730 --> 24:24.710] is the 12V, 5V DC-DC conversion. [24:24.710 --> 24:29.450] So we can very conveniently connect this dongle to our car [24:29.450 --> 24:31.710] without the requirement for a power bank [24:31.710 --> 24:33.970] and power supply of the Raspberry Pi. [24:34.430 --> 24:35.450] As a short disclaimer, [24:35.450 --> 24:37.770] we are no electrical engineers, [24:37.770 --> 24:40.190] so if you have any recommendation about this, [24:40.190 --> 24:42.150] feel free to contact us. [24:42.150 --> 24:45.550] We are quite happy about recommendations. [24:45.570 --> 24:49.430] This circuit for 12V, 5V DC-DC conversion [24:49.430 --> 24:53.510] is just taken out of the datasheet of the used IC. [24:54.870 --> 24:58.850] Feel free to come offstage to us and discuss it with me. [25:01.990 --> 25:05.570] We have also added the possibility to add status LEDs, [25:05.570 --> 25:07.110] but that's to be done. [25:09.370 --> 25:13.270] They are connected to the GPIO pins of the Raspberry Pi, [25:13.270 --> 25:15.250] so if you want to extend the project, [25:15.250 --> 25:17.490] you can use them for your own purpose. [25:18.350 --> 25:20.030] So, we have the hardware. [25:20.570 --> 25:22.150] Now, the software. [25:23.110 --> 25:27.970] I'm just going very briefly over the software architecture of our tool. [25:27.970 --> 25:30.750] So, if you want to use it in the Bluetooth mode, [25:30.750 --> 25:32.790] as a Bluetooth controller, [25:32.790 --> 25:34.310] there's an install script for that. [25:34.310 --> 25:38.250] You just run it on your pre-imaged Raspberry Pi [25:38.250 --> 25:42.010] and it will set up everything which is required. [25:42.670 --> 25:44.310] If you don't want to do it, [25:44.310 --> 25:45.810] then just run it on your own laptop. [25:45.810 --> 25:48.130] There's a run script for Linux. [25:48.130 --> 25:51.370] For Windows, you just directly run the Python protocol. [25:52.910 --> 25:58.090] The run script actually will also set up some interfaces and stuff, [25:58.090 --> 26:00.690] but you can do this beforehand [26:00.690 --> 26:03.430] if you do not want to execute it with pseudo-privileges, [26:03.430 --> 26:06.190] because that's required for interface management. [26:06.810 --> 26:09.630] Then, for emulating the game controller, [26:09.630 --> 26:13.230] for the Bluetooth version, we used the HitPi project [26:14.810 --> 26:17.170] to emulate a Bluetooth device, [26:17.170 --> 26:19.310] and if you run it on your own laptop, [26:19.310 --> 26:21.710] we used the VGamePad library, [26:21.710 --> 26:25.530] which is also cross-platform, so it also runs on Windows. [26:27.330 --> 26:29.590] You can also use that. [26:29.830 --> 26:33.290] For the Bluetooth one, it doesn't really work on Windows so far, [26:33.290 --> 26:35.570] so if you have any recommendations on that, [26:35.570 --> 26:37.490] and are an expert on Hit devices, [26:38.690 --> 26:41.110] also pull requests are welcome. [26:42.730 --> 26:49.390] So, now to our actual domain components. [26:49.390 --> 26:50.570] We have a car detector. [26:50.570 --> 26:52.090] If you have multiple vehicles, [26:52.090 --> 26:54.190] as we have the ID3 and the Tesla, [26:54.190 --> 26:56.590] you can give it basically a list of CAN IDs, [26:56.590 --> 26:58.510] and it will figure out which car it is, [26:58.510 --> 27:02.150] and then use the according configuration. [27:02.470 --> 27:05.410] The heart of our project is the car connector, [27:05.410 --> 27:09.670] which will convert all the CAN signals [27:09.670 --> 27:14.750] in the messages to triggers for the Xbox emulation. [27:15.290 --> 27:17.770] And then there is the vehicle configuration, [27:17.770 --> 27:21.330] which has all the vehicle-specific stuff in there. [27:21.330 --> 27:25.150] And I'll just have a more detailed look on that. [27:28.490 --> 27:32.110] You can configure a name for your vehicle to reference it. [27:32.510 --> 27:34.830] Then you have to specify which operation mode, [27:34.830 --> 27:37.590] if you want to use the internal mode or the UDS mode. [27:37.590 --> 27:40.010] Sometimes, if you have an older car, [27:40.010 --> 27:42.450] where there is no gateway in between the internal buses [27:42.450 --> 27:45.250] and the OBD2 connector, [27:45.250 --> 27:47.890] you can also use the internal mode for that. [27:48.390 --> 27:54.790] Or if you install the OBD2 adapter for the Tesla. [27:56.350 --> 27:58.470] Otherwise, for the UDS mode, [27:58.470 --> 28:01.590] you will also have what you can see on the right side, [28:01.590 --> 28:03.870] and you will have to send those polling messages [28:03.870 --> 28:05.470] I talked about earlier. [28:05.470 --> 28:07.250] Basically, you can just paste them in here, [28:07.250 --> 28:11.390] and it will periodically send them to get the data. [28:11.390 --> 28:13.870] There is also an update interval. [28:14.510 --> 28:16.310] Usually, we have a higher interval [28:16.310 --> 28:19.250] for the steering angle and brakes. [28:19.250 --> 28:21.950] And for the buttons, we use a lower update interval, [28:21.950 --> 28:25.430] because there is a limit how fast the ECUs will respond. [28:26.170 --> 28:27.310] Also, we have some... [28:27.310 --> 28:30.430] You can see the auto-detect IDs I mentioned before. [28:30.430 --> 28:34.730] And also, we have some high-level configuration stuff. [28:34.730 --> 28:37.510] For example, we limit the steering, [28:37.510 --> 28:38.950] because if you play a racing game, [28:38.950 --> 28:41.570] and you have to two times turn the wheel [28:41.570 --> 28:45.290] for the maximum steering, it's just too slow, right? [28:45.630 --> 28:49.410] And also, there is the steering dead zone, [28:49.410 --> 28:53.110] which basically, you have a bit more space [28:53.110 --> 28:57.490] to set your steering wheel to zero. [28:57.490 --> 29:00.670] Because otherwise, if it's like 0.01 degrees, [29:00.670 --> 29:02.570] and it will always go left in the menus, [29:02.570 --> 29:05.830] or you just cannot drive straight, [29:05.830 --> 29:08.450] it's actually pretty hard to get your steering wheel [29:08.450 --> 29:10.310] to exactly zero degrees. [29:10.510 --> 29:12.070] So, that's pretty handy. [29:12.990 --> 29:17.210] I'll go a bit into detail on the signal configuration later. [29:17.870 --> 29:22.550] But for now, let's look at how it works out. [29:22.550 --> 29:24.230] Yeah, we are ready to play. [29:24.230 --> 29:27.090] Unfortunately, we are not allowed to bring our car with us, [29:27.090 --> 29:29.930] so we have brought some videos of the gaming experience. [29:29.930 --> 29:33.710] You can see me here driving with first-person view, [29:33.710 --> 29:35.850] playing SuperTux Kart. [29:39.740 --> 29:42.780] You can see I control the racing car [29:42.780 --> 29:45.700] with the steering wheel, left and right. [29:45.700 --> 29:47.860] And now I've paused, because you can see [29:47.860 --> 29:50.740] I put my foot on the brake. [29:50.880 --> 29:52.860] Let's see what happens next. [29:55.290 --> 29:59.530] As expected, the racing car slows down, [29:59.530 --> 30:01.270] and I was overtaken. [30:02.450 --> 30:09.690] Now, you can see I've started the indicator. [30:09.710 --> 30:12.210] We've mapped the indicator function for left [30:12.210 --> 30:15.590] to throwing items in this game. [30:15.590 --> 30:18.130] You can do this for your own purpose, for your own game, [30:18.130 --> 30:20.130] but we've mapped it like this. [30:20.450 --> 30:24.190] So you can see here, I'm throwing this exploding muffin [30:24.190 --> 30:29.290] to the racing car in front of me, [30:29.290 --> 30:31.010] so it will explode. [30:31.010 --> 30:36.790] Unfortunately, because PowerPoint is a little bit annoying, [30:36.790 --> 30:39.230] sometimes, usually you should see [30:39.230 --> 30:44.690] that I've turned on the full beam flash, full beam 2, [30:44.690 --> 30:49.390] so we've mapped the full beam trigger [30:49.390 --> 30:53.130] to the nitro activation in the game. [30:53.590 --> 30:56.590] So it's very cool, driving in the night, igniting, [30:56.590 --> 30:58.710] and the car speeds up. [30:59.930 --> 31:01.050] See what happens? [31:01.050 --> 31:04.410] You can see the nitrogen. [31:04.490 --> 31:09.450] Now, you can see it's a little bit difficult to drive, [31:09.450 --> 31:12.410] especially with just one hand, [31:12.410 --> 31:15.470] but it is possible to race, [31:15.470 --> 31:19.210] it is possible to overtake enemies in this game, [31:19.210 --> 31:23.050] and it is also possible for you to get the right items, [31:23.050 --> 31:26.110] in this example, an acceleration one, [31:26.110 --> 31:28.270] to win racing games. [31:33.120 --> 31:35.300] And it's actually a lot of fun. [31:36.000 --> 31:38.860] You see, we're very excited about this. [31:40.580 --> 31:43.880] So, maybe, over to Tim. [31:43.880 --> 31:48.540] So, the question all of you probably have in your mind, [31:48.540 --> 31:52.420] how do you support your own car to use this? [31:52.420 --> 31:55.240] Well, before you get started on that, [31:55.240 --> 32:00.580] just make sure you keep in mind the safety. [32:00.640 --> 32:04.180] So, make sure you cannot accidentally drive into a wall. [32:04.180 --> 32:07.360] Why? Because if you're in your garage, [32:07.360 --> 32:09.300] and you're really into your game, [32:09.300 --> 32:12.840] and by accident you switch to drive mode, [32:12.840 --> 32:14.720] you don't want to do that. [32:15.500 --> 32:18.660] You're probably out on the gas, right? [32:18.660 --> 32:21.320] So, make sure you cannot do that. [32:21.320 --> 32:25.240] Of course, there's less of a problem on combustion engine vehicles, [32:25.240 --> 32:29.140] where you do not have to turn on the engine, [32:29.140 --> 32:33.260] but then make sure not to drain your 12-volt battery, [32:33.260 --> 32:34.720] like playing all night. [32:36.020 --> 32:41.160] It's probably not good if you do not have a charger connected. [32:42.120 --> 32:43.700] So, what do you need? [32:43.700 --> 32:46.060] I think we talked about everything of that. [32:47.040 --> 32:52.060] You can also use just an OBD2 open-ended cable, [32:52.060 --> 32:56.820] if you do not want to solder your own OBD2 head. [32:57.220 --> 33:01.100] So, that all should be less than 50 bucks, I think, to get started. [33:01.560 --> 33:04.180] If you use the diagnostic mode, [33:04.180 --> 33:07.900] and you have to get a diagnostic tester to reverse-engineer that, [33:07.900 --> 33:10.020] that really depends on the car, probably. [33:10.020 --> 33:12.400] There are sometimes some very cheap ones, [33:12.400 --> 33:15.520] and if you have to get a garage-level one, [33:15.520 --> 33:17.100] it's pretty expensive. [33:17.100 --> 33:20.580] So, yeah, probably too much. [33:21.060 --> 33:24.140] Okay, and then you can start reverse-engineering. [33:24.260 --> 33:27.540] So, here you can see the UDS tester setup, basically. [33:28.540 --> 33:32.080] The actuator, we are looking at a steering wheel angle, as before. [33:32.440 --> 33:36.880] Here we have a tablet with the diagnostic tool, [33:36.880 --> 33:38.880] which reads out the steering angle. [33:38.880 --> 33:43.100] And here we have my laptop, which runs CanSniffer, [33:43.100 --> 33:44.420] which is a very convenient tool [33:44.420 --> 33:47.620] to show you the differences in car messages. [33:48.120 --> 33:52.240] And what we'll do next is turn the steering wheel [33:52.240 --> 33:54.420] to see where the information is. [33:55.300 --> 34:00.460] And actually, I turn it one time completely to the left, [34:00.460 --> 34:03.480] and one time to the right to get the min and maximum value, [34:03.480 --> 34:04.820] which is possible for the signal, [34:04.820 --> 34:07.300] but you have seen where it is located. [34:08.720 --> 34:11.400] And, yeah, sometimes you're lucky, [34:11.400 --> 34:16.340] and you will find already complete CAN database files, [34:16.340 --> 34:19.520] those called DBC files, online for your car. [34:19.520 --> 34:22.360] Then you can also try to get this information out of there [34:22.360 --> 34:24.680] and use that. [34:24.680 --> 34:27.540] But otherwise, reverse-engineering of this data is quite good [34:27.540 --> 34:31.440] because it's like you can easily turn the steering wheel [34:31.440 --> 34:34.040] to see where the data is, right? [34:34.040 --> 34:35.840] It's just if there are 3,000 messages, [34:35.840 --> 34:39.220] it might take you some time to find the right one. [34:39.220 --> 34:42.460] Then for configuring it, [34:42.460 --> 34:45.340] you basically add all this information, the CAN ID, [34:45.340 --> 34:49.280] the position in the signal, and the length of the data. [34:49.460 --> 34:52.080] And then that's why we use Python for the configuration. [34:52.080 --> 34:58.000] You can just use a function to specify the signal mapping. [34:58.220 --> 35:03.720] In this case, we have the first byte turning to the left, [35:03.720 --> 35:04.940] the second to the right, [35:04.940 --> 35:06.860] and then we specify the min and maximum value [35:06.860 --> 35:11.180] and map this to a range of minus 1.0 to 1.0. [35:12.800 --> 35:18.360] All right, that's what you need to configure for your own car. [35:19.420 --> 35:24.120] In conclusion of this talk, if anybody asks you, [35:24.120 --> 35:26.020] especially our professor, [35:26.020 --> 35:29.760] now you definitely know that V2G stands for Vehicle-to-Game. [35:31.580 --> 35:34.320] Car hacking can be really fun. [35:34.320 --> 35:36.920] And I think our project is a great entry point [35:36.920 --> 35:38.180] if you want to get into that [35:38.180 --> 35:43.860] or just want to be able to say [35:43.860 --> 35:47.240] that you have a very expensive game controller at home. [35:48.240 --> 35:50.680] Always be careful if you do that stuff. [35:50.680 --> 35:52.380] Do not drive into walls. [35:53.520 --> 35:56.240] We actually use it, as Janis said before, [35:56.240 --> 35:59.420] as a demonstrator to motivate students to show it to visitors. [35:59.420 --> 36:03.340] It's always a good icebreaker to get started [36:03.340 --> 36:06.080] about talking about automotive security. [36:06.620 --> 36:09.840] And so the only question that remains is, [36:09.840 --> 36:11.680] what are you going to use it for? [36:18.810 --> 36:20.690] Feel free to contact us. [36:20.690 --> 36:23.190] Do any contributions to our project. [36:23.190 --> 36:25.770] Write us an email. Here you can see the QR code. [36:25.770 --> 36:27.490] The Git repository is public, [36:27.490 --> 36:32.850] so you can make an issue or do a pull request. [36:32.850 --> 36:37.050] Feel free. We're happy if we can keep in contact with you. [36:38.610 --> 36:42.890] And I think we have eight minutes left for questions, if there are any. [36:42.890 --> 36:46.730] Otherwise, we can also take further questions offstage. [36:50.520 --> 36:55.020] Have you thought about playing with heads-up display? [36:55.020 --> 36:56.700] You know, you can get these things now. [36:56.700 --> 36:59.660] You just put it on the dash and it'll actually just reflect [36:59.660 --> 37:05.700] your iPad or anything up onto the windscreen. [37:05.700 --> 37:09.280] And it looks like a heads-up display kind of a thing. [37:09.280 --> 37:10.520] Have you thought about that? [37:10.520 --> 37:15.960] Just for a way to project onto the screen. [37:17.520 --> 37:18.760] Where's the question? [37:18.760 --> 37:21.540] Oh yeah, so the question was if we have thought about [37:21.540 --> 37:27.720] projecting the game, basically, onto the screen of the car. [37:27.720 --> 37:30.680] So we've thought about that. We haven't done it. [37:30.680 --> 37:34.620] We also thought about it because the ID3 actually has a heads-up display. [37:36.540 --> 37:42.860] Yeah, so I think there are adapters to the protocol they use there. [37:42.860 --> 37:48.040] And then you can use it as an HDMI interface, basically, if you plug in there. [37:48.040 --> 37:50.660] So we have some plans, maybe, for the future. [37:50.660 --> 37:54.400] But we actually haven't done that or tested it. [37:54.400 --> 38:01.200] Just putting a projector in the back of the car is probably quite good. [38:01.200 --> 38:03.120] It's not a security-related problem. [38:03.120 --> 38:07.200] It's just throwing money on it via such a converter. [38:07.240 --> 38:11.100] And then you can easily connect your laptop with those internal screens of the car. [38:11.100 --> 38:13.900] That's expensive but easily doable. [38:15.900 --> 38:19.680] Yeah, but come up with your own setup. [38:19.680 --> 38:22.600] I think there's a lot of possibility, right? [38:23.140 --> 38:24.100] Yeah. [38:27.050 --> 38:32.210] The question was how if we build up a flight simulator out of this. [38:32.210 --> 38:35.590] If you have a real airplane, maybe you can transfer this. [38:37.030 --> 38:38.010] I don't know. [38:38.010 --> 38:41.330] Maybe you can use also your car for this. It should be possible. [38:41.330 --> 38:43.390] It's just an Xbox controller. [38:43.810 --> 38:46.290] You can map it to anything you want. [38:48.250 --> 38:50.610] Okay, any further questions? No? [38:50.610 --> 38:51.070] No. [38:51.070 --> 38:51.850] Alright. [38:51.950 --> 38:53.730] Okay, thank you. [38:53.730 --> 38:55.750] Thanks for listening and have a nice day. [38:55.750 --> 38:57.070] Enjoy the last day of DEF CON.