This is a talk called Understanding Heavy Truck Event Data. With part two. With part two, he's going to talk about something about electronics. I'm a software guy. I never understand anything he says. So what does this talk about? It's about data stored on heavy truck engine control modules, communicating with them, and reverse engineering proprietary diagnostic protocols used by heavy truck ECMs in the context of accident reconstruction. So the outline, background information, you know, what are ECMs, and what is HVEDR data? That's mostly what I deal with on a day-to-day basis. And then I'm going to work through an example of reverse engineering ECM network data. So heavy truck crashes, semi-trucks, big over-the-road trucks haul lots of stuff. They crash into stuff all the time. In 2008. There were 380,000 of these things involved in trucks just that year, or involved in crashes just that year. 4,000 of which were fatal. And 66,000 were injury crashes, including the fatalities. Average cost per crash, according to, I think, NHTSA, is over $148,000. If it's an injury crash, that goes up to $331,000. And if there's a fatality, that goes up to $7,000. Yes, in the U.S. Expensive crashes lead to lawsuits, and lawsuits lead to forensic examination, which gives rise to the field, the profession of accident reconstruction. So the accident reconstructionist's job is to review the data and determine who is at fault. If they're law enforcement, that could lead to criminal charges, charges of negligence. And if they're private and they're working for an insurance company, that could lead to criminal charges, charges of negligence. If they're private and they're working for an insurance company, that can lead to civil claims. So the parties involved are insurance companies, law enforcement, and attorneys. Those are the three people who you always try to avoid in your day-to-day life. Insurance companies, cops, and lawyers. Those are who I have to deal with all the time, so feel bad for me. Scientific reconstruction. TIPIC traditionally uses physical evidence, such as deformation of the vehicle and measuring skid marks on the road. You can do some math with weight of the vehicle, coefficients of friction, and then figure out who is going how fast, and who hit who when. In recent years, you end up with these things called event data recorders. So this, those of you who are sitting close enough can see this. It's a passenger vehicle event data recorder. It's its own dedicated box. Usually there will be somewhere under the dash. People call them black boxes, almost none are black. This is one of my pet peeves. They're all silver. So if you want to call them silver boxes, that's fine, but not black boxes They're typically integrated into an airbag control module and they depending on the model They weren't standardized until just a couple years ago. So it was kind of a crapshoot what you'd get before then And they would record speed before the crash brake usage whether or not the driver was buckled up stuff like that And it's a purpose purpose-built device Which is great for forensics it all this thing does is it wakes up it decides hey Do I need to deploy the airbags if it does then it records what's called a deployment event if it doesn't it recalls what it? records what's called a non deployment event and then it's read by a special tool called the Bosch CBR kit in most cases and That's it for forensics. That's great Heavy vehicle EDRs are a completely different beast. They're not legislated Heavy trucks are not required to have them. I think what happened was The government regulators went to the heavy trucking industry and said hey you should really really include this stuff in your ease in your engine control modules Otherwise, we may be forced to legislate you. This is not a veiled threat It was a veiled threat. So they all began implementing this stuff Began showing up in the early 90s as an add-on but nowadays it's standard in pretty much all of them And it's extracted using maintenance software not actual forensic software like the Bosch CBR kit it's the same stuff that you would use for driver information reporting or Diagnostic maintenance and diagnostics so The data like I said, it's control. It's in the engine control module whose primary focus is controlling injector timing You know all the stuff that an engine computer does to keep the engine running, right? Because the if you if you caught our talk on Friday I think we talked about how data hungry the trucking industry is. They said oh we have these computers and they can store data and We can do we can gather all this data that will help our fleet customers be more efficient in their business So maintenance history they track driver behavior Some ECMs actually have a mechanism where if a driver is really good on fuel economy, it'll raise the vehicle Speed limit for a little bit that's called the driver reward So if you're really good, it'll let you cheat on the speed governor a little bit, which is an interesting interesting Motivational tool It also stores fault codes so mechanical faults, you know If your car is throwing a check engine light you go to down to O'Reilly's and have that cheap little scanner same kind of thing But more full-featured and well, we're interested in crash event data and all of this may be interesting in a forensic context So maintenance data if you can prove if you can support a narrative where the fleet was negligent on maintenance You can go to the fleet and sue them or pursue criminal charges So issues with heavy vehicle ECM forensics the maintenance software is not Great as a forensic tool usually many of them delete evidence Some of them if you forget to uncheck a box it clears all this data on other ones If you click next and then it comes up Do you want to delete this data? Yes or no and yes is right under where your mouse was to click next before so if you're not paying attention stupid stuff like that It's also stored in securely if you This that's a different talk But the cryptography that they use for their secure file format is stuff like a password protected zip file And it's all one password and I have it written down someplace and vehicle impacts Frequently cause data loss imagine that so if you're storing your data in such a way that The thing that you're trying to record causes your software to not read it properly. That is a problem Speaking of data loss, so I'm gonna just kind of run through a case study It's kind of boring if you if you just talk about this stuff in general So I'm gonna go over a specific case where we solve this problem Let's play this video I hate computers Go I I I I I I I Did it seriously just copy over the ScreenShot bool pul � يbear bool pul P conten dią vividão de can leis combatie Ok, I have some still images of the aftermath in a few slides Ok I have some still images of the aftermath in a few slides so we're just going to go off of those imagine that that city bus over Ok, I have some still images of the aftermath in a few slides so we're just going to go off of those imagine that that city bus over there just had a school bus bus crash into it, and the carnage was glorious. I just need you to imagine that for me. So we crashed a bus on purpose. I occasionally moonlight as a crash test engineer, and it was an experiment to verify that the HVEDR data stored on board actually matched what happened in the real world. The plan was crash bus, connect software, download data, so then we have the data, and then we have all the stuff from our accelerometers and GPS and everything, and then we would compare it in Excel and do science. So here are some gratuitous carnage pictures. That is a pretty good delta V right there. That's from the inside of the bus when I was trying to recover some of the equipment. So as you can see, if you were seated on that side of the bus, it would have been road pizza. It would have been pretty bad. So we were going through and trying to extract the data, and we were able to. And this is a picture of us going through. And you can see the sudden decel event, or I'm sorry, this cat calls them quick stop events. So we have the, so good. It recorded a quick stop event. Awesome. So we go to extract it, and it's going through and receiving data. I'm thinking that I'm going to get to go to bed early tonight, which is kind of a rare occurrence on these crash tests. Oh no, it was unable to retrieve snapshot of Mountain Dew. I had to get into it. So surprise, surprise. When buses hit stuff, they break stuff. And power loss during event writing causes data loss. So the way these ECMs work is all of the event data recorder data is stored as a series of frames. And when it detects this speed loss, it's not like a passenger airbag where it has an accelerometer and detects a shot. It has an accelerator and detects a shot. It just detects a sudden drop in wheel speed, which is transmitted over either the J1708 or J1939 bus. And if it's interrupted while it's writing, then you get an incomplete record. But can we get it back? So I'm really sorry. I was assuming I was going to have a projector today, but I don't. This is the logged network traffic, if you can all squint. And so this is over J1708, and it's kind of a degenerate transport protocol that this manufacturer invented. Because I looked at it, and I saw increasing sequence numbers and everything. And I thought, man, that's weird, but that's not how J1587 does transport. Well, this is a thing that they invented. And you can see that there's three messages within each record, and then this byte over here. It increments by one every time. But then, and there's this kind of request-response framework where it says, hey, I want this frame, and then it gives it to it. And then it says, I want this frame, send it. And then here it just says, send it, send it, send it, send it, send it, which is the software going, are you there, guys, hello? After which point, you know, when it gets no response, it just throws everything away. So. So power loss caused only the last few frames to not be extracted. And the OEM software just took its toys and went home. It said, if I can't get the whole thing, I'm not giving you anything. So if we decode the traffic, we had cheat codes because we had GPS and we had a few different IMUs hooked up to this thing. So doing manual analysis of the speed data, we found that we found something. That looked a lot like what our GPS logs showed the vehicle speed was. And it was the J1587 format, one byte, miles per hour times two. And the records in frame appear to follow a PID value format. In this case, the PID was 32. So this is road speed as we decoded it. And then, so how close were we? As you can see, we've. We've plotted on the same axes the actual road speed. We logged it as it was transmitted across the bus live. And then along with the recovered EDR speed. And then we also recorded using GPS road speed and actually using a few different methods, we logged speed. And as you can see, it's basically dead on for all of them. And it tops off at 27. Point five miles an hour. So the takeaway from that is that kind of destruction can easily happen at low speeds. Don't text and drive, please. And the takeaway from all this is we now have a well verified forensic methodology for covering partial ECM data from power loss. Decoding the other PIDs required dumping a proprietary database made by a fly by night operation in Florida several years ago over comm using Python. Which is something I don't want to get into because it caused me to lose a little hair. But at the end of that, we were able to decode all of these records, including the ones that we didn't have cheat codes for. So now we can extract this stuff without the buggy software that we were trying to work around in the first place. And with that, I will hand it over to my electrical engineering friend. So I'm going to talk about some of the background that led to what we were able to do with the stuff Haystack there talked about. So one of the problems we have with doing research with heavy trucks is that they're extremely expensive. In the earlier we showed you that that crash, we were very lucky to have access to. A school bus and a city bus that had been decommissioned and there was a that was a conference for a bunch of accident reconstructionists. So somebody was willing to destroy those. That's pretty rare. So for our day to day research, we had to build a tool. It isn't very common for like a big trucking fleet or someone who owns a truck to just let you have access to their vehicle and potentially do things to it that could destroy it or disable it or cause them. Monetary harm. So we had to build a device. So the device we ended up building was called a truck in a box. And again, sorry for the small picture since there's no projector. But the device here, we essentially. Oh, sorry. I'll go back a little bit. We took all of the electronics from the inside of the engine department in a this is a Navistar Pro Star with a Max Force 13 engine. And. And. And. Put the electronics in this apparatus and hooked up a bunch of sensors to convince the electronics that it was in an actual vehicle and powered it up and turned it on and started doing stuff to it. This was an incredibly tedious process. You can see the this was part of the wiring harness going to the ECM. This was handmade. I think there were something like two or three hundred wires in this apparatus. So the the truck in a box project was originally funded by the. The DARPA cyber fast track program. So thank you to much if you know much is. We we assemble all those components into a box and then we we actually had a semi functional vehicle that we could test on the bench and we could we could do things to it that you wouldn't want to do to a real vehicle that could potentially destroy it at almost no cost. So to recreate all of the things inside the vehicle, we had to create the J. Nineteen thirty nine network, which is a basic. Can bus, which is not complicated. Lots of people have talked about that. The older legacy J. Seventeen eight bus and we had to kind of roll our own electronics for that. And we talked about that in our talk on Friday. There's some stuff on GitHub. If you were interested, we had to hook up and simulate passive sensors, which were just resistors and potentiometers and things like that so that we could set the oil pressure to a value where the ECM didn't think it was having issues. And then we had to simulate some more active signals. I'll talk about that. But more in a minute, some of the manufacturers publish voltage values for some of these sensors, so we were able to simulate those pretty simply by just reading the manual and hooking up the resistor values and some of them we actually had to reverse engineer. So in the first truck in the box, we had the main control module, the instrument cluster, and then rather than actually install these two other modules, the body control and the brake controller, we ended up recording traffic from a real truck and just. Just playing that traffic back at the other two ECU so that they thought it was in the in the box. It turns out that their functionality is simple enough when the key on the ignition is off that you don't really need to do anything other than broadcast a few can messages. We used a thing called the National Instrument C Rio to broadcast all of those simulated traffic messages. We also use that to simulate some of the more complicated analog sensors. It'll talk about in a second. And again, the passive sensors were done with potentiometers and resistors. So these active sensors, there's a bunch of sensors on the ECMs that don't work like a resistor. You have to they change over time. So they're like a pulse width modulation or like a sine wave. And the ECM does pulse counting to figure out what what's going on. So we've got two sensors that the ECM was particularly frustrated that it could not see when we hooked up to it. And it kind of refused to do anything until we solve those problems. One of them. It was the accelerator pedal with no accelerator pedal, it wouldn't do anything, even even though it's like a resting truck is just sitting there, the accelerator pedal is sending a position as long as the power of the truck is on. So that was a PWM signal. We hooked up a microcontroller and solve that one in a couple hours. The more complicated one was the vehicle speed sensor. This is the sensor that actually is on the mechanics of the truck that helps it determine how fast it's going down the road. So again, apologies for the small picture because the no projector. But this is the laser pointer is not going to work in the middle here is a toothed ring. That's the vehicle speed sensors, tone ring and then off to the left is a little little black nubs looking thing that's actually a magnetic pickup and it can detect the changing ridges in the rain. So we bought the tone ring, we hooked it up and it was kind of complicated because you have to spin this thing pretty fast to get it working. So we rigged up a an adapter that we cut out using some some prototyping equipment and hooked up a remote control and since this is something spinning very fast using some welds not by somebody who knows how to weld, we hid behind something metal after we spun it up and eventually figured out that was safe and it wasn't going to fly apart, we hope. So there's a picture of it spinning in a vice hooked up to the or with holding the sensor near it and we ended up getting this signal on a oscilloscope and it's just an AC signal at about a kilohertz and the frequency varies depending on how fast the vehicle is moving. The unfortunate part for this is that the the signal can reach up to 100 volts peak to peak. So basic like a microcontroller can't do that. So we had to use the National Instruments CREO to generate a a differentials not differential rail to rail signal. So we spun it up. We got it up to 3000 RPMs. I believe the final vehicle speed was something like 85. And we fed that into an ECM and magic the ECM converted the analog signal into a canned message on the network. So it actually thought it was moving and it passed the sense that message along to the instrument cluster and it actually started counting up miles. So it thought it was going down the road, even though the key wasn't off and there's actually no engine. It was kind of fantastic. Eventually, we ended up building a a more safe apparatus. with this enclosure around it in case the thing ever decided to fly apart because metal things spinning at 3,000 RPM is like to fail. So we built this apparatus that was much more reliable, and we were able to use it for several years. And then here's a picture of an instrument cluster we rigged up, and we're feeding the ECM the signal, and then the ECM is broadcasting the CAN traffic, and the instrument cluster is receiving it. So that's nice, but what's that good for? Well, that's not particularly useful for security analysis, but we can do some reverse engineering on the ECM to figure out how it stores some of the data. So as James was talking about earlier, these devices store event records for when you slam on the brakes or something bad happens. So that gets stored in flash memory. So we can use our fake vehicle speed sensor to put in a pattern that we know what it looks like, run the ECM through that, that simulated driving pattern, and then slam on the simulated brakes, and the vehicle will record that as a crash or hard brake event. And then we can go fishing around in the flash memory for that pattern to see how it stores that data. Now, that sounds simple, but it's terribly complicated. The first challenge is these ECMs are incredibly rugged. So in cars, ECMs are just like a little thin, metal can, and maybe the circuit board inside has some simple coating over the top of it. But with the truck ECMs, these things are like cast aluminum. A lot of times they're epoxied into the case. And the whole point of that is they have to go for millions of miles and endure road grime, oil, all kinds of stuff that can get all over them. And so here's a picture of the inside of an ECM. This is the inside after we opened it up of one we found. And you can see the little patch, if you're close enough, where we had started to clean away so we could get to the flash. It was just disgusting. And we don't even know what this is. It could be oil, it could be road grime, it could be anything. But it was covered, even on the inside. And there's a gasket seal around this ECM. This was an older one that was pretty simple to open. All we had to do was take out some screws and pop off a rubber seal. But that was probably the only time we ever encountered that simplicity. Most of the ECMs we had to mill apart. So you can't see it here. But this is a... This is an ECM where we are milling the connector housing off the top of it so that it will release the circuit board so that we can get to the components that are hidden from us. So once we spent a few months disassembling all these ECMs, breaking several of them at, you know, a couple thousand dollars a pop, we had to clean the boards up. We had to get road grime or whatever off of them if they were surplus. Then we had to get the conformal coating, which was part of the, you know, the protection. Not protection from me, protection from road grime and such. We had to get the board out of the way. We had to take that off, and some of that requires different caustic chemicals depending on the material they used for conformal coating. It could be acrylic. It could be an epoxy. Some of them we couldn't figure out, and just the solution was to leave it sitting in a chemical bath for a couple of days and eventually it flaked off. Sometimes, so did some of the components. So we eventually, we get a bare circuit board. We use a hydro rework station to get the chips off of the board. And then we used a universal chip reader to get the data, off the chip. These are just a generic device you can buy from a company like Dataman or Zeltek. They have a socket for different ICs, and if you're lucky, they make one for the chip you've got, and then they've got an algorithm for extracting it. So we didn't have to develop the algorithm for removing the data from the chip. So there's a picture of one of the flash chips that we got out. This one was clean beforehand, and this still has the conformal coating on it, but they're relatively simple devices once you get them off the board. So here, again, sorry for the small size. You can see some raw hex data, and then that's the engine serial number highlighted. So we've actually got access to some of the internal data. And then here we found the hard break event. This is the record of actually spinning up the vehicle speed sensor and then stopping it suddenly and it reporting, oh, hey, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I went through a hard breaker crash event. So we were able to extract that data from the chip. So even if the ECM is in pieces, as long as that chip isn't cracked in half, we can get to it. So the conclusions, reverse engineering these ECMs, it's not impossible. It's a lot of work, but we can go from the analog input data all the way down to the internal hex storage stuff on the flash chips. We can simulate things that you could never do to a real vehicle. like crash it into a wall because I mean that would be one expensive and no one wants to buy a truck just to crash it into a wall except you know NHTSA. So we were able to do that in the lab and then reverse engineer all the stuff. For future work we're looking at tearing open some of these newer ECMs. We were very lucky that most of the older ones had a separate flash storage chip. Some of the newer ones they integrate the flash storage into the same package or on the same die and that makes it a lot harder. I can't just pull it out and stick it in a reader. We're looking at doing ECU analysis for some of the other units like the brakes and the telematics units. So we'll hope to be presenting about that in the future. Thank you very much for your time. We've got plenty of time for questions if anyone has any. Again sorry for the lack of projector. So if you want to come up and see any of the pictures feel free. Yeah, we gave a talk at the main conference on truck hacking and we'll put it up on the GitHub. I think that's truckhacking.github.io. Give us like a couple of days to get home from the conference and put those up. But we'll put them up there. Truck hacking, excuse me. Yeah, github.io. You want to say anything? Thanks everybody.