network ice and the chief architect of black ice intrusion detection system and well be discussing today is some of our experiences of running ids systems in the battlefield in particular I'll be discussing how to evade or how people are evading intrusion detection systems and then I'll be introducing some new methods that we've been working on that allow hackers to implement new methods of intrude of evading intrusion detection systems to start with I'm going to talk about a little bit about the background and the surrounding areas of intrusion detection systems and how this applies it's basically marketing drivel but you'll have to bear with me for a moment ideas systems are sort of like weaponry in the war against hackers but they're kind of like flaky weaponry it's kind of a tank that you might take out to a battlefield and enemy soldier walks up behind it aims a gun at it and the tank explodes this is like in the movie Kelly's heroes from 1968 where Donald Sutherland plays oddball who gets behind a German Panzer tank and in the small little missile at it and then the tank blows up and the way he was able to do this was by a foot soldier running around behind the tank rather than the frontal assault where all the armor is now of course all tanks can be blown up the only question is is whether you do it with a nuke or howitzer or with a handgun ideas are a lot like radar systems that trigger on the the passing flight of flocks of birds and automatically launch missiles at them while at the same time not detecting enemy fighter planes that are bearing down on you during the Iran-Iraq war the Iranian the Iraqi insult and not the Iran-Iraq war the Gulf War Desert Storm the Iraqi soldiers were famous for throwing down their weapons and running away this was their primary battle strategy so these analogies in the weaponry in the war against hackers ideas systems are a lot like this they they work well in the laboratory I can bring my ideas system in I can run an exploit script I can say see my ideas catches this attack but when you put them into the real world into the battle conditions they start to fail they start to flee the battlefield they blow up from behind they trigger on the passing flights of birds now here is the the Pliking marketing pitch network guys right now we estimate is the the market leader in intrusion we're only like number five in terms of the monetary value whatever from 1999 we believe that more traffic is being monitored by black reduces detaps and this is partially because I s P t pid could I because we can keep up with the traffic where a lot of others fail. But it's also because we've got it running on 2 million desktops. We have two versions. We have Black Ice Defender, which is a personal IDS that runs on a desktop computer. And then Black Ice Sentry, which is a traditional network-based intrusion detection system like Snort or RealSecure or NetRanger and so forth. And then the competitions products. First of all, the exploit signatures are not as extensive as they would have you believe. There's lots of decodes that just sort of say, well, somebody logged in and that's about it. There are lots of port numbers they trigger on. There's lots of CGI strings you just add one right after the other. When you get beyond all that and really hunt down the exploit signatures they have, they're not nearly as extensive as you would think. Even ours, if you go through our list, they're not as extensive as you would think. If you go through our list, you'll see lots of CGI programs, lots of ports. Though we do have lots of other good exploit signatures. Existing technologies are easily evaded by really commonly available programs. These aren't really uber-hacker programs. They're things that you can download, configure, and run, like Fried Router, Whisker, and other stuff. I'll also be introducing some new techniques that really will put them in knots. And they also die. Pretty gruesomely under heavy load or complex traffic. As I like to say, they'll easily flee the field of battle like Iraqi soldiers. To start my talk of the technical side of things now, now that I'm done with the marketing stuff. You see that the marketing department pays for my flight out here in my hotel, so I have to sort of throw them a bone here. What is a network IDS? Fundamentally, it's shown in this little diagram. You have a hacker, and he wants to break into your website. He wants to break behind your website into your corporation. Your external presence is the web server, the FTP server, your name server, your mail exchanger. The network IDS will monitor the network traffic, looking for signs of intrusion against your computers. Hopefully, it will tip you off that someone is actively attacking you. And if they break in, it will tell you how they did it. However, a network intrusion detection system, In both cases, there's a lot of the data we have on the internet, Is there a Sean Hedges in the room? Some of you might know this already. He's lost. The Feds are looking for him. Is there a Sean Hedges? So, in the previous diagram, I tried to emphasize the fact that, network intrusion detection is based on private and private notifications. detection systems detect that they're happening but don't necessarily protect you. They're sort of a early warning system and then a post-forensic system. They're like a detective that doesn't witness the actual crime but tries to piece together the clues afterwards. It's like the Columbo movies and television shows where he comes in 15 minutes after the crime has happened and then he tries to, over the course of the show, pieces together the clues until he figures out what happened. And hackers are really, really good at, at least really good hackers I should say, they're really good at smudging these clues and hiding their fingerprints. So a network IDS system is like a detective or a sleuth and it really isn't like this psychic system that sort of knows everything that happened and tells you exactly that you've been broken into or not. They detect. It's not really a protection thing. It's an enhancement to your protection. Now I'm going to start talking about classic evasion techniques. The first one was written I'm not quite sure when it was written, a year and a half ago, two years ago, called FragRouter. It was written by a reseller of NFR to really irk the market leaders like Cisco and ISS. It's a very simple utility. You can download it, run it. What it does is, as shown by the little two diagrams here, is it fragments the attack. Most IDS systems bring in a packet, look for a signature, and then say, well, is it a sign of intrusion? A common intrusion is the PHF attack. It's the one that we all use now as the sort of the standard one that we use when we describe signatures. What FragRouter does is it fragments that across three different packets. So none of the three packets now contain the signature CGI bin PHF. You see a little bit of the CGI bin and a little bit of the PHF in each packet, but not the whole signature. This causes the IDS system to be completely silent. FragRouter also goes through a lot of firewalls. Most firewalls have a configuration option saying disallow fragments, but it's frequently not configured correctly. And since you can fragment packets so that they don't get damaged, or they can't get a good reading on the port number, they'll allow the packets on through. FragRouter requires an extra machine. The hacker sets up this extra machine on his own side. He then passes all of the traffic on through, and the FragRouter then automatically fragments whatever it is. It could be any attack. The IDS at the victim's side can no longer detect the attack, and is pretty much silent. Some IDSs at least give a little bit of indication, and will say, I'm seeing an excessive number of fragments, but they have no visibility into what's really going on. Nmap, which is a common utility that pretty much is the first thing a hacker's going to run against your site when they're attacking you, has a couple of stealth features. The first stealth feature of Nmap was this stealth scan, or half open scan, or sin scan. And what it does is it doesn't complete the TCP connection. It starts it, but doesn't complete it. And this evaded lots of host-based intrusion detection systems, because they would only start the logging process once the connection had completed. But from the network side of things, this doesn't evade network intrusion detection systems at all. We see all the sin packets. As a matter of fact, when we see lots of these connections not being completed, we actually can tell that it's a stealth scan. But there are other stealth scan features of Nmap that do evade intrusion detection systems. And that's, again, using the fragmentation technique. As you fragment the sin, and then the IDS system can't put it together and figure out what it is, and doesn't know what it is, and doesn't detect the sin scan. And it evades some firewalls, it evades some IDS systems. I recently tested one IDS from a vendor that claimed to support a reassembly, but yet could not detect the Nmap sin scan. The fragmented one. Another classic evasion technique is to flood the IDS, to attack it itself. Lots of IDSs fail under these DDoS attacks, distributed denial of service attacks. I heard one vendor recently comment that they can do like 30,000 and even more packets per second, which is more than you'll ever see on normal networks. Normal 100 megabit networks. But yet, they do fail still under 148,000 frames per second, under heavy loads. And yes, they're not normal, but that's what the hacker does, is they create abnormal conditions. A buffer overflow isn't normal, it's abnormal. Vendors are designing for the normal case, not so much the exceptional case. Today's IDSs are built under the same assumptions that applications are built under, which is to say, you're building for what normal people need. What do you normally do for that 80% of what normally happens? IDSs really need to be built for that 20% exceptional cases. And by the way, packets per second is often the more difficult thing that IDSs have to handle, rather than bits per second. Most IDSs can handle 100 megabits per second, but they can't handle the fully loaded and saturated network with lots of small packets. As a matter of fact, the maximum for 100 megabit networks is 148,800 packets per second. That's actually only about 66 megabits per second because of spacing between frames, but it will kill most IDSs. And when they fail, they fail really hard. I show three graphs here of three possibilities. Let's say that the number 100 represents the maximum that you can put across that wire. And maybe the IDS fails at about 75%. Well, IDS number one in this diagram shows that the IDS basically processes 75% of the traffic and drops the other 25%, no matter what that traffic is. But what really happens is that IDSs start to degrade. So the more traffic you pump in, the fewer that's actually processing over time. So you pump in 75, it processes 75. You pump in 80, it now processes 70. You pump in 90, now it processes 60. In reality, they really act like IDS number three. And soon after they reach their limit, they start failing really, really fast. A lot of them, when you do pump in that full 148,000 frames per second, they actually detect zero frames. And I've run that test against a couple of competitors, and that's indeed what they do. Black Ice can handle 148,000 frames per second. This little notebook is a 400 megahertz Pentium II. And I've pumped 148,000 frames per second at it with a little smart bits tester. It's actually kind of cool. But that's because the founders of Network Ice, we come from the sniffer world. And this is the same diagram we would use to describe sniffers. We would look at our competitors, and we would say they do the same thing. You pump in too much traffic, and they go to zero. So in Network General, we tried to do the same optimizations. Just try to optimize the system to at least fail the test. Fail gracefully when it's going to fail. Network General started with sniffers on 286s, so on 10 megabit networks. The engineer that wrote the drivers for the 286 on 10 megabits is the one who wrote the drivers for 100 megabits at Network Ice. So how can you generate that if you're a hacker and you want to flood the system? A lot of DDoS attacks will work if you're trying to attack Yahoo or eBay or E-Trade or all these other major websites. And they've got really fast links. They've got gigabit links. How are you going to flood them? Well, one easy way is with a smurf or a fraggle attack. My home network, I'm running off of DSL. And I see this a lot. I see lots of people trying to use my whole area around my home to do these attacks. The way they work is the hacker sends in a ping to the broadcast address for my whole area. The router then splits that out essentially and sends a ping to everybody in that subnet. Well, by spoofing the IP address of the victim, everyone in that subnet responds to that victim. So even though the hacker has maybe a dial-up line, they can do some pretty severe damage against a victim that's got a gigabit line. That's what I do in my home network. My machine, of course, doesn't respond to these pings or to UDP echoes, but I see the attempts. Now, let's say that the victim only has a T1 line. And the IDS is behind it on 100 megabit. Well, you're not going to be able to overflow. And you can overflow the T1 line, but the IDS itself will not be overflowed because it's still only processing 1.5 megabits per second. But you can do a lot of internal smurfs. That you send the smurf inside through to the corporation, and the corporation basically smurfs itself, and the IDS overloads now on a 100 megabit network. A similar rule applies to the T1 line. Another technique is jamming. This is like radar jamming. Back in World War II and World War I, when radars were first developed, they equally developed lots of techniques against radars. And the easiest way was to jam the radar. Flood it with electronic signals that didn't know how to handle or too much signal, and it would basically die. You can do this against a lot of IDSs from a dial-up line. You run attacks that generate lots and lots of frames with lots and lots of signatures. The IDSs attempt to be really robust. They try to log each and every attack. So you do a decoy scan, which spoofs your IP address. You run target, which spoofs most of its attack's IP addresses. And you just keep running it on your dial-up line. Eventually, the database will fill up with all these events and keel over. A lot of vendors use access databases, which keel over really, really easily. We allow access. We recommend other databases. Real databases. One of our vendors has an interesting message. I've found that every single customer that uses this vendor product that I've ever talked to is familiar with this error message, which is DB high watermark reached. There's also a queue overflow message. And they all are familiar with this message because they get it. And they have to go in and start cleaning out their database. This is one of the ways that they flee from the field of battle. Another classic evasion technique is Rainforest Puppy's whisker. It changes the signature of how the attack appears on the wire, but doesn't change its meaning. And here's an example of all these attacks are the same. They all mean the first one, which is CGI bin PHF. And it changes this pattern. One way is to use the head command rather than the get command. It doesn't get the full file. But we'll test to see if it's there. And you can often do a lot of buffer overflow exploits with it. You can URL encode the characters. So like percent 63 is a C. You can append some extra slashes, which a lot of web servers just strip out to meaning one slash. You can go descend directories and pop back up again with a dot dot. So a foobar slash dot dot means the same as nothing. You can put a slash and a dot in the middle of it. Or a string of these, as many as you want. And all they really mean is the same directory. So it tells the web server go into CGI bin, then go into the same directory. And if you repeat them, it's going to same directory, same directory, same directory. And then execute PHF. Another one takes advantage, I believe this is Windows, of putting the percent 00, which encodes a null string. If the HTTP server is doing string copies, it will fail to copy the rest of the string. Or if the web server doesn't do that and doesn't do the string copy, it gets the entire string. But if you do a string copy on the IDS, it will fail to get the entire string, and the rest of it's ignored. When RFP released this, he released his original whisker scanner with just the head command as being the IDS evasion technique. And then a few months later, I'm not quite sure how long later, he released the next version that had ten of these style of IDS evasion techniques. Most of them would only work on specific web servers. These other ones listed here are pretty much generic. I pull out just the head and the two of these are sort of off to the side because those are the ones that affected Black Ice. I was kind of ticked off on this first release because it immediately evaded us and I had to go in and fix the head and re-release a patch. But then I went through and tried to figure out everything else he might be adding because he claims he's going to add some more IDS evasion techniques. And I figured out nine of them, but I didn't quite catch the tenth one. And the cool thing is we released patches to our product very quickly after RF whisker was released, both versions. A lot of vendors today still can't catch these, or at least catch all of them, especially if you combine multiple techniques like encoding in URL encoding and then add the dot directory, self-referencing directories. Now, whisker is just a CGI scanner. It scans a website and looks for a few hundred possible scripts that the website might be running. If you're a script kiddie and you want to break into a website, the first thing you're going to do is run whisker on it, find out it's got one of the hundreds of CGI programs vulnerable, then you'll exploit that CGI program. When you do the exploit, you have to do the evasion yourself. Like in this case, I've shown how to access a website for the PHF and put the self-referencing directory, a dot, and then to encode the dot with URL encoding, which comes out as a %2e. My website actually has what looks to be a PHF script on robertgram.com, which is my website, just so I have fun with hackers that try to access it. Actually, I do a lot of stuff on my website. If you scan around, you'll find lots of these little Easter eggs on it. The next classic evasion, now I believe somebody yesterday discussed this. I wanted to go to it, but the room was filled, and I couldn't ever get into it. To see how much of that's overlapping with this, it probably overlaps entirely. I probably showed a lot more techniques. Fed spying on us again. When you write at buffer overflow, one characteristic that you see for most of them is that they have these fillers of no-op codes to align where they want to jump into the code. For example, on the x86 architecture, the 90 op code is a no-op. It does nothing. A lot of CPUs have multiple no-op codes, so simply by replacing the standard no-op with a different no-op, you can evade the signature looking for no-op codes. You can also fill it with normal ops, stuff that actually do things. If you're going to overwrite a register, your no-op code could actually just be an increment of the register that you're about to overwrite later on. The x86 has lots of no-ops. Being a nice little system processor, it provides us lots of complicated ways to do nothing. Now, if you want to be truly evil, when you do that fill, most of these exploit scripts start with a little fill of fill all the no-ops. Like this little for loop here. If you want to be nasty, what you do is, you create your little table of what you want to be your no-op codes, and do a random lookup. Every time you run your script, you'll have a different signature on the wire. Even if I'm looking for certain patterns of no-ops, it still won't work, because there are different patterns every single time. The reason this affects network-based intrusion detection systems is that they're mostly based upon the packet grep technology, which is bring in a packet, look for a pattern. Alternative technology that, I know at least one company is using, is protocol decoding. It doesn't really care about the exact pattern that you're using. What it cares about is that you're doing something suspicious. In this case, if you're doing a buffer overflow attack against a POP3 server, rather than looking for the actual overflow itself, you say, hey, he's just entered in a username that's a thousand characters long. And it's got some binary in the username. This is something extremely suspicious. Now, you can evade that actual pattern of buffer overflow all you want, but you still detect the fact that you've got the suspiciously long username. As I mentioned before, a lot of these intrusion detection systems have a long list of ports that are suspicious ports. My back orifice is 31337. Sub7 uses two different ports. But these things can run on any port. If you look on your firewall logs right now, you'll see lots of scans for port 27374 and 1243 for the Sub7 Trojan horse. And you're seeing lots and lots and lots of these scans. So you're thinking, I see so many of these scans, it must be that everyone's running Sub7 on the default ports. But actually, looking at our own, what we've seen on the net, is that most successful compromisers are actually at non-default ports with non-default passwords. And we can see this sort of stuff because we run on some ISP backbones, and our customer base actually sends us a large number of these files when our proxy texts the fact that they've been exploited. So the real danger is that you've got these Trojan horses running on non-default ports, and the default ports are just noise. And the reason they're so common is not because people are running at those ports, it's because the Sub7 itself contains a built-in scanner. I compromise one person, and the first thing I do is I tell that one person to scan the whole internet looking for other possible victims. It rarely finds them, though, at the default ports. The way these Trojan infections work is that a hacker wants to get the Trojan on your computer. It might do so by posting to Usenet. Some victim somewhere in the world, unrelated to the hacker, goes to the Usenet group, says, hey, this is a great new porn picture viewer or something, downloads the program, runs it, and infects themselves. Now, if it's during a non-default port or a non-default password, one way that the hacker can find who that is is by telling the Trojan horse to notify them. Now, you can't notify the hacker directly because then it's like a clear finger-pointing for the feds to follow. So instead, the hacker has them notify a third party, which can be done with email, IRC, ICQ, or a number of other options. The hacker then logs on to that third party system and finds the victims that have all notified themselves to him. At that point, he uses the password and port number to break into the victim's machine. This is the Sub7 Edit Server program, which sets all these values of how it's going to actually compromise the person. You can see that it will notify via ICQ, via IRC, which IRC servers, email systems, and so forth. One of the cool things it has is that it can use a random port on startup, which means every time it runs, it's going to run at a different port, so that there's no amount of scanning for ports that will ever find this system, because it will always run at some other port. But yet, having an IRC notify will always tell the hacker exactly which port's currently in use. So even if you're a user with a notebook computer, maybe, on the road, dialing up, every time you dial up, you notify the hacker where you are, and he'll come find you. From our own evidence, it looks like the IRC is the most popular way for notifying the hacker. So those are the standard evasion techniques that people are using today. They're very simple to use. It's not really too difficult. Now we get into some uber evasion techniques. The first is the theory. As I mentioned before, packet grep systems are looking on the wire for patterns. Logically, according to the OSI model, that belongs in the presentation layer. The OSI model was this model developed back in the 80s. It's a very big bureaucratic process, and it's supposed to be the overall end-all of describing how technologies like this should work. It tries to define, okay, layer one, you're worried about cabling, getting the bits across the wire. Label two is getting two machines to actually talk and send data to each other and getting frames, what they call, across the wire. Layer three is getting IP end-to-end across the entire Internet, not just locally. TCP is getting two applications to talk to each other. The session layer is this meaningless thing that ever and actually never turned out to be worthwhile in practice, and no one ever uses it. The presentation layer... By the way, there's lots of books about the OSI model, and when you look for the description of the session layer, it always comes down to two things. The session layer is something that manages sessions. Well, what's a session? Well, it's one of these things that you get in the session layer. And so I've looked... Every time I find a new book on the OSI model, I look to see if they've actually defined it any way. It's not circular. I never found one that does. Well, I found one a long time ago, and really the session layer came from these old teletype, terminal-type things, and there are some concepts in there that never apply outside of that environment. So then there's the presentation layer. And back in the OSI model, they wanted to negotiate the presentation layer. But really, lots of protocols have a presentation layer, even though it's not really a separate entity. And all it's specifying is how data is formatted across the network. For example, in SMTP, it might be the MIME encoding, sort of a presentation layer-type concept. And the application layer is the mail, the IRC, FTP, web, and so forth. RPC has a very distinctive presentation layer. One of the lesser-known things about that layer is something called record marking. When you send RPC packets across a TCP connection, TCP creates this virtual byte stream, so you must know when a command ends and begins. And so they do that with this record marking code. Now, lots of protocols do this, but what RPC has added to that whole mix is the ability to fragment the records. So most protocols, when running over TCP, they have a length field. That's the first field that says the length of the command. So even though TCP might segment it out into multiple packets, they know exactly how many bytes are in that command. TCP adds something where you can send multiple of these length-encoded items that all then combine back into the common original record. And the way that would work is in this little diagram here, I have the normal record, which is the RPC command in white, which is prefixed with a 4-byte length field. The top bit of that length field says whether there will be another, whether it's the last fragment of this record, or whether more fragments follow across the TCP connection. So I split, in this case, in this diagram, that white command into two fragments, each with its own record mark. The first one says that another record fragment follows, and the last one says that's the last fragment in the whole stream. Now, if you want to be nasty, you want to randomly combine the TCP layer segmenting and the RPC layer record marking. And then one of the cool things is, normally, in normal traffic, these things are always working together. You see a TCP segment across the wire, it always starts with a record mark, but doesn't have to be. So in this third little diagram here, I show where I fragmented the TCP segment separately from the record marking segment. So I'm sending four TCP segments for that original request. So the upshot of that is, is that you're not going to find a traditional RPC pattern in that TCP connection. So I wrote a little code. I'll be posting this to my website after DEF CON. And what it does is you replace your traditional socket send function that sends the data across the wire in your exploit script with mysend. What mysend does is it randomizes where it's going to record mark and fragment the stuff and where it's going to segment at the TCP layer. If you're familiar with RPC, it has, XDR has this very distinctive rule that everything has to be fragmented on four, or everything has to be on four byte boundaries. So all integers must be four bytes. You can't have a three byte integer. A string of someone's name that's nine bytes long has to be padded out to an even 12 bytes with nulls at the end. But that XDR restriction does not apply to record marking. I point this out because the first time I did the anti-evasion stuff in Black Ice, I made the assumption that was XDR. And then I played around with the spec, realized it didn't have to apply, tried it out on the exploit script, and sure enough, it evaded, so I had to change my code yet again. So anyway, so we call the mysend function, instead of your normal send function that you have as part of your exploit script, it calls the mysend upper function, which adds the record marking stuff to it with a random length field, and then passes it to the TCP layer, where I again then randomize how long the TCP segment is going to be. I also put a little random sleep time there, so if you're trying to find the traffic over time, that messes up too. And what I come up with is something that looks like this, is randomize where I'm going to record frag and randomize where I'm going to TCP segment. So if my, original command is like a port dump command. Port dump is a scanning technique. You scan an RPC server and ask it what services are running. This is how you hunt down to see which ones might be vulnerable that you're going to exploit with buffer overflow exploits. This is what the packet looks like in hex. Right below it is a decode. The first four bytes are that record frag. The first byte is that little bit saying it's the last record frag in the sequence. Because it normally doesn't record frag on requests. Then you have the XID, the message type, it calls as RPC version two, which is all RPC we use today. Support map command is port map version two. The procedure is dump, which is procedure number four. There's no authentication or verification. Here's what it looks like after it gets through the my send functions. The first packet has a TCP segment of zero and zero. The next packet has a TCP segment of zero, five, and so on and so forth. Those first four bytes, of course, are the record marking stuff, where I've randomly chosen that the first record's going to be five bytes long. By the randomization of the packet, even that record mark itself was segmented in the TCP segments. I have about one, two, three, four, five, six, seven, eight, nine, ten, 11, 12, 13, 14, 15, 16, 17. I've got 17 packets there where originally I had only one packet. It's also about 70 bytes long where the original packet was about 40 bytes long. This, of course, gives IDSs fits. Most IDSs still don't reassemble TCP streams, but even if they did, the stream wouldn't look like anything like they've ever seen with RPC. They don't detect the port map attack. I've tried this against a number of the other IDSs. Sure enough, they detect the normal one, but they don't detect the evaded one. This is particularly important because, because of the way that a lot of IDSs work, well, I assume they work with RPC, is RPC runs its services at random ports, like CMSD, Calendar Messenger Service, an exploit that a lot of Solaris machines fell victim to last year, runs at a randomly chosen port. When it starts up, it registers with port mapper at the well-known port of 1.11 and tells it which port it's running at. Back at Network General when we worked on the sniffer, the way we got around this fact was by using a heuristic called smells-like, where we looked at an RPC request and said, does this look like an RPC request? RPC is kind of cool because it's very distinctive. You have that record mark. You have the XID, which is random. The message type is either 0 or 1, so you've got four bytes that are either going to be 0 or 1. RPC version is always 2, so that field must be 2, and so on and so forth. We can really distinctively say 99.9% of the time whether it's RPC. But in this packet, those rules don't apply. It looks nothing like RPC anymore according to those heuristics. Heuristics that try to deal with the record mark can always be evaded by carefully constructing your record to look like something else. The only way to get around that is the IDS needs to not use those heuristics and must instead keep a lot more state around. It must profile the target to say, I see a port mapper response come back. Therefore, I know which ports all the services are running at. That's RPC record fragging. That was suggested to me by Doug Song, who wrote the original Frag Router. He's working on a Frag Proxy, or I'm not quite sure what he's working on, that will do this automatically for you, whereas my code you have to add to your script and change the script. The next one is something that I discovered myself, where I'm using the Telnet channel on FTP. If you read the FTP specification, it says that the control channel is really Telnet. Now, the later on host requirements RPC says, no, it's really not Telnet. It's just something that looks a lot like Telnet using the same option strings, the out-of-band option communication. What Telnet has is strings that start with FF, a byte with all ones, followed by either one or two bytes of the option code. In the Telnet usage, it's really complex. You can negotiate which terminal you are, what your backspace character is going to be, and a lot of other stuff. In the normal Telnet environment, the issue is so bad, you can basically avoid any IDS detection on the Telnet channel. You can reconfigure your backspace character to be Q or something like that. So your IDS is seeing a string of Qs, but the target system is seeing a string of backspaces. But in the FTP case, none of that can be negotiated. All they can negotiate is whether to use the abort option, the abort Telnet option code. Everything else is a null option. So an FF followed by any other byte is pretty much ignored in the FTP command channel. So when you log on as, in this case, user rob, you can put in that FF and then another byte. The F1 is the Telnet no-op code. But any byte will do, because it will strip it out and ignore it. So instead of seeing user rob, you see this user garbage rob, and it's pass-like garbage, and foo. And this is a lot like, conceptually like RPC. It's at the presentation layer of the OSI model. I'm changing how I'm formatting this stuff. So you think through all of the, the exploits that FTP can do, they're all pretty much run across the, the control channel. Like bounce scans, the tar compress, execute bug, buffer overflows, change working directory to root, logging on with username and password, site exec, there's been a lot of site exec holes lately, printf style format bugs, shell characters and so forth. Now as I was working on this and testing it out, I found a number of problems. Unix supports this three, this three character do, don't, command negotiation. Where the client logs on and says, I want to do something or other. And the server comes back and says, no, I don't support that, or I do support it. And the cool thing about that is, is you can desynchronize, and IDS, because you can start up and say, send the do command, FTP comes back and says, won't. The FTP, by the way, the specification now with host requirements RFC, says that it should respond with the won't for everything. Because it shouldn't really support telnet. So, you can send, you can pepper your code with these, like you can send a command like user password, and in the middle of that user string, send the do command, and you'll get back to this don't command, and it'll really confuse the IDS. Unfortunately, Windows FTP implementation from Microsoft doesn't support the three character code, only the two character evasion stuff. It also has that same null problem with, as Whisker does with the string copy. So you can send a null to it, prefixed by the option code, then it'll stop processing the string, and anything after it won't be interpreted by the server. Now, if the IDS interprets that string, it will no longer figure out what the users, or the hacker is really doing. But of course, if it does do the same logic as the Windows NT stuff, then it will no longer be able to detect all the attacks against the Unix FTP server. Now, there's also the problem that a lot of Windows FTP servers you might download off the web don't support any of this option stuff at all. So, what you really need to do is to profile the target, and figure out what kind of FTP server is the target running, and then adjust your IDS algorithms accordingly. Also, if you're writing the exploit scripts, you equally have to profile the target. For example, a lot of scripts run across the anonymous authentication, so the first thing you should do is encode the user string. If you get back an error, you know it's not handling the option code. If you say, okay, anonymous is allowed to log in, or guest accounts allowed to log in, then you know that it did accept the option code, and you should use option codes from then on. You can use the same technique back used in the RPC record fragging, is randomize the whole thing. Like, just every character is either randomly the original character, or one prefixed by the option evasion. So here's an example of where I do the change current working directory to root. A logon is anonymous, and I send that corruption in the user string, but the server supports FTP, or telnet options, and says, great, guest account log in okay, continue on. I then do the exploit, change current working directory to root, and I insert my little option codes in there so it doesn't look anything like change current working directory to root, and indeed, all the other IDSs fail to detect this. Though on the server, I got back 250 success, meaning I actually was able to change my current working directory to root, and I can grab any file off the server I want. A similar technique, using sort of the presentation formatting of the data, is within DNS. First of all, you have the case sensitivity issue. I notice that a lot of IDSs assume that the case will be either all uppercase or all lowercase, which is the case. The second thing is, is that DNS supports this name compression thing, where it splits up names in order to compress responses and requests. This has long been used to crash IDSs and to crash sniffers, because you can cause it to reference itself in an infinite loop. The way this compression works is that you have like one name, maybe I try to reference www.yahoo.com, it comes back and says, well actually there's lots of servers there at www.yahoo.com, they're like ww1, ww2, and so forth. Now, in order to compress that DNS response, the first one says the full yahoo.com, and the second ones have a pointer saying, continue on now with the rest of the original yahoo.com. So when you look at the text decode of it, you see something that looks a lot like this. You see in the clear text the first name followed by a lot of other fractions of the name. And this is where you can create and crash an IDS or a sniffer, is where you make that self-referential loop, saying reference myself and continue here. And it'll continue to continue here and hang. Or you can tell it to point off to Never Never Land where it will crash. Oops. So I wrote a little version bind scanner. In the bind Berkeley Internet Name Demon, which services like 90% of all name requests on the Internet, you can query which version of the software is running. And you have a special record called a text record that's in the chaos class with the string that you're looking up, version.bind. And that's like hard coding to the code as an Easter egg that returns what version it's running, like 8.22 or 4.31 or something like that. Well, a lot of IDSs detect this because it's a common scanning thing you do when you're attacking a DNS server. So I did two evasions here. One of which is I changed the name to be capital V and small version, capital B and small ind. And I played around with this for a couple of days. And I couldn't, I used all sorts of different arrangements by using this name compression by taking the second part of the name and pointing it off somewhere else in the packet. And I finally came down to the only way I could figure out how to get it to work, by going to the source code of bind, of course, was to put the dot bind after the end, logical end of the DNS portion of the packet. So that I see version, where you see that plus here in the text decode, it's actually specifying the offset where to find bind. And the web server will paste this back together to version dot bind and return you the correct string. But if you're looking for version dot bind in the packet, you're not going to see that as a contiguous signature that you can trigger on. So I'll be posting that DNS scanner to my website as an example after DEF CON. The problem is I couldn't get it to quite work on Linux. I throttle it for bulk scanning and the clock function on Linux wasn't quite working. I don't know why it would stop incrementing after a while. All of these evasion techniques, which I discovered after I wrote the presentation here, are at the OSI presentation layer. Like HTTP, RPC, FTP, DNS, they're all changing how the data is formatted but not the meaning of the data. So I decided that it would be kind of cool to actually add these directly into Nmap so that Nmap's FTP bounce scans will automatically evade and RPC null proc evade, all the null proc stuff it does to detect RPC services will also evade the IDS. So today's networks, the most popular way you can exploit a site is through DNS, through bind. A huge number of bind exploits over the past year. FTP, you know, there's a new one discovered every week. New exploit into FTP. RPC services, Sun Solaris machines and Linux boxes have been exploited with RPC a lot in the last few years. Of course, HTTP with all this CGI stuff will never end. You'll always be able to break into boxes with that. And of course, Trojan horses. So these are the most popular ways that people are actually hacking into systems today. And of course, the easiest way of evading IDSs are using those protocols that I've just demonstrated. I like to do this, you know, back and forth, along with the frag and the flood and the jam techniques of either fragmenting any attack with fragmentation or flooding or jamming the IDS sensor, bringing it down. So the idea of evading IDSs with protocols is still not a widely researched topic in the hacker community. I've been just working on a few protocols because they're the most commonly used and found I can easily add to these protocols the ability to evade IDSs, including black eyes, which is why I fixed it so it no longer works. Lots of protocols are vulnerable to these presentation layer attacks or application layer evasion. And the reason I'm presenting it is because a lot of the competitors still haven't dealt with fragmentation, which is like really, really old. They really need to be kicked in the pants and say, you need to add these to your products. As I started with the presentation here, the IDS vendors are selling you a tank that some, you know, oddball can walk up behind with like a grenade and blow it up. And this is not a really good state of the industry right now. So this is the end of the presentation. I'll be posting the slides to this URL on my own personal website. I've got a FAQ on generic network intrusion detection stuff at my website. And we'll be coming out with a Linux version a lot of you might be interested in beta in about a month. Are there any questions? There.