Okay, so yeah, thanks for coming out. Can everybody hear me okay? Alright, so yeah, let's get right into it. Okay, so yeah, I'm Ed Lezik. I work on the advanced security research team at Trim Micro. It's a pretty awesome gig because I get to do offensive research all day. Basically, find ways to break things and then build cool exploit demos around it. And of course, you know, do the responsible thing and disclose all the vulnerabilities I find to the zero-day initiative. And we work with the vendors to get all the issues fixed. Since I've been working there, I've found over 40 vulnerabilities in different things, mostly IoT stuff. Hold on, hold on, please, please, please. But yeah, I also do like to speak at conferences. This is actually my fourth time speaking at DEF CON. For some reason, they keep... They keep letting me come back. I'm not sure why. But yeah, I've spoken at Recon, Ruxcon, Torcon, stuff like that. Okay, so when I started this project, I didn't even know what Crestron was. A co-worker of mine actually had a couple of old Crestron devices and wanted me to take a look at them. And, you know, I do love to take requests, so I said sure. So I thought, like, since I had no idea who they were... There are probably some other people out there that don't know what they are and what they can do either. So I figured it would be good to do, like, a little intro type thing. So basically, Crestron devices are device controllers. They're fully programmable and customizable. Their bread and butter is kind of audio-video. That's what they're known for, is like an audio-video distribution and control type setup. But they're also doing, like, you know, the fancy things where you, like... Go into a room and there's, like, a touch panel on the wall. And you, like, click a button and it'll open up the shades and stuff like that. And they're also getting into, like, building management systems. They've got the capability to type HACnet into your Crestron controllers. I've also seen them used in access control and security settings. You know, like a touch panel on a door. You click the button and it'll... Pop you into somebody who can let you in kind of thing. Anyways, like I said, they're fully programmable and customizable. They've got basically any way you could possibly want to interact with the device. So you can do infrared, serial, TCIE, of course. You can even do, like, straight relay control, MIDI control. Crestnet is kind of their own little thing. So basically what you do is you write a program. In what's called SYMBOL, which is their little programming language. And you basically use that to write actions to perform on your devices. But you can also write UIs, stuff like that. The main thing, though, is that programming can be very complex. And most people, when they're having Crestron installed in their offices, will kind of farm that out to a third party. Programmer, installer. That's going to be important to know later on. So, yeah, the two... First off, the main way that you interact as a programmer with the Crestron device is through what's called the CTP console, the Crestron Terminal Protocol. And that's basically the bulk of what this talk is about. And then there's also the CIP. That's kind of how Crestron devices talk to each other. And it's like a binary protocol. So as far as where you can find Crestron devices, basically everywhere. I see them a lot in universities, but also in fancy office environments. So, you know, our Trem Micro office actually has some Crestron devices in our office. To make sure we're secure, reachable from the other networks. I know that. But, yeah, also, like, sports arenas, like the big Jumbotron and stuff like that could be a Crestron install. Airports have got a funny little thing to say about that later. Lots of hotels are putting these in their guest rooms to do fancy things, like I was saying with the shades and controlling the TV and stuff like that. And then, of course, rich people's houses. So this is a screenshot. This is a screenshot of a Crestron site where they list some of their major enterprise customers. You can see it's all over the place, like ExxonMobil, Amazon, Twitter, Coca-Cola, Raytheon. So really, like, you know, they've got both of the Cisco's, both food and networking Cisco's. And they are not shot. They're not shy about their partnerships with Microsoft. They actually like to point that out quite often. So, basically, Crestron is Microsoft's exclusive partner to manage all AVM and AVM resources worldwide. So, basically, I read that as they are in every Microsoft campus across the world. And, you know, they're also partnering more and more. And just like last week or the week before, Crestron won the 2018 Microsoft Global IoT Partner of the Year Award. So they, you know, they like to talk about that. But they also have some other, like, case studies and stuff on their website. So I grabbed a couple of my favorites off of there. So here's the Massachusetts Bay Transit Authority. They use Crestron devices when they're controlling and communicating with their train lines and stuff. The Chicago Police Department. I don't know if you can see this. I don't know if you can see it in the picture. But there's, like, a little touch screen on every desk. That's a Crestron device. And then this is probably my favorite. The Virginia State Senate. So, like, all of those are Crestron touch screens. And they say, like, yay, nay. Like, that's how you vote. It's like clicking on the Crestron thing. I like this especially because in the case study, they were, like, trying to do, like, the security. Like, you want to make sure your voting angle, like, you want to make sure your votes are secure, blah, blah, blah. Use Crestron. And so since we're in Vegas, this is a screenshot from a hospitality showcase brochure that Crestron has that basically lists all of the properties on the strip that use Crestron, including Caesars Palace, Aria of Dara, all the MGM grids. They actually have a partnership with the MGM brand. So, yeah, there you go. There's that. Okay, so that was deployment as far as products go. Kind of their two main flagship lines are the 3-series controllers, which I've got one. I've got an MC3 right there. And then they've got touch screens, which are also very popular. Again, I've got a TSW716 right there. Those touch screens are being deployed in, like, a one-in-every-room type deployment. So you'll see these in, like, every conference room in an office kind of thing. But they don't just do that. They do, like, a lot of different things. I could spend an entire career looking at just Crestron things. So platform-wise, 2D5. They've got their Windows platform, which is mostly Windows CE. But I've seen mentions of other versions of Windows. I haven't come across them. But apparently they're out there. And then the touch screens are actually Android tablets. And they've also got their video processors and digital media streamers that they use Linux. So basically, if something... Everything I talk about today is specific to the Windows side or the Android side, I will try my best to point it out. I have kind of a small sample set. So some of them are, like, I don't know if this is specific to Windows, but whatever. Okay, and just a quick little note about the firmware images on them. So the MC3's firmware was basically a zip archive of WinC ROM images. You should be able to emulate it, but I haven't gotten that working yet. I used the dump ROM tool to dump the file system out of the OS image so that I could look at it. There's the file types of the binaries in there. Also interesting to note that in the firmware, they actually still have, like, the Windows CE debugging tools. It lets you connect, like, Visual Studio to a Windows CE device to debug it and stuff. It's just kind of... It's kind of interesting to see those still in there. And then for the TSW, again, it was a zip archive of Android system images. So it had everything you would need to run a full Android system inside the firmware image. The system image was an EXT4 file system, so I just mounted it and got access to the file system that way. There's the file types, 32-bit ARM. And I did most of my actual in-depth reversing on this platform because I'm more familiar with that than I am with Windows CE. The binaries, I could get them to disassemble cleaner. So I just spent most of my time there. I used the Windows platform to kind of, like, you know, verify some things and then find some other, like, simple things like hidden commands and stuff. Okay, so we know what they are. Now we need to be able to find them. One of the first things I always look for when I'm starting a new IoT project is a discovery packet. And Crestron did not disappoint. They have this magic packet. I think that might be the CIP protocol. I haven't gone into, like, what the bytes signify or anything. Because I didn't really need to. It wasn't important for my purposes. But it would be something to look at in the future. So, yeah, you send this packet to 41794 broadcast. You're going to also do a unicast, which will be important for my next slide. But the response you get back from all the Crestron devices contains their host name, the model, the firmware version, and the build date. So, you can add it to show again. So, now you can look for Crestron devices that are connected directly to the Internet. Usually, there's around 20,000 to 23,000 of these directly connected. The results of models show that it was, like, the two most deployed devices that were connected directly to the Internet were an even split between a CP3 and an MC3. And for those eagle-eyed observers in the audience, that's actually the Las Vegas airport here. They have a Crestron device connected directly to the Internet running at the airport. Okay, so, all that said, what is Crestron? Well, there are a lot of different things running different programs on different platforms in different environments. But I did find a couple of universal truths. And this is where we get into the good stuff. So, universal truth number one. Unauthenticated admin access to the CTP console by default. Okay, so, the CTP console, I mentioned it earlier, but it's basically a telnet console connected or listening on port 41795. And it gives you a lot of built-in commands that you can run to control different aspects of the controller. It's got a sandbox file system. So, just limited access. And you can, like, upload and download files within that sandbox. Auth, they actually have some really good authentication mechanisms. You know, they've got different access levels. And active directory tie-ins. And encryption. But it's all off by default. And nobody, you know, nobody turns it on. So, like I mentioned earlier, you kind of, like, the complexity of these systems is so great that you kind of have to rely on a security-conscious programmer to know that they need to enable authentication. And they end up, like, concentrating more on authentication. They're focused more on getting all of the moving pieces working together than they do, like, working together and also having to enable security and stuff like that. It's just another headache that it just doesn't happen. And on top of that, it's not exactly a one-step process either to get authentication enabled. So, it just never gets turned on. So, when you connect to the CTP console, you get, like, a little header that tells you, like, what device you're connected to. And if you run it, who am I? An anonymous user and administrator. Okay, so once you get in, basically the standard things, I mean, they give you a lot of commands. I'll show you in the demo, but a lot of commands are available by default. But some of the basic things you can do is change, like, bring up different services. Like, they've got a website. They've got a server on there. SSH, Telnet, FTP. The Android tablets actually have a SIF server running on them to do that intercom thing at the door that I was mentioning. You can also get access to all of the network info, like the IP address and the MAC address, which is also going to be important in a minute. And then you can also do arbitrary file upload within that sandbox using the FGF file and FPUT file for HTTP or FTP file transfers. And then they also have Xmodem available if you're old school. And then you can also do firmware updates and program updates. If you made a program that takes in commands, you can send that program commands through the CTP console, and you can just mess with that. You can mess with people by sending different things to the on-screen display, like messages, and you can play audio with video files and whatever. Have fun with people. So that was fine. But I knew that typing help all and seeing the list of commands, that that probably wasn't all of the commands that are on the thing. So I started pulling apart the binaries for those services and I ended up finding a bunch of hidden commands that are completely undocumented that you also have access to. So you can see all of the running processes. This is outside of the sandbox. All of these binaries are running outside of the sandbox. You can also view and modify all of the stored SSL certificates on the devices, which could come in handy for certain things. This one was just kind of funny. Dr. Watson is on the Windows CE platform, so it could help you with debugging crashes. This one I thought was really cool. You can actually directly talk to the chips on the board using I2C. So you've got your WEProm, your video decoder and stuff. I thought that was cool. I've only seen that on Windows CE, and actually I think I've only tried that on my MC3. So I don't know if that's a widely used command or not, but it's there. The real fun stuff that you can do, though, is on the Android platform. So you've got this browser open and browser close, where you can open up the Chrome browser and direct it to whatever website you want. You can also send key presses and touches, to the UI of the Android device, so essentially full control remotely of the Android tablet. And then you can also record audio from the microphone remotely. By just running this command, you give it the name of a file and the length of time you want to record, and it will dump audio from the microphone to a file that you can download via the FTP on the device. You can also control mic volume and stuff like that, so pretty awesome. Okay, let's get into our first demo. So I think my MC3 is starting to die on me, so I have to begin to wake it up before I can use it. There we go. Okay, so this is my scanner. It basically sends out the magic probe to the broadcast and then parses all of the return values I get. And then for each IP address that's sending in a response, I'll open up the... or I'll attempt to open up a connection on their CTP console and run the WHOAMI so that I can enumerate what user I am. So running that... Oh, I love you. Okay. So running that, you can see I've got 192.168.1.3. This is the MC3. There's the firmware that it's running, the build date, and you can see open CTP console running as an administrator. And then on 192.168.1.2, that's a TSW, again, firmware, and the CTP console is open, but you'll notice it says, oh, no. And if you look at the binary that handles this, you can see it's doing, like, one check for one value, and if that check returns false, then it defaults to unknown. So I guess that just doesn't work on the Android Linux platform. I'm honestly not really sure about that. So let's try connecting to the MC3. Anybody see that? Down at the bottom of the screen. Should I try that again? Hang on. There we go. Is that better? Can everybody read that okay? So basically, if you type help all, you can see, like, they give you a huge amount of commands. You can run, like, a lot of commands. And one that I'm going to run, I don't know if I even mentioned this one, but... So, yeah, ipconfig, you can get, like, the MAC address remotely, even if you're not on the same subnet as the device, which is pretty cool. Okay. I don't know who's... Who am I? So I know I'm a administrator. So let's connect to the TSW. So, again, huge amounts of commands available. You can see there's a lot of SIP stuff. On this one, you have access to media stuff. So kind of cool. If I do, like, browser open, and you'll see, like, the Chrome browser pop up on there, I think. And I can do, like, you know, browser close to close it. So kind of cool. If I do, like, DIR, you can see this is not the full file system. But this is all you have access to. So, you know, kind of cool. Whatever. But I'm a very greedy person. So you have a significant amount of control over these devices that they just give to you out of the box. But I wanted more. So I started looking for ways that I could escape out of the CTP sandbox and get full control over the OS. So I was looking around at the different CTP commands, and I found something interesting when I came to the sudo command. And apparently I wasn't the only one who found this either, which I'll mention in a minute. But, yeah, so... So, yeah, something interesting in the sudo command, where you can see there's, like, a cr-eng-superuser, cr-superuser, and then this binary SUPWE generator thing that they're calling, which leads me to universal truth number two, secret engineer backdoor accounts. So, yeah, the two accounts, cr-superuser and cr-eng-superuser, I found out, like, this week, that these were also simultaneously submitted by Justin with Security Compass, or Jackson with Security Compass. Like, I seriously had a lot of vulnerability advisory collisions on this. Hardly ever happens to me. And these were all, like, all of us submitted these within weeks of each other. It was really super coincidental and crazy. But, yeah, shout out. So these backdoor accounts are present in all their current products that implement the sudo command, I believe. Again, my sample set is a little limited, but I think the way they work is they've got unique passwords for every device, which is like a 16-character, alphanumeric, randomly generated password. But it's actually algorithmically generated, based on the MAC address of the device, which I already showed you we can get through the CTP console. So that would have been... Okay, this is probably the only time you'll ever hear me say they should have hardcoded the passwords in the firmware. Because if they had found some way to hardcode the password and just burned it into the firmware, if it was unique for a device, that would have been fine. Or if they generated it based on something I couldn't get, remotely, also fine. But instead, based on something I have access to remotely through the CTP console, and they included the generator algorithm in the firmware. So I was able to reverse engineer the generation algorithm. So stick with me here. It's complicated. So basically you start out with a SHA-1 digest. You populate it with the MAC address. And a static string. There's a different static string for CR Superuser and for CR ENG Superuser. So depending on which one you're trying to use, you have to use the right static string. So you take that SHA-1 digest, and you use that as the key for an RC4 cipher with no ID. And then you use that RC4 cipher to encrypt a second static string. And then the resulting encrypted string, you go through each character of that, and it modules it with 62, which is the length of their character set. And then you use the result as an index to pick a character out of their character set. And then you end up with a 16 character alphanumeric password for your Superuser for that device. And if you're super lazy, I also implemented it as a Ruby script, or a Ruby function. So there you go. You can enjoy that whenever my slides get released. Okay, so what can you do with the Engineer Backdoor accounts? So the CR ENG Superuser enables even more hidden commands. So on the Windows CE side, you can actually do console debug commands, and it'll list out all of the commands, even the undocumented ones. So that's pretty handy to have. Also on the Windows CE platform, they give you access to regedit, so you can edit the registry of the device. And they give you a launch command, which actually lets you execute any executable on the device, even outside of the sandbox. Then on the Android side, they've got this telnetort command that gives you options on or off, and that lets you turn telnet on or off. But when you do that as the CR ENG Superuser, they give you the third option, which is telnet debug. So when you do telnet port debug, it actually opens up a root shell on the device that you can connect to outside of the sandbox. And as far as CR Superuser, I actually haven't found a use for that yet. Okay, so let's go for some more demos. Everyone still with me? All right. What the hell? Okay. So what I do with the AMC3, you can see here's the generating the password based on the MAC address, all that stuff. So I connect to the CTP port on the AMC3. I run ESTAT, which is a command that also gives you a MAC address I parse that out, send it, and generate the password for the engineering user. And then I basically use the regedit command to disable authentication for telnet. And then I launch telnet0. And that gave me a telnet shell outside of the sandbox on the AMC3 devices. And then if we look at, the TSW side, it was much more straightforward. So again, generating the password, running the ESTAT to get the MAC address, and then all I do is run telnet debug, and it opens up a debug shell for me. All right, so let's run those. I'm going to have to ping my, my guy again a little more. Okay, let's try pinging him first. Okay, he's back. Zoom. Oh, shit. Oh no. Oh. It's not working. Let's try the TSW one. Hopefully the demo failed. Hopefully both of my demos don't fail. There we go. This one's cooler anyway because it's an actual... And so now if you do, like, LLS, you can see you're actually outside of the CTP. file system and have full access to all of the good stuff. I found out it's actually running Lollipop. Like Android 5.1.1, I think. So kind of out of date, and I don't know if that will change in future firmware versions or not. But yeah, so... Okay, so... Debug shells. Vendor drag doors. Awesome. Okay, so. That was awesome. That was a fun thing to find. But also, since it's DEF CON, we should talk about some RCE vulns. So I found 22 command injection vulns on the Android platform. I actually had to cut myself off. Because I kept, like, finding more vulns while I was re-causing other vulns. And it's like, I gotta get these advisories. So yeah, the ping command, vulnerable to command injection. This is another one of those collisions that I found out about after the fact. But yeah, Kale and Jordan from Rapid7 also found that one. And then Durr was also found by Jackson. But then there's also, like, user CTE. Basically anything that takes, like, a string from the user. So kind of a typical... This subfunction was actually called quite a bit by various commands. So you can see the disassembly and then the decompiled version of that disassembly on the right. You can see it's pretty straightforward. Just like, you know, build up that string based on the input you're given. And then send it straight to system. So super, yeah, super easy. I noticed that these commands seem to be, you know, programmatically handled on Windows CE. So, you know, they weren't vulnerable to the same command injection as on the Android platform. I don't know if that's because their programmers are more familiar with Windows CE. Because they've had a longer history with it or what. Don't want to guess. But yeah, everything was just kind of punted to shell on Android instead of handling it in code. Most were super simple to exploit. Like, is Durr, backticks, whatever commands you want to run, backtick. There were a couple of them that were more difficult. I had to jump through some hoops to get exploits out of those. So, like, route add and route delete. They take whatever argument they're giving and they upcase it before using it. And since this is a Linux-based platform, commands are case sensitive. And there aren't any useful all uppercase commands that I know of. So my first solution was to create a shell script filled with the commands that I wanted to run. And then call it all capital blah. And then upload it with that arbitrary file upload from earlier. So I could just get it into the sandbox. But the uploaded script didn't have execute permissions. And $shell and $bash were not set. So I found out... I actually learned this while I was doing this. So normally... When you use $0, it gives you a reference to the calling program. But apparently when you're doing this from within a system call, $0 actually gives you a reference to the shell. Which kind of makes sense because a system like spawns a new process that will be an actual shell. So using $0, I was able to get a reference to shell. So then the final injected string... Was $0$ifs for an internal field separator. Because it all had to be in one argument. And then dot slash blah. And then it would actually run my shell script. I found out much much later that dot is actually a unix command. I never knew that before. But it works kind of like source. So I could have also used dot instead of $0. But whatever. Whatever works. So final demo of my talk. So we already got a root shell. I've got an exploit that could give us another type of root shell on here. But not good enough. I wanted to do something different. So... So what I did, I used that command injection to modify one of the config files that controls all of the streaming settings. And then I used the command injection again to restart the CSIO service to pick up those changes. And then all of a sudden RTSP streaming started working. So I'll show you that in just a second. First, let me connect to... Hang on. Let's see. Let's see. Oops. Okay. So you've got your file system. You do like... I love this example because it's so like immediately obvious that it works. And all of a sudden there's a test.txt in there. So if you do like... You can see that you're running... You're injecting commands as root. I just love that example. Okay. So let's run the... Let's run the good script. Okay. Sign-in mode enabled. And in a second, we're going to pop up VLC. So a very important thing to note is that there's no change on the touch screen to indicate that it's now remotely streaming from the webcam. And did I mention that these things are being used in like hotel rooms and stuff? Yeah. Okay. So there's my final demo. Let's see if we're doing the demo on time. Okay. So let's wrap things up. So the potential for good security practice is there in these devices. But the problem is that it's just turned off by default. So you have to rely on either an installer or some programmer. To do it for you. Or if you know that this problem exists, then you can do it yourself. Which is kind of one of the reasons why I like giving talks like this. It's informing that the problem is actually there. But basically, bottom line is if security isn't enabled by default, it's not going to get enabled. So it really is dependent on Crestron making the changes, which they have. I'll get to that in a second also. So yeah, this was an interesting situation. Because of the types of environments where these things are deployed. It makes it so there's a high potential for use by insider threats. So like you've got these things in all of Microsoft's boardrooms. And let's say Microsoft has a disgruntled employee somewhere in the world. What are the odds of that? So they could actually... use things like this. Like recording from the webcam at the microphone. To do like corporate espionage. And like snoop on the boardroom meetings and stuff. And then of course the hotel room thing. So usually you say like, oh we're going to put these devices on their own isolated network. So all the Crestron devices are separate from all the other things. But then you have the situation with the hotel room. Where just some hotel guest goes into a room with one of these devices. Pulls it off. Plays it in their laptop. And now they can reach all of the other ones in all of the other hotel guest rooms. You know. Something to keep in mind. And like I mentioned earlier. The Android platform seems way less secure than the Windows CD platform. Which caught me off guard at first. Because you know I immediately like, oh Windows CD. Ha ha ha. So insecure. But they actually did a much better job on the Windows CD platform than they did on the Android platform. So I don't know if they're just like starting to spread themselves too thin with moving to different platforms or what. But so very very important slide. Crestron has released updates to address all of the issues that I've discussed today. I actually got word earlier this week. That my advisories for all of this. All of this stuff were finally going to be released yesterday. But yeah. Crestron has released updates for all of this stuff. And more importantly than that. Enable authentication. It's a few steps to get it enabled. But you should definitely do that. Because if the actual decent authentication mechanisms are enabled. Then none of my attacks. I couldn't even get into the CTP console to pull off any of my attacks. So. And as usual with these kinds of projects. I've got lots of work that I still need to do. So there's lots of stuff still on the CTP platform. There's way more homes that I haven't scratched the surface of yet. But there's also the simple programming language that might be good to audit. The POP files which are the firmware files. And then there's a crazy amount of other services. Listening on these things also. Like CIP. HTTP. SNMP. You name it. And then of course they've got a slew of other products. Like XIO Cloud would be cool to look at. And XPanel. Blah blah blah. Anyways. The last thing. The last bullet point on this. IOAVA. Is kind of just like whispered rumors at this point. But what that stands for. Is. Internet of Audio Video Alliance. So it's a partnership between Crestron, Microsoft, and Intel. To make like an embeddable device that can go and turn all AV equipment into Internet of Things equipment basically. So that's something to keep an eye out for in the future. And then yeah. That's it. Those are ways that you can reach me if you have any questions. Or just want to chat about stuff. Yeah. There you go. Thank you. . .