00:00:00.033 --> 00:00:03.003 >>Hey guys, thank you for coming to our presentations. It 00:00:03.003 --> 00:00:07.941 is called key logger video mouse or how did we turn our KVM into 00:00:07.941 --> 00:00:14.081 a raging key logging monster. So before we begin meet the team. 00:00:14.081 --> 00:00:19.419 My name is Yaniv Balmas and joining me is Lior Oppenheim 00:00:19.419 --> 00:00:23.891 aka, the mad scientist and we are researchers for check points 00:00:23.891 --> 00:00:29.763 or technologies. So let's drive right into our problem. So our 00:00:29.763 --> 00:00:34.401 problem as with my other computer science problems starts 00:00:34.401 --> 00:00:37.804 with computer so we have computers and we have many 00:00:37.804 --> 00:00:45.646 computers and we have a lot. And the problem is each of these 00:00:45.646 --> 00:00:49.516 computers actually need ASCII board video and mouse set in 00:00:49.516 --> 00:00:53.353 order operate and when we have a lot of these computers then we 00:00:53.353 --> 00:00:57.724 have a lot of keyboards and video boards and mice and this 00:00:57.724 --> 00:01:02.195 creates a lot of mess on your desk so we can't figure which 00:01:02.195 --> 00:01:08.835 monitor go to which computer and the thing is that this is an age 00:01:08.835 --> 00:01:12.806 old problem and was solved with this device called KVM. For 00:01:12.806 --> 00:01:19.112 those that are for some reason not familiar within device. It 00:01:19.112 --> 00:01:24.451 is short for keyboard video and mouse. And what it does is it is 00:01:24.451 --> 00:01:28.422 used to connect the same set of keyboard video and mouse to one 00:01:28.422 --> 00:01:32.259 or more computers. Right so it all works something like this. 00:01:32.259 --> 00:01:36.496 If you have two computers under your desk and they are both 00:01:36.496 --> 00:01:40.400 connected to a KVM device which is connected to a keyboard video 00:01:40.400 --> 00:01:43.637 mouse on your desk and now everything is routed to computer 00:01:43.637 --> 00:01:46.940 number one and everything is cool and you can play your 00:01:46.940 --> 00:01:50.510 favorite video game and suddenly your boss steps in your office 00:01:50.510 --> 00:01:55.682 and you just managed to push the button and boom catastrophe is 00:01:55.682 --> 00:01:59.286 avoided, everything is now routed to computer number two. 00:01:59.286 --> 00:02:05.325 So that is easy and that is how it works so where can we find 00:02:05.325 --> 00:02:09.997 the KVM devices. So we can find them on your desks such as the 00:02:09.997 --> 00:02:14.234 example I just showed you before or we can find them inside your 00:02:14.234 --> 00:02:19.206 server X and that is because they holds something like eight 00:02:19.206 --> 00:02:21.708 servers and it only makes sense to put a KVM in there in order 00:02:21.708 --> 00:02:24.111 avoid having eight sets of keyboard video and mouse. And 00:02:24.111 --> 00:02:27.180 last but not least, we can find KVMs in very secured 00:02:27.180 --> 00:02:31.885 environments and is because in those environments we have 00:02:39.192 --> 00:02:42.262 several networks and some of them are pretty sensitive and 00:02:42.262 --> 00:02:44.731 some of them are just a corporate network connected to a 00:02:44.731 --> 00:02:49.069 internet and for a user than needs to work on some of these 00:02:49.069 --> 00:02:52.305 networks at the same time, it only makes sense to have a KVM 00:02:52.305 --> 00:02:54.307 on his desk. So to sum it up KV Ms every where. In every 00:02:54.307 --> 00:02:56.309 technological environment that you go do you find a lot of 00:02:56.309 --> 00:02:58.311 these just laying around here and there. So let's take a look 00:02:58.311 --> 00:03:00.247 at evolution of KVMs along the years. So it all started off in 00:03:00.247 --> 00:03:02.249 1980s or 90s with something that looks like this and known as AV 00:03:02.249 --> 00:03:08.255 switch and just a electronic box that you connect from the board 00:03:16.496 --> 00:03:22.502 to keyboard video and mouse set and when you switch to B board 00:03:26.940 --> 00:03:29.543 everything is routed to the B board. And that worked really 00:03:29.543 --> 00:03:35.549 fine. That is until technology advanced just a bit and came to 00:03:39.152 --> 00:03:45.459 be USB keyboards. When we have USB keyboards KVMs need to be 00:03:45.459 --> 00:03:51.231 evolved also and they is how we met these modern KVMs. They 00:03:51.231 --> 00:03:56.069 contain some USB stack in order provide like smooth transition 00:03:56.069 --> 00:04:01.241 between the boards and a lot more other features like you 00:04:01.241 --> 00:04:05.912 know DVI outputs HD MI outputs and they support millions of 00:04:05.912 --> 00:04:10.083 keyboards and all that stuff. And the next evolution is when 00:04:10.083 --> 00:04:17.157 we met this stuff called matrix KVMs. They controls thousands of 00:04:17.157 --> 00:04:23.530 computers and use big environments. So obviously, we 00:04:23.530 --> 00:04:29.102 consider KV Ms evolve a lot over the years but the problem is a 00:04:29.102 --> 00:04:33.340 lot of guys still considered those as those same old stupid 00:04:33.340 --> 00:04:38.645 boxes. But obviously you know, they are not those stupid boxes. 00:04:38.645 --> 00:04:43.750 Take a look at some of these KVM features. They have hot keys and 00:04:43.750 --> 00:04:49.422 on screen display menus and web menus inside them so those 00:04:49.422 --> 00:04:56.463 devices run code. They are minicomputers sitting on your 00:04:56.463 --> 00:05:02.202 desk and thinking okay so if the run code then what can we do 00:05:02.202 --> 00:05:07.174 with them. So what the one common thing between all the 00:05:07.174 --> 00:05:12.245 features that I just showed? So the one common thing is all the 00:05:12.245 --> 00:05:17.083 features require the KVM to be and to process key strokes. They 00:05:17.083 --> 00:05:20.854 don't just take the key strokes from the keyboard and pass it on 00:05:20.854 --> 00:05:24.691 the computer. Now they have a Parsitan see where it is and 00:05:24.691 --> 00:05:28.528 maybe that is like a combo that you just pressed and the thing 00:05:28.528 --> 00:05:34.935 is if they process key strokes all we food to do is find a way 00:05:34.935 --> 00:05:40.540 to alter the execution flow just a bit and find some kind of free 00:05:40.540 --> 00:05:45.312 memory space in there and then we can store those key strokes 00:05:45.312 --> 00:05:50.917 over there and we just dump them out and so we achieve the key 00:05:50.917 --> 00:05:55.722 log. That is not a software key loggers because no software is 00:05:55.722 --> 00:06:00.126 running on your computer. It is like running at minus four. I 00:06:00.126 --> 00:06:03.897 lost track of the readings during the past few years. But 00:06:03.897 --> 00:06:08.034 that is not the hardware key logger also because there is not 00:06:08.034 --> 00:06:12.672 a hardware key logger involved in this. You connect a -- KVM to 00:06:12.672 --> 00:06:16.276 your computer. Right? So that is really cool and that was our 00:06:16.276 --> 00:06:23.316 subject. Sorry for that. I think there is (indiscernible) in 00:06:23.316 --> 00:06:30.590 here. And what we did I didn't want to work on my KVM because I 00:06:30.590 --> 00:06:34.294 kind of need it so I went to our help desk department and told 00:06:34.294 --> 00:06:40.100 them, my KVM kind of broke and I need a new one and they said 00:06:40.100 --> 00:06:45.405 okay just grab this one and take it. So I took it and I went to 00:06:45.405 --> 00:06:49.876 my office and opened the box and started unboxing it. So first 00:06:49.876 --> 00:06:56.783 thing I take out is KVM. And then there is some KVM cables 00:06:56.783 --> 00:07:02.522 and one cable that looks like this and manuals and warranties 00:07:02.522 --> 00:07:08.528 and a CD which one was called firmware upgraded utility and 00:07:11.698 --> 00:07:18.171 the other file named (indiscernible) so we were 00:07:18.171 --> 00:07:22.575 thinking okay so this file had like really high levels so it 00:07:22.575 --> 00:07:26.613 was compressed but we could not really decompress it with any 00:07:26.613 --> 00:07:31.951 method we tried so both me and LIOR are advanced guys so we 00:07:31.951 --> 00:07:37.957 this runs on windows then we said we can try and reverse 00:07:39.993 --> 00:07:44.564 engineer this and extract it. So that should be a easy task. All 00:07:44.564 --> 00:07:50.170 know when we tried to analyze this update utility it turned 00:07:50.170 --> 00:07:56.810 out not such a easy task and that is because we kind of 00:07:56.810 --> 00:08:02.849 figured out this utility is used upgrade the entire line of KVMs. 00:08:02.849 --> 00:08:06.119 Contains of thousands of functions and on top of that it 00:08:06.119 --> 00:08:10.724 is like a C plus plus code and really messy thing we didn't 00:08:10.724 --> 00:08:14.861 want to mess around with it so but when we (indiscernible) 00:08:14.861 --> 00:08:19.966 bugger then we saw what we expected to see. I mean, this 00:08:19.966 --> 00:08:25.805 thing reads this ping file and presses it on to decompression 00:08:25.805 --> 00:08:30.410 function and stores output at some kind of space so we went to 00:08:30.410 --> 00:08:34.013 this memory space and looked what was stored in there and 00:08:34.013 --> 00:08:38.418 hoped that we can find our firmware. So this is what we 00:08:38.418 --> 00:08:43.456 found. A blob and looks like this and this is kind of imagine 00:08:43.456 --> 00:08:47.293 representation. So we started looking at some of these 00:08:47.293 --> 00:08:53.600 features. 11 so one of them is that this is 64K long blob and 00:08:53.600 --> 00:09:00.507 the other thing has a low level so that means no longer 00:09:00.507 --> 00:09:06.046 compressed and those are not encrypted and has no strings not 00:09:06.046 --> 00:09:10.650 a single one. That kind of looked a bit strange to us but 00:09:10.650 --> 00:09:17.457 we kept ongoing so we made some frequency analysis and tried to 00:09:17.457 --> 00:09:23.263 compare with other firmwares and nothing came close. Nothing. So 00:09:23.263 --> 00:09:25.532 what we did is use (indiscernible) for those that 00:09:25.532 --> 00:09:29.669 are not familiar that is tool to find signatures of known 00:09:29.669 --> 00:09:34.974 firmwares and really cool to and we use this on this blob and got 00:09:34.974 --> 00:09:39.612 zero results. Nothing at all. Then we were just sitting at 00:09:39.612 --> 00:09:44.384 this blob and saying we don't know what to do with it. So we 00:09:44.384 --> 00:09:49.022 must find another way so that was a complete failure. So at 00:09:49.022 --> 00:09:52.659 this point we had two options and one could be to go back to 00:09:52.659 --> 00:09:57.831 firmware utility and reverse engineering this and but that 00:09:57.831 --> 00:10:01.935 would be a really tedious job. Might take us days or weeks or 00:10:01.935 --> 00:10:05.271 months and we don't really feel like doing it and the other 00:10:05.271 --> 00:10:09.576 option would be to be creative about it and by being creative 00:10:09.576 --> 00:10:17.016 you must understand how the process works. So remember that 00:10:17.016 --> 00:10:21.287 I showed you, that is the serial cable connects to ports on your 00:10:21.287 --> 00:10:25.892 computer and then connects to KVM and you run utility and some 00:10:25.892 --> 00:10:32.532 how it test this blob and test it to the device on the cable. 00:10:32.532 --> 00:10:38.538 So all we need to do is just to download some kind of software 00:10:42.108 --> 00:10:44.110 and then hopefully we can just have to analyze the serial 00:10:44.110 --> 00:10:46.513 protocol and extract the data from it and then don't really 00:10:46.513 --> 00:10:48.581 need to reverse engineer this thing and that is pretty cool 00:10:48.581 --> 00:10:54.854 and that is what we did. So challenge accepted. So we start 00:10:54.854 --> 00:10:58.391 sniffing the serial particle and we're stiffing it, stiffing 00:10:58.391 --> 00:11:02.662 sniffing and that is what we get. What you see is serial 00:11:02.662 --> 00:11:06.966 protocol and messages marked with red are from the KVM 00:11:06.966 --> 00:11:11.004 particle and yellow is to 2KVM. So let's start analyzing this 00:11:11.004 --> 00:11:15.174 thing. So first thing we noticed is that each of these messages 00:11:15.174 --> 00:11:21.180 has some kind of fixed header to it and that has the X volume of 00:11:21.180 --> 00:11:26.352 4655. Fifty-five which is representation of FU. (laughter) 00:11:26.352 --> 00:11:32.959 all right. So we were thinking, is anybody trying to tell us 00:11:32.959 --> 00:11:38.498 something and yes, they are trying to tell us something. 00:11:38.498 --> 00:11:44.003 They are telling us this is firmware upgrade. (laughter) so 00:11:44.003 --> 00:11:50.677 we kept on analyzing this and next thing we notice is this is 00:11:50.677 --> 00:11:55.181 some kind of code. Goes like A0A1A2A3 and most of these is 00:11:55.181 --> 00:11:58.985 composed of A3 messages so this tells us that this part must be 00:11:58.985 --> 00:12:05.558 some kind of handshake and this part must be the date transfer 00:12:05.558 --> 00:12:09.395 and that the part we are interested in. So we can find 00:12:09.395 --> 00:12:14.667 some kind of sequence number in each of these data messages and 00:12:14.667 --> 00:12:21.407 goes like it is goes the 0123 up to end of file and that is cool. 00:12:21.407 --> 00:12:24.277 And now there is only one thing missing because each serial 00:12:24.277 --> 00:12:28.181 protocol need to have some kind of checks to it in order nor 00:12:28.181 --> 00:12:33.519 both sides to validate the data got from side to side and this 00:12:33.519 --> 00:12:40.426 is it. (indiscernible) that is our checks and balance. So we 00:12:40.426 --> 00:12:45.331 would not find anymore problems so we figured out that 00:12:45.331 --> 00:12:49.936 everything is analyzed. So all we have to do now in order to 00:12:49.936 --> 00:12:54.474 get data from it get rid of handshake part and take a look 00:12:54.474 --> 00:12:58.778 at the data part and then again get rid of all the serial 00:12:58.778 --> 00:13:06.419 protocol related bytes and put it together. Guess what it is 00:13:06.419 --> 00:13:10.823 the same old serial blob. All these devices all these firmware 00:13:10.823 --> 00:13:16.162 utility update take this blob and pass it to the device on the 00:13:16.162 --> 00:13:20.967 serial cable. So again, this got us -- everything is happening 00:13:20.967 --> 00:13:23.469 inside the device so next step is only step is we failed, to 00:13:23.469 --> 00:13:29.175 open up the device so that what we did and looks like this under 00:13:29.175 --> 00:13:35.181 the hood. Now our first impression of this we are 00:13:39.419 --> 00:13:43.356 software guys what are we doing looking at something like this. 00:13:43.356 --> 00:13:47.393 This is lot of electronics in there. What can we find out from 00:13:47.393 --> 00:13:51.931 this and we felt depressed and it and went to the bar opposite 00:13:51.931 --> 00:13:57.070 of our office and had a few shots and then you know we said 00:13:57.070 --> 00:14:01.407 we might not be hardware guys but we try and find out what the 00:14:01.407 --> 00:14:05.178 chiefs and maybe they will give us a view about what is going on 00:14:05.178 --> 00:14:11.184 now, is this firmware actually being processed. So we did just 00:14:14.721 --> 00:14:18.791 that. So first thing we noticed is there are two big chiefs over 00:14:18.791 --> 00:14:22.895 there and we know nothing about it. It is the vendor name on 00:14:22.895 --> 00:14:27.300 them and just judging by the amount of pins we think they are 00:14:27.300 --> 00:14:30.303 (indiscernible) but we don't know anything more nana so. So 00:14:30.303 --> 00:14:33.706 they are just big light boxes to us and the other thing is 00:14:33.706 --> 00:14:38.311 (indiscernible) called PLD which is programmable logical device 00:14:38.311 --> 00:14:41.714 and what it is just if you programmer you open up the UI 00:14:41.714 --> 00:14:45.351 and design your own logic severe and burn it into the chip and 00:14:45.351 --> 00:14:50.056 the chip runs the circuit. So we know it is PLD but we have no 00:14:50.056 --> 00:14:53.659 what is logic is running inside it. So you can say that is 00:14:53.659 --> 00:14:58.564 another light box for us. And then we kept ongoing and we 00:14:58.564 --> 00:15:03.803 found something we know. That is memory. 2K we know what it does 00:15:03.803 --> 00:15:08.441 you write stuff to it and read stuff from it and also connected 00:15:08.441 --> 00:15:11.077 to something called (indiscernible) which again, 00:15:11.077 --> 00:15:14.514 know I remember from any University days something about 00:15:14.514 --> 00:15:19.819 flip-flops and but at this point I have no idea what it does. We 00:15:19.819 --> 00:15:24.357 just left with one chip over there which turned out the be 00:15:24.357 --> 00:15:27.760 the most interesting chip of them all. That is 00:15:27.760 --> 00:15:30.263 (indiscernible) processor for those that are not familiar with 00:15:30.263 --> 00:15:35.568 this, that is advance version of 8051 and intelligence based chip 00:15:35.568 --> 00:15:41.841 and actually runs intelligence 8051 assembly which is easy to 00:15:41.841 --> 00:15:46.145 learn and thing is this the really common in the embedded 00:15:46.145 --> 00:15:50.683 world. You can find these chips from anywhere to toasters to 00:15:50.683 --> 00:15:56.222 space shuttles. It's really that versatile. So okay. We now have 00:15:56.222 --> 00:15:58.891 everything mapped and now we need to understand how the 00:15:58.891 --> 00:16:04.297 firmware flows inside the PCP. So we know that it goes into 00:16:04.297 --> 00:16:08.434 through this port and goes somewhere into the device but 00:16:08.434 --> 00:16:12.104 where. If it goes up the 8052 chip but it can go up the basic 00:16:12.104 --> 00:16:18.945 chips or you know maybe some kind of combination or maybe 00:16:18.945 --> 00:16:21.714 chunks of it goes to each chip or maybe it goes to one chip and 00:16:21.714 --> 00:16:25.551 then to other. We don't know. That is a big mystery to us and 00:16:25.551 --> 00:16:32.158 what we did in order solve that mystery is google it up and when 00:16:32.158 --> 00:16:37.663 we did that we can find this PCP which is same KVM as we use only 00:16:37.663 --> 00:16:43.302 this one has eight ports while ours only has four ports. Same 00:16:43.302 --> 00:16:46.606 vendor, same everything. And look at it there is something 00:16:46.606 --> 00:16:50.543 really interesting about this because you see those big black 00:16:50.543 --> 00:16:55.414 boxes I talked and there are two of each. To double the ports and 00:16:55.414 --> 00:17:00.853 two of these chips and the PLD is the same. However, there is 00:17:00.853 --> 00:17:06.025 only one external ram and only 18 --> 052 chip so this is like a 00:17:06.025 --> 00:17:13.399 big moment and we any okay so maybe this 8052 chip is brains 00:17:13.399 --> 00:17:19.338 behind this KVM and maybe this entire blog is just going in 00:17:19.338 --> 00:17:26.546 there. So now all we need to do is understand the 8052 chips 00:17:26.546 --> 00:17:33.786 being upgraded so each of these 8051 or 8052 chips has 00:17:33.786 --> 00:17:37.690 integrated UR port in them and UR again nor those that are not 00:17:37.690 --> 00:17:43.462 familiar is just acronym for universal transmit I think. And 00:17:43.462 --> 00:17:48.167 what is it is generic serial protocol and so now we just need 00:17:48.167 --> 00:17:52.305 to understand which chief pins are responsible for this upgrade 00:17:52.305 --> 00:17:58.844 process and in order do that we can just be able to do the test 00:17:58.844 --> 00:18:03.082 and we saw the UR port the connected to this chip and those 00:18:03.082 --> 00:18:06.419 are (indiscernible) pins that are used for the firmware 00:18:06.419 --> 00:18:12.425 process. 13 so now just a matter of using logic and find it out. 00:18:14.760 --> 00:18:19.865 Challenge accepted. So 30, 45 China mills shipping days later, 00:18:19.865 --> 00:18:23.469 we can finally use logic. We ordered this device a logic 00:18:23.469 --> 00:18:29.108 analyzer and called logic and what it is just does a couple of 00:18:29.108 --> 00:18:33.045 wire was clips and you clip them on the to the IC pins and then 00:18:33.045 --> 00:18:37.283 you see the electronic signals going on it and that is cool so 00:18:37.283 --> 00:18:40.519 what we need to do now is use this logic analyze it and tap 00:18:40.519 --> 00:18:44.724 those pins and just look at the signals going on during the 00:18:44.724 --> 00:18:50.096 firmware update process. So it looks like this. We connected to 00:18:50.096 --> 00:18:54.800 export and other ones just ground so we can differentiate 00:18:54.800 --> 00:19:00.539 ones and zeros and doing that we opened the logic (indiscernible) 00:19:00.539 --> 00:19:05.878 and took a look at that results and that is what we see. We have 00:19:05.878 --> 00:19:09.515 packets going from the UR port and to the UR port and if we 00:19:09.515 --> 00:19:12.518 Zoom out of this picture we can see a pattern. These lines are 00:19:12.518 --> 00:19:18.524 going to UR port and these are going from the UR port. It is 00:19:23.729 --> 00:19:28.367 serial protocol right. So now what we need to do is take all 00:19:28.367 --> 00:19:32.872 these signals and put them in the right order and then we can 00:19:32.872 --> 00:19:36.542 see a serial protocol going into the UR port containing the 00:19:36.542 --> 00:19:43.382 actual firmware right. Does that look familiar? Yes. That is the 00:19:43.382 --> 00:19:48.154 same serial protocol that we just saw before. So what's great 00:19:48.154 --> 00:19:51.724 failure. What can we do now. We did everything now. Now we need 00:19:51.724 --> 00:19:55.961 to open up the chip and we don't like messing with chemicals and 00:19:55.961 --> 00:20:00.099 stuff like that so we at this point thought that is complete 00:20:00.099 --> 00:20:04.837 failure, but then we give it second thought we said, there 00:20:04.837 --> 00:20:10.242 are something now that we know that we didn't know before. I 00:20:10.242 --> 00:20:14.313 mean, before that, this big blob we doing know what it was being 00:20:14.313 --> 00:20:18.317 translated into it was complete mystery and now we kind of 00:20:18.317 --> 00:20:23.022 pretty sure this is being translated into 8051 assembly 00:20:23.022 --> 00:20:29.061 because it goes into the 8052 chip so if that is the case then 00:20:29.061 --> 00:20:33.766 maybe we can some time (indiscernible) ourselves and 00:20:33.766 --> 00:20:38.838 get the firmware. So I'm not a big code breaker but I do know 00:20:38.838 --> 00:20:44.643 one good code breaker his name is Lior and he's a bit mad. But 00:20:44.643 --> 00:20:49.515 that is okay so I went to his office and gave him a promise of 00:20:49.515 --> 00:20:54.320 the vegas ticket and got him to joint the project. So please 00:20:54.320 --> 00:21:02.094 welcome LIOR. (CLAPPING) >> Thank you. So let's do recap of 00:21:02.094 --> 00:21:08.100 what we already know. So again as he said this blob is 00:21:10.870 --> 00:21:14.840 translated into 8051 something. That is our assumption and also 00:21:14.840 --> 00:21:18.344 this translation is happening somewhere inside the 8052 chip. 00:21:18.344 --> 00:21:26.018 So all we need to do is break this and this is not encrypted 00:21:26.018 --> 00:21:29.989 or compressed so sort of (indiscernible) scheme so we 00:21:29.989 --> 00:21:33.826 need the break the (indiscernible). Challenge 00:21:33.826 --> 00:21:39.832 accepted. So this is same blob as before so now let take a look 00:21:39.832 --> 00:21:43.002 at the end of the blob, you see in yellow the blob we have 00:21:43.002 --> 00:21:48.974 (indiscernible) 53 almost to the end of blob and you think well 00:21:48.974 --> 00:21:54.547 this might be like zero (indiscernible) at the end of 00:21:54.547 --> 00:22:01.086 the firmware which we know is coming but for us 8051 was the 00:22:01.086 --> 00:22:05.824 same operation. So all we need to do is take the blob and start 00:22:05.824 --> 00:22:11.463 with 53 and then we get this and maybe this is it or I don't 00:22:11.463 --> 00:22:16.802 know. Let's take this blob and open it. This is what we get. So 00:22:16.802 --> 00:22:22.007 at first it looks like really good. I managed to disassemble 00:22:22.007 --> 00:22:24.810 all the (indiscernible) but if you take a closer look you see 00:22:24.810 --> 00:22:30.816 that something is wrong. You see the last two lines are move A 00:22:33.853 --> 00:22:38.991 coma R6. It is twice in a row. Maybe in 8051 you need to do 00:22:38.991 --> 00:22:41.727 everything twice in order to make sure it is happened. I 00:22:41.727 --> 00:22:46.532 don't know. But you notice something here is wrong. So we 00:22:46.532 --> 00:22:52.538 took another binary and (indiscernible) 8051 and we got 00:22:54.607 --> 00:23:01.981 the same picture. (indiscernible) so we have this 00:23:01.981 --> 00:23:05.417 strong assumption of what is going on here but just to make 00:23:05.417 --> 00:23:09.822 sure we took these picture of the cat and we opened up and 00:23:09.822 --> 00:23:14.026 guess what the same thing all over again. So then we realize 00:23:14.026 --> 00:23:17.763 that if you believe hard enough, everything can be 8051 assembly. 00:23:17.763 --> 00:23:24.536 But doesn't help too much so we are back to your blob. And we 00:23:24.536 --> 00:23:29.375 decided to keep this operation because we thought that it is 00:23:29.375 --> 00:23:35.114 moving in the right direction. (CLAPPING) What is happening 00:23:35.114 --> 00:23:41.120 here? So moving in the right direction but now we can take a 00:23:43.789 --> 00:23:47.493 look at the last eight bytes. They are not the (indiscernible) 00:23:47.493 --> 00:23:53.499 and let's take a closer look on them. So we say what does this 00:23:55.567 --> 00:24:02.808 eight bytes mean? There are some clue left to us (indiscernible) 00:24:02.808 --> 00:24:08.580 we are safe thank you. >> I kid you not. I have somebody else's 00:24:08.580 --> 00:24:13.152 bag. I'm like, the fucking bottle is not in here and in 00:24:13.152 --> 00:24:16.822 fact none of my stuff is in here. So I have a bag for sale. 00:24:16.822 --> 00:24:22.828 (laughter) we will be right back. >> Okay. Try to keep 00:24:28.567 --> 00:24:31.804 going. So is there a clue that someone left us? I don't know. 00:24:31.804 --> 00:24:37.509 But at first we thought this might be some checks and error 00:24:37.509 --> 00:24:41.847 correction so we took these bytes to calculate the checks of 00:24:41.847 --> 00:24:47.953 the blob and also the CRC and some other logarithm and none of 00:24:47.953 --> 00:24:53.726 them were a close match to our byte. So as far as we know it is 00:24:53.726 --> 00:24:58.230 not some sort of error correction. And then we thought 00:24:58.230 --> 00:25:05.003 well, right until now we only analyzed is single version like 00:25:05.003 --> 00:25:07.873 the one that came with -- the single firm versus but a we know 00:25:07.873 --> 00:25:12.444 the website there are many more so we downloaded some of them 00:25:12.444 --> 00:25:17.783 and let me show you this table of the bytes of many different 00:25:17.783 --> 00:25:20.519 versions. And you see that this numbers are not random. Like, 00:25:20.519 --> 00:25:26.525 you see that A1 byte repeating 70 times so not random. So we 00:25:29.728 --> 00:25:36.101 are thinking that this byte some how represents some data but 00:25:36.101 --> 00:25:40.072 again it is opposite so we can see what it is. And then our 00:25:40.072 --> 00:25:46.044 moment came and we decided to take these -L bytes and release 00:25:46.044 --> 00:25:50.282 them next firmware versions as stated by the vendor. And then 00:25:50.282 --> 00:25:57.289 we saw some pattern forming up here. Like you see this byte 00:25:57.289 --> 00:26:01.493 like 99 -- 99 up here is three times in the first row and also 00:26:01.493 --> 00:26:05.464 three appears three times in the corresponding firmware versions 00:26:05.464 --> 00:26:09.768 and number A1 appeared twice in the second row so could be the 00:26:09.768 --> 00:26:14.139 four or one appearing twice but it is the four but why because 00:26:14.139 --> 00:26:17.776 it is consistent throughout different versions. So we did 00:26:17.776 --> 00:26:20.712 some work and found the mapping between every value from the 00:26:20.712 --> 00:26:27.920 eight byte and the corresponding digits and then we like we 00:26:27.920 --> 00:26:32.391 didn't know what to do with it and then we thought like let's 00:26:32.391 --> 00:26:37.796 take this value and also see their presentation. So 00:26:37.796 --> 00:26:43.802 (indiscernible) value and you see here there is this constant 00:26:46.705 --> 00:26:50.809 portion of byte which is like constant and also there bits in 00:26:50.809 --> 00:26:54.146 the middle that keeps changing and not only changing but they 00:26:54.146 --> 00:26:56.715 are incremented. They are following those over the 00:26:56.715 --> 00:27:01.453 counter. The counter in the middle of the bytes is weird so 00:27:01.453 --> 00:27:05.724 we thought maybe we should be like rotate the entire byte 00:27:05.724 --> 00:27:08.427 three positions to the right and the counter will move to the 00:27:08.427 --> 00:27:12.531 right end of the byte so we did that and then we got these 00:27:12.531 --> 00:27:17.169 values. And I guess that most of you will recognize these values 00:27:17.169 --> 00:27:22.641 but for those that don't, those are as key values, they are the 00:27:22.641 --> 00:27:25.811 same -- they have ASCII values that we want. They are mapped to 00:27:25.811 --> 00:27:30.482 the digits that we found earlier. So now we know that 00:27:30.482 --> 00:27:34.286 these are portions and sounds good and do the operation on the 00:27:34.286 --> 00:27:39.858 blob and when you do this you get the blob change and now we 00:27:39.858 --> 00:27:42.461 actually have like string and I don't know if you can see 00:27:42.461 --> 00:27:46.932 through here but there are strings and looks like a basic 00:27:46.932 --> 00:27:51.003 64. But you she looks really good but the sequence of the 00:27:51.003 --> 00:27:57.876 byte is not correct so let's take a closer look on this one. 00:27:57.876 --> 00:28:04.416 So this is 24 byte from the string. Here they are. I will 00:28:04.416 --> 00:28:12.324 try and continue. So it is 24 bytes like string and it is 00:28:12.324 --> 00:28:16.261 divided into eight byte chance and what do I mean by that, some 00:28:16.261 --> 00:28:19.665 of the characters are misplaced but they are only misplaced 00:28:19.665 --> 00:28:23.769 within their own chunks so let me try to explain this better. 00:28:23.769 --> 00:28:27.573 The A, the I and the Q in the first position are in the 00:28:27.573 --> 00:28:32.177 correct position. So just move this down and the GOW should be 00:28:32.177 --> 00:28:36.682 moved to the second position. And the CKS third position 00:28:36.682 --> 00:28:39.117 always in the correct position and from there on, that is it. 00:28:39.117 --> 00:28:44.156 We found (indiscernible) which fixed the sequence of the bytes 00:28:44.156 --> 00:28:50.162 in the strings so let's take these table that we found outand 00:28:54.433 --> 00:29:01.006 operate it of the entire blob and guess what, we managed to 00:29:01.006 --> 00:29:06.878 break the (indiscernible) and got meaningful 8051 assembly. 00:29:06.878 --> 00:29:12.884 (CLAPPING) thank you. >> Guess what, we have a tradition here 00:29:19.124 --> 00:29:24.062 at DEF CON for first time speaker these guys got in it. 00:29:24.062 --> 00:29:26.898 Seems like they are doing well. You guys like this talk? >> 00:29:26.898 --> 00:29:32.904 (CLAPPING) >> All right. To DEF CON, to the new speakers and all 00:29:37.109 --> 00:29:43.115 you knew attendees. (CLAPPING) good job. Wait. Hold on. Yep. 00:29:47.219 --> 00:29:53.225 That is what it is. >> So it is assembly with loops and control 00:29:56.795 --> 00:30:01.867 so we know that now that we break -- we succeeded in 00:30:01.867 --> 00:30:05.170 breaking the (indiscernible) so now let's have some fun. So we 00:30:05.170 --> 00:30:10.642 know how two break the scheme and we can now design our own 00:30:10.642 --> 00:30:14.913 custom firmware and implement our key logger inside it and up 00:30:14.913 --> 00:30:19.351 load to KVM but first we need to (indiscernible) so we need to 00:30:19.351 --> 00:30:21.987 learn some 8051 assembly. So for your convenience we did the 00:30:21.987 --> 00:30:27.993 review. So on the plus side it is very easy to learn language 00:30:31.229 --> 00:30:35.867 and even many students are learning it and has only 40 00:30:35.867 --> 00:30:39.337 instructions on the downside I don't know if it is a compiler 00:30:39.337 --> 00:30:42.441 problem but some functions are not really functioning. You see 00:30:42.441 --> 00:30:46.378 the code jumped to middle of the function and doesn't do all the 00:30:46.378 --> 00:30:51.450 logic it is supposed do and really hard to reverse and those 00:30:51.450 --> 00:30:56.355 there is just a single memory (indiscernible) and the firmware 00:30:56.355 --> 00:31:01.059 keeps a back up and restores the register and causes code mayhem 00:31:01.059 --> 00:31:06.131 and it is hard to reverse, and in the end the register keeps on 00:31:06.131 --> 00:31:09.067 changing and it is happening because of the register banks 00:31:09.067 --> 00:31:12.738 and so it is like regressing between different banks and you 00:31:12.738 --> 00:31:17.309 need to keep the value of the register so in the end we 00:31:17.309 --> 00:31:22.247 decided to give it one and a half stars of the five and we 00:31:22.247 --> 00:31:25.083 appreciate their effort but (indiscernible) much better so 00:31:25.083 --> 00:31:30.021 we will stick with this one. But now let's take a look on the 00:31:30.021 --> 00:31:33.892 actual code so these are taken from the this the visual 00:31:33.892 --> 00:31:36.728 representation of the main function so let's take a look in 00:31:36.728 --> 00:31:40.832 it so this part is responsible for heat sparing. Heat is the 00:31:40.832 --> 00:31:44.169 (indiscernible) and responsible for passing the inputs from the 00:31:44.169 --> 00:31:48.140 keyboard and this is part is responsible for the 00:31:48.140 --> 00:31:50.675 (indiscernible) he is handling. You see -- you can like press 00:31:50.675 --> 00:31:54.679 some keys and it will change the ports and this part on bottom is 00:31:54.679 --> 00:31:57.949 responsible for left control (indiscernible) of the operation 00:31:57.949 --> 00:32:02.387 it is change the light in the keyboard so this part is 00:32:02.387 --> 00:32:06.024 responsible for that. And this is interesting part, this part 00:32:06.024 --> 00:32:09.861 is responsible for the keyboard emulation and why this is so 00:32:09.861 --> 00:32:13.765 interesting at first we thought (indiscernible) the key logger, 00:32:13.765 --> 00:32:19.504 it's pretty like sounds (indiscernible) but now we know 00:32:19.504 --> 00:32:24.509 that KVM is responsible for keyboard and not only read the 00:32:24.509 --> 00:32:29.014 keyboard inputs but type the computer its own key strokes and 00:32:29.014 --> 00:32:33.418 implement some sort of rubber duckie (indiscernible) on each 00:32:33.418 --> 00:32:40.959 and ever port so let me show you scenario where we can use this 00:32:40.959 --> 00:32:46.031 ability, with this malicious KVM. So let's say we have 00:32:46.031 --> 00:32:49.534 internet connected network and also a area connected network 00:32:49.534 --> 00:32:54.806 and say this security experts spends hours in creating secure 00:32:54.806 --> 00:33:00.745 connect ability in the network to prevent any misuse but in the 00:33:05.884 --> 00:33:11.990 end the users that computer. And each of these computers need to 00:33:11.990 --> 00:33:15.093 have a set of keyboards mouse and screen. And the user is 00:33:15.093 --> 00:33:17.729 upset so creates this mess on his desktop and the purchasing 00:33:17.729 --> 00:33:20.832 department and ask for a KVM and they give him one and connect 00:33:20.832 --> 00:33:23.969 KVM to the network and now you only need one set of keyboard 00:33:23.969 --> 00:33:27.472 and mouse. And what would happen if this KVN is infected with our 00:33:27.472 --> 00:33:32.077 malicious firmware. Say this malicious agent can wake up in 00:33:32.077 --> 00:33:35.113 the middle of the night and start typing things to some 00:33:35.113 --> 00:33:39.451 computer and you will say of course this computer is password 00:33:39.451 --> 00:33:43.655 protected but I will ask you, who do you insert your password 00:33:43.655 --> 00:33:48.326 to the computer. Using keyboard which is connected to KVM so we 00:33:48.326 --> 00:33:53.598 know the password. So we can log into the computer and type some 00:33:53.598 --> 00:33:59.871 command which who download into the computer and now we have 00:33:59.871 --> 00:34:03.041 (indiscernible) over this computer and you can reboot your 00:34:03.041 --> 00:34:06.678 computer and you can format it and change it completely and we 00:34:06.678 --> 00:34:10.148 can still effect you every time we want from the KVM. But that 00:34:10.148 --> 00:34:15.854 is not it. Our malware can type itself to the memory space of 00:34:15.854 --> 00:34:21.226 the KVM and from there the KVM can change port to the computer 00:34:21.226 --> 00:34:25.931 and type the malware back and now we have two malware on each 00:34:25.931 --> 00:34:32.003 of networks and using the KVM we can connect these two malwares 00:34:32.003 --> 00:34:35.840 and back to CNC server on the internet. So the CNC server can 00:34:35.840 --> 00:34:41.546 control using the KVM and the malware inside got the computer 00:34:41.546 --> 00:34:46.618 and you see this breaks segregation of course so I want 00:34:46.618 --> 00:34:52.624 to show a quick demonstration of this scenario. >> So what you 00:35:17.148 --> 00:35:19.784 should see on your screen in a second this guy can code break 00:35:19.784 --> 00:35:25.790 but can't connect. Just a second. Can you see it? No. 00:35:46.678 --> 00:35:52.250 Okay. So what you see on the screen that is supersecured 00:35:52.250 --> 00:35:55.153 network computer. The most difficult part of our writing 00:35:55.153 --> 00:35:58.757 this malware KVM is to transfer the file from the internet 00:35:58.757 --> 00:36:02.093 computer to super secured computer so LOIR had the 00:36:02.093 --> 00:36:08.099 computer over there and he will just start our malicious KVM in 00:36:20.278 --> 00:36:26.284 just a second. No hands. So what we're doing now is starting a 00:36:33.058 --> 00:36:39.064 neat trick of creating a certificate of base 64 sting and 00:36:48.406 --> 00:36:52.043 then using the certified to decode it again and make it 00:36:52.043 --> 00:36:55.647 binary. So we're typing the binary file that we want to 00:36:55.647 --> 00:36:59.884 transfer from the computer to the supersecure network and this 00:36:59.884 --> 00:37:06.891 would take a few more seconds. Twenty minutes, we have time for 00:37:06.891 --> 00:37:12.897 that? No. So interesting thing how do we do the up link and the 00:37:15.600 --> 00:37:20.872 thing is we use the keyboard for that. The keyboard 00:37:20.872 --> 00:37:24.075 (indiscernible) is some space in it that we can pass bytes back 00:37:24.075 --> 00:37:27.412 and forth and you know there is more than three like five 00:37:27.412 --> 00:37:31.649 because two of them are Japanese so we have spaces and we can 00:37:31.649 --> 00:37:36.287 transfer data back and forth from the computers with the KVM. 00:37:36.287 --> 00:37:40.658 So that is what you see here. And it feels like it's going to 00:37:40.658 --> 00:37:46.664 end. Just about now. Do you have any jokes? No, ran out of jokes. 00:37:52.604 --> 00:37:58.610 (indiscernible) that's the end of it. And that is it. We 00:38:10.588 --> 00:38:16.594 encrypted the file and our certificate and (indiscernible) 00:38:24.736 --> 00:38:30.742 decode it now we have a binary file and we run it. That's it. 00:38:38.583 --> 00:38:44.589 (CLAPPING) so the KVM can do one more thing if it works. Hey that 00:38:55.466 --> 00:39:01.406 is our presentation. So a lot of you guys are asking you needed 00:39:05.543 --> 00:39:11.549 to have physical access in order do that and the answer is yes. 00:39:14.485 --> 00:39:21.593 Our research our POC used physical access and there are 00:39:21.593 --> 00:39:25.196 two things attack factors that are possible during this 00:39:25.196 --> 00:39:29.133 scenario one of them is give me 30 seconds alone with your KVM 00:39:29.133 --> 00:39:35.073 and it will be hacked and you can attack the supply change and 00:39:35.073 --> 00:39:40.278 we have known some incident where this happens and other 00:39:40.278 --> 00:39:46.284 thing is we use the KVM that didn't have update over internet 00:39:48.686 --> 00:39:54.826 but the same vendor and lots of others have those so this can be 00:39:54.826 --> 00:40:00.598 upgraded using IP and then can be attacked remotely and some of 00:40:00.598 --> 00:40:05.069 these KVM have web menus that let you do the firmware upgrade 00:40:05.069 --> 00:40:09.407 process and they are password protected but you know KVMs are 00:40:09.407 --> 00:40:15.013 not expert proof. Just googling it up we found all of these CVEs 00:40:15.013 --> 00:40:18.149 that are related to KVMs and broke the web menu and let you 00:40:18.149 --> 00:40:21.352 up load your own firmware so these can be done remotely. And 00:40:25.657 --> 00:40:30.094 what can you do? I mean, well first of all know your 00:40:30.094 --> 00:40:33.831 environment. Sometimes you don't really have to connect the KVM 00:40:33.831 --> 00:40:38.503 to the internet computer that is supersecured network so just 00:40:38.503 --> 00:40:42.140 know the vulnerables. The can be done. We just showed you this. 00:40:42.140 --> 00:40:46.878 So if you can avoid it, then please please do. And sometimes 00:40:46.878 --> 00:40:50.315 of course you can't avoid this and when you can't avoid this 00:40:50.315 --> 00:40:54.352 you have this creature called secured KVMs and they are 00:40:54.352 --> 00:40:58.323 military grade KVMs but I know no one that uses them because 00:40:58.323 --> 00:41:02.593 they cost like 10 times more than this here but you know 00:41:02.593 --> 00:41:06.698 sometimes it is money well spent I think you are not convinced of 00:41:06.698 --> 00:41:10.234 that and the last thing is just be innovative. We just sat in 00:41:10.234 --> 00:41:15.173 our office and said what can we do in order do that and we saw 00:41:15.173 --> 00:41:18.810 one presentation here that kind of maybe solved this problem and 00:41:18.810 --> 00:41:23.081 what we did is like install agent on each desktop and it can 00:41:23.081 --> 00:41:27.385 small key logger and just checks stats of key logging so you know 00:41:27.385 --> 00:41:32.323 the thing is we heed the type a lot of key strokes fast and same 00:41:32.323 --> 00:41:37.261 as a lot of over stuff and the stats change and we see the user 00:41:37.261 --> 00:41:40.565 is not using backspaces or the difference between the key 00:41:40.565 --> 00:41:44.869 strokes are small then we know something is going on and all we 00:41:44.869 --> 00:41:49.140 need to do is pop up this message box which will mess up 00:41:49.140 --> 00:41:53.111 the entire process and will make our job a thousand more times 00:41:53.111 --> 00:41:57.081 difficult so not a perfect solution but it is a cool thing 00:41:57.081 --> 00:42:03.020 and you know I guess we can be innovative. And that is it guys. 00:42:06.724 --> 00:42:12.730 Thank you. Any questions? >> (indiscernible) >> That was a 00:42:22.073 --> 00:42:28.079 regular USB keyboard but could work on every keyboard. >> 00:42:38.322 --> 00:42:46.664 (indiscernible) >> So the question was if we use like a 00:42:46.664 --> 00:42:51.369 keyboard smart card would it still work? The answer is yes. 00:42:51.369 --> 00:42:55.706 If you need to log on to computer with a smart card it 00:42:55.706 --> 00:42:59.977 will prevent the attack but if it is password protected we know 00:42:59.977 --> 00:43:10.655 that so we can log in as the user. Anyone else? thank you! 00:43:10.655 --> 00:43:12.657 (CLAPPING)