My name is Tony Martin. I'm a security architect. I also do some research on the side. When I get bored, things tend to get broken. You can ask my wife. She's sitting right over there. And here's a shameless self-promotion about myself. If you want to take a look at my background. So, one day I was sitting at home and I was kind of bored. And well, things tend to get broken. I had this brand new device. This QNAP device. And my home has. And I started poking around at it. I was like, take a look at it. And I'm playing with it. And the great thing about these devices is their functionality is expanding. They're no longer just backing up your data or providing a network share. They are now serving your content, your entire network. They have syslog servers. They can do email. They can do all kinds of things. So, I started taking a look at it. I was playing with cross-site scripting. So, I wanted to see if I could find some sort of a field in there that if I played with it, I could get immediate feedback. So, here you see the admin. There was a blank description. So, if I go in and I edit the admin. And I can edit the descriptions here. It says testing. And you'll see testing show up. So, really, really quick. Cross-site scripting. What happens here is an attacker just sends a string. The server stores a string. It's just a string of characters to the server. And the server will deliver that out to the client. When the client web browser gets it, it will then take that string. And that's when the bad thing happens. It will execute it. So, I wanted to take a look here and put it into the description field and put it into an alert. Alert with this. And this is the classic attack string. You put this in. And what I was expecting was, is if there was a cross-site scripting, is you would see this little pop-up window come up with a 1. But this is what happened. Nothing showed up. It filtered it out. And I said, oh. And so, what this told me was, is what they're doing is a form, a very, very bad way of trying to be to make cross-site scripting is called blacklisting. They're attempting to filter out all the bad data. But there are so many variable combinations, you really can't do this approach successfully. So, I tried putting in this. I tried different types of things. I wanted to map out what their blacklists looked like. And so, I put in this into the iframe to the admin account. And this was a bad thing because, well, it locked up my device. It tried to render and he saw loading data. And my device completely locked up. And I couldn't go back in to delete this cross-site scripting script. So, I had to reset my device at this point, back to default. Thankfully, the data stored on the, oh, there we go. Got some quiet going for now. Thankfully, the data on the devices was still set. But, so, what I did is I created a temporary user. I was able to play with that. And I could delete that temporary user if things blew up in that cross-site scripting. One of the favorite tools that I really, really like to use when I was playing with this was Firebug. And what it allows you to do is you can see this test user here. And I have some sort of an iframe. And what it wants me to do is when I enter in this JavaScript source, I can take a look at what it did for the rendering. So, I can click on that field and it'll show me what is the rendering in the HTML. I want to touch in really quickly on how you're supposed to properly mitigate cross-site scripting. So, when you saw in that script, it uses a lot of the tags for the brackets for the script tagging for JavaScript and whatnot. So, to do that, what you need to do is you need, you're supposed to, as you're outputting from the server, sending to the client, you're supposed to output sanitize various characters so that they won't be rendered by the browser, but the browser will see them and just display them as the characters they're supposed to. And take a look at OWASP. These are the list of the various types of characters you're supposed to work in, including all whitespace and even Unicode characters. You've got to be really, really careful. There's really good packages to handle this. You've got to be careful that you get it right in the right context also, whether it's going into HTML data, whether it's a tag, whether it's going into JavaScript insert, or an attribute. So, be really careful. Another thing is, is content security policy. I want to touch on this really quick. And what this is, is header directives in your page where you can say, only run JavaScript from these sources. So, it allows you to prevent someone from running JavaScript, but it won't stop them from doing HTML injection. So, they can still mess with your page. So, you still need to be careful, but it's a really, really, really, strongly recommend you use this. So, back to the device that I was playing with. So, it had an interesting feature. If you enter in, this is the login page. Enter in and use an admin and give it a junk password. When the administrators log in, it pops up this little window down at the bottom and says, hey, someone tried to log in with the administrator. And it'll tell you, and it'll give up this little warning. And you go in here, over to the systems log, and it'll say, this is the IP address they were coming from, and here's the user they were trying to log in from. So, very, very helpful. It's a great little interface. And I was like, oh, that's interesting. That might be helpful for me. So, I have a little demonstration here. So, we have the administrators logged in the background. Here's a different web browser. We're going to enter in a YouTube iframe into the user name and just a junk password. And so, when the user, the administrator then comes up and they take a look and you can see it pops up right there, the YouTube iframe. I'm like, wow, that's going to be fun. And then we go in and you open up the syslog and you can see the browser there. And when you press play, though, nothing happens. And the other interesting thing is it's always refreshing the syslog. This log display. So, it's always refreshing it, too. So, this is always, if the administrator has any, if they're ever logged in or they ever look at this, it's going to immediately pop it up. So, this is an interesting type of thing. So, I want to take a look at what happened. Why didn't my YouTube frame load? So, Fire, take a look at Firebug. And if you look here, you can see that what it did is it cut off telling which video. Because the administrator field will only accept admin characters of 30 characters long. So, this was one of the other things. So, I had this blacklist I had to get around. And I also had this 30-character string that I had to get along. So, I'm thinking, how can I inject anything decent with only 30 characters? So, then I took a look at a URL shortener. I could have the, so the idea was is if I had the iframe sent to a URL shortener and then I could have the URL shortener sent to a file that I wanted to. And here's a very simple file that's just very, and all it's going to do is display the word hi. So, the way this works is you enter in the iframe and you can see it's going to trim. Give it the bad password. It pops up in the bottom corner for the administrator. They see the word hi. And also in the log, the system log, it's going to show it the same thing. So, if we expand this and we take the word hi and we put it in our iframe for our YouTube video, we see the following. And if I can find my mouse because I always lose it. My mouse disappeared. There it is. Oops. Hold on. I need my video. Sound. I need to start over. Where's my sound plug in? This doesn't work without sound. All right. Here we go. All right. So, we're triggering the attack on the Assistant Administrator and it even pops up in the And you see that it'll refresh and it'll keep going. And so, I'm not going to bore you. But yes, I got to Rickroll you all. So, thank you very much. That's the end of my talk. And have a good... No. Just joking. So, I like to use the Rickroll. Everybody knows and everybody has understanding. When I'm doing pen tests, if you're breaking someone's stuff, sometimes a little bit of egos can get bruised. But you put this in there and it makes people laugh. And so, it disarms them. And then you can actually really start teaching them and showing them what's going wrong. And then they become curious. Why did this happen? So, while everybody understands that this is getting Rickrolled, my family, they don't understand that. Whenever my kids hear this video, they come running and saying, Daddy, what did you hack? What did you hack? Because to them, this means Daddy hacked something again. My eight-year-old daughter said, Daddy, I never get to hear the whole video. Can you please let me hear it? So, I let her see it and watch it. She was interested. But when I was playing with this thing, I was really trying to explore the edges of the device. Seeing what's wrong with the edges. What can an external person do? And this attack not only could work on the admin interface, but also worked on SSH, SFTP, Telnet, all of these. Any of these authentication interfaces, it would pop up. Someone was attempting to log in from this interface and this is the user ID that they were trying to use. And this would attack. But I also started playing around, taking a look at this. Since it's a file sharing system, what happens if I have access to the file share? And so, if you create a file, and this is the command to get it. I had to play around to be able to figure it out. But this is the file. And the administrator takes a look at that file in the file browser for the system. This is what they're going to see. They'll get to see Rick Ashley. Again, with the hover over for the file, they'll also see all that. And same with the directory. So, you could do essentially attack through the directory. And it also has a syslog. Syslog is a collector. Syslog collector. So, you can have all kinds of devices sending. What their log information is. You can collect it at this one central point. Well, this was also vulnerable to the attack. Are we doing a number three at 3 o'clock? No, we don't. This is the last talk. Yep. So, I wanted to do a talk at DEF CON on this. I have this great, this is really great potential here. I want to do a talk at DEF CON. But unless you can get to Roo, there's no sense in coming here with any type of presentation. So, I want to really quickly say I had to do a few cheats. So, one of the cheats that I had to do. Is I had to disable no script. No script prevented all the attacks. I also had to disable active mixed content blocking. This is some security feature in Firefox. Where if you're going to a secure website. And you try and put insecure data. It will block it. Saying this is a security problem. And where the problem runs into is in the forwarding. While the URL shortener has the secure content in HPS. What I was forwarding it to, my test site, did not. So, if I really wanted to be an elite hacker. I could have registered and used a good site. But I said, heck with it. I'm just going to use this. And so, I disabled active mixed content. This is another tool that I love to use. Is OWASP's app. And there's other tools for this. But what I like to use it for is a proxy. And what it does is it records all of your traffic right down here. So, it records all your traffic. And you can click on any of these. And you can see what the cookie is. That was sent. Which URL. And the post parameter data. You can also right click on it. And you can make modifications to any of the fields in here. And then you can send. So, you can resend these. You can make modifications really quickly and easily. And resend it. And see what the response is from the server. Very, very powerful. So, I said, all right. If I want to be able to get root access on this device. I want to see maybe I can add a system administrator account onto it remotely somehow. So, taking a look at it. So, here we have the to be able to add a user. And what this does is it's going to create a user temp with a super strong password of a single character. And giving them the group of administrator. Looking back in. And this is what the taking a look at the function here of the packet that's sent. Take a quick look here. And you can see what is sent up. And so, you can see in here user name temp. The administrator. The other interesting thing that I found is if I took those post parameters and I just copied them. I copied them up on the URL. That worked as well. So, that made my life a lot easier in later attacks. Because I didn't have to deal with the post data. I could just deal with one long URL. And if you run that, the return data, you hit the send and you can see off pass with the CDATA1. And you go into the system and there's the user temp that was added in. So, that's good. But if you, I needed one thing. For their attempt to prevent cross site request forgery. They took a value that's in the cookie and added it to the URL. So, only the server should have access to that cookie value here in SID. To be able to attach it to the URL so that, I mean, only the browser should have that. So, that the server will validate that the data in the cookie is the same as that's coming in on the URL. This prevents someone from sending you like a phishing attack type of thing. And triggering that off. So, I needed to be able to get to this SSID value. So, I was trying to figure out, to do that, I need to get to the cookie. So, I went back to my file. Removed the URL, the YouTube link. And I put in this, the alert document cookie. Seeing if I could get to it. But this didn't work. Obviously, because browsers enforce the same origin policy. And what that does is this JavaScript will only run and will only access the cookies from the site that it's being run from. So, since this was being run from my own site. It was delivering my cookie site. Not the cookie from the network access device. So, it's like, all right. This isn't going to work. And I started playing around with, okay, is there some way with only 30 characters that I can pass that value and forward it off. I couldn't find anything. And I played around. I played around. Probably someone else could have done it. But I wasn't able to. So, I said, all right. Maybe there's another way. So, I fired up Rack Proxy. Rack Proxy is another tool that's good for finding vulnerabilities. And you use it as a proxy. And you point your web browser at it. And then you exercise your website. And looking through there, I found a reflective cross-site scripting. So, very, very quick. The prior cross-site scripting attack we saw with YouTube video is called a persistent. Meaning it's stored on the system. A reflective isn't stored. And what a reflective looks like is, so you pass in a URL parameter. In this case, it was for an album. So, you can, in this device, you can actually listen to music. And so, you can create an album or a playlist equivalent. And you give it an album name here. And you can see it up there. It's testing. And what happens is it's down in here. You can see that it reflects in the body of the HTML the word testing. So, the nice thing you can do with this is you can figure out how to escape the sequence. The character sequence. And break out of the HTML. And then get it to run your own script. And when you do that, you get this. So, now I have an ability to inject scripts on the system. And if I change it from just doing a pop-up alert one, but I pop up the document cookie, I can see I can get to my SID value that I want to. So, on my website. So, then you extend it. So, instead of just getting the document cookie, what we're going to do is we split out and get to that value that we want with a little bit of JavaScript. And we do an alert on that SID. And this is what that whole command looks like. You just remove all the carriage returns. Add that on to execute that URL. And now I have my session ID that I need to get to. So, now I have an ability to get to that session ID value. Through this reflective cross-site scripting attack. Go back to the ability to add the user. This was that long URL. And you can see here, what we're going to do is we're going to create a user with test two. And somewhere in here, administrator privileges. And so, I'm going to build up a script that will get the SID. Take this URL. Add that value right to the end of it. And then change the window to this new URL, which will then cause it to add a user. But what I need to do is when I first put this in, well, it blew up. Because this is part of the long URL. It blew up because it started trying to interpret these as part of the URL. So, you have to URI encode this URL. And then you embed right in here that URL value. So, the encoded URL is here. So, what's going to happen is it's going to be executed is you get the document cookie. Get the SID. Put that long URL to add the administrator here. Decode the URL. Add the SID to the end of it. And then we change the window location. And that should get it to execute. And just testing it out, taking that long, long string. And you can see here what it looks like. And you can see it says here off past one. And in the test, you go in and you can see temp two. So, let's put this all together. There's quite a few steps here. You take this entire string here. We put it, go back to the page where we had the YouTube link. And put that in there. So, now this is the steps that happen. You go to it and you enter in the attack into the login field. The admin views the cross-site scripting attack. This loads the iframe. Which then in turn loads trim. Which redirects you to the off-site file. The off-site file has a redirect to this reflective cross-site scripting attack. Which will load the cookie. Gets the session ID. Builds the URL to add a user with admin privileges. Redirects the add to add this user. Redirects it to add the user. And then see if we get root. And here I'll hit play. And we'll take a look what happens. So, we see that there is only the admin and backup user. We trigger off the attack. Go back here. And it takes a little bit sometimes for the window to pop up. And I'll get. Some water. So, there the window popped up. We refresh it. And go back in. And now we've added our administrator. A new administrator account remotely. We attempt to log in with that administrator account temp 2 in the other web browser. As the attacker. With the super strong password of a single character. And we can log in. So, now we can remotely get our own admin account on this device. Okay. So, that was very interesting. So, I was all excited when this happened. I was like pumped. I got root. I'm going to get root. So, then go fire up SSH. Try and connect it with my user temp 2. And I'm denied. I was like, oh, no. So, I'm like trying to figure out why. On this device, the only admin can log in through SSH. Unless I want to be able to load a lot of special software. So, at this point, I'm moping around. I'm wandering around. I'm like my head's down. I'm all depressed. Because I was so close. My life thinks I'm stranger than normal. Which is normal, I guess. So, I'm fairly depressed. And I put it aside for a few days. And then a few days later, something said, huh, maybe I can get around this. So, I decided to take a look. So, if I can't get my, if I can't get to root with my own admin account, how about I can hijack the admin account? So, I took a look here. And this is what happens. When very standard is logged in the admin. I want to change the password. Enter the old password. Enter your new password twice. And this is what the data looks like. So, you can see username admin. Here's the new password you want to change to. Here's the old password. And then I saw this in the post parameter. Need check yes. Need check yes. Why is the client telling the server that it needs to check? So, I then went in and I tried to change it. But temp 2, because I'm still its admin. I changed temp 2's. I'm the super admin on the system. I can change anybody's password. And you take a look here. And you can see username temp 2. The password you want to change to old password is blank because we don't need it. Need check equals no. So, I said, uh-oh. And I changed the username from temp 2 to admin. And I ran it. And it executed. So, I was able to change the administrator's account from actually from any other account could change any other account. Password on the system. There was no authentication. So, a low privilege user could change admin privileges. So, this is essentially what it needed to execute. So, I think now I have the key piece that I need to be able to get through. So, this is what the URL is going to look like. I'm going to change the admin's password to this super strong single character here, which is the MD5 of it. And I'm going to leave my SID blank because I'm going to concatenate that in. So, we're going to go through the steps yet again. We're entering the persistent query. Cross-site scripting attack into the login field. The administrator views this cross-site scripting attack. It loads the iframe. The iPhone loads the URL redirector. Redirects to the off-site file. This redirects to the reflective cross-site scripting attack, which gets the cookie, parses out that session ID, attaches it to the end of the URL to change the admin password. Redirects the user to that, the admin to that URL. And let's see if we can get root. Hopefully, we still do. So, here we're going to show you. I'm logging in as the administrator. Remember, I had to reset the device so the password was still admin. I hadn't gone and changed it. So, you see it's admin, admin, and it logs in. Go over to my other browser. And I enter in the attack. And you give it a few seconds. It's going to pop up here. There we go. So, it triggers the attack on the administrator. You can see it actually hit the XML there. And so, now on the other web browser, I go in. I log in as admin with my super strong password. And I'm in. And so, I call up SSH. And I'm able to SSH in. Who am I? I am admin. And if we take a look. The user ID is 00. So, I have root on the system now. So, now I have root. I have my talk. I have just about everything I need for my talk for DEF CON BET. I need a cool name for my attack. Because you know what? Everybody else. We have Heartbleed. We have Shellshock. We have Poodle. Ghost. Freak. Everybody these days, if you want to be cool, you have to name your exploit. So, I wanted to be cool just like everybody else. So, I need to come up with a cool name. So, what I did is I took a look at all the various things. So, I'm doing remote cross-site scripting. I exploit authentication root on and as. And I punch this into a website that would take a look at all your words and try and figure out different things for you. So, this is one of the first ones that came up was remote access to on and as. So, I thought, oh, I could call the attack reason. The reason attack. And if we want to give it an X man flare, we could call the cross-site scripting remote and give it X reason. I thought, well, that was not too bad. I said, what else do I have? I'm curious. I'm not going to take the first thing. Curiosity always kills the cat. So, we've got to keep going. This one came up was arson. And we extend that to X arson. But an old show that I used to love to watch, Beavis got in some trouble for saying similar things. So, we'll pass on that one for now. Remote cross-site script exploit to on and as is Exxon. Some company might not be too happy with me calling that the name of their exploit. And I might get in a little bit of trouble. And I get in enough trouble with my wife as it is. So, I like to try and stay out of it where I can. As much as possible. This was a possibility. Texas. But you know what? I didn't think the tack was that big. They do things really big down there. So, I passed on that one. I kind of like this one. My exploit has a name. Methane. But a friend of mine said it really stunk. So, we're going to pass on that one as well. This one was tempting. Cool hackers named their exploits. Cheap. It's somewhat appropriate. Being cheap about it. And getting even more appropriate is cool hackers exploit names. Or cheapen. And I was like, oh, that one's really tempting as well. But let's keep going. See what we have. Cool hackers named their exploits. Cane. But I couldn't find anything for able. And that one's already been used some years ago. So, I finally came across it as I need an exploit name to be cool or neon tool. And when I went over to Whois, neon tool was available. So, I got it. I grabbed it. And I registered it. And then when I showed this to my wife the first time, she said, how much did that cost? And I just looked at her and I said, I love you, honey. So, here's the timeline. After I reported to the company, I first reported the day before April Fool's. I gave a few following reports on April 21st and May 22nd. Along the way, unfortunately, I broke their reporting tool. I'm not going to quite say how. But it was an accident. I didn't mean to. And I think their customer support people weren't too happy with me. Because they started to, I think, ignore me a little bit. And I think there was a small company. There was some confusion on how to handle these types of security vulnerabilities. A friend of mine helped me. We reached out through the incidents response teams and were able to get a hold of the security people. And once I got in touch with one of their security people, they were great to work with. They were very, very responsive. They were very apologetic for not getting up. And they said they had a breakdown in the process, which happens. And so around mid-July, they got me some test builds. And I was able to test some of the protection, some of the stuff, not all of it. But they did, for a lot of the cross-site scripting, it looks like they were doing most of it very well. So I was happy there. They finally got the release out four days ago, which was a big relief. Because that meant I now could give my talk. So I was very, very appreciative that they got that out there so that I could give this talk here. And I was very happy about it. So here's my advice. A lot of these small companies, they have these devices out there. And like this company, they have a lot of my data. And they have a lot of everybody else's data. And I don't mean, I don't want to put them down. Because now they have a much more secure device. Because they have these fixes out there. So if you have these devices sitting around, play with them. Especially if they're yours. If it's someone else's, ask permission. If it's on a web server. . Be careful. Don't get in trouble. But play with it. Try to do this and help these companies to really get their devices more secure. Because, man, this is our data that's sitting on these. This is our systems. Try and make sure when you break these devices, record your findings as you're going along. I don't know how many times just playing with all kinds of different things. And I found out I broke something. And then I tried to spend hours trying to figure out how did I recreate this. Report this stuff to the company. Help them out. Give them time. I work with a lot of development teams. And they're usually flat out. Their schedule is flat out for at least the next six months, if not a year. And all of a sudden you come along and you throw a whole bunch of work on them. And they have this time frame that they have to get it out by. It's really, really hard on these teams. So please be patient with them when you're dealing with them. And offer your help. Offer your service. Say, I'll help you. Here's solutions that you can do. If you want me to take a look at any debug builds, test builds, I will definitely do that. Really quick thank you. I'd like to thank everybody here for attending my talk. Thank my family for putting up with me. Thank you to Packet Hacking Village for letting me talk here. And if there are any questions, I'm going to take them offline. Thank you very much for attending my talk. And I hope everyone's had a great call-in. Thank you.