00:00:00.167,00:00:05.606 So Brent that’s a sexy title but umm I know what you are thinking, I don't have a 17 car 00:00:05.606,00:00:10.611 garage. So what are you doing for me? Alright soo where is my newbs at? I'm a newb where is 00:00:14.047,00:00:19.653 all my newbs? Got any newbs in here, thank you for your honesty uh uh yeah this is gonna help 00:00:19.653,00:00:24.491 you get going into the fun stuff so the painful stuff you don't have to worry about until later 00:00:24.491,00:00:28.128 alright. So I'm hep I'm trying to help out the newbs. Do I have any professionals in here, any 00:00:28.128,00:00:32.766 tuners anyone get asked to drop um a performance engine into a mini van for one of their 00:00:32.766,00:00:36.937 customers, there you go he knows the pain. Im tryna help you get at home at night so your wife 00:00:36.937,00:00:41.808 and kids can see your smiling face. And then also just for the average consumer right. Alright 00:00:41.808,00:00:46.747 who remembers the Volkswagen scandal? Dieselgate anyone remember that? yeah. This is 00:00:46.747,00:00:51.485 going to help you actually like grab data for your car and not have to spend a lot of time 00:00:51.485,00:00:55.122 learning how to look at that data it will just -computer will be like boop- here you go. You 00:00:55.122,00:01:00.560 are going to say ii don't really think my car is doing what they sold me you know like I was 00:01:00.560,00:01:04.731 suppose to get a clean diesel engine and now its doesnt look very clean. So this is what. 00:01:04.731,00:01:09.703 this is what this code is for ok! you know the I got it the 17 cars no one is got 17 cars you 00:01:09.703,00:01:15.676 are doing back to back to back but um thats what im talking about alright. And uh oh all the 00:01:15.676,00:01:22.249 benefit oh and this too. It doesn't just do cars ok. Ill get into it a little bit later but 00:01:22.249,00:01:26.954 umm industrial control systems. Anything where the computer is setting a fixed packet like to 00:01:26.954,00:01:31.191 another computer and there is no metadata this this code is probably going to help you do 00:01:31.191,00:01:34.895 your job or whatever you wanna do, whatever you wanna hack, whatever you wanna play with ok. 00:01:34.895,00:01:39.900 So this not just cars. Alright so disclaimer. Active Duty Military, uh this views are my 00:01:42.102,00:01:48.041 own do not reflect Department of Defense, United States Army, The United States Air force or 00:01:48.041,00:01:52.980 really anyone else other than me so if I say something stupid its on me its not on America 00:01:52.980,00:01:57.985 alright. Alright so this is going to be an oversimplification and again I'm 00:02:00.454,00:02:05.025 a newb so please do not nuke me after this but let's just categorize all the nets under 00:02:05.025,00:02:10.731 two flavors alright. We got vanilla flavor first the general use network and your goal here 00:02:10.731,00:02:14.768 is I want something flexible alright this is the internet for example I just wanna be able to 00:02:14.768,00:02:18.639 add or remove hosts, I wanna be able to add or remove links, I won't have to worry about really 00:02:18.639,00:02:24.311 what the net is doing I just wanna get onto it, I wanna talk to another endpoint. But you 00:02:24.311,00:02:27.981 sacrifice something that nets guarantees. You have no guarantees your message is going 00:02:27.981,00:02:32.619 to get there. You have no guarantee when it's going to get there. So I might have to resend 00:02:32.619,00:02:37.557 or I might have to let them know hey this is my IP, what's your IP and there is a bunch of 00:02:37.557,00:02:41.862 metadata that is going along with this to make sure that the message actually gets there and 00:02:41.862,00:02:45.265 it gets there in a reasonable manner, gets there all in one piece so if you got a bunch of 00:02:45.265,00:02:49.870 metadata at this general use network then you have the exact opposite end of the spectrum 00:02:49.870,00:02:54.941 where I don't want to be flexible, I want guarantees. When I press my brake in my car 00:02:54.941,00:03:00.680 I want that brake to work alright I dont wanna have a resend of me pressing my brake I 00:03:00.680,00:03:04.217 wanna just work I want it to work on time so I need a guarantee that is going to get 00:03:04.217,00:03:07.587 there and a guarantee that is going to get there at a particular time to a control 00:03:07.587,00:03:13.360 network but I'm willing to lose the flexibility on the back end right so your car you are not 00:03:13.360,00:03:17.230 gonna add an extra wheel to your car well maybe who who is going to ask an extra wheel to their 00:03:17.230,00:03:22.269 car maybe some psycho in here I dont know? But uuuu you are not so much worry about that you 00:03:22.269,00:03:25.872 want that guarantee of timeliness and delivery guarantee umm and this code is 00:03:25.872,00:03:32.546 focus specifically on control networks. um what you lose though is if you wanna look a 00:03:32.546,00:03:36.283 the general use network you've got all that juicy megadata that you can be like uhhh alright 00:03:36.283,00:03:39.986 i've got this tag, that tag. you've probably don't even need to look at the actual payload 00:03:39.986,00:03:43.924 itself. You could just look at just the metadata but you don't have any of that on the control 00:03:43.924,00:03:49.463 network. On the car its just bits. Here is 64 bits, here is another 64 bits there is no 00:03:49.463,00:03:54.734 there's not a lot of metadata there. So a lot of people have already done a lot of work way 00:03:54.734,00:04:00.006 smarter than me to help you play with general these general use networks what I'm going to you 00:04:00.006,00:04:04.277 know Fred Stone is going to call a general use network. Voip the inner web, smart phones, 00:04:04.277,00:04:10.417 internet of things um and just in addition to academia you know you got wireshark, you've got 00:04:10.417,00:04:16.556 snork. You've got all this things that will plug into open source or widely used things. 00:04:16.556,00:04:21.962 You've got a bunch of academics with 20 pound brains cracking this problem uh in particular 00:04:21.962,00:04:26.800 this last four guys, I think you can get this on the defcon media server if you want and nerd out 00:04:26.800,00:04:30.737 and check out some of this um this last 4 guys I thought did pretty good work with the 00:04:30.737,00:04:36.143 general use network you know the automated reverse engineer but I wanna play with cars or I wanna 00:04:36.143,00:04:41.982 play with medical devices or I wanna play with planes or a train or something else. There 00:04:41.982,00:04:46.987 is nothing really there to help you until now. Alright! So umm lets see what we can do. I just 00:04:50.123,00:04:55.128 wanna get a bunch of raw data of my control network I wanna click a button then boom it spits out 00:04:55.128,00:04:59.332 some useful actionable information and maybe it might be off by a bit or 2 but its 00:04:59.332,00:05:05.105 going to get me 90% of the way there alright I just want the magic to happen and that's what 00:05:05.105,00:05:08.742 this code is going to do the code on the Github repo and ill talk a little bit more about 00:05:08.742,00:05:14.881 that in a second. Umm but Brentwhat are you doing on the slide? Like what is all this? 00:05:14.881,00:05:18.318 This is like an eye chart right we call this in the military this is an eye chart like why 00:05:18.318,00:05:23.256 are you doing this to us? Like I did not deserve this why? Alright so the cool thing is 00:05:23.256,00:05:27.727 when you get on the Github don't be overwhelmed you only have to worry about the preprocessing 00:05:27.727,00:05:30.997 everything is loosely coupled so you can literally take a different protocol I've already 00:05:30.997,00:05:35.068 done this by the way. You can take a different protocol not change any of the rest of the 00:05:35.068,00:05:39.239 code the other 90% and it will automatically reverse engineer that different protocol for you 00:05:39.239,00:05:43.743 that's why I was saying it's not just cars right. If you can sniff some data off a medical 00:05:43.743,00:05:48.515 device and it fits the assumption that every time some little widget on the medical 00:05:48.515,00:05:53.920 device is talking to another widget and it always sends 2 bytes or 64 bits or something 00:05:53.920,00:06:00.527 like that every single time. This code is probably going to work for you ok? When I do a 00:06:00.527,00:06:04.698 demo a little bit later im actually gonna do 3 different flavors of demo ok. Cause we got 00:06:04.698,00:06:08.168 -we got set up so I couldn't bring my own laptop. So I'm going to do 3 different flavors 00:06:08.168,00:06:13.640 of demo make sure everyone is fully satisfied with this presentation. Umm the demo is 00:06:13.640,00:06:17.577 gonna be doing this first 2 steps alright. Just to show you how quick it can be and it's 00:06:17.577,00:06:23.116 going to be a real time thing if you wanna put this on like arm chip or some sock or something 00:06:23.116,00:06:26.886 like that you could totally do that and i'll be efficient enough really efficient actually 00:06:26.886,00:06:31.424 um and then also how do actually slice and dice that bad boy. Um Im going to specifically show 00:06:31.424,00:06:36.896 you some slides and like walk you thru the mentality of this this step of slicing and dicing 00:06:36.896,00:06:41.968 the data so you can get out the actual information. Um and then there is going to be a bunch of 00:06:41.968,00:06:45.772 um more on the Github again don't be overwhelmed you just need to worry about the first 00:06:45.772,00:06:50.076 part. Alright so let's walk through the logic not the code but the actual logic of um how 00:06:50.076,00:06:55.081 do I slice and dice? So what do I mean by that? Lets say my data is a sentence- this a sentence 00:07:02.489,00:07:08.395 exclamation mark.- I've got 4 words and 1 exclamation point so I can slice and dice that guy 00:07:08.395,00:07:14.701 alright this is called Lexical Analysis to math nerds and stuff like that and then each little 00:07:14.701,00:07:20.206 piece of that is a token and that process is tokenization so I wanna tokenize my data. I 00:07:20.206,00:07:23.877 wanna figure out where the boundaries are the logical boundaries and then I wanna pull 00:07:23.877,00:07:27.580 out each logically distinct piece that the original equipment manufacturer program 00:07:27.580,00:07:32.252 into that chip to transmit over the wire. I can't just take the big chunk all at once, its 00:07:32.252,00:07:37.691 nonsense ,and there is this other process there is Lexical Analysis and then there is 00:07:37.691,00:07:43.396 Semantic Analysis saying let's assume i've been successful at slicing and dicing correctly now 00:07:43.396,00:07:48.034 I want to understand this one piece. What is this? What am I looking at? I want the computer 00:07:48.034,00:07:52.906 to help me figure that out right? if I earlier chart when I show you where they all look 00:07:52.906,00:07:57.944 exactly the same I want that kind of information and the computer can figure that out for 00:07:57.944,00:08:03.516 me and it does now. So lets copy and paste over to 64 bit payloads lets just assume that 00:08:03.516,00:08:09.422 widget A on the car is talking to widget B like the break is talking to uh like a body 00:08:09.422,00:08:14.994 control module or something, its sending 64 bits, 64 bits over and over again so many times 00:08:14.994,00:08:18.665 maybe its synchronized maybe it's not but its just sending it over and over again. The exact 00:08:18.665,00:08:22.936 same format the exact same payload length im watching this happen over time and im 00:08:22.936,00:08:29.042 recording it you could just take all that 64 bits and you could plot it or do whatever you want 00:08:29.042,00:08:33.380 and it's probably gonna be nonsense or you could do the slice and dice operation this 00:08:33.380,00:08:39.185 Lexical Analysis and say alright let's grab bits 0 to 6 and just look at those and interpret 00:08:39.185,00:08:43.356 those as a distinct piece of information and I’m going to take bit 7 to something else. 00:08:43.356,00:08:47.694 I'm gonna keep slicing and dicing. Just like I did with the sentence find the individual 00:08:47.694,00:08:52.966 words and then when I extract that this is an actual example from a real car by the way. Um 00:08:52.966,00:08:57.971 you know if I look at bit 16 to 32 I get the vehicle speed and then if I look at bit 32 to 39 00:09:01.074,00:09:05.178 another copy of the vehicle speed. Actually this isn't the vehicle speed this is the RPM 00:09:05.178,00:09:08.948 per wheel and as you can imagine there is 4 of these signals and there is a little bit of 00:09:08.948,00:09:13.620 metadata at the front. So that's one example of what these process what the output of these 00:09:13.620,00:09:18.591 would look like ok. So how do I actually do the slicing and dicing? How do I do this 00:09:18.591,00:09:22.896 automatically? How do I teach the computer to do it? Alright lets say im looking at the 00:09:22.896,00:09:28.034 observations so ive got this example I'm looking at bit payloads ok everyone following 00:09:28.034,00:09:31.771 me? and then at my first observation 0111000000 and then some time goes by I see the the 00:09:31.771,00:09:36.776 microcontroller send another 10 bit message 1000 so on so forth so what you are seeing is from 00:09:43.850,00:09:48.154 top to bottom time kind of elapsing as im watching observations then from left to 00:09:48.154,00:09:53.326 right im watching the bits ok. So the way that you can get a very good educated guess on how 00:09:53.326,00:09:56.463 do I properly slice and dice? this bad boys is look for the least significant most 00:09:56.463,00:10:00.533 significant bit no matter what they are doing unless they are encrypting it or they 00:10:00.533,00:10:05.405 deliberately write some shenanigans to reverse the bits and then put them back together 00:10:05.405,00:10:11.211 again. You are gonna have a least significant bit and a most significant bit what happens is. 00:10:11.211,00:10:17.016 If I take a copy of these observations and I shift it by 1 observation ok and I Ex-Or Tose 00:10:17.016,00:10:23.556 2 copies what you get is how many times is the bit changing between 0 and 1? How frequently 00:10:23.556,00:10:28.561 is it transitioning ok? And then if I take the sum of each column now resulting Ex-Or then I get a 00:10:31.064,00:10:36.102 very good indication of where is my least and most significant bits embedded within these 00:10:36.102,00:10:42.075 larger payload alright? As you can see 1 2 4 7 and there is a break and there is a locally 00:10:42.075,00:10:47.247 logical piece of information 1 3 7 um in this case you know the right hand 3 bits was counting 00:10:47.247,00:10:52.352 from 1 to 7 or something like that and when you plot it, it becomes even more obvious 00:10:52.352,00:10:56.122 especially to us as humans right. You can see a very definite slope there is a little 00:10:56.122,00:11:00.260 hill and then it stops and there is another hill like oh ok the OEM probably has 2 pieces of 00:11:00.260,00:11:04.831 information and then these payloads that its sending now I can make a pretty good educated 00:11:04.831,00:11:11.704 guess. Alright so how does that process actually work so those of you familiar with like a hill 00:11:11.704,00:11:15.508 climbing algorithm or like a machine learning folks in here you probably have heard of that 00:11:15.508,00:11:19.345 before um you do exactly that like im going to start at the bottom of the hill or the top of 00:11:19.345,00:11:22.215 the hill and just keep going until I find that the least significant bit that is 00:11:22.215,00:11:26.386 transitioning a whole bunch of times and then all of the sudden there will be these sharp drop 00:11:26.386,00:11:30.323 of. That's probably the most significant bit to another piece of information embedded in that 00:11:30.323,00:11:34.594 payload so im just going to cut it -pish- right there im just going to take however many bits 00:11:34.594,00:11:39.065 that is and then I'm gonna put that to the side bit number 1 I'm going to start over again, 00:11:39.065,00:11:45.438 bit number 2 you know, bit position 15 here we go 16 17 18 I got you. And then we are going 00:11:45.438,00:11:50.443 up to bit 32 and we are going to -Pish- make another cut bit number 2 theresust those bits im 00:11:50.443,00:11:54.514 gonna look at those later and what happens is when you see that again these is the real 00:11:54.514,00:12:00.687 world example from a car, I didn't give any heuristics or anything to to the algorithm it 00:12:00.687,00:12:05.692 really is just that simple and easy to teach in many times not always but often times is that 00:12:05.692,00:12:10.930 qui- easy to teach a computer just grab these bits and um slice and dice it that way now 00:12:10.930,00:12:16.402 i've got the information but Brentyou said? Once I slice and dice how do I know what kind of 00:12:16.402,00:12:22.942 information that is Alright, that a true point. Um It would loo- the- one of the folks in 00:12:22.942,00:12:26.679 this auditorium right now listen to the full speech it will literally take me 2 and 1/2 00:12:26.679,00:12:31.117 hours to explain this last part. I don't say that to like show of or anything just a matter of 00:12:31.117,00:12:35.588 fact, I dont wanna put people to sleep. Just go on the Github after this if you are interested 00:12:35.588,00:12:40.893 if you got that hookin you know? and check it out um we've got a document there you know, it's 00:12:40.893,00:12:44.597 very well documented if you want to know more about how to actually identify like these is 00:12:44.597,00:12:48.501 that type information versus that type thats Semantic Analysis but i'll just give you 00:12:48.501,00:12:52.171 one example right, cause I'm going to show you a bunch of examples as part of these demo. 00:12:52.171,00:12:56.476 Um so I just want you to understand what you are seeing. Alright in this case alright you 00:12:56.476,00:13:00.446 got the super micro print so if anyone it's got like eagle eyes you could maybe read that 00:13:00.446,00:13:05.985 probably can't um but what I did is I just threw this however to map the car it looked at I think 00:13:05.985,00:13:10.990 there is probably 120 ids floating around the car all craziness. It grabbed slices 00:13:13.259,00:13:17.363 from different payloads all over the car and said hey that little slice looks like that slice 00:13:17.363,00:13:20.700 which looks like that slice which looks like that slice and what you get at the end of that 00:13:20.700,00:13:26.639 is Oh Hey! um Mr Hacker here is all the things that look here is all the apples, here is all the 00:13:26.639,00:13:31.077 oranges. Here is all the bananas um that I found in this car alright I don't know the full 00:13:31.077,00:13:35.048 name but I can tell that these things all look similar so you don't have to do that the um 00:13:35.048,00:13:40.653 process anymore ok? It will do it for you. And it will by the way this particular sample um I 00:13:40.653,00:13:45.925 was actually able to request J1979 diagnostic information is my Prius um I'm conservationist 00:13:45.925,00:13:50.530 I guess at least if you ask other people in the military they've got the like dual legged 00:13:50.530,00:13:56.069 trucks like the 4 wheels and everything um I ask the guys hey! give me vehicle speed while 00:13:56.069,00:14:01.174 im gathering these data and it turns out this exactly vehicle speed for when I was going um 00:14:01.174,00:14:08.147 thru this driving sample so um I wont get into the details of like how can I claim accuracy 00:14:08.147,00:14:14.087 with this stuff if I don't have any true data but what I found is actually over 90% accurate 00:14:14.087,00:14:19.692 most of time across all 17 vehicles we looked at um so it might be off by a bit or 2 and 00:14:19.692,00:14:24.163 for those of you that have no you know work with this stuff you know being off by a bit is 00:14:24.163,00:14:27.867 kinda of a big deal. But it will definitely get you very very far along the process where you 00:14:27.867,00:14:31.704 could get home at night or you can believe that your OEM sold you the features that they 00:14:31.704,00:14:36.109 thought they sold you or you could be a newb and show of to your friends. Alright so let's 00:14:36.109,00:14:40.046 reverse engineer some stuff so again I’m going to break this deme in sorta 3 different parts 00:14:40.046,00:14:43.382 alright. The first part I'm going to walk through its just going to be the slides because I 00:14:43.382,00:14:48.087 don't have my own computer here I'm going to show you all 17 cars just sorta of the output of 00:14:48.087,00:14:52.592 the semantic analysis slice and dice and the label it says diesel it all look the same and 00:14:52.592,00:14:57.563 im gonna prove to you that I i dint tweak it I didn't tune it to any one car. I just gave it 00:14:57.563,00:15:02.402 certain settings and then I let it go and every single car got something out. The second demo 00:15:02.402,00:15:07.940 im gonna open it up to questions or let people look at it um but honestly it's just like output 00:15:07.940,00:15:13.379 thing like this is how long things are taking and the third demo ill hang out either outside 00:15:13.379,00:15:18.017 the room or over on the side here with my personal computer i've got it right here with this 00:15:18.017,00:15:22.121 code loaded up with some data samples if you just wanna talk about it or you wanna see it 00:15:22.121,00:15:28.895 like actually been run in real time more than happy to do that for you ok? So what you are 00:15:28.895,00:15:35.701 seeing you are going to see 2 like groups of plots, what each group is gonna be a car and 00:15:35.701,00:15:40.206 again the its sliced and diced it did the semantic analysis piece and these all look the 00:15:40.206,00:15:44.744 same then it put them all in one grouping for me I didn't do any work and it's like here you go 00:15:44.744,00:15:49.248 enjoy ok. So on the left it's going to be vehicle on the right it's going to be another vehicle 00:15:49.248,00:15:53.853 and if says cropped to fit it just means it just found a whole bunch of these and I'm tryna 00:15:53.853,00:15:58.624 make it so it's not microprint for you all so I i I cut off a couple of the signals that were 00:15:58.624,00:16:05.131 on there so that way we can sort of see it. Um so on the right hand side um the just so you 00:16:05.131,00:16:09.702 know every single sample here I collected in the same driving scenario so I had people in the 00:16:09.702,00:16:15.975 parking lot and then we um we drove down a small little hill and went for about a 3 and 1/2 00:16:15.975,00:16:20.980 mile drive and kinda of stop lights and a lot of right turns and things like that and then we 00:16:20.980,00:16:24.584 came back to the parking lot and stopped.So you see it kinda goes up and then probably comes to a 00:16:24.584,00:16:29.388 stop and goes up probably comes to a stop and then a lot of times for example this one on 00:16:29.388,00:16:33.626 the left here vehicle 3 if you've ever worked with CAN networks controller Area 00:16:33.626,00:16:38.531 Networks and cars by the times the oms like they put a counter that it sort of keeps track it 00:16:38.531,00:16:43.369 sort of like error checking in this case it grab a bunch of counter from vehicle 3 um 00:16:43.369,00:16:50.309 probably vehicle speed from vehicle 4 here it'll just go thru these, on the bottom here 00:16:50.309,00:16:55.181 of the Github I do have one data sample again from my car, my personal car that you could just 00:16:55.181,00:16:59.952 start jamming right away just download it from GitHub, clone the repo um load up that data 00:16:59.952,00:17:06.425 file and start hacking. Again you could see like the pattern sort of look very similar again 00:17:06.425,00:17:10.963 I had everyone drive very similar. Vehicle 11 it did have a little bit of trouble um I 00:17:10.963,00:17:15.968 think its off by 1a t on the second signal. Um Actually yep this is going around the hill, 00:17:18.905,00:17:24.377 going around the hill alright 17 cars now that is sort of just proof number 1, proof number 2 00:17:24.377,00:17:26.379 I'm gonna load up this video and them um if anyone it's got a question. I think it seems like 00:17:26.379,00:17:28.381 a lot of people are real shy so you could just come up here and ask me if you dont wanna talk in 00:17:28.381,00:17:33.386 front of the group. ok? And then after that I'm more than happy to show people on my computer. 00:17:41.894,00:17:45.898 Thank you very much! [applause from the audience]