So, I'm Val Smith. I run attack research. I do a lot of stuff with the Metasploit guys. Woo, Metasploit! Spent a lot of time researching attack techniques, what real attackers are actually doing. Do some breaking into computers and developing exploits and all that kind of stuff. You might have seen a few of my talks before. I pretty much talk about a completely different topic every single time, and this is going to be no different. Is this on? Oh my gosh, it is. I'm Colin Ames. I work with this character. Do security research, hopefully Metasploit development a little more, and general nonsense. Hi, I'm Dave. So, I've done security research for the past ten years on various things, bouncing around, everything from writing installation for drivers to doing malware reversing. All right, so, we're going to talk about spear phishing and a few tools that we developed to do that for pen testing, basically. Working on some standardized tools to run on top of or in conjunction with Metasploit to do this sort of thing. So, we're going to start off with some file phishing stuff, talk about some web things that we've been working on, Tor. It's going to be crazy. All right, so, why spear phishing? Well, this is the way that people are actually getting in now. You know, back in the day, people got in with buffer flows, you know, remote exploits, they'd find some port, they'd send their payload at you. And really, with firewalls and everything else that people have implemented, that's not as prevalent. People are sending emails, or they're directing you to websites, it's all client-side type attacks. And they're blending a whole bunch of different types of attacks together. Like, they'll have a malicious website combined with a malicious document, which then sends you off to some malware, and the social engineering component to trick you into doing these things. So, they're blending these attacks together. So, those of you in the audience that are pen testers, how often do you get to do phishing attacks against your customers? Anybody who does it frequently? A couple. All right. All right. That's better than none. If you're not doing this, you're really missing a major vector. Like, one of the big threats to your customers is that they're going to get hit by spear phishing. And so, if they're not letting you do this, then you're missing out. So, it's because of this kind of thing that I think that the security industry as a whole is sort of failing right now, because we're not actually testing what real attackers are doing. You know, we're sitting there in the boardroom, we're doing our little pen test and our scans, and the attackers are, like, hitting it up. You know, we're going to hand them a checklist of, here's your highs and your lows and your mediums, and this is what you should do, and what you've got to patch, and the attackers are blowing them, you know, blowing them up. Now, Val's a very calm person, but we really want to hit this home. This is what you should be doing. This is how bad guys get in. This is how you hack things. All right. So, one of the things that we've been seeing that's pretty prevalent out there is that there's a lot of these web kits that are designed to do this sort of attack. Russians are doing it, a bunch of people are doing it. MPAC, Tornado, LuckySploit, these are really sort of common web kits that deploy exploits to the client. to the clients in the browsers. Now, if you're a pen tester, you could go try to find these or download these, but who knows what's in them? I mean, it could be anything. It's an uncontrolled environment. A lot of these are backdoored, meaning that you get a shell, somebody in Russia gets a shell, too. So, you know, you don't want to be introducing that into the networks that you're trying to test on the up and up. The other thing is that there's a lot of file format exploits coming out, especially, like, PDF exploits, and these are sometimes getting built into the frameworks that already exist in the Metasploit or Core Impact or whatever, but a lot of them sort of have the same problems that web kits have in the sense that it's not really well understood what's in them. A lot of times they just pop up a blank PDF that crashes. It's hard to target those. And there's not a lot of knowledge out there about reverse engineering file formats. And so, you know, our solution to this was we're going to go out and we're going to figure out what bad guys are really doing. We're going to reverse engineer it. We're going to take those techniques and put them out there. We're going to put them together in a sort of standardized, modular way that people can use and trust and know what's in it, open source. So the sort of workflow that we've come up with to do this kind of work is that we thoroughly recon the target first. You know, we figure out everything we can about who they are, what they do, what their business is, how they communicate, and then build a legend for our tech, meaning, you know, what are we going to pretend to be? Are we going to pretend to be a vendor sending them spec sheets for whatever they're trying to buy? Are we going to pretend to be their editor for their newsletter? So we want to look for documents that are plausible from them. We're going to build our vector, meaning, is it going to be a PDF we're going to send them? Are we going to redirect them to a malicious website, email? Whatever the vector we're going to choose for this attack. And then we're going to send it off and see who we get. So, you know, that's on the attack side. On the backend side, we've got to have sort of our own infrastructure to handle this stuff. We're going to need a server-side exploitation system, something that can handle all these clients coming in. Because when you send out a phish or, you know, you send 10,000 people to a website and you're going to get a bunch of shells. And how do you handle all that? You can't just manually do one at a time. And also, one of the things that attackers have to worry about is if they have a firewall, how are we going to bypass it? Are they doing egress filtering? What ports are they allowed to, you know, send out? And so there's some upfront work to do there. You know, for example, inject your payloads into browsers that are already authorized to get out through the firewall or get out through the proxy. And then you're going to want to automate stuff. Because when you're dealing with hundreds or thousands of shells, you don't want to have to, you know, okay, this shell, I'm going to type my commands. This shell, I'm going to type my commands and dump my passwords. You'll never get done. A lot of times on pen testing engagements, you've got two days or a week or two weeks. So all this stuff is kind of complex and needs sort of a framework to work in. So, you know, I talked a little bit that client-side is sort of the new paradigm. You're hearing a lot about frameworks these days. This is sort of the direction people are going. And phishing is really the client-side attack facilitator. You know, that's the way you get, drive people, if you're doing targeted stuff, to whatever your exploit is. There's a lot of tools out there, but a lot of them are manual or stand-alone, with the exception of, like, Browser Autopone. You could go get Core Impact, which has some of this stuff in it, but that's a lot of money. Not everybody can afford that. But pen testers really need something that's standardized, that they can control and understand and prove to their customers that it's safe, that they can automate. And, you know, customize their attacks. And really, one thing that's left out in a lot of these tools is the concept of targeting. You know, how do you target who you're going after and make it look plausible? All right. So, targeting specifically, I mean, you have to break it down into a lot of different pieces. And most of this is heavily influenced on the talk that Val and HD gave a while back, Tactical Exploitation. And it sort of goes back and forth to that. And it's very, very focused on social engineering. It's driven by social engineering. You know, how do we socially engineer that user, that weak link on that network to get us in? And that's really where, you know, we're going to push it to. And it requires a lot of steps. And you have recon. You have to take that recon and, you know, derive it down and distill it into something that's useful that you can then reimplement and use to actually get in. So, you know, the first thing that's really, really useful that we're going to talk about and get into more depth here is, you know, file harvesting, file hunting, that sort of thing. And this is really as simple as, you know, Googling, creative Googling a company's website and finding out, well, what PDFs you got? What docs you got? You know, let's see. Let's see what you're putting out there. You know, or is your, you know, quarterly statement there? Is your biweekly newsletter there? Is, you know, something that will give me insight into your network, into the way that you do things there available? And so, you know, of course, the first thing is to find all these documents the best way you know how. I mean, so Googling is always a good bet. There are other search engines. We like to use as well. So that's useful. And then, you know, you have to step it down. Like, the first part of file harvesting is, well, hey, why don't you read the document? There's amazing things you can find in documents. There's, you know, scans every once in a while that we get, usernames and passwords, I believe. But more importantly, you get a feel for the, you know, the social engineering aspect behind it. Like, what are these users expecting? You know, do you see a lot of newsletters coming out? Do you see a lot of product, you know, discussion? Do you see, you know, forums? Do you see forum posts? This sort of thing. And so the documents that you can grab from their network openly from the Internet gives you great insight into all of this. And then, of course, you can dig a little deeper and start scraping metadata. You know, Word documents are great at this stuff. They store everything under the sun. You know, and even PDFs are pretty good at this as well. So you can get names, e-mail addresses, numbers. In fact, even operational details such as what OS are they running, what software, what patch level. And so that's how you kind of dig deeper and deeper. So as Tactile Exploitation talks about specifically, you know, you need to understand the infrastructure that you're attacking. You need to understand what your scope is, what the paradigm that you're shifting towards. And really, how you do this is enumeration first once you're out there on the Internet and you're pushing forward and you want to see everything that you can find. And there's a couple of different ways in VowelCover, I think, a bunch of it here in fairly good light, I hope. And, you know, you just sort of step through it, step through it. Now, the good stuff that Vowel will get into here shortly is bots versus browsers and other proxy logs and that sort of stuff. And it's just great information. All right. So, you know, one of the things when you're going after your clients is how do you know what their internal addresses are? How do you know where their web traffic is coming out of if you're going to target it? You know, you need to gather as much information about the target as you can. A lot of times you want to do this in a passive way so they don't know you're coming, they don't see you. One of the things that we've been looking at is the fact that a lot of sites out there have proxy analysis logs which are sort of the reverse of web server logs. These track all the stuff that clients are doing as they come out of a network and provide a web interface so that you can look at that data. And, you know, for example, up here, it's hard to see, but essentially this gives us a list of internal behind-the-net IP addresses and a couple of hosts. Okay. This is another example of a proxy analysis logging tool. This is some Russian site, and it gives you the user IDs of the users and the traffic from when they're surfing the web. So now we've got some users to target. We know their internal IP address range. We haven't done any scans on their network or sent them anything. You can find cool stuff like this. I think this is in the Ukraine. This basically tells us what antivirus they're using and the fact that they update it and how often they update it and the dates of when they update it. So we know. If we're going to target these guys with a phish, we better be able to bypass Kaspersky because they're running it and it's up to date. So some of the cool things that you can also look for in these logs is crutches of individuals who are on a network. So it's been once or twice that we've seen there and seen them going to porn sites. It gives you an idea of what they're looking for. Every once in a while you can find them clicking on spam. So you can go find the spam and know these guys are nice guys to go phishing after. Yeah. If you see a guy that goes to Suicide Girls every day, then you know, okay, I'm going to send them a Suicide Girls update email. You know, with, hey, here's some new pictures or whatever. And then you see stuff like this in these logs that tells you, oh, they're running Windows because they're going to Windows update and, you know, they update rather frequently. The next thing is like, okay, well, if we're going to target people, we need to know what IP ranges that we're dealing with and which ones are their, you know, web-hosted company IPs and which are their internal network IPs for their company. And one of the ways to do this is, well, you start off and you look at, you know, the domain name. We pick some random Chinese domain to play with. You get one IP address. So if you go searching through news groups and mailing list for people posting from that domain, you'll actually find other IP addresses in the headers which are often their corporate internal network. You know, it's where their network is. So attacking their web host may not get you far. But attacking their actual network may be what you want to do. So this helps you target that a little bit better. And you look it up and, you know, it's owned by the same people. It's in the same country and all that stuff. It's just an IP that you may not have known about. Bots versus browsers. Browsers is awesome for this, too. Once you get these kind of IP ranges from proxy logs or from mailing lists or whatever, you know, go look them up and you can see the user agents without ever having to get them to your site. You just go and see, okay, well, they're running, you know, Firefox on Windows XP or whatever. So the next piece, you know, we briefly spoke on it earlier. And then we've covered a lot of this targeting for, you know, network information and that sort of guy. Now we're going to dig a little deeper into the network and find specifically for files that we're looking for, files that will get us access, things that are useful. So here's, you know, a newsletter for a phishing site that talks about phishing. We like this. But in general, when you're looking at these or targeting these networks in general, there's a lot of information to be gleaned. And the useful stuff that you see oftentimes is, oh, well, we just went to this conference or we published at this conference or you have speakers or you're hosting this conference. So updated slides, always good. You know. Newsletters. Eerie vibrations. And, I mean, and so when you dig through these things, that's what you're looking for. I mean, and it's, you know, you dig, dig, dig. And now we get to the good stuff. So what we really want to do is we want to find a PDF in our particular case here. We picked PDFs for specific reasons that we'll get into here shortly. And we want to infect it. We want to create it as our payload to get into their network. And there's lots of reasons for this. PDFs are probably the most prolific document format there is out there right now. And I think you can take all the others and add them together and they still don't equal up to how many PDFs you can find just by doing a simplistic file type search on Google. You know. I'm not really, really big into that sort of number. But that's how I've based a lot of this. And people generally seem to trust them. They also have lots and lots of features. So first, you know. We have to find a PDF. So here's some general stuff. Now there's an interesting thing and, you know, a little Easter egg in the corner here. Can we see something that's wrong? Val's a good guy and all. But sometimes he forgets to log himself out of Gmail when he's, you know, searching for things. Now this doesn't necessarily tip them off that you're looking. But, you know, that's leakage. That's information leakage that you didn't need to do. So be careful when doing this sort of thing. Yeah. You might hit some site that's already been hacked by somebody else and then screw your Gmail account. So here we are. We're kind of going through. And, you know, we come across this PDF. This one looks fairly interesting. It's a newsletter and it's about a conference that's ongoing and so forth. And here's another thing that we want to point out here specifically is, again, Val has done something wonderful that I always love to see is people opening PDFs in their web browsers. This is great. I love it when you do this because it elevates my PDF to run with full access. I don't have to ask you permission anymore to, you know, launch cmd.exe. Or, you know, do all those other fun things that I really like to do that we'll talk about a little later. So as we keep going down, we go down to, you know, your reading. Here we are. We're just reading now. And, you know, we can see here that we have the person that writes this newsletter and distributes it. And, you know, we can follow it up here. And you can see in the corner we have another follow-up Google search that shows you who it is, who the editor is. So now we're getting a good target list. And now we want to find, you know, cross-correlation. We want to see sites that trust this. Leveraging. What do we... Who reads this? Who's interested in this? Who are they partnering with? And, you know, because this could give us more attack structure, more vectors to enter from. And so, you know, continuing on and just digging a little deeper, looking for e-mail addresses. These are good targets. Good targets. Keep going. And, you know, continue and look for those relationships that can maybe be leveraged at a higher level than ones you've already found. And so you just sort of keep structuring it further and further. Yeah. So this helps you decide, okay, well, I want to send this newsletter from organization A to organization B because I know they have a relationship and they're using the same content. And this is something you might expect or trust. So the actual, you know, specifics of PDF infection. Now, so, I mean, I'm talking about infection. I'm going to take ready-made PDFs that are valid information, your information, information you read, information you provided to us, and I'm going to infect it with a payload. This doesn't destroy the information. In fact, the information is still there. And there's some wonderful features about PDF that makes this amazingly easy. So as you've heard, I'm sure, in the news and other things, you know, PDF has got tons of features. Adobe, I love them for this. They love features. Gosh, everyone wants to have Flash in their documents. Everyone wants to be able to view a web in their documents. Hey, why not have a document launch commands? That's wonderful. So, you know, we have just tons of vectors in PDFs that we can leverage. And these are allowed, this is a feature of the document format itself. Not even a vulnerability or an exploit. This is just what's built there, given to us, say, hey, go ahead and use this. Functionality is great. You know, and again, PDFs work all over. You know, they work on Linux. They work on OSX. They work on Windows. So you have a wide range of targets that you can use with just one file format. And again, we like to believe that they're trusted. We'll see how much people continue to trust them as we go on. As things, we keep to. Keep picking on PDFs quite a bit, so. But so, you know, there's been a lot of good research out there. I want to, you know, throw up some of these names. These are good people to go looking for if you want to learn more about PDFs, about the structure of them, about attacks on them. You know, and so these are good places to go. And there's some great code out there that does a lot of what we're going to be talking about. And most of the stuff is structured at how do we analyze PDFs for malware and that sort of thing. And that's kind of where we're going to try and set ourselves apart. Because we're interested in attacking with PDFs. So a byproduct of this, of course, is that, yes, I can take apart a malicious PDF and tell you, you know, what shell code is it using, where is it beaconing to, so on and so forth. But that's not really our primary goal. So the attack basics specifically for PDFs, you know, we have vulnerabilities. And we want to turn those vulnerabilities into exploits. You know, you've got JavaScript. Those are prolific. There's, I think, six or seven at least, you know, overflows in the actual JavaScript interpreter for Adobe. And specifically in Adobe Reader. And, you know, you've got Flash. There's just fully featured things. I mean, if you fuzz this, you can get information and you can get, you know, good results. And, you know, of course, JBIG. These are filters. A filter, you know, in a PDF is just a way of displaying information or translating it from one median to another. I think Puskat was telling me that she fuzzed for about ten minutes to find the JBIG exploit. And so then you start leveraging design features on top of, you know, vulnerabilities for your attack. And that's what we're going to actually do specifically for, you know, our infector. So, you know. The deep mechanics of this is when a PDF is opened, it parses through lots of objects. And of these objects, you can get, you know, varying results of what you can and cannot do. Useful ones are open actions. Open actions take you to other object groups that can do things. Open actions are always associated or not always, but mostly associated with malicious PDFs and so forth. But they're actually also legitimate uses. If you have an index of, you know, 40 pages and actually page number one is number 41, you have to use an open action to hide it. You have to hop to page 41 if you want to open page one when you view your PDF. So this is controlling content the way the content is driven and viewed by the actual PDF reader. And so we want to use this. We're going to leverage this to kind of point it to where we have bad things to go. Next is you have additional actions, which is AA here. And these are all object types in PDF, which can then go further on. And the open action that we're using, you know, we're going to use something that calls CMD. And it's very, it's interesting. So you go through and you have all of these features that you take, you basically overload and use to base your attack. And so the most important feature here is PDFs have a wonderful thing called incremental updating. Incremental updating is that you leave all content in the PDF in place. And anything that you want to change, you just add to the end of the file. You just append it. You just put it at the end. At the end of, you know, a PDF file, you have end of file as we see here. And then you just start adding new objects. Or overwriting objects. I don't have to change anything on the PDF to infect it. This is wonderful. So this leads us to our, you know, our actual Metasploit module. And so what our Metasploit module does is you pass it a PDF that you found that you want to infect. It then will infect it with a Metasploit payload. And it will launch it. So let's see how the demo gods like us today. . . Good. . . . . . . . . . All right. So what he's doing is loading up two console, Metaswitch consoles with resource files that do the multi handler which is going to catch the cells coming in and then his PDF stuff. So if we can show it here. So we're showing the PDF that we saw earlier, this SDIAP v2 and 4. Now an important feature of the actual module in this particular case is that we want the file name that we're going to create here to be very, very similar but not the same. And I'll explain this in a second. And this is more or less, you know, we could make it a random file. But random files are strange looking. Normal users don't open random files. So well, that's not true. But we're trying, we're really trying to, you know, play to their side of the coin here. So make sure you name it exploit.pdf so they open it. They love exploit.pdf. And another thing that I want to point out here is this is not a vulnerability. This will work on every single version of Adobe till the end of time. Unless they change functionality of PDF, which I don't actually see them doing, to be honest. We don't have it in temp. Hmm. So Val told me. He had set this all up. But he lied to me. He did not move it to temp to make our life easier. But it's okay. It's okay. I wish tab complete worked on Val's VM. Hmm. All right. Maybe now it will work. If you spell re-exploit correct. Ha. Huzzah. So as it goes through here, we just see it, you know, we picked a payload. We used a Maturpa reverse TCP. Nothing fancy. And it just, it spit out a new one in temp. Which is our other one. And that loaded up into a, we have a web directory for that. Let Val log in here so I can own him. . . Bye. . Actually, do you want to own yourself? Do you want to click through it all? Sure. I'll own myself. Hopefully. Hopefully. It'll eventually log in, I promise. You know what? This is wrong. Let's own Root. Val Smith's a wuss. Because Val Smith's a good guy. He uses, you know, user privilege separation. He never runs his administrator. All right. So what we're going to do is we're going to connect to our, you know, we're going to assume that you're connecting to a web server that's hosting up this PDF, and we're going to hopefully launch it. And you can, of course, attach this to an email that you're sending in, which is the more traditional vector that we use. So here we see it. It opens the PDF, and it immediately asks him to send it. Save the same PDF he just opened. That seems a little odd. So actually what it's asking him to save is our actual payload. And then the next thing it kicks up, that's CMD. It asked him to call CMD. So let's go check other VM and see what happened. Hopefully something. We got a session. All right. So basically what happened when we opened that PDF is that we got owned. All right. Do a hash dump. Say what? Actually. It's all the same. The newer versions of AcroRead on Linux, I haven't checked it recently on OSX, but Linux will not call commands directly anymore since version after, After, I think, 7, the 8 version will only call the default web browser, which is generally Firefox. So, of course, you can do other interesting things like call Firefox exploits through Adobe. But we'll get to that later, maybe. All right, we're going to crank because we want to make sure that there's time for all the other Metasploit track people. So we're going to jump into the next piece, which is web phishing. Now, the idea behind this is that you want to direct your targets to your website with some means, whether it's an email or you hack their website and put your stuff on it. And then Egypt gave a great talk about target enumeration, and we're going to talk a little bit about that from a more basic point of view. This is stuff you can take home and play with and figure out how to do yourself. And then the next thing you want to do is social engineer the target into believing that everything's okay, nothing bad's happening to them, and then execute code on them using some social engineering techniques we're going to talk about. Then you've got to handle your access just like we did with the PDF, and then automate your post-exploitation activities. All right, so I sort of have some really general stuff. And a lot of this is taken straight from how real attackers do their web kits, but I did it in such a way that at least you can understand the code. It's fairly simple, and you can use it without thinking I'm going to, you know, backdoor it. So we want to do OS detection and IP detection, figure out what browsers they're running, and then make a decision on, okay, well, if they're running this OS and this browser, we want to send them over here. Similar, along the same lines as browser Autopom. We've got some decloaking stuff, and then some signed job applets. So... In general, what we do is we sort of built some little modules to do client-side enumeration, and you can extend these to do all kinds of crazy stuff. And I'm not going to read all the code, but I'll just sort of show you a little overview of each thing. So the first thing we want to do is generate the header for our page, whatever it's going to be. In this case, we're going to check and see if they have JavaScript enabled, and if not, we want to bounce them out to some safe URL, you know, maybe their company site, or whatever we're trying to iframe in. The next thing we want to do that's sort of important, especially to pen testers, is we want to verify that the target IP is in scope. We've been on pen tests where we've done phishing and accidentally owned random people's home boxes, so you don't want that to happen. You want to make sure that the only IPs that you're hitting are in the scope of whatever your engagement is, and if they're not, bounce them off to some innocuous site that's not going to hurt them. So, you know, we just have some code to help you do that. We want to verify that they have Java installed, because this particular text is not going to work. The attack requires Java. So we just have a really simple, this is like simple, easy stuff, but we have them in a modular way that you can just go grab these things for your own attacks if you're trying to build a phishing thing for client-side engagements. Then we want to know what OS they're reading. This particular function is really based on user agent stuff. Egypt's got some really targeted, reliable ways of finding about OS and patch level and service pack level, which you should definitely check out. Then gathering information about the browser. You know, are they running Opera, or Internet Explorer, Safari, or Firefox, or what have you. All right, another thing that can be useful while you're, I mean, if you've got them as a captive audience and they're hitting your web page, you might as well gather information about their internal IP. And so there's a couple of ways to do this. We have a JavaScript method, which allows us to get their internal behind the NAT IP address. We also have a Java applet. There's a guy out there, regulus.de, who released an applet to do this, and we sort of maybe reverse engineered it. And added some bling to it. You can go to his site and get more info about what this class exactly does, but it'll essentially do some stuff to get you their internal IP address. And if you're really interested in decloaking internal IPs or finding out if someone's coming through a proxy or Tor, check out hdsdecloak.net. It's got all kinds, you know, just a hundred different ways of doing this same kind of thing that go way beyond what we have here. Then you might want to log all this stuff. You want to know, okay, this IP hit me at this date and time, and they're running this stuff in case, you know, your customer says, hey, you guys didn't really own me or you did own me and something bad happened. You want to know if that was you or somebody else. It's very helpful to log this stuff. So we just have an example of what this sort of little front end will do. Normally you wouldn't output this to the user because obviously it looks weird, but send it to a database. Okay, so, you know, the social engineering aspect of all this is having a Java applet that you can distribute your payloads in a similar way to the PDF stuff that Colin was talking about earlier. You know, we love Meterpreter. That's sort of our favorite thing, so we're going to distribute that in this case. The idea behind this is the client's going to hit a page. They're going to get a Java applet window pop up that, you know, asks them to run an applet. They're going to hit run, and it's going to cause the client to, in the background, download Meterpreter and execute it and then send you a shell. So we have some really, really simple applet code for doing this. It basically just goes and gets the Meterpreter and executes it. You can play with this and make it better. You know, it's just some example code. Now, how to make this really deadly is if you cryptographically sign the Java applet as your target, most users are going to go, oh, look, my website has a little signature thing asking me to run something. They're going to trust that because it's from their site, signed as their company. You know, why would they question it? They're going to hit run, and they're going to get owned. So, you know, we usually change up these file names to reflect the target's infrastructure. If they're running WordPress or some other content management system, we want to make sure our stuff matches that. So it's not just some random, you know, Java applet file that they never heard of before. We've got the commands for doing this here. If you want to do it by hand to show you how to sign, cryptographically sign these Java applets. By the end, you know, once you run through all those commands, you'll end up with a series of files, including the class file and a certificate and a key store. And then you're going to need a web page to launch this. And I've got an example. Typically, you would throw this into an iframe or something like that and also display the target's real website. So they think nothing bad is going on. And they're going to get a little pop-up that looks like this. In this case, we signed it as Metafish. We could sign that as anybody, you know, Microsoft or target ABC or whatever it is. It's literally a text string, whatever text string you want. Okay. So some of the automation sides, Metasploit has the capability to handle n incoming sessions, essentially. So you want to be able to automate a bunch of functions like all your post-exploitation stuff that you don't want to do. You can do it by hand if you're getting hundreds of shells coming in, like getting your passwords, adding users, updating or uploading other types of backdoors that go beyond what a interpreter might be doing. And, you know, keep cognizant of what egress ports are allowed. So I've got just some basic examples on how to create your interpreter binary so it will work. I'm not going to go into that. You can read it on the slides later. And then your basic commands for setting up the multi-handler session. And then on the automation script. You can use any script you want. We've got an example, but, you know, there are a whole bunch out there. So you want to deploy an interpreter to your target using whatever means you can, whether it's an effective PDF, a malicious website with a Java app like we're going to show in a minute, or whatever exploits, or just email it to them. A lot of people will just click on an interpreter executable. And then watching, you know, for your session coming back. And success. So in this case, the demo we're going to do, there will be an automated scraper that will go and grab all this kind of information, generate a directory with timestamps and IP and all that. And then you'll end up with a bunch of files that have hashes and network neighborhood and whatever. Darker operator's got some scripts out there. HD's making... Oh, he's going to talk right after this on the types of scripts he's doing. So check that out. All right. So briefly, before we get to the demo of this. I'm going to talk about obfuscation. One thing a lot of attackers are doing are obfuscating their iframes or the ways that they're getting these payloads to you. Because people are having host-based intrusion detection systems or AV or whatever detect these things and block them. And this is an example of iframe obfuscation where they essentially write a JavaScript that breaks up the word iframe into different variables and then reassembles it later. And a lot of your tools that would look for iframes in the HTTP request won't see this kind of thing. There's other stuff you can do. We see this all over on, like, Chinese and Russian web kit sites where they encode their URLs and commands and whatever they're loading with, you know, just, like, character encoding. We have a few different examples here. These are just different ways to evade detection from, you know, getting stopped. Because it sucks when you hack the machine and they've run the commands and the shell gets stopped because they're running AV. There's a website out here, Script Asylum, which has a bunch of examples of encoding, decoding for your JavaScript. I advise you check it out. It looks cool. And then Egypt's talk for Ajax obfuscation. He mentions this a little bit briefly and I don't know if he'll talk about it more. But it's cool stuff. All right. So we're going to attempt a demo. And this time you'll get your hashes off that same box. For those that wanted those last time. Hopefully. All right. So we're going to load up a couple of Metasploit sessions with some resource files that preset them up since I can't type for crap. And the settings for the actual web applet is, you know, this is using HCP server from Metasploit. And it just basically defines, you know, what class name you want to use, this sort of thing. It builds what payload you want. We've picked, you know, reverse TCP meterpreter. And it just sort of sets through all these things. So there's a few things you're going to want to set in here like who you want to sign the applet as. You can put whoever you want. What ports and all the typical stuff. And also the URI path, meaning, you know, what do you want, what directory do you want this to come out of. And we picked CN underscore gov. So I'm going to get it set up here. You want to explain what's going on? So this is actually calling out to Java, which is a bad thing. HD assures me that he can just sort of throw out Java bytecode. So we'll be moving to something a little cooler and sexier later. But, you know, this is basically just compiling the Java applet. It, you know, renames a bunch of the functions. Puts the calls in to the right IP addresses and so forth. And builds and signs it. And then hosts it up on a website. All right. So I think we're all set up and running. I'm going to switch to our other VM. Windows is so much slower than Linux. . Interesting side note while we're waiting for him. The actual command, the CMD call that called the payload is due to the opening of page one. So if you went to page two and then back to page one, it would, in fact, launch the command over again. And you'd get two shells. Okay. So I'm going to go to our little client side enumeration web page that we have built. And what it's going to do is it's going to tell us, you know, what's going to happen. And what it's going to do is determine, is this a viable target? Is there in scope? Is it what we want to hack? Yes. And it's going to bounce us off to the Java applet. Hopefully. So if you can see up there, it decided that we were a good target. And it shipped us off to this other URL, which is a same IP address but a different directory. And it's running really slow. But I promise, it's just because it's in a VM. So what we've done is we've iframed in, you know, something that would look normal to our target so that they don't think that they've been hacked. All right. Eventually here, we should get a window or something. All right. We're going to try that again. Everyone pray to the demo gods. Quick, kill the chicken. Someone. Yeah, I haven't got the pop-up window yet. I think it's just really slow. All right. While we're waiting for that to work, we'll show it to you real quick in a video. I think my VM is hosed or something. It's running really, really slow. And I think that's what the problem is. But never fear. We have backup. All right. So you can see this is sort of a video of what you're just looking at. You've got to pay real close attention because Val clicks yes real fast. I've got to find that. I've got to find the spot where it actually happens. All right. So like he said, I clicked that really fast. He's such a trusting fellow. So what they get is a pop-up that says, hey, this is signed by whoever. And we could assign that as Chinese government. If we wanted to. They're going to click run. And then it's going to complete. Let's check our thing over here, see if it worked yet. Oh, look. It's sending. I don't know why it's so slow. It's not like we're hacking or anything. All right. So we've got another video of the attacker side so you can see what happens. I think our actual demo is going to work. I think it's just going to work in, like, super slow motion. Because everything goes perfectly when you're hacking boxes. Always perfectly goes as planned. All right. So essentially what happens is it ships off the interpreter EXE once they hit run on the cryptographically signed job applet. And then just opens a session on the other side. And runs the auto scraper to gather basic information. All right. So you see an interpreter session opens up. You can interact with it. You can execute a shell. You know, typical stuff like you can with an interpreter. And then sort of what the auto scrape stuff will look like is you have a director with the IP, time stamp and things like that. And you have all these different files. Like if you get hashes. And these hashes are meaningless. So crap. You can crack them if you want. I don't care. You know, what the network neighborhood is. Repeat your question? Or you're heckling? I think it was a different room. All right. So anyways, I don't know what's up with this. Like it actually sent the applet. But it never sent them interpreter. All right. Demo fail. Regardless. We'll move on to the next piece. Okay. So we were on a pen test one time. And we were supposed to go off site. Because it turned out that the people we were pen testing were monitoring our traffic. Sometimes the people who hire you and the security teams are not in sync. But so what I started playing with was some of the Tor stuff. And everybody knows about Tor for using it for anonymously browsing the web. But we started thinking, well, what if we can go ahead and do more with it? And so a lot of this is already published. But it takes a lot of time to figure out exactly how to do it. So that we kind of put it together. And these guys didn't have any clue that we could go as far as we could. So the first thing that we looked at was who do we want to be? So who do we want to come out as? Do we want to come out in China? Do we want to come out in a city where the place is located? One of the things that we're seeing as a trend is people are starting to get real reactive to being penetrated. So you'll see, oh, they all of a sudden block off all access to China. Or they all of a sudden try and block off everybody except for their local neighborhoods for their VPN. So instead of having to drive somewhere and try and figure out, you know, what the site will look like from China and having to fly to China, we just use Tor. An easy way. You can go ahead and buy a virtual server somewhere. That's kind of expensive. It's another way to cover your tracks, kind of keep the defense off guard. So if you're actually trying to test the security teams and they're expecting you to come out of your home base in San Francisco or wherever, they might be looking at that city a little bit more. If you're coming at them from Mexico, well, then they're not expecting it. So a little bit just on how to set it up and a couple of notes that we found. So in a lot of the documentation, it mentions that you can just specify a country in an RC file for Tor. It turns out that's a little bit harder to do. It doesn't seem to work correctly except in some of the betas. And one of the other things that we started to find is, and actually we found this from the defensive side, too, is if you're seeing a scan and it starts hopping IPs mid-scan, all of a sudden you start thinking something's up and it's a little bit more suspicious. So it's kind of nice to define your exit node to one particular location. And just pop out of that one place when you're doing a scan and then go to another place for another scan or for an attack. So, of course, the easiest way to figure out where you want to pop out of is through a Vidalia. You can go, you can see the little country flag, get an idea of what city it is, what the location is. The only big problem there is you have to have unique names in your Tor RC file or else you could potentially pop out of an exit node that you're not using. You're not expecting to. So the unnamed is a really bad choice if you're going to use Vidalia. So you go ahead, you choose your exit node, put it in your Tor RC file, make sure that you're strictly exiting out of that node with the strict exit node equals one. And just put a comma list, if you want more than one node, put a comma separated list of the exit nodes you want to pop out of. Of course, if you want to get some of those other, like, unnamed or not unique named exit nodes, you can do that. But if you want to get some of those other, like, unnamed or not unique named exit nodes, you can do that. But if you want to get some of those other, like, unnamed or not unique named exit nodes, you can do that. You can do this through a couple of websites that track it. So they'll give you a unique key that you can go ahead and put into the Tor RC file, and then you can pop out right at that node. And here's an example from one of the Tor sites. So this isn't real important unless you're coming back later. This is just how to get to the, where to set the Tor RC. Now, one of the things I discovered when I was talking with people about this is, Now, one of the things I discovered when I was talking with people about this is, they don't really understand what they have on their box when they're looking at Tor. So you see people running proxy-aware tools through the 8118 port, Privoxy. The problem is that will fuck with a lot of your tools, especially if it has Java on the other end or Flash. So you'll get weird false positives. So that's, you can do it, but it's not what I would recommend. Tor also has a full SOC spy proxy on 9050. And there are a lot of people who think Vidalia is Tor, And there are a lot of people who think Vidalia is Tor, but it's not, it's just the GUI. You don't need it at all. So there are a couple of standard tools that you can use if you want to get any TCP connection to go over Tor, or basically any. There's proxy chains, Tor SOCs, and TSOCs. They each have their own pluses and minuses, and we'll go over a couple of them. Depending on what I'm doing, I use different ones. A lot of the scans, I tend to like proxy chains because it gives you a little bit more feedback. The way these work, though, is they hook the socket call directly. And send that over the proxy. The reason this is important is so if you're trying to use Nmap as root, it opens a raw socket, so you really don't want to do that. It's doing it for efficiency, but then it ends up bypassing the proxy chains or the Tor SOCs. You also need to be careful about DNS leakage, IP leakage. One of the things that I always recommend, and that I do just now as standard practice, because if nothing else, I sometimes fat finger it and forget to put Tor SOCs at the beginning of the command, is IP chains off wherever you're going. Make sure none of your stuff leaks. If you want to know that you accidentally did it, put it in your logs. Always try not to run as root also, just in case that nice raw socket is opened. Yeah, we've seen Tor nodes that inject malicious code into every web page that you visit, so running as root can expose you to that. Yeah, that's true too. So I kind of went into a quick config here. The important parts, so we want to come back to this later, that's great, but the important parts are actually the timeouts. So if you're going to try and do something like Nmap over Tor, you need to play with these timeouts a lot, because you'll get a lot of false negatives or false positives. TSOCs, even a simpler config, you just point it to the local host at the Tor port, and Tor SOCs basically work. It works right out of the box. So we can go ahead and we can Nmap over Tor. It's actually not too bad. It can be problematic with the timeouts, as I mentioned before, and you have to be careful about your exit nodes. Some exit nodes won't allow 135 out, or other exit nodes won't allow some port out. So sometimes you'll fail and you think that you shouldn't. Just try another exit node and see if you're successful. Now, the results are not exactly foolproof, and it takes a lot of time, but if you run it overnight and then come back in the morning, you have something you can play with. So it's better than having to wait. A lot of the reason this came up is I just didn't want to wait for a pen test that we were supposed to go offsite for. I got anxious and wanted to get to hacking. Of course, you can't do any UDP, so be careful there. So here's an example of proxy chains with Nmap over Tor. Now, the important part here to note is that first access denied, let me see if I can... So this access denied here is showing you that the 443 is being denied. Now, if you just let this scan go, it'll take forever to actually time out, because basically it's still trying to get that connection going. Basically all of the Torsox proxy chains, they try and assume that the port's really supposed to be open, and they're timing out for a different reason, and they're being rejected for a different reason. So they keep retrying. So you can go and you can tweak what your scan is. And if you're using the minus A option on Nmap, you can end up finding a lot about the end host. And you just kind of sit there and play with the port ranges that you want to see and what ports are being scanned for. And you can find out, yeah, this is an open SSH running Ubuntu, and there's no OS detection. It's really nice. So here's an example of the scan that I was actually running. Again, it's blog.attackresearch.com. So we were popping out right in China. Except I lost the cursor again. Well, we're popping out here in China, going over 22 and 80 straight to blog. So in blog, all that was seen was China traffic from this random exit node. But let's go a little bit further. So Nmap's nice, but you can do a lot of more interesting things. So we ran NIC2 over Tor. We tried it a couple times with the privoxy, but that's one of the reasons I mentioned before. We switched over to using Torsocks. And what was nice about this is we were actually able to root a couple boxes, all remote, coming straight from some other IP somewhere else in the world. And it just took overnight. And all of a sudden, we were able to find a directory on some random website that they didn't know about or didn't think about that had the complete build documents, including the usernames and passwords to their entire website, database, everything else. So it's a nice thing to think about. We just showed it up here, again, scanning our attack research box. And you can see I use proxy chains because it gives us a little bit of output so we can see what's happening. And you can see each chain being created as it's going over the Tor network and hitting attack research. The minus host here, just as a side, I know I mentioned that you should try and use IPs whenever available. The host is to get to the virtual host on the IP that you're going after. So it's not actually doing a DNS lookup. It is a necessary thing with NIC2. But you can go further. And this was one of the fun ones that I was playing with one day. And we did a full VPN over Tor. It's painful. It's slow. It dropped a lot. But we were able to connect up eventually to the remote end. And to a VPN site that we were after. So it was popping out wherever we wanted it to. Now, it took two boxes to do this. So it's a little bit of a strange setup. But the nice thing about TSOCs, TorSOCs, proxy chains, all of them, is they only end up hooking your outbound stuff. So you can still listen. So if you use something like TCPXD or any of the port redirectors, it will go ahead and listen on one port and then inject it straight over the Tor network to wherever you want. So all we had to do was take our second box, have it VPN in to our first box, and that realistically piped it all over the Tor network. So these guys asked me, of course, what about Metasploit? And for a while there, I was doing TorSOCs with Metasploits until I read a post from HD and found out it's much easier than that. So all you have to do is set the global proxy to a SOCs4 proxy on localhost pointing to your Tor port. And there you go. Of course, you're restricted to connect shells. If you do a reverse shell, you're going to have a bad day because it points right back to you. So there's still some limitations. And we went ahead and decided to show that, though. Okay, I guess we're skipping this so that we can give more time to the Metasploit. Hold on a second. I actually want to see if our script ever came back up. I'm going to have Dave do the demo of his tool, and we're going to skip Metasploit over Tor, because basically, yes, you can Metasploit over Tor. All right. I'm going to bounce this box. Okay, so of course, once you get onto a box, you want to be able to get your command shell back. And it's... And you want it to be persistent. So can you... You want to have this anonymous server out somewhere. Well, you can use Tor to do that. They're the .onion sites. Normally, this requires Tor on both sides. So if you want, you can get onto your attacker's box, install Tor, install TSOX or PrivOxy, and sure, no problem. You can have a backdoor going over Tor in no time. It's actually fairly easy with Bash. So you can get Bash over Tor by setting up a hidden service on one of the Tor servers and just doing a netcat. You can also do it with the built-in TCP in Bash. And... But in the interest of time, what we did is we didn't want to do that. We didn't want to have to install Tor on the remote end. So we wrote a tool. This backdoor goes through a website called torproxy.net. It's not the only one out there, but it's an easy way to bounce through. So we can do HTTPS straight to this place in Germany, and then it'll go anonymously to the Tor network. So in the end, no one really knows where we are. And forensics from the... from the place that has this backdoor on it is really nasty, because everything's going HTTPS out their site. So it's not like it's the Tor network that's going over the wire. So IPSs that block Tor? No good. So there's some really nice benefits on this. Of course, no need for any special clients, just the actual backdoor. Oh. Apparently I'm not close enough to the mic. So... Can't tell who the server belongs to, of course. Don't know who the .onion belongs to. And it's all going over HTTPS out the front door. It's not what I would call an interactive at all. It's... or it's not interactive. It's just a simple send commands. And it's also very asynchronous. So it's not a fast backdoor. But it's extremely useful if you're trying to hide where you're coming from or any tracks and make it very hard on the defense. So just a quick kind of visual, because apparently a lot of people have trouble visualizing this. Yeah, the victim's going over HTTPS to the TorProxy.net. So TorProxy.net at that point can see your traffic entering the Tor cloud. But really all they can see is something going to a .onion site and some random traffic that looks like HTTP over the actual connection. So we're going to run this on a demo. Oh, that is true. One of the things I did forget to mention. So I ended up actually writing this backdoor twice. Once in Ruby, and then after I... my machine crashed and I lost my backups. Important to know where your backups are. Colin even saw me make them, but I can't find them. I wrote it again in mono. So it's using C sharp and mono. One of the benefits being that since now Ubuntu and Debian and a whole bunch of distributions are starting to come with mono, I can actually use the same executable on Linux and Windows. And the backdoor will work. No problem. So what we got is a... basically a backdoor that communicates all over SSL through the Tor network anonymously and is cross-platform. So let's see if we can get it up here. Now I admit I'm doing this all over video because as we've seen... You can get it up, Dave. Oh, yeah. So as we've seen, the network here is kind of iffy and I'm not going to try and tempt Tor with the network here. All we'll do is waste everybody's time. I can't grab it. Where is it? It's right there. So here I am on my Linux box. I'm setting up a server for the Windows. And I'm going to set up the server for the Linux side here. There we go. He's doing two demos at once. Yeah. Linux and Windows. So since this takes a while to actually run, I figured I would get everything out. So here's the actual command that's going out. This is just debug output coming out from the backdoor right now so I could show it. You can see it going to the torproxy.net and at the end of the URL here, there's a .onion. And that's the actual onion server that it's sending everything to. Very similar on the Linux side. All HTTPS leaving the network. So on the Linux one, we want to go ahead and run a command. So we'll go ahead and do an ls-la on slash. So that's going to take a while to come back. I mean, it is over Tor. It's going to be a bit... If we go over to the Linux client, we can actually see this stuff being transmitted. So it's being transmitted in 200 byte modified base 64 encoding. So it's just in the git request is the actual data coming out. It's coming back. So now here on the Windows side, we'll go ahead and do something else. ipconfigure is what I chose just so we can see it. Now if we go back over to the actual Linux place where the backdoor is, or the Windows place where the backdoor is, we can see it going by. Same thing. 200 bytes at a time, modified base 64. And if we go back to the Linux client, there's the output, or the Linux server. Client server gets confusing in Tor. But we succeeded in sending our complete command over Tor SSL out from the victim. So just to show kind of the speed, we're going to go ahead and do a uname-sa, and this time I'm not going to switch out. So uname-sa isn't exactly big. It's only one or two packets that need to be sent. There it is. All over Tor. And on Windows, there's our ipconfig. Coming back, all the data. And that's pretty much it for the Tor backdoor. Oh, yeah. Talk about this real quick. Oh, yeah. So one of the things we were throwing around in the office was we were going to do a Gmail backdoor, and we never got to it. We just got busy. And our thought was we were going to use DynDNS to trigger when to go check Gmail. Well, then all of a sudden we see this maybe a month ago. The TweetMyPC came out, or at least a newer version that's more functional, where you can control it over Twitter and Gmail, your PC remotely. So if you trust Twitter and Gmail, that way you don't have to deal with Tor, which is kind of nice. If you still don't trust Twitter and Gmail, you can go ahead and use Tor. It's just another way to go ahead and hide the traffic, especially since, how many corporations are still trusting Twitter and Gmail? A lot of corporations are using Gmail as their primary means of communication. So it's just another way to deal with it. It's customizable. Something to play with. Can't take credit for it. All right. So far what we've talked about is we're going to give you a MetaSuite module that will infect targeted PDFs for you. We're going to give you a MetaSuite module that does cryptographically signed Java applets and client-side enumeration. And we're going to give you a backdoor that's SSL cross-platform anonymous over Tor. That's it so far. So of course there's lots of other people out there doing similar things. A lot of us in the Metasploit community in this. And one of our good friends, Dean DeBeer, actually has created a front end that will actually wrap around all this. It gives us a nice fishing framework. And so we're talking about Metafish. This is really Metafish. It's called Assegai. And so here's some generic things here. We got some nice statistics and pretty pieces. You log in. You run all of your fishes this way. It generates templating and you can mimic websites. So here's the users you sent your fish to. Did they click? Did you get a user and password out of it? That sort of thing. And it keeps track of all of the specific statistics, when they clicked, what they were on, so forth. If it can load an ActiveX control, it'll do that and try and get more information from you. If it can load other things, it just continues. And this is all leveraging Metasploit under the hood. And so you load in a CSV of your email addresses you want to send it to. Here's a nice SSL web page that you want to send them to to say, hey, we now have upgraded SSL. Log in. And so here's the setup here. We have a nice screenshot showing if you want to attach a pre-made format here, kind of the two froms. And then in this case, we're showing the email collab vulnerability that MC here wrote. We just want to attach it. It'll automatically create it using Metasploit under the hood and attach it to your emails to send out. And that's it. Everyone we want to thank. Thank you for coming. Thanks. All right. Really quickly, any questions? If not, catch us after the talk. There's a whole track still going on on Metasploit Talks. A bunch of people are going to come up and do their thing. So please stay and hang out and watch that. Thank you very much. Thank you. Thank you. Let's hear it for the rest of the floor as we take a deep breath same step after the break.