1 00:00:00,000 --> 00:00:01,620 Thank you all for coming. 2 00:00:02,080 --> 00:00:04,100 Thanks DEF CON for having me up here. 3 00:00:04,360 --> 00:00:11,300 As Juris mentioned, I've been involved here in a lot of different ways, but this is the first time I've actually been up on the stage, so it means a lot. 4 00:00:11,560 --> 00:00:14,880 Do we have any car enthusiasts in the audience? 5 00:00:15,060 --> 00:00:16,180 Yeah, okay. 6 00:00:17,340 --> 00:00:20,880 Any of you ever had problems with your emissions testing? 7 00:00:21,300 --> 00:00:22,920 Yeah, we're going to have some fun. 8 00:00:23,960 --> 00:00:26,640 So I assume you all can see something. 9 00:00:26,640 --> 00:00:27,680 I can't see shit. 10 00:00:27,680 --> 00:00:33,560 But we're going to talk about the ODB2 systems in cars and what we can have fun with. 11 00:00:33,960 --> 00:00:36,880 So this is a car I bought about ten years ago. 12 00:00:36,880 --> 00:00:41,320 It's a fun go-kart of a car. 13 00:00:41,820 --> 00:00:44,220 It has a little quirk about it. 14 00:00:44,220 --> 00:00:45,800 Anybody know what this car is? 15 00:00:45,800 --> 00:00:46,480 Anybody? 16 00:00:47,160 --> 00:00:50,460 Yeah, so we've got the Wankel rotary motor in it. 17 00:00:50,880 --> 00:00:54,920 And specifically, these things love to kill catalytic converters. 18 00:00:57,200 --> 00:01:01,540 But at the time, I was living in Kansas City, and they don't do emissions testing. 19 00:01:01,800 --> 00:01:04,200 Oh, by the way, did he mention SetKC? 20 00:01:04,200 --> 00:01:06,740 Yeah, so we'll wrap around to that. 21 00:01:07,880 --> 00:01:09,960 So, you know, it's not there. 22 00:01:09,960 --> 00:01:10,940 We don't have to worry about it. 23 00:01:10,940 --> 00:01:14,600 So I enlisted my little helper, and we were like, fuck that, get it out of here. 24 00:01:15,320 --> 00:01:17,920 So life was good for about eight years. 25 00:01:18,480 --> 00:01:21,940 Then I decided, well, let's move to the West Coast. 26 00:01:22,020 --> 00:01:25,980 Turns out, they don't like that so much around here. 27 00:01:26,620 --> 00:01:31,960 However, as I was digging into the laws, they had this statute that got me kind of excited. 28 00:01:32,020 --> 00:01:37,800 It said for collectible vehicles, we don't do emissions testing. 29 00:01:37,800 --> 00:01:39,980 I'm thinking, well, this car is kind of unique. 30 00:01:39,980 --> 00:01:40,800 It's old. 31 00:01:40,800 --> 00:01:41,800 They don't make it anymore. 32 00:01:41,800 --> 00:01:43,940 It's the last time they made this type of motor. 33 00:01:44,840 --> 00:01:47,520 So I'm like, yeah, let's start digging into this. 34 00:01:47,520 --> 00:01:50,960 And then, you know, used infrequently, sign me up, right? 35 00:01:52,180 --> 00:01:53,780 This is how I'm going to get in. 36 00:01:53,780 --> 00:01:56,500 But then they had this last little thing at the end. 37 00:01:56,500 --> 00:02:03,860 It's like, every person must have, every person who's of a driving age in your house must also have another car. 38 00:02:04,980 --> 00:02:08,520 I've been working from home for like, ever. 39 00:02:08,680 --> 00:02:14,060 And I drive this car less than 5,000 miles a year, maybe once a week, right? 40 00:02:14,060 --> 00:02:23,920 So not only do I have to have this car that I never drive, but I have to have another car registered to me that I never drive, right? 41 00:02:23,920 --> 00:02:26,200 And motorcycles don't count. 42 00:02:26,320 --> 00:02:29,500 Lots of other fun little things don't count. 43 00:02:29,500 --> 00:02:36,700 You have to have a car that you can drive every single day, regardless of the fact that my wife works from home, I work from home, we take the kids to school. 44 00:02:36,700 --> 00:02:37,660 That's it, right? 45 00:02:37,660 --> 00:02:39,720 So we're like, well, glad. 46 00:02:39,880 --> 00:02:43,800 I'm kind of a hoarder, so I still have the catalytic converter and all that kind of crap. 47 00:02:43,800 --> 00:02:44,720 Put it back in. 48 00:02:45,640 --> 00:03:00,820 A thing about that, if you don't ever have to do emissions testing, and it's never a concern of yours, if you just put the stuff back in there and you go and try and get it tested, there's this thing that happens in the computer that they don't really ever tell you about unless you have to deal with it. 49 00:03:02,420 --> 00:03:05,220 I was like, what the fuck does it mean to not be ready? 50 00:03:05,400 --> 00:03:14,820 And you dig into it, and I pull up the service manual, and sure enough, after you reinstall these parts, and it turns out any time you reset the battery, you're going to have to go through the cycle. 51 00:03:15,040 --> 00:03:22,340 Drive the car up to a certain speed, let it idle for so long, and meanwhile you have to have the air conditioner off and all that stuff. 52 00:03:22,340 --> 00:03:24,240 Did I mention I live in the desert? 53 00:03:25,020 --> 00:03:30,560 Driving a car around for 40 minutes to do this with the air conditioner off is not fun. 54 00:03:30,580 --> 00:03:37,540 But I tried for months doing this thing while in the time that I don't actually drive this car. 55 00:03:38,180 --> 00:03:42,140 And I just can't get rid of these goddamn readiness monitors. 56 00:03:42,140 --> 00:03:44,920 And so I'm like, what the hell? 57 00:03:46,000 --> 00:03:48,360 So let's throw back to DEF CON 26. 58 00:03:48,460 --> 00:03:49,680 Mentioned I was tech Casey. 59 00:03:49,680 --> 00:03:51,340 Anybody heard of the badge pirates here? 60 00:03:52,320 --> 00:03:55,020 So this was their first badge they made. 61 00:03:55,260 --> 00:04:00,340 As part of a tech Casey kind of let's have fun, we're going to be part of badge life, blah, blah, blah. 62 00:04:01,280 --> 00:04:10,680 And as part of it, I made this little add-on to my badge and hooked it into the ECU and it could read the oil temperature and water temperature and stuff. 63 00:04:10,680 --> 00:04:12,600 So I was like, yeah, I've done this before. 64 00:04:12,600 --> 00:04:15,840 At the time it was a UART adapter, no problem. 65 00:04:16,360 --> 00:04:19,980 It's a little high-level, but really how hard can it be? 66 00:04:20,040 --> 00:04:23,580 So I start digging into the protocol. 67 00:04:23,580 --> 00:04:25,780 There's an authentication mechanism in the front. 68 00:04:25,780 --> 00:04:30,000 We're like, okay, I've got to bypass that at some point, right? 69 00:04:30,000 --> 00:04:31,680 There's something that's going to happen. 70 00:04:31,780 --> 00:04:36,500 Anybody who's familiar with Canvas right now is going, oh, yeah, okay, I know where this is going. 71 00:04:36,800 --> 00:04:40,020 A basic data frame. 72 00:04:41,060 --> 00:04:45,320 As I dug in to the next part, by the way, the references for all these are on there. 73 00:04:45,320 --> 00:04:46,000 I'm not going to go there. 74 00:04:46,000 --> 00:04:46,900 We only have 20 minutes. 75 00:04:46,900 --> 00:04:47,920 We're going to keep this moving. 76 00:04:48,660 --> 00:04:52,200 Zero to eight are the possible authentication IDs, okay? 77 00:04:52,200 --> 00:04:57,100 So when I saw that is the moment when I went, you know what, maybe I don't have to do this the right way. 78 00:04:57,100 --> 00:05:01,240 I can just kind of tell the computer to do what I want it to do. 79 00:05:01,840 --> 00:05:08,560 So I did what any sane person would do and put together a thread board that let me hook up a logic analyzer. 80 00:05:09,040 --> 00:05:10,680 That's kind of what it looks like. 81 00:05:10,680 --> 00:05:15,840 You can buy these things off of Amazon for a couple of bucks and you hook them up. 82 00:05:16,660 --> 00:05:33,420 But then you plug in a logic analyzer and anybody who is familiar with Canvas knows this part, but anybody who's just kind of getting into analyzing hardware signals, you'll notice that the signal never goes near zero. 83 00:05:33,420 --> 00:05:40,560 So you have it's plus 2.5 up or down over 1.7 volts, I believe. 84 00:05:41,260 --> 00:05:45,780 And it's inverted together to cancel noise and all that stuff. 85 00:05:45,780 --> 00:05:53,500 So if you want to be able to use like a Salia logic analyzer or any of the cheaper stuff, you need to do a little bit of messing around. 86 00:05:53,500 --> 00:05:57,420 So this is what we call a DC filter or an AC coupling. 87 00:05:57,420 --> 00:06:05,320 And you're essentially just removing that low level DC voltage from the signal so that you can get something like this. 88 00:06:05,560 --> 00:06:12,100 And also I added a cap in there that rounds off the top so you get a nice square wave, but square being relative. 89 00:06:12,940 --> 00:06:14,340 So now we see data, right? 90 00:06:14,340 --> 00:06:17,080 At the top of the screen we can see it's actually starting to parse data. 91 00:06:17,080 --> 00:06:24,360 We're not going to dig into it too much, but at least we can confirm what we read in the document is what we're seeing, right? 92 00:06:24,360 --> 00:06:25,300 It's good. 93 00:06:25,400 --> 00:06:30,200 But what I really wanted to do was, hey, how can I respond to this thing in a programmatic way? 94 00:06:30,560 --> 00:06:33,900 So these things now, they don't even bother to separate them. 95 00:06:35,040 --> 00:06:36,840 I can't fucking see the screen. 96 00:06:38,560 --> 00:06:39,360 Sorry. 97 00:06:40,560 --> 00:06:42,840 You pay six bucks for six of these. 98 00:06:42,840 --> 00:06:43,680 They don't split them up. 99 00:06:43,680 --> 00:06:44,820 You just pop them off or whatever. 100 00:06:44,820 --> 00:06:46,820 But these are your transceivers. 101 00:06:46,820 --> 00:06:49,680 I have ESP32s laying around the house. 102 00:06:49,680 --> 00:06:52,360 Anybody who plays with these kind of things have them, right? 103 00:06:52,380 --> 00:06:56,220 It has a built-in CAN bus controller, but it doesn't have a transceiver. 104 00:06:56,220 --> 00:06:57,300 So you need one of these. 105 00:06:57,300 --> 00:06:58,260 They're a couple of bucks. 106 00:06:58,260 --> 00:07:01,640 You get them off of Amazon, plug it in, and then you can start seeing this kind of stuff. 107 00:07:01,640 --> 00:07:08,080 It's actually acknowledging packets instead of just being able to listen to it. 108 00:07:08,820 --> 00:07:14,100 So as we dig in a little bit deeper, we see there's the identifier field, but just fixed, by the way. 109 00:07:14,100 --> 00:07:17,840 The zero is the ECU, so you just tell it you're the ECU. 110 00:07:17,860 --> 00:07:20,580 You tell it this is the received packet from the scanner. 111 00:07:20,580 --> 00:07:23,280 It's saying, well, there's a link, there's a service, there's a PID. 112 00:07:23,320 --> 00:07:37,000 Turns out there's this handy little thing called Wikipedia that you go in and you look it up, and it tells you exactly what it's looking for, and then you go back to the other page where they have this little decoder tool that says, oh, I can't, you know, 113 00:07:37,000 --> 00:07:41,240 if you receive this message, this is how you want to respond and construct the frame. 114 00:07:41,660 --> 00:07:44,780 So we have a response , right? 115 00:07:44,780 --> 00:07:46,820 So now you can see it's being sent on both. 116 00:07:46,820 --> 00:07:51,280 It's a response on both sides when you send a message. 117 00:07:51,280 --> 00:07:53,980 So echo, I believe is what we call it. 118 00:07:53,980 --> 00:08:01,100 But then we have this error that happens right after we respond to the goddamn thing, and this is what happens. 119 00:08:01,100 --> 00:08:10,240 So this is a little cheap scanner you can buy anywhere that I just use for clearing messages and stuff, but the goal at first was, like, can I even fool this thing? 120 00:08:11,340 --> 00:08:14,580 That screen I looked at for probably two months. 121 00:08:15,360 --> 00:08:18,660 Turns out these kinds of things are pretty complicated. 122 00:08:18,660 --> 00:08:21,220 It's just so many different layers that you're worried about. 123 00:08:25,100 --> 00:08:29,080 Yeah, you just got to make sure you're keeping track of every little piece. 124 00:08:29,260 --> 00:08:37,380 And it didn't help that at this time I had lots of friends on Twitter going, AI coding agents are awesome, you should really look into these, blah, blah, blah. 125 00:08:37,380 --> 00:08:44,620 I'm thinking, great, I'm in this really, really complicated project, now's a great time for me to start exploring AI coding tools. 126 00:08:47,100 --> 00:08:54,400 Malicious ignorance is about the best word or phrase I can come up with to describe that experience. 127 00:08:55,660 --> 00:08:57,920 Something it's really, really good at. 128 00:08:58,140 --> 00:09:05,520 The, like, writing registers, reading back registers, debugging information, all that kind of crap it was really, really great at. 129 00:09:05,520 --> 00:09:15,600 It thinks about hardware like a high school level kid who just read a book on hardware thinks, right? 130 00:09:15,600 --> 00:09:20,500 It had convinced me that I knew nothing about hardware at all. 131 00:09:20,680 --> 00:09:25,580 And the protocols were just garbage and everything that I thought I knew was just terrible. 132 00:09:26,120 --> 00:09:27,480 Don't listen to it, right? 133 00:09:28,140 --> 00:09:31,140 Half of what we're going to do with these things is figure out how to teach them. 134 00:09:31,140 --> 00:09:50,020 But in the process, I ended up actually abandoning the entire design of the original one, digging in a little bit deeper, I learned the canvas controller on this thing is actually kind of a pseudo copy of whatever the SDA 1000 proper one was, and there's some details that they don't expose that you really need to know when you're figuring out all the timing and all that kind of crap. 135 00:09:50,020 --> 00:09:59,720 So I went with an external spy controlled one, which has the secondary benefit of later on, I actually wanted to proxy on the same board without having to, like, chain two ESPs together. 136 00:09:59,720 --> 00:10:02,300 So I'm like, I know I can run multiple spy buses. 137 00:10:02,380 --> 00:10:04,720 I'm sorry if I'm high leveling some of this stuff. 138 00:10:04,960 --> 00:10:06,500 You're just going to have to look it up later. 139 00:10:06,500 --> 00:10:07,700 We only have 20 minutes. 140 00:10:09,620 --> 00:10:12,840 But, yeah, faster, faster, faster. 141 00:10:12,840 --> 00:10:19,120 So we've gone through, we have it working, and sure enough, we have a working response to the scanner. 142 00:10:19,140 --> 00:10:25,920 This is very, very phase one, gone through all this, but within the end of the day, we have this thing reading out exactly what we want. 143 00:10:25,920 --> 00:10:31,040 So these are the same screens that we saw earlier where I was like, god damn, I just can't get it to do what I want. 144 00:10:31,040 --> 00:10:38,780 Now I've proven this concept of, like, okay, we can actually show that we can convince this little crappy scanner to do what we want. 145 00:10:39,000 --> 00:10:47,280 So, you know , I have an emulator working, and I had some working knowledge of the AI thing, and I forked it off and said, hey, turn it into a proxy for me, let's see what happens. 146 00:10:47,280 --> 00:10:48,460 It can't hurt, right? 147 00:10:48,560 --> 00:10:52,040 So it turns out, it actually didn't do a real bad job. 148 00:10:53,180 --> 00:11:06,160 But the ultimate incarnation of this thing is you've got the two breakout boards, one goes to your scanner side, one goes to your ECU side, and installed, it looks like this. 149 00:11:06,160 --> 00:11:13,180 I mean, it looks, if you've ever crawled under the dashboard and looked at your ODB2 plug, you've got a legit-looking thing. 150 00:11:13,180 --> 00:11:14,180 That's part of the thing. 151 00:11:14,600 --> 00:11:30,580 And I should mention, too, in the state where I live, which I haven't said what it is, but the rule is, it doesn't matter, as long as there's no check engine light and they can plug the thing in and it reads what it wants to read and it gets an okay, then it says, 152 00:11:30,580 --> 00:11:31,560 yeah, it's going to work. 153 00:11:32,720 --> 00:11:36,100 So we have a video. 154 00:11:41,510 --> 00:11:45,390 So it starts off just, you've got to start the motor when you get up there. 155 00:11:46,090 --> 00:11:51,710 It gets it running, make sure the, come on, move it a little faster. 156 00:11:53,330 --> 00:11:59,150 So we can see the DAS is running, we have RPMs, it's all working the way you would expect it to. 157 00:11:59,430 --> 00:12:03,230 Then we get our ODB2 tester out. 158 00:12:04,330 --> 00:12:05,970 That one, we plug it in. 159 00:12:05,970 --> 00:12:07,990 This is your factory configuration. 160 00:12:12,150 --> 00:12:20,670 I know it feels like an eternity when I've been talking this fast, but really, it just, so you can see, it run the scan, it can't really see with the lights, huh ? 161 00:12:20,670 --> 00:12:27,070 But it's showing, like, there are two incomplete, or actually more than that in this case, because I had reset the motor. 162 00:12:27,070 --> 00:12:28,990 Running through them, doesn't work. 163 00:12:30,270 --> 00:12:42,550 So I reach under there and just kind of move the, pull that cable out, plug in the adapter and then tuck it back under the dashboard and I'll just skip forward in the video a second. 164 00:12:47,670 --> 00:12:48,770 There we are. 165 00:12:48,990 --> 00:12:56,190 It took about two minutes total to do this, if you can see the time stamp, but I'm impatient, so come on. 166 00:12:56,530 --> 00:12:57,250 Okay, there we are. 167 00:12:57,250 --> 00:13:07,030 We have it plugged in with the photo that you saw before and we can see we have zero codes, monitors, zero incomplete and 11 ready. 168 00:13:07,190 --> 00:13:10,050 So that's, we have it working. 169 00:13:12,630 --> 00:13:19,810 I chose specifically not to include any kind of active testing in this presentation. 170 00:13:19,870 --> 00:13:23,070 You can extrapolate from that what you want. 171 00:13:23,410 --> 00:13:30,530 But you can go to this website as of right after this talk and download the code for this and all the instructions on how to build it. 172 00:13:30,730 --> 00:13:32,030 So have fun.