All right, so at Black Hat, we did a 150-minute presentation called Tactical Exploitation. At DEF CON, we're going to do a 40-minute presentation called Tactical Exploitation. You may want to record it and play it back slowly. We tried not to sacrifice content, so we'll see how well we can do this. Worst case, after this, we're not going to do any Q&A here. We're going to go to the Track 1 Q&A room, and we can actually do additional demos there if anyone's interested. So, first thing, this talk is called Tactical Exploitation. It's about a different way to do pen testing, a different way to look at your targets. Personally, I've been kind of sick of how folks who are new to the security industry are getting started by running Nessus and following that up with Core Impact or Metasploit, and that's all they do. And this talk is really supposed to be a way to look at those other ways to get in, other ways to get shells, other ways to compromise a network that don't depend on an existing vulnerability or a specific tool. So, first off, who are we? My name is H.D. Moore. I'm a director of security research at a company called Breaking Point Systems. We do network test equipment, and it's not really that interesting to most of the folks here. I'm also the founder of the Metasploit project and one of the core developers. I'm Val Smith. I've been contributing to the Metasploit project for several years, and I'm one of the founders of Fence of Computing. So, why you should care. This talks about a different approach to owning. So, instead of looking for a specific vulnerability, a new zero-day, a new something, basically looking at what you actually have and just using the stuff you already have to get a shell. All sorts of new techniques, new tools, kind of rehashing some really old stuff that still works really well. And it's all, you know, real-world tested and mother-approved. So, first off, the first section of this is going to be about target profiling. Some discovery tools you may or may not know about, hopefully some new stuff in there. One of the fun demos we're going to do today is, actually first published in, I think, 1999 or 2001. And the difference is, I can still get a shell on an XPSP2 box with it, so I don't care. So, when you see things like that that are kind of old research, the point is, now they're really feasible, they're really easy to do, and we've automated the crap out of it. The second section of this is all about getting remote access. We're going to cover things like trust relationships, fun NTLM stuff, all kinds of cool stuff. Okay, so, basically we're going to talk about the tactical approach. Vulnerabilities are transient. They come and go, you know, you'll have O-Day today, tomorrow it'll be patched. So, really, you need a long-term approach to breaking into computers. Target the applications, the things that people use. Target the processes, the things that they have running on their servers. Not necessarily big commercial products, things they write in-house. Especially target the people. The people are a big part of this. Trusts, you know, networks trust each other, people trust each other, accounts trust each other. So, target those things, and you will gain access. So, let me do this. Sorry, we're still trying to figure out how, after we've chopped up our content, how to split it up. So, give us some leeway. So, first off, crackers are opportunities. They're going to break into whatever they can. If you have a job breaking into a bank, and they say, well, you can test this server, this server, and this server, but not this server at not this time, well, that's your restriction. It's not the restriction a real attacker's going to have. So, make sure, when you're talking to a client, about a possible engagement, you make those things clear, that anything they restrict you from doing is probably the most severe thing that is the point of attack. I can't tell you the number of times we've done a pen test, and someone has said, well, you can test everything but our domain controller. It's like, the only reason I'm doing this pen test is to crack your domain controller. So, keep those things in mind. Like, you really want to make sure your client, or whoever you're doing your pen test or attack against, understands that whenever they put a restriction on your scope, they're doing themselves a disservice. And anything you don't test, someone else is going to test, whether they want to or not. So, hacking's really not about exploits. It's all about the data, but it's not about, it's all about the data, but it's not about getting root, or getting admin, or anything else. Sure, so, you know, see what you can go after. Can you go after corporate information, design information, things that the company doesn't want you to have. I mean, getting root on a box is cool, but what can you do with that? A lot of times, having access as a regular user is actually more important than being root. They're logged less, they're watched less. You can move around the network. Hacking is using what you have at hand, not necessarily exploits, to gain further access to more hosts and to more data. Whether it's passwords, trust relationships, hijacking services, authentication systems, and we'll go into detail on all these different things. Security is primarily a people problem. People write your software, people introduce your bugs, people screw up and double-click on the viruses that you send them, people secure your network. So, identify the meat wherefore. So, there's lots of great tools for finding out who actually works in an organization, or what they do, or getting a list of email addresses. There's tons of great tools for this stuff. One that I want to focus on today, just because it's so freaking awesome and not many people know about it, is a tool called Evolution from Paterva.com. Does anyone here actually use Paterva, excuse me, Evolution? Wow, okay, so like one or two folks. Great. Well, this is definitely a badass tool you should be using. So what Paterva does is you give it a piece of information, like a name, an address, an email address, something like that. It'll go through and find everything related to that using about 40 or 50 different backends. It'll crawl Facebook, trying to find pictures of you. It'll crawl Flickr. It'll go through your LinkedIn account and try to find associations. It'll go through a company name related to your LinkedIn account and gives you this really cool graph-like interface you can use to basically dig into more information about a given person, product, domain, et cetera. So, all that stuff. All these types of tools. What they give us is the full name, the username, email address, employment history, phone numbers, list of personal websites. This is a huge amount of information you can grab from these tools. Here's an example of actually running the Evolution GUI tool against HDMore, which you find my email address, you find websites I've been mentioned on, you actually get my phone number out of it. And at this point, if I decided to double-click the hdm.metasport.com link here, it would actually go through and find every other email address at metasport.com or find any other place where that address has been referenced. So, where have I done posting? Where have I, any other place my address has shown up in a listing? Same thing down here. Gmail, the browser fund site, you'll find any site that links to that site and so on. Okay, so this is basically like a little case study of how important this information is when you're breaking into networks. A lot of people tend to focus on an IP address, a range of IP addresses, but this information really helps you out. In one example. We started with a company that we were going after, that we knew we wanted to target, and a specific type of information at this company. What the job descriptions were. So we started searching the internet for what people are likely to be working on the information or the work that we really want to target. So in this particular case, we found an online personnel directory. We found people with access to the data that we wanted. A lot of times you can find people's resumes out on their sites. They don't know it's linked. They have it in some hidden directory. But that's good information because it tells you they're working on the systems that you want to go after. In a lot of big corporations or large targets, the email address is the username. So if their email address is joe at whatever dot com, they're going to be logging in as Joe. So target that. In this particular example, we had a guy, we'll call him Joe Targetstein, and he was a lead engineer in a big semiconductor department of a company. We found his email address in the online directory. Old news groups. Gave us a hint as to what his hosting was. What his username might be. So what do we have? I mean, just searching the internet about a person, we now have a username to target, a hostname to target, to go after a very specific information that we want to get. Not just get root on a random machine. All right. So we're actually going to be flying through a lot of this material pretty quick. The way it's kind of structured is we're going to talk about different ways to do discovery. We start with the people, going to the networks, the applications, and so on. And we're halfway in, we actually flip to actually doing exploits against hosts. So if this sounds like kind of boring remedial stuff. Well, yes, but it's important, and we're going to go into why it's important as we go through this process. The next thing we're going to talk about is network discovery. Basically identifying every asset that your target has. So if you know that a bank, you know what their domain name is, and you're trying to do a pen testing against that site, they may not be the only server they have. May not be the only place they've hosted a resource. You need to go through and find every MX record against every single host. You need to find out what internal networks they have, what branch networks they have. How are the branch networks connected? What outsource services do they run? Do they have an outsource spam gateway? All these things are critical to your asset and critical to breaking in and need to know how to find them. There's a lot of really good tools for this. There's things like, you know, VOs, bruteforcers, there's MMAP, you know, the different open source resource tools, but we're going to go and skip ahead to some things that most folks probably haven't heard of before. So lots of fun things. The neat things about these services is that they're services. They go through someone else's server to bring you information about your target. So in other words, the target has no idea that you're profiling them or pulling information about them at all. Val, do you want to talk about that? Do you want to cover the first two? Sure. All right, that mic sucks. So the idea behind this is to use other people's services to do your attacks. You know, what people currently do is they'll attack an address or they'll attack a network from wherever their lab is. So your target is going to get things in their logs to let them know that this kind of stuff's going on. There's a lot of good websites out there like Central Ops, Digital Point. What these sites do is provide the services that you would normally do by hand off their web page, which means that attacks are coming from their networks. Central Ops will give you like a dossier on your target. Domain name, mapped IP address, who owns the network, who owns the domain name, even in some cases what ports are open for a certain subset of standard ports. A lot of good information. Digital Point is a great site because it'll do DNS zone transfers. Super old thing that still works today. I use it all the time. So this is good intelligence gathering for your targets, and it's about building up a picture of what to attack. All right. This works. Great. So the other two sites I'm going to talk about are DomainTools.com and Paterva.com. A minute ago I showed you the Paterva GUI interface. So if you download their product, install it, try it, you'll see this neat little graph interface. However, they've got a web demo as well, and the web demo basically runs all the same tests but coming from their server, not yours. The next one we'll talk about is Domain Tools. And Domain Tools used to be called WhoIsThatSC? Has anyone actually used that service before? Excellent. All right. Great. Well, there's a really cool feature of Domain Tools, and what that is is any time a domain is registered, they get that domain sent to them by the registrars. And they say, okay, you know, this new domain exists. So we're going to reverse DNS that domain, find out what it resolves to, put it into a big-ass database, and later on we're going to allow someone to query and say, okay, what domains exist on a given IP address? In other words, they keep track of every domain on the freaking Internet and give you a list of what V hosts are on a given IP address for you. So some fun examples of that. If you run Domain Tools, this reverse IP thing against Defcon.org, you find a great list of all these cool different domains running on the same server. You've got DarkTangent, you've got Defcon.net, and Defcon.net's interesting because it resolves to more than one IP address, and we'll go into that a little bit later. You've got HackerJeopardy, and this thing called HackerPoetry. Has that been announced by anybody? Because I'm going to put a bolt in my head if I have to listen to any HackerPoetry. It sounds horrible. And just in case you don't know who the DarkTangent is, you can now go to thedarktangent.com. With Defcon.net, I mentioned before that it resolves to two different IPs. So this is the first IP. If you look at the second IP, we go on to the next slide. And here you can actually see that Defcon.net is actually the same server in one case as zeroday.com, zeroday.net, securityzen.com, and zeroday.com with a Z. And there's actually a bunch of personal domains I ripped out for Jeff and Ping's sake, just like Republic of Ping, all these other great ones. So I pulled those ones out, but they're entertaining to look at at least. So if you're ever mad at me, I'll tell you why. If you're mad that someone else stole zeroday.com, they're not using it, you can bitch at Jeff. But apparently, he's had it for like 10 years. He's had it so long that when he first registered the domain, all the Wares kids were like pestering him, trying to say, hey, can I use that for my Wares stuff? Because you know, zeroday used to be about Wares, and now zeroday is about security stuff. So he has all these security guys saying, hey, can you use that for my security stuff? So I suggested that we use it for kind of like a power sellers for zero bay. So if you're a real power seller for your zeroday, you can actually get an email address at odata.com, and hopefully Jeff will go with that. So what does this get us? These different sites will do proxy DNS probes, they do zone transfers, you can list a virtual host for every IP address, you can do port scans, trace routes, all kinds of great stuff. And the best thing is none of it comes from your system. So even if the client says, hey, you're not allowed to test this, or hey, I only want you to do tests against this IP, you're not testing it, they are. So I'm just saying, you may not be in breach of your agreement, but it works. So those are kind of the benefits. The next thing we're talking about is active discovery. And we're still talking about network discovery. How do we figure out what IPs they use, what networks they use, where they come from, how they browse the web from, what's their NAT gateway, all those types of information. One of my favorite techniques for this is just doing SMTP bounces. Just about anybody with an Exchange server configured will bounce an email back out from their Exchange server with usually the internal headers, internal host names, internal version numbers of exchange inside the headers of that email. So don't be scared just to email your target. I mean, they get so much freaking spam each day that if you send them a jumbled email, they're not going to know the difference. It's great. So abuse that. Sorry. Go back. Also, there's things like definitely brute force vhosts, so definitely even though who is that SE or domain tools doesn't show what host names are on a given IP address, try connecting to and just sending a host header of intranet or www or admin, things like that. You'll find all kinds of great cases where the user had misconfigured the server and actually hosts their intranet site on the same physical IP. But assume that the DMS is there. The DNS will do the work of hiding that from the external users. And finally, you can actually just watch outbound DNS traffic. If you send someone an email from a domain where you control the resolver for it, so let's say you create a fake subdomain called mysubdomain.metasupply.com, you send them an email from Bob at mysubdomain.metasupply.com, or sorry, bob.anothersubdomain.thatsubdomain.metasupply.com, when that mail server tries to bounce it back to them, it's going to do DNS lookups for that. Through that technique, you can figure out what DNS server and what, excuse me, not only what type of DNS server. Where that DNS server is located inside their internal network by looking at those queries coming in. So, if they're using an external server for all resolution, you'll see that, because they'll get queries from external IP address that's not related to their NAT gateway. If it's using an internal DNS server, like Microsoft DNS, something like that, you'll be able to not only find out that they're coming through the NAT gateway, but you'll also be able to realize what type of server it is based on the port sequence and the XID sequence. So, here's an example of messing with RSA, because RSA is awesome. We all think RSA is great for security, right? RSA is security. I mean, hell, they've got security in their name. All right. So, RSA is nice because they run it in a bunch of different mail server products inside. And if you email just a random unknown user at their domain, it'll bounce back and it'll actually have the internal IP address to the mail relay, not even the headers, in the freaking subject. Like, they'll say, hey, this bounced out of 10.100 to 8.152, and great, thanks, RSA. Okay. So. Okay. So, if the network is the toast, applications are the butter. This is about application discovery. Every application that your target is running is a potential entry point, whether it's commercial applications they purchased, things they've written in-house. So, finding these applications is the trick. A lot of times, you're not going to get some high-profile Windows remote exploit. You're going to go after an application. So another point to this is slow and steady win-to-de-face. A lot of times, people will scan, you know, large blocks of IP addresses, every port, and that's really noisy. You know, we like to do stuff like, for example, that command up there is an Nmap command that says don't ping the target, scan for a specific port, in this case, the MSSQL port. This gives you a ton of information without making a ton of noise. What does it tell you? It tells you most likely what the operating system of the target is. If it's running MSSQL, it's probably Windows of some sort. It tells you that they're running MSSQL and that they're available. So, you know, think a little bit different. A lot of people will assume, oh, every attack's going to begin with a full-on Nmap port scan. And that's not necessarily true. IDSs will detect that, try to avoid it by doing slow, targeted, one-shot, one-kill type attacks. So one good example of this is one of the targets we were working on had an internal application for doing software licensing and distribution. They'd written this in-house. It was installed on something like 10,000 computers at this company. We spent a couple of hours. We got a copy of this. Spent a couple of hours with IDA, Alidebug, checking it out, and it turns out they had a static admin password hard-coded in this application. So every host on the network used the same admin password to get their software and their licenses. This means every accessible node was owned. We didn't use a single exploit. We were just targeting the application. Do you want to switch, please? Yeah. Yeah. All right. So who's heard of W3AF? Okay. A few folks. Great. So kind of what I'm trying to do with this talk and with some of the parts of the talk is talk about tools that are really great that a lot of folks don't really know about yet. And W3AF is a good example of that. It stands for the Web Application Attack and Audit Framework. It's this neat little read-line-enabled shell, and you can actually do all these cool things like brute-force v-hosts, brute-force directory structures, brute-force names, all these things you normally want to do with websites. So you normally have to use an external tool. But you can do it all from this quick little console, and it's easy to use. I mean, it's kind of like Metasploit, so I like it in terms of how the console works. So I've been calling it Metasploit for the web. But unfortunately, it's written in Python. Outside of that, I love it. And I'm sure he feels the same way about Metasploit being written in Ruby. So we get along on that. Finally, there's actually a whole new set of classes in Metasploit 3 for writing your own quick vulnerability scanners. If you want to write a vulnerability scanner that connects to every host on a certain port and sends some data to it, receives data from it, does something to it, that takes about five minutes in Metasploit 3. You can find examples of that under modules, auxiliary, scanner. We've got one that gets the version of every box running with SMB open, like 139.4.45. We've got another version that'll go through and find the web server version for every host in the local network. Another one that actually mask-defaces every host in the local network via put request. So it's whatever you want it to be. But if you're going through the same steps over and over again of writing something that parses CIDR mask. There's connections. There's error handling. And all you're really doing is connecting to a service and doing a probe. You can do that in about three lines of code in the Metasploit 3 mix-in modules and templates. So keep that in mind if you're writing your own stuff. It's really good if you find a custom application or an evil misconfiguration on a customer network and you want to find out what other system that applies to. So let's say a default password for a web interface. Say, okay, well, they've got it set to this here. I want to make sure it's not the same password set for every other node. And it has threading support. So you can set the number of threads to be like 1,000 or 256 and kick off that many hosts at the same time. And the whole thing is kind of done for you and reporting is all nice and whatnot. So just keep that in mind if you're doing your own application discovery. The next step is client app discovery. And this is a little bit trickier because you can't... The clients have to connect to you for you to get that information. However, client apps are so vulnerable that they're definitely a good target. And a lot of folks aren't actually trying to do profiling of client applications during a pen test. And they're really easy to fingerprint, but you have to get them to do something. But I mean, excuse me, client apps really are your last chance entrance. If you can't do anything else... You should be able to at least exploit a random client. And the reason for that is the admin can really focus his time on a couple of servers to lock them down, but he really can't focus his time on 10,000 users or 50,000 users or even 30 users. So there's lots of different probe methods you can use to profile client applications. The most obvious one is use mail and email link to... Excuse me, mail a link to a website to every client. Abuse the all at and everyone at and team releases. So if you know the company of software, try emailing SW team at. Try emailing everyone at, all at. These folks get so much spam that even if they see a weird email come in, it's not going to raise that many flags, especially if you make it look like a Viagra spam, something like that. You can also do things like send a message disposition notification emails. There's things that when you get an email and it pops up saying, send a request that you notify when you receive this. There's really, really annoying things that just about everyone here probably ignores. There's actually a huge swarm of corporate clients out there that will autorespond to these. So just because you're smart enough not to enable that stuff doesn't mean they are. So definitely give a shot with those as well. And finally, once you figure out the NAT gateway of your target, try searching just via Google or anything else for the external IP address. A lot of times what you'll find is that IP address will end up in exposed web logs. So you can find out not only what types of browsers they use, but whether or not they like goat porn. I mean, anything. You can find out what sites they visit based on that. Finally, so this is actually a technique and kind of a process that a lot of folks really don't do. When you're focusing on... Excuse me. When you're doing a pen test. When you're trying to focus on specific servers, IPs, versions, software, what you don't look for is whether or not certain activities occur. Like for instance, how many times have you seen a completely locked down network, but then when you go into the network, you'll see they're doing an anonymous FTP transfer to an external host every night at a certain time. I mean, that kind of stuff, it's a huge weakness, but at the same time, it's not something you can only look for. So what I want to talk about are a couple of ways you can actually look for this type of activity. Actually identify the processes being used to actually attack those protocols and attack those types of weaknesses. Good examples that are looking for large IP ID increments in the middle of the night. So who here is familiar with IP ID scanning? Great. A lot of you guys. The general premise is that a lot of different hosts, each time they send a packet, they'll increment their IP ID counter, and that'll wrap after 64K and so on, but if you ping that host and see the IP ID coming back and then ping it again, if you do the delta between those two IP IDs on a host that supports this type of incremental IP ID, you can determine how many packets are sent between those two pings. So you can do all kinds of great things. You can basically do a remote traffic monitor of any host you want through this method. Additionally, a lot of FTP servers, and especially Microsoft FTP, they support a command called site stats. And what this will return is the number of times each command has been executed on that server. And this gives you a great amount of information because you can determine when uploads are being done, when deletes are being done, when people log into the server. You can start getting a feeling for, okay, if I want to start hijacking data ports, what's the time to start scanning for it? And finally, you can actually look for the IP ID. You can look for the last modified header on static content on websites to figure out when they do automated transfers or automated backups. A couple of cases I've seen, people actually delete the entire web directory before they sync it over each time. So you have about a 30-second to one-minute window where things like the .htaccess file aren't there, where there's a directory index listing, but they delete and index the HTML. So basically, by going through the web route, and this doesn't work for dynamic content, and doing basically a head request against each image in the directory, compare all those timestamps. See if they're all within a second or two of each other. Or see if they're a few seconds apart or a minute or two apart. Now try it again the next day, the next day, the next day, over a week-long period. What you may find out is they're actually doing a full backup or a full upload every night at a certain time. Now you know when you want to start W-getting that site as fast as you can, trying to find a window where the .htaccess isn't there or it's otherwise misconfigured. So are there any existing tools for this stuff? Not that I've seen. Correct me if you have seen some in the Q&A session, hopefully. I'd just tend to use HPing, Pipe2, a log file, basically. I don't know. Or Netcat or any other tool for the site stats stuff. Here's an example of the site stats command running on ftp.microsoft.com. And this is just one of many, many nodes inside the FTP cluster. Something to keep in mind is this node's only been up for 47 days and it's had over two billion user commands. So they get a lot of FTP traffic. However, they've had two billion users do the user command, but they've only had 3,035 store commands. So if you basically profile the number of times a store command has been run over a period of time, you can determine when they're actually done. They're doing their uploads. And when they're doing their uploads, you now know you can actually interfere with that by hijacking the data port. And I'll talk about hijacking data ports and that stuff a little bit later on. The point of that is even if you can't steal their file, you can still destroy their backups. And you see some other commands like delete, make directory, et cetera. The next example is a website called hacker.com, which I picked right before Black Hat because it was fun. I started profiling this site around 8 p.m. and I stopped it around 6 a.m. or something like that. Or probably 10 p.m. is when it started. So this is basically... The delta between the IPID increments accounted for the integer wrap across about a nine-hour period, something like that, nine or 10 hours. So around 10 p.m., you can see it spikes to about 3,000, but the baseline traffic is pretty low. As I get right around midnight, you see a huge spike in traffic. This is actually some kind of automated backup process. There's somebody just debiting the crap out of that site right around midnight. This is the kind of thing you want to look for. If you're profiling a server and you want to find out when they're doing large backups, when they have some kind of data recovery routine running, this is how you can do so. You can also find other types of activity through this method and be like, hey, something really big happens at this time. Let me know what that is. And this little graph was actually generated with a little one-liner Ruby in five minutes. So if you want to know how to do it, let me know after the talk and I can show you the code for it. Then you see the traffic kind of lulls down for about six, seven hours. And finally, you can see everyone in the U.S. starts to wake up again and the traffic builds back up. So if you're curious how much traffic a site has and their server does sequential IPID increments, this is a great way to do it. What you may see sometimes is that you get two or three sets up. One of the IPIDs is back. In that case, you're actually hitting a load balancer. So one server will respond back with 1,000, 1,001, 1,002. Another one is 9,001, 9,002. And you have to kind of keep track of both of those at the same time. So on to the external network. That was kind of our discovery techniques or discovery phase. Just different techniques to keep in mind when doing a pen test to profile services, find users, find networks, find applications, just some quick tips. The next section is all about actually breaking in. The first thing we're talking about is external network and we'll work our way inside. The internal side, usually called the crunchy candy shell or whatever you want to call it, what the administrator usually thinks they're exposing are the host they specified. This web server, this mail server, this application server. What they're really exposing is all those things plus their VPN services, plus their proxy services, and plus all those different client-initiated sessions. A lot of folks don't realize that the public NTP servers, if you send a command called monlist to them, they'll come back with a listing of every IP address, every client that's actually connected to them within a certain window of time. There's only an infinite number of public NTP servers. What you can do is build code that basically goes out and pings each one of these servers with this monlist command every five minutes and not only do you find out when a given organization is querying the public NTP servers, how many different clients are querying it and whether or not those clients are inside or outside of the firewall. You can just help out by looking at the source port. NAT gateways will translate that from the normal source port, which is 123, to something else and it also gives you a window where you know if you send a spoof packet from that time server to that host on that source port. You'll get back to that time client and now you can actually start doing attacks against those NTP clients themselves. Any case where you can see the outbound UDP traffic and see those source ports, you now know what the NAT gateway mapping is and you can actually target those applications. I mentioned FTP before. Does everyone here know how FTP works? You realize there's two connections. There's control, there's data, the data ports allocated based on either the server or the client. Active FTP, the client opens up a listener for that and passive FTP, the server opens up a listener. That's basically it. Going through a NAT gateway, there's all sorts of problems with active FTP. I'm not going to talk about them too much, but if you see large spikes in traffic, try scanning for the ports used by the NAT gateway, like 32K to 45K or even 1024 to 64K, just repeatedly, trying to find those open ports. A lot of times there's different vulnerabilities with how NAT gateways handle active FTP and I'm not going to get into those here, but just keep those in mind when you're doing this kind of testing. Finally, passive FTP, this is much more common. This means the server opens up a port and the client connects to that server. If you can also connect to that server, log in as anonymous or you just port scan the crap out of it, you can actually predict the ports that are being used in a lot of cases. Microsoft FTP is a really good example of this. Their FTP server will sequentially allocate those data ports no matter what client it is. If you connect FTP to Microsoft.com and you send the passive commands, it'll come back saying, port 100. The next client who's doing it will get port 101. The next client will get 102. Microsoft FTP is smart enough that if you connect to that data port instead of being the real client. It'll kick you off, it'll say, sorry, I'm not going to send you that data, that wasn't your data port. However, you'll still break the backup, you'll still break that transfer. What you can do is if you profile a backup process running in the middle of the night and you know what endpoints are, you can find these data ports and you can steal the data ports before the client can get them. In doing so, you can break their disaster recovery system. There's a tool I wrote for this called PassiveAg.pl. It's been around for a really long time, but it still works really well for this type of thing. Finally, moving on to attacking web servers. Don't ever make sure when you're doing an assessment against a website, you always check for things like slash old, slash backup, slash admin. This should be old hat, but you can find all kinds of really cool things with it. Example, Cray.com for the last five years has had this directory called slash old. Until about a year and a half ago, it actually had directory indexing enabled. Inside the directory was a five gig file called backup.tar. Any guess what that was? All right. They finally made the directory for it. Excuse me. It's disabled directory indexing, but there probably still is a file called that. I have no idea. I didn't actually try to download it. That's an example of a server that's been misconfigured, just an old directory there. Some admin probably hasn't thought about it in 10 years. Look for that kind of stuff. It's really, really prevalent. Another example that I see a lot is source control files being left in the web route. Here's a contrived example that I found on the internet, just some random website that happened to have it. Basically, when you check out a subversion tree or a CVS tree, it usually brings out, it brings its source control directories with it. Those directories give away things like the root of the tree, where to log in to actually get that source code, the files in any given directory, things like that. For a long time, freshme.net had the CVS entries file exposed. It was awesome. Finally, Scoop finally removed it, so that's solved. Another good example of that is ebay.com. Almost every one of their virtual hosts had CVS slash entries exposed for a really, really long time. About a year and a half ago, they finally fixed that as well. That was useful because you didn't want to see what little new advertisements coming out. You could do that on the image server, stuff like that. A couple quick tricks, and then I'm going to turn it over to Val to talk about a case study and a quick example. If you see a system that's using, excuse me, if you're doing a test against a web server and you're trying to figure out whether or not it's behind an Apache reverse proxy, where you have Apache working in proxy mode and it's actually proxying it back to an internal server, the easiest way to do that is just do a get request with percent zero zero after your slash. You're done. The Apache server will actually puke back an error saying, hey, could not find this file. This version, so and so and so and so. If you're testing an IIS server and now all of a sudden you get an Apache error, now you know you're going through an Apache reverse proxy. Another configuration I see a lot is Apache's dynamic virtual hosting. What this is, instead of having to create a virtual host configuration file for every system you have on your large ISP server, you say, hey, just look in the sub directory for any file, excuse me, any directory named the host name the client sent. If you want to add a new vhost, you just do a make directory, www, Bob's house of hardware dot com, whatever you want to call it. Unfortunately, what I see a lot is the global configuration for Apache will have index directed, excuse me, indirect, index listings enabled for directories, and each individual sub host or vhost may be locked down, but the main configuration is not locked down. What you can do is if you get slash HTTP 1.1, host colon percent zero zero slash, what that will do is actually return you the index of every vhost on that server. You actually get served the directory below the vhost directory. It's a neat trick when you're testing ISPs. With that, I'm going to turn it over to Val. Thanks, Dan. Okay. This is just an example of things to think about when attacking web hosts, which are pretty good targets. In this particular case, we had a web host with thousands of sites that they were hosting, both virtual hosts like whatever dot com as well as tilde slash user. All these hosts had CGI scripts, applications for the customers. We found one particular CGI that they had put up as a demo to show people. People who were going to sign up with their company, what kind of CGI scripts you could run on their server. The great thing about this particular script is it had a directory traversal problem. This isn't a remote exploit. We can get a show with this, but we could gather a lot of intelligence about the server. In this case, we were able to basically go through the whole server into every directory which the web server user had access to and see what they had in there, backup files, other CGI scripts. Eventually, what we found out was they had hundreds of maybe even thousands of CGI scripts that were either user written or just downloaded off the internet like web hints or whatever. What we could do once we had identified these scripts is go download them ourselves and either write bugs for them or find bugs that were already well known. We had hundreds of ways to break into the server. One of the great things about this particular server was that it was Solaris. It turns out that Solaris treats directories. It uses files. On a Solaris box, you can do cat directory name is the same as doing an LS inside the directory. The nice thing that this lets us do is over a directory traversal bug, we can treat all the directories on the Solaris server as files and enumerate everything inside of them even if they don't have indexes available for us. Again, the %00 byte destroys everything. It's great. We're flying through material here. We just want to make sure we finish in time, but the next thing I'm going to talk about is DNS servers. When you're doing a pen test, make sure you brute force not only external host names such as www.domain.com, mail.domain.com, just go through the whole dictionary, but also brute force internal names. Look for sites called intranet.local.lan and things like that. Intranet.what are the domain names but .int or .lan is the TLD. A lot of folks don't split their DNS correctly. Something you may also notice is a lot of the transaction IDs used by these DNS servers, or DNS servers, are not split. These DNS clients are really predictable. For example, recently the bind 9 server had a PRNG attack demonstrated where you can actually, once you know one transaction ID in the source port of the server, you can then find out what the next transaction ID is. What that gives you is the ability to spoof responses to a DNS cache and inject whatever host name you want into their cache externally. These are really good attacks. I'll talk about some ways you exploit this stuff a little bit later on, but it's pretty obvious that you can replace someone's DNS entry that bad things are afoot. Also birthday attacks, they work against all sorts of things. Basically, where you basically have to split your DNS. You just brute force the number of responses you send back and eventually get it to hit because there's only 64K possible transaction IDs and the source port's usually predictable. You can almost guarantee you can hit a birthday attack with any server that doesn't do anything specifically to prevent against it. A lot of these new DNS servers we're seeing, I think Mara DNS is okay, but a lot of the newer ones that are popping up as alternatives to bind don't protect against these types of attacks that have been around forever. One more thing to keep in mind is a lot of VxWorks servers and VxWorks based upon VxWorks, VxWorks appliances are used for things like VPNs, proxy servers, routers, things like that. All those little embedded network devices. The built-in DNS client in the VxWorks product has sequential transaction IDs and sequential source ports. If you can convince any of these devices or anything running VxWorks to do a DNS query, you can spoof the response back in and basically forge the response to it. A lot of security vendors are actually basing their products on these VxWorks OS and keep that in mind. If you see that, you can probably inject random responses or spoof responses back to these clients. For the most part, these products don't do a whole lot of DNS resolution internally. They usually hand it off to something else. If anything does, host-based checking, that's one way to get around it. Finally, a lot of alternative DNS implementations will actually, if you send an extra response to the data you send back, it will also cache that response. You may be asking if you're a BobToast.metasupply.com, but you can return back BobToast.metasupply.com and www.cnn.com. It will cache that second entry as well. Just things to try when you're testing DNS servers. Ten minutes. All right. We're going to haul ass. Authentication relaying. One of the great things about NTLM is that no matter what authentication implementation you have coming inbound, you can redirect that to anything outbound. For example, if you have an NTLM-enabled SNTP client connecting to you as an SNTP server and it tries to do NTLM authentication to you, you could turn around and connect back to the SNTP port on a different host entirely. Just basically pass the authentication straight through and use their SNTP client to authenticate against an SNP server. By the same token, you can use an SNP incoming connection to authenticate an external exchange website or any other IS server that supports NTLM authentication. If you can get any sort of NTLM authentication coming inbound, you can then apply that to either the target itself, excuse me, the incoming connection server itself, like going directly back to the client, or to an external host or any other host that supports NTLM because it just passes through this generic block for the most part. We're going to go into more of this later, but keep that in mind. There's all kinds of great things you can do with it. Finally, a little bit about social engineering. This has been beat to death, but make sure that if you're charging $50,000 for a pen test, you can afford to burn a couple CDs. If you're charging $100,000 for a pen test, you can afford to get a whole bunch of USB keys and load them up with some awesome software that just happens to be a backdoor. If you're doing a million dollar pen test, you can go out and buy a whole bunch of Nokia N770s. You can buy a bunch of N800s. You can buy Sharp Zorises. You can send them off to each of the CEOs saying, hey, you won this new sweepstakes. Welcome to that conference you presented at. You are the winner of this new award. Enjoy your Nokia. Then you think about these Nokia devices, and I'm sure Dave Attell will attest to this because he has a product based around it, is they run Linux, and so they can run your exploit tools. You can put a whole set of backdoors under one of those Nokia devices, hand it to the CEO, and give him directions of how to sync it to his network. He syncs it in, your backdoor runs, and everyone's happy. Another example I saw that was really neat is actually embedding an open WRT core into an e... UPS battery. So you rip the battery out. You put an open WRT core into it. You put an Ethernet switch into it. You plug it in, and you just walk into a building, throw it over your shoulder, and say, hey, I'm here to fix the printer. You go into the printer area. You unplug their UPS, if they have one, or you just put this one in line, and now you've got your own little Linux server on the network. So it's... I'm not going to take credit for the idea, but I think it's really cool, and definitely keep it in mind when doing physical tests. So on to the internal network. First of all, some NetBios names are magic. There's a name called WPAD. Anyone know what that means? No. Okay. Well, a couple folks do. So WPAD is like the web something auto-proxy discovery. Actually, web proxy auto-discovery, something like that. That's a name that's looked at by default by Internet Explorer when it's set up in its default configuration to automatically detect your proxies. So if you say, you know, automatically detect your proxy, it'll look for a host called WPAD. And actually, it'll... There's been different bugs with it. We don't have time to cover it. But if you want to see a really funny website, go to WPAD.com, because for a long time, they received... They're actually the top-level WPAD server for the whole Internet. And they had fun with it. There's also another magic host named the CA license, which means if you have a host called this on the network, anybody running a CA product will try to connect you for licensing updates. And you can cause all kinds of hell. So the next step. So WPAD is magic, because you can exploit this web proxy auto-discovery technique. You can basically convince them to connect to your web server to figure out how to proxy their outbound connections, which is awesome. However, you can also do that via DHCP. If you want to do that, you can do that via DHCP. You can do that in the case where you've got a Microsoft DNS server running DHCP. You can do dhcpcd or dhclient with dash H option of WPAD, and it'll actually register your host name of WPAD in the local domain. So you can quickly back... Excuse me. You can quickly become the outbound web proxy for everybody in the local network with this one command. It's lots of fun on Microsoft networks. Next. So now we're going to talk about a practical example of hijacking NTLM to get a remote shell on a fully patched Windows XP Service Pack 2 system. And it's pretty straightforward. Yes, it's based on SAP Relay 2, but it's all done in Metasport. It's deployed in Chinese, and this is really old code, back in 99, 2001. But now I can do it, and I can read the code. So first thing you do is man in the middle of outbound traffic. Lots of different ways you can do it. We talked about WPAD. You can also just ARP spoof, et cetera. You can have a rogue access point to sit around the airport. What do you want to do? You can actually inject it into Tor connections and do this against Tor users, whatever you like. Next. You want to redirect them to an intranet website. And this is intranet in the sense that they'll still connect to you for the intranet side as well. Because you designed your proxy server to redirect all traffic, even internal traffic, back to yourself. What you do here is get around the zone bypass. So when they try to browse the internet site, you send them to an intranet site. And then from the intranet site, you go to this, which is actually a UNC link to an SMB share. So in IE 5, 6, and 7, you can just do an image source tag, backslash, backslash, IP, share name, something with JPEG. In Firefox, before 2005, you can just do mosaic on URL, colon, file, slash, slash, slash, slash. That's actually a bug. They fixed it. But they didn't fix the last case, which I'm not going to talk about. Finally, you can use third-party plug-ins to do the same thing. Force them to go to UNC URL. The goal here is to get them to do an SMB connection to your system. The reason for that is once they connect to your system, you can connect back to them. So when they connect to you, you connect back to them. You ask them for their challenge. Say, hey, I've got this cool challenge key. Why don't you authenticate against it? And they go and do that. And you pass it back. And now they're authenticated. And this actually works really well. Like it's not a trick. It's not a bug. It's not anything else. That's just how SMB authentication works. If you don't have sign-in enabled and a couple other caveats. But it works on most systems by default. So finally, now you've got an authenticated SMB connection on their system. You disconnect them. You keep the authenticated session and use that to connect to admin dollar. Upload your shellcode inside of executable. Then use the service control manager to start that shellcode as a service. And then enjoy your remote shell. And that's all there is to it. It's pretty damn simple. And it works. So I'll show you. So over here we've got a Windows XP Service Pack 2 system. It's fully patched as of this morning. There's nothing fancy with it. It even has the firewall turned on, but it does have file sharing enabled. It's also joined to a domain. So that's one of the caveats you have to do to exploit XPSP2. And the user has to have a password set, which is also pretty common in a domain or corporate environment. So what we're going to do back over here is... That's good. Okay. So here's a little shell script. What a shell script does is it starts up a NetBIOS named even, which basically advertises my name as WPAD. And you can do this a billion other ways too. This is an easy way to do it. Next, we're going to start up Apache. And Apache is going to start up. It's going to serve a file called WPAD.dat, and that file is going to have, let's see, one little JavaScript function in it that says, no matter where you try to connect to, go through me as your SOC server. So we just return SOC to this little syntax. You can look up a lot of stuff about WPAD, great Wikipedia article, if you want to learn more. So the next thing we'll do is run MSF console with this RC file. This RC file runs a fake SOC server, so we become that SOC server, which will then, no matter what page they request, will return the image source, you go backslash, backslash, UNC URL, it's my SMB server. And then we run our SMB relay exploit. And this thing will use the shell reverse TCP payload and use that as a payload if they connect in. So we're just going to go ahead and run that. So MSF console, dash R, the RC file, there we go. So this cycle will run up. So while that's chewing through, I'm going to go ahead and on a command shell over here, I'm going to show that if I type ping WPAD. It's going to resolve to that host, and it's doing that via NetBios. So if you're on the same local network as any Windows box, you can do the WPAD method, and I am an idiot. Set that up, all right. So here we go. So now the exploit's running. You can see we said L host, L port, normal variables, everything's going here. It's all running in the background. So now from the vulnerable XP system, what we're going to do is try to browse the internet. So go www.midgetsex.com. Who knows? There could be something cool there. Hopefully it doesn't actually exist. All right. So now you can see it says waiting for. What happened is it went out, connected to my Apache web server, downloaded WPAD.dat, then decided to connect to my SOX proxy. My SOX proxy said, yes, you have connected to Midgetsex. Welcome. And then it served up an HTML page that basically just had a UNC URL. And now in the background now, it's trying to negotiate SMB to my SMB relay agent. My SMB relay agent's connecting back to them and owning the crap out of it. So here we see all kinds of crap. So we see here's the authenticating in, we're saying, your authentication failed, give me a real password. It goes, okay, here's a real password. Thank you, drive through. So we authenticated, we connect to admin, share, upload our shellcode, do that, do that, do that. Here we see in our console, we actually got a shell. And Windows went ahead and tried to keep doing it a few other times. We said, nah, we already got a shell on you, we'll leave you alone for now. So now on your console, which you can have multiple background shells, do an entire network at once if you feel like, sessions-shell, you say, hey, we got a session, session-i1. We're going to do that. We're going to do that. There we go. Session. So pretty straightforward. So just to prove that it actually is the right shell, echo, we, hello.txt. We go over here, look at the desktop. We see we got a broken image link. And now we go look on the desktop, we got hello.txt, and it says, we. All right. So we're running short. We're running short on time. And I don't want to take up any more of Val Smith's demo time. So let me get through this real quick. Back where we were. We've got a good 30 minutes worth of material still, but I think our time's up. Our time is up? All right. We will move our entire presentation into the QA room. So everybody cram in there.