1 00:00:11,820 --> 00:00:18,280 network ice and the chief architect of black ice intrusion detection system and well be 2 00:00:18,280 --> 00:00:25,920 discussing today is some of our experiences of running ids systems in the battlefield in 3 00:00:25,920 --> 00:00:31,880 particular I'll be discussing how to evade or how people are evading intrusion detection 4 00:00:31,880 --> 00:00:39,060 systems and then I'll be introducing some new methods that we've been working on that allow 5 00:00:39,060 --> 00:00:46,380 hackers to implement new methods of intrude of evading intrusion detection systems to start 6 00:00:46,380 --> 00:00:50,620 with I'm going to talk about a little bit about the background and the surrounding areas of 7 00:00:50,620 --> 00:00:55,240 intrusion detection systems and how this applies it's basically marketing drivel but 8 00:00:56,540 --> 00:01:01,700 you'll have to bear with me for a moment ideas systems are sort of like weaponry in the war 9 00:01:01,700 --> 00:01:08,020 against hackers but they're kind of like flaky weaponry it's kind of a tank that you might take 10 00:01:08,020 --> 00:01:14,040 out to a battlefield and enemy soldier walks up behind it aims a gun at it and the tank explodes 11 00:01:14,620 --> 00:01:21,560 this is like in the movie Kelly's heroes from 1968 where Donald Sutherland plays oddball who 12 00:01:21,560 --> 00:01:25,800 gets behind a German Panzer tank and in the small 13 00:01:25,800 --> 00:01:30,640 little missile at it and then the tank blows up and the way he was able to do this was by 14 00:01:30,640 --> 00:01:35,480 a foot soldier running around behind the tank rather than the frontal assault where all the 15 00:01:35,480 --> 00:01:41,940 armor is now of course all tanks can be blown up the only question is is whether you do it with a 16 00:01:41,940 --> 00:01:51,240 nuke or howitzer or with a handgun ideas are a lot like radar systems that trigger on the the 17 00:01:51,240 --> 00:01:55,220 passing flight of flocks of birds and automatically launch missiles at them 18 00:01:57,100 --> 00:02:02,120 while at the same time not detecting enemy fighter planes that are bearing down on you 19 00:02:04,920 --> 00:02:11,860 during the Iran-Iraq war the Iranian the Iraqi insult and not the Iran-Iraq war the Gulf War 20 00:02:12,600 --> 00:02:18,940 Desert Storm the Iraqi soldiers were famous for throwing down their weapons and running away this 21 00:02:18,940 --> 00:02:20,720 was their primary battle strategy 22 00:02:27,240 --> 00:02:32,960 so these analogies in the weaponry in the war against hackers ideas systems are a lot like this 23 00:02:33,480 --> 00:02:39,200 they they work well in the laboratory I can bring my ideas system in I can run an exploit script I 24 00:02:39,200 --> 00:02:45,440 can say see my ideas catches this attack but when you put them into the real world into the battle 25 00:02:45,440 --> 00:02:51,060 conditions they start to fail they start to flee the battlefield they blow up from behind they 26 00:02:51,060 --> 00:02:52,780 trigger on the passing flights of birds 27 00:02:55,800 --> 00:03:02,640 now here is the the Pliking marketing pitch network guys right now we estimate is the the 28 00:03:02,960 --> 00:03:05,040 market leader in intrusion 29 00:03:05,040 --> 00:03:12,100 we're only like number five in terms of the monetary value whatever from 1999 30 00:03:12,100 --> 00:03:21,860 we believe that more traffic is being monitored by black reduces detaps and this is partially because 31 00:03:21,860 --> 00:03:22,440 I 32 00:03:22,440 --> 00:03:23,100 s 33 00:03:23,100 --> 00:03:24,000 P 34 00:03:24,000 --> 00:03:24,160 t 35 00:03:24,160 --> 00:03:24,380 pid 36 00:03:24,380 --> 00:03:24,920 could I 37 00:03:26,000 --> 00:03:28,920 because we can keep up with the traffic where a lot of others fail. 38 00:03:29,680 --> 00:03:33,220 But it's also because we've got it running on 2 million desktops. 39 00:03:33,480 --> 00:03:34,560 We have two versions. 40 00:03:34,700 --> 00:03:38,360 We have Black Ice Defender, which is a personal IDS that runs on a desktop computer. 41 00:03:39,480 --> 00:03:44,100 And then Black Ice Sentry, which is a traditional network-based intrusion detection system 42 00:03:44,100 --> 00:03:48,400 like Snort or RealSecure or NetRanger and so forth. 43 00:03:53,460 --> 00:03:55,300 And then the competitions products. 44 00:03:56,680 --> 00:04:00,320 First of all, the exploit signatures are not as extensive as they would have you believe. 45 00:04:00,800 --> 00:04:05,040 There's lots of decodes that just sort of say, well, somebody logged in and that's about it. 46 00:04:05,440 --> 00:04:07,700 There are lots of port numbers they trigger on. 47 00:04:07,760 --> 00:04:10,480 There's lots of CGI strings you just add one right after the other. 48 00:04:10,860 --> 00:04:14,360 When you get beyond all that and really hunt down the exploit signatures they have, 49 00:04:14,560 --> 00:04:16,720 they're not nearly as extensive as you would think. 50 00:04:17,000 --> 00:04:18,380 Even ours, if you go through our list, they're not as extensive as you would think. 51 00:04:18,400 --> 00:04:20,460 If you go through our list, you'll see lots of CGI programs, lots of ports. 52 00:04:22,160 --> 00:04:24,240 Though we do have lots of other good exploit signatures. 53 00:04:26,000 --> 00:04:31,840 Existing technologies are easily evaded by really commonly available programs. 54 00:04:32,240 --> 00:04:34,900 These aren't really uber-hacker programs. 55 00:04:35,440 --> 00:04:41,360 They're things that you can download, configure, and run, like Fried Router, Whisker, and other stuff. 56 00:04:41,560 --> 00:04:45,080 I'll also be introducing some new techniques that really will put them in knots. 57 00:04:46,360 --> 00:04:47,400 And they also die. 58 00:04:48,400 --> 00:04:50,640 Pretty gruesomely under heavy load or complex traffic. 59 00:04:51,060 --> 00:04:54,720 As I like to say, they'll easily flee the field of battle like Iraqi soldiers. 60 00:04:57,340 --> 00:05:01,500 To start my talk of the technical side of things now, now that I'm done with the marketing stuff. 61 00:05:01,720 --> 00:05:04,740 You see that the marketing department pays for my flight out here in my hotel, 62 00:05:04,900 --> 00:05:07,140 so I have to sort of throw them a bone here. 63 00:05:10,080 --> 00:05:11,880 What is a network IDS? 64 00:05:13,240 --> 00:05:14,840 Fundamentally, it's shown in this little diagram. 65 00:05:14,900 --> 00:05:17,340 You have a hacker, and he wants to break into your website. 66 00:05:18,400 --> 00:05:19,760 He wants to break behind your website into your corporation. 67 00:05:20,440 --> 00:05:25,900 Your external presence is the web server, the FTP server, your name server, your mail exchanger. 68 00:05:27,640 --> 00:05:35,120 The network IDS will monitor the network traffic, looking for signs of intrusion against your computers. 69 00:05:35,840 --> 00:05:38,780 Hopefully, it will tip you off that someone is actively attacking you. 70 00:05:39,160 --> 00:05:41,880 And if they break in, it will tell you how they did it. 71 00:05:45,100 --> 00:05:47,520 However, a network intrusion detection system, 72 00:05:52,380 --> 00:05:53,400 In both cases, there's a lot of the data we have on the internet, 73 00:05:53,400 --> 00:05:56,100 Is there a Sean Hedges in the room? 74 00:05:57,880 --> 00:05:59,160 Some of you might know this already. 75 00:06:00,400 --> 00:06:00,960 He's lost. 76 00:06:05,080 --> 00:06:06,680 The Feds are looking for him. 77 00:06:06,740 --> 00:06:07,640 Is there a Sean Hedges? 78 00:06:14,620 --> 00:06:17,580 So, in the previous diagram, I tried to emphasize the fact that, 79 00:06:17,640 --> 00:06:18,380 network intrusion detection is based on private and private notifications. 80 00:06:18,400 --> 00:06:22,380 detection systems detect that they're happening but don't necessarily 81 00:06:22,380 --> 00:06:24,980 protect you. They're sort of a 82 00:06:26,520 --> 00:06:29,920 early warning system and then a post-forensic system. 83 00:06:31,520 --> 00:06:33,320 They're like a detective that 84 00:06:33,320 --> 00:06:37,880 doesn't witness the actual crime but tries to piece together the clues 85 00:06:37,880 --> 00:06:41,780 afterwards. It's like the Columbo movies and television shows 86 00:06:41,780 --> 00:06:45,980 where he comes in 15 minutes after the crime has happened and then he tries 87 00:06:45,980 --> 00:06:49,980 to, over the course of the show, pieces together the clues until he figures out 88 00:06:49,980 --> 00:06:53,940 what happened. And hackers are really, really good 89 00:06:53,940 --> 00:06:58,040 at, at least really good hackers I should say, they're really good at smudging 90 00:06:58,040 --> 00:07:02,060 these clues and hiding their fingerprints. So a network 91 00:07:02,060 --> 00:07:06,060 IDS system is like a detective or a sleuth and it really isn't like this 92 00:07:06,060 --> 00:07:09,700 psychic system that sort of knows everything that happened and tells you exactly 93 00:07:09,700 --> 00:07:13,560 that you've been broken into or not. They detect. 94 00:07:13,560 --> 00:07:16,700 It's not really a protection thing. It's an enhancement to your protection. 95 00:07:20,160 --> 00:07:21,440 Now I'm going to start talking about 96 00:07:21,440 --> 00:07:25,580 classic evasion techniques. The first one was written 97 00:07:25,580 --> 00:07:29,300 I'm not quite sure when it was written, a year and a half ago, two years ago, called FragRouter. 98 00:07:30,620 --> 00:07:33,820 It was written by a reseller of NFR to really 99 00:07:35,180 --> 00:07:37,300 irk the market leaders like 100 00:07:38,100 --> 00:07:41,460 Cisco and ISS. It's a very simple utility. 101 00:07:41,580 --> 00:07:42,560 You can download it, run it. 102 00:07:43,560 --> 00:07:47,320 What it does is, as shown by the little two diagrams here, 103 00:07:47,480 --> 00:07:52,320 is it fragments the attack. Most IDS systems 104 00:07:52,320 --> 00:07:56,240 bring in a packet, look for a signature, and then say, well, is it a sign of intrusion? 105 00:07:57,520 --> 00:08:00,160 A common intrusion is the PHF attack. 106 00:08:01,180 --> 00:08:04,280 It's the one that we all use now as the sort of the standard 107 00:08:04,280 --> 00:08:08,120 one that we use when we describe signatures. What FragRouter does 108 00:08:08,720 --> 00:08:11,980 is it fragments that across three different packets. 109 00:08:11,980 --> 00:08:17,560 So none of the three packets now contain the signature CGI bin PHF. 110 00:08:17,720 --> 00:08:23,620 You see a little bit of the CGI bin and a little bit of the PHF in each packet, but not the whole signature. 111 00:08:24,060 --> 00:08:28,080 This causes the IDS system to be completely silent. 112 00:08:29,120 --> 00:08:31,940 FragRouter also goes through a lot of firewalls. 113 00:08:31,940 --> 00:08:35,080 Most firewalls have a configuration option saying disallow fragments, 114 00:08:35,400 --> 00:08:41,960 but it's frequently not configured correctly. And since you can fragment packets so that they don't get damaged, 115 00:08:41,960 --> 00:08:45,300 or they can't get a good reading on the port number, they'll allow the packets on through. 116 00:08:48,340 --> 00:08:50,240 FragRouter requires an extra machine. 117 00:08:52,460 --> 00:08:55,660 The hacker sets up this extra machine 118 00:08:55,660 --> 00:08:59,500 on his own side. He then passes 119 00:08:59,500 --> 00:09:03,360 all of the traffic on through, and the FragRouter then automatically 120 00:09:03,360 --> 00:09:05,520 fragments whatever it is. It could be any attack. 121 00:09:06,800 --> 00:09:11,640 The IDS at the victim's side can no longer detect the attack, and is pretty much silent. 122 00:09:12,580 --> 00:09:15,780 Some IDSs at least give a little bit of indication, and will say, 123 00:09:15,880 --> 00:09:21,140 I'm seeing an excessive number of fragments, but they have no visibility into what's really going on. 124 00:09:26,560 --> 00:09:31,920 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, 125 00:09:33,060 --> 00:09:34,620 has a couple of stealth features. 126 00:09:34,940 --> 00:09:40,740 The first stealth feature of Nmap was this stealth scan, or half open scan, or sin scan. 127 00:09:41,360 --> 00:09:44,400 And what it does is it doesn't complete the TCP connection. 128 00:09:44,560 --> 00:09:48,280 It starts it, but doesn't complete it. And this evaded lots of 129 00:09:48,280 --> 00:09:52,640 host-based intrusion detection systems, because they would only start 130 00:09:52,640 --> 00:09:55,420 the logging process once the connection had completed. 131 00:09:56,400 --> 00:10:00,600 But from the network side of things, this doesn't evade network intrusion detection 132 00:10:00,600 --> 00:10:04,740 systems at all. We see all the sin packets. As a matter of fact, when we see 133 00:10:04,740 --> 00:10:09,060 lots of these connections not being completed, we actually can tell that it's a stealth scan. 134 00:10:11,320 --> 00:10:16,220 But there are other stealth scan features of Nmap that do evade intrusion detection systems. 135 00:10:16,620 --> 00:10:19,180 And that's, again, using the fragmentation technique. 136 00:10:19,540 --> 00:10:25,360 As you fragment the sin, and then the IDS system can't put it together and figure out what it is, 137 00:10:25,440 --> 00:10:27,820 and doesn't know what it is, and doesn't detect the sin scan. 138 00:10:29,100 --> 00:10:32,580 And it evades some firewalls, it evades some IDS systems. 139 00:10:32,880 --> 00:10:40,340 I recently tested one IDS from a vendor that claimed to support a reassembly, but yet could not detect the Nmap sin scan. 140 00:10:40,740 --> 00:10:42,180 The fragmented one. 141 00:10:45,060 --> 00:10:50,060 Another classic evasion technique is to flood the IDS, to attack it itself. 142 00:10:51,180 --> 00:10:56,740 Lots of IDSs fail under these DDoS attacks, distributed denial of service attacks. 143 00:10:57,720 --> 00:11:05,340 I heard one vendor recently comment that they can do like 30,000 and even more packets per second, 144 00:11:07,300 --> 00:11:09,880 which is more than you'll ever see on normal networks. 145 00:11:09,880 --> 00:11:11,160 Normal 100 megabit networks. 146 00:11:12,040 --> 00:11:17,860 But yet, they do fail still under 148,000 frames per second, under heavy loads. 147 00:11:18,340 --> 00:11:22,920 And yes, they're not normal, but that's what the hacker does, is they create abnormal conditions. 148 00:11:23,500 --> 00:11:25,540 A buffer overflow isn't normal, it's abnormal. 149 00:11:27,200 --> 00:11:30,660 Vendors are designing for the normal case, not so much the exceptional case. 150 00:11:32,700 --> 00:11:37,720 Today's IDSs are built under the same assumptions that applications are built under, which is to say, 151 00:11:37,900 --> 00:11:39,860 you're building for what normal people need. 152 00:11:39,880 --> 00:11:42,220 What do you normally do for that 80% of what normally happens? 153 00:11:43,360 --> 00:11:46,580 IDSs really need to be built for that 20% exceptional cases. 154 00:11:47,980 --> 00:11:54,860 And by the way, packets per second is often the more difficult thing that IDSs have to handle, rather than bits per second. 155 00:11:54,960 --> 00:12:03,440 Most IDSs can handle 100 megabits per second, but they can't handle the fully loaded and saturated network with lots of small packets. 156 00:12:04,200 --> 00:12:09,860 As a matter of fact, the maximum for 100 megabit networks is 148,800 packets per second. 157 00:12:09,880 --> 00:12:17,220 That's actually only about 66 megabits per second because of spacing between frames, but it will kill most IDSs. 158 00:12:19,300 --> 00:12:21,860 And when they fail, they fail really hard. 159 00:12:22,140 --> 00:12:24,640 I show three graphs here of three possibilities. 160 00:12:25,460 --> 00:12:31,440 Let's say that the number 100 represents the maximum that you can put across that wire. 161 00:12:32,780 --> 00:12:36,180 And maybe the IDS fails at about 75%. 162 00:12:37,180 --> 00:12:46,360 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. 163 00:12:47,400 --> 00:12:50,380 But what really happens is that IDSs start to degrade. 164 00:12:50,860 --> 00:12:56,840 So the more traffic you pump in, the fewer that's actually processing over time. 165 00:12:57,180 --> 00:13:00,080 So you pump in 75, it processes 75. 166 00:13:00,640 --> 00:13:03,060 You pump in 80, it now processes 70. 167 00:13:03,300 --> 00:13:05,280 You pump in 90, now it processes 60. 168 00:13:06,860 --> 00:13:10,080 In reality, they really act like IDS number three. 169 00:13:10,440 --> 00:13:13,820 And soon after they reach their limit, they start failing really, really fast. 170 00:13:14,860 --> 00:13:21,060 A lot of them, when you do pump in that full 148,000 frames per second, they actually detect zero frames. 171 00:13:22,040 --> 00:13:25,260 And I've run that test against a couple of competitors, and that's indeed what they do. 172 00:13:27,220 --> 00:13:31,220 Black Ice can handle 148,000 frames per second. 173 00:13:31,900 --> 00:13:35,220 This little notebook is a 400 megahertz Pentium II. 174 00:13:35,220 --> 00:13:40,140 And I've pumped 148,000 frames per second at it with a little smart bits tester. 175 00:13:41,160 --> 00:13:42,140 It's actually kind of cool. 176 00:13:44,400 --> 00:13:48,340 But that's because the founders of Network Ice, we come from the sniffer world. 177 00:13:49,120 --> 00:13:51,800 And this is the same diagram we would use to describe sniffers. 178 00:13:53,000 --> 00:13:55,640 We would look at our competitors, and we would say they do the same thing. 179 00:13:55,740 --> 00:13:57,820 You pump in too much traffic, and they go to zero. 180 00:13:58,920 --> 00:14:01,320 So in Network General, we tried to do the same optimizations. 181 00:14:01,320 --> 00:14:05,200 Just try to optimize the system to at least fail the test. 182 00:14:05,200 --> 00:14:06,440 Fail gracefully when it's going to fail. 183 00:14:07,120 --> 00:14:11,820 Network General started with sniffers on 286s, so on 10 megabit networks. 184 00:14:12,500 --> 00:14:20,680 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. 185 00:14:24,200 --> 00:14:27,840 So how can you generate that if you're a hacker and you want to flood the system? 186 00:14:28,260 --> 00:14:34,860 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. 187 00:14:35,460 --> 00:14:37,300 And they've got really fast links. 188 00:14:37,360 --> 00:14:38,080 They've got gigabit links. 189 00:14:38,200 --> 00:14:38,880 How are you going to flood them? 190 00:14:39,440 --> 00:14:42,180 Well, one easy way is with a smurf or a fraggle attack. 191 00:14:43,500 --> 00:14:45,960 My home network, I'm running off of DSL. 192 00:14:46,160 --> 00:14:47,320 And I see this a lot. 193 00:14:47,380 --> 00:14:52,680 I see lots of people trying to use my whole area around my home to do these attacks. 194 00:14:53,380 --> 00:14:59,440 The way they work is the hacker sends in a ping to the broadcast address for my whole area. 195 00:14:59,960 --> 00:15:04,160 The router then splits that out essentially and sends a ping to everybody in that subnet. 196 00:15:05,200 --> 00:15:10,500 Well, by spoofing the IP address of the victim, everyone in that subnet responds to that victim. 197 00:15:10,860 --> 00:15:16,800 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. 198 00:15:18,700 --> 00:15:19,840 That's what I do in my home network. 199 00:15:19,940 --> 00:15:26,640 My machine, of course, doesn't respond to these pings or to UDP echoes, but I see the attempts. 200 00:15:30,880 --> 00:15:33,760 Now, let's say that the victim only has a T1 line. 201 00:15:33,760 --> 00:15:37,060 And the IDS is behind it on 100 megabit. 202 00:15:37,820 --> 00:15:39,740 Well, you're not going to be able to overflow. 203 00:15:40,040 --> 00:15:45,980 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. 204 00:15:47,140 --> 00:15:50,220 But you can do a lot of internal smurfs. 205 00:15:51,360 --> 00:15:58,920 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. 206 00:16:02,880 --> 00:16:03,740 A similar rule applies to the T1 line. 207 00:16:03,740 --> 00:16:04,980 Another technique is jamming. 208 00:16:04,980 --> 00:16:06,160 This is like radar jamming. 209 00:16:07,120 --> 00:16:13,280 Back in World War II and World War I, when radars were first developed, they equally developed lots of techniques against radars. 210 00:16:13,400 --> 00:16:15,120 And the easiest way was to jam the radar. 211 00:16:16,460 --> 00:16:21,140 Flood it with electronic signals that didn't know how to handle or too much signal, and it would basically die. 212 00:16:22,880 --> 00:16:26,100 You can do this against a lot of IDSs from a dial-up line. 213 00:16:26,220 --> 00:16:30,580 You run attacks that generate lots and lots of frames with lots and lots of signatures. 214 00:16:31,320 --> 00:16:33,140 The IDSs attempt to be really robust. 215 00:16:33,740 --> 00:16:36,880 They try to log each and every attack. 216 00:16:38,020 --> 00:16:41,960 So you do a decoy scan, which spoofs your IP address. 217 00:16:42,040 --> 00:16:45,120 You run target, which spoofs most of its attack's IP addresses. 218 00:16:45,600 --> 00:16:47,780 And you just keep running it on your dial-up line. 219 00:16:49,460 --> 00:16:53,020 Eventually, the database will fill up with all these events and keel over. 220 00:16:54,080 --> 00:16:57,880 A lot of vendors use access databases, which keel over really, really easily. 221 00:17:01,420 --> 00:17:03,220 We allow access. 222 00:17:03,740 --> 00:17:05,060 We recommend other databases. 223 00:17:05,380 --> 00:17:06,020 Real databases. 224 00:17:10,460 --> 00:17:12,820 One of our vendors has an interesting message. 225 00:17:12,880 --> 00:17:18,460 I've found that every single customer that uses this vendor product that I've ever talked to is familiar with this error message, 226 00:17:18,640 --> 00:17:20,780 which is DB high watermark reached. 227 00:17:21,000 --> 00:17:22,720 There's also a queue overflow message. 228 00:17:23,540 --> 00:17:26,280 And they all are familiar with this message because they get it. 229 00:17:26,440 --> 00:17:28,660 And they have to go in and start cleaning out their database. 230 00:17:30,160 --> 00:17:32,860 This is one of the ways that they flee from the field of battle. 231 00:17:36,060 --> 00:17:39,520 Another classic evasion technique is Rainforest Puppy's whisker. 232 00:17:40,220 --> 00:17:45,260 It changes the signature of how the attack appears on the wire, but doesn't change its meaning. 233 00:17:47,220 --> 00:17:50,480 And here's an example of all these attacks are the same. 234 00:17:50,620 --> 00:17:53,440 They all mean the first one, which is CGI bin PHF. 235 00:17:54,700 --> 00:17:56,600 And it changes this pattern. 236 00:17:56,860 --> 00:18:00,660 One way is to use the head command rather than the get command. 237 00:18:01,740 --> 00:18:03,260 It doesn't get the full file. 238 00:18:03,260 --> 00:18:04,660 But we'll test to see if it's there. 239 00:18:04,780 --> 00:18:06,940 And you can often do a lot of buffer overflow exploits with it. 240 00:18:07,480 --> 00:18:09,400 You can URL encode the characters. 241 00:18:09,700 --> 00:18:11,780 So like percent 63 is a C. 242 00:18:13,260 --> 00:18:18,420 You can append some extra slashes, which a lot of web servers just strip out to meaning one slash. 243 00:18:19,340 --> 00:18:23,280 You can go descend directories and pop back up again with a dot dot. 244 00:18:23,580 --> 00:18:26,560 So a foobar slash dot dot means the same as nothing. 245 00:18:27,980 --> 00:18:30,300 You can put a slash and a dot in the middle of it. 246 00:18:30,420 --> 00:18:32,420 Or a string of these, as many as you want. 247 00:18:33,260 --> 00:18:34,780 And all they really mean is the same directory. 248 00:18:34,960 --> 00:18:38,980 So it tells the web server go into CGI bin, then go into the same directory. 249 00:18:39,200 --> 00:18:42,240 And if you repeat them, it's going to same directory, same directory, same directory. 250 00:18:42,400 --> 00:18:43,500 And then execute PHF. 251 00:18:45,220 --> 00:18:50,900 Another one takes advantage, I believe this is Windows, of putting the percent 00, which encodes a null string. 252 00:18:51,520 --> 00:18:57,620 If the HTTP server is doing string copies, it will fail to copy the rest of the string. 253 00:18:58,060 --> 00:19:02,520 Or if the web server doesn't do that and doesn't do the string copy, 254 00:19:02,520 --> 00:19:03,720 it gets the entire string. 255 00:19:03,960 --> 00:19:08,060 But if you do a string copy on the IDS, it will fail to get the entire string, 256 00:19:08,140 --> 00:19:09,360 and the rest of it's ignored. 257 00:19:11,960 --> 00:19:17,420 When RFP released this, he released his original whisker scanner with just the head command 258 00:19:17,420 --> 00:19:19,100 as being the IDS evasion technique. 259 00:19:19,940 --> 00:19:23,080 And then a few months later, I'm not quite sure how long later, 260 00:19:23,180 --> 00:19:29,260 he released the next version that had ten of these style of IDS evasion techniques. 261 00:19:29,260 --> 00:19:33,100 Most of them would only work on specific web servers. 262 00:19:33,560 --> 00:19:35,360 These other ones listed here are pretty much generic. 263 00:19:37,540 --> 00:19:41,900 I pull out just the head and the two of these are sort of off to the side 264 00:19:41,900 --> 00:19:44,060 because those are the ones that affected Black Ice. 265 00:19:45,020 --> 00:19:48,740 I was kind of ticked off on this first release because it immediately evaded us 266 00:19:48,740 --> 00:19:51,600 and I had to go in and fix the head and re-release a patch. 267 00:19:52,620 --> 00:19:55,520 But then I went through and tried to figure out everything else he might be adding 268 00:19:55,520 --> 00:19:58,020 because he claims he's going to add some more IDS evasion techniques. 269 00:19:58,020 --> 00:20:01,440 And I figured out nine of them, but I didn't quite catch the tenth one. 270 00:20:02,900 --> 00:20:09,200 And the cool thing is we released patches to our product very quickly after RF whisker was released, 271 00:20:09,300 --> 00:20:09,820 both versions. 272 00:20:10,360 --> 00:20:14,420 A lot of vendors today still can't catch these, or at least catch all of them, 273 00:20:14,620 --> 00:20:19,460 especially if you combine multiple techniques like encoding in URL encoding 274 00:20:20,020 --> 00:20:25,060 and then add the dot directory, self-referencing directories. 275 00:20:28,020 --> 00:20:29,800 Now, whisker is just a CGI scanner. 276 00:20:30,020 --> 00:20:34,340 It scans a website and looks for a few hundred possible scripts that the website might be running. 277 00:20:34,940 --> 00:20:37,460 If you're a script kiddie and you want to break into a website, 278 00:20:37,660 --> 00:20:39,480 the first thing you're going to do is run whisker on it, 279 00:20:39,540 --> 00:20:44,800 find out it's got one of the hundreds of CGI programs vulnerable, 280 00:20:45,300 --> 00:20:47,240 then you'll exploit that CGI program. 281 00:20:48,160 --> 00:20:50,640 When you do the exploit, you have to do the evasion yourself. 282 00:20:51,480 --> 00:20:56,820 Like in this case, I've shown how to access a website for the PHF 283 00:20:56,820 --> 00:21:00,540 and put the self-referencing directory, a dot, 284 00:21:00,720 --> 00:21:04,560 and then to encode the dot with URL encoding, which comes out as a %2e. 285 00:21:05,940 --> 00:21:10,520 My website actually has what looks to be a PHF script on robertgram.com, 286 00:21:10,620 --> 00:21:14,660 which is my website, just so I have fun with hackers that try to access it. 287 00:21:16,980 --> 00:21:18,600 Actually, I do a lot of stuff on my website. 288 00:21:18,620 --> 00:21:22,600 If you scan around, you'll find lots of these little Easter eggs on it. 289 00:21:25,420 --> 00:21:26,800 The next classic evasion, 290 00:21:26,820 --> 00:21:30,240 now I believe somebody yesterday discussed this. 291 00:21:30,300 --> 00:21:32,260 I wanted to go to it, but the room was filled, 292 00:21:32,360 --> 00:21:33,640 and I couldn't ever get into it. 293 00:21:34,000 --> 00:21:35,940 To see how much of that's overlapping with this, 294 00:21:36,000 --> 00:21:36,960 it probably overlaps entirely. 295 00:21:38,040 --> 00:21:39,580 I probably showed a lot more techniques. 296 00:21:44,540 --> 00:21:45,760 Fed spying on us again. 297 00:21:47,780 --> 00:21:49,080 When you write at buffer overflow, 298 00:21:49,400 --> 00:21:51,740 one characteristic that you see for most of them 299 00:21:51,740 --> 00:21:54,840 is that they have these fillers of no-op codes 300 00:21:54,840 --> 00:21:57,860 to align where they want to jump into the code. 301 00:21:58,960 --> 00:22:01,560 For example, on the x86 architecture, 302 00:22:01,940 --> 00:22:04,680 the 90 op code is a no-op. 303 00:22:04,740 --> 00:22:05,320 It does nothing. 304 00:22:06,820 --> 00:22:09,180 A lot of CPUs have multiple no-op codes, 305 00:22:09,400 --> 00:22:13,720 so simply by replacing the standard no-op with a different no-op, 306 00:22:13,840 --> 00:22:17,060 you can evade the signature looking for no-op codes. 307 00:22:18,440 --> 00:22:20,120 You can also fill it with normal ops, 308 00:22:20,180 --> 00:22:21,980 stuff that actually do things. 309 00:22:22,060 --> 00:22:22,960 If you're going to overwrite a register, 310 00:22:22,960 --> 00:22:26,040 your no-op code could actually just be an increment of the register 311 00:22:26,040 --> 00:22:27,600 that you're about to overwrite later on. 312 00:22:29,580 --> 00:22:31,500 The x86 has lots of no-ops. 313 00:22:31,500 --> 00:22:32,840 Being a nice little system processor, 314 00:22:33,100 --> 00:22:35,900 it provides us lots of complicated ways to do nothing. 315 00:22:39,540 --> 00:22:41,280 Now, if you want to be truly evil, 316 00:22:41,920 --> 00:22:43,120 when you do that fill, 317 00:22:43,240 --> 00:22:46,380 most of these exploit scripts start with a little fill 318 00:22:46,380 --> 00:22:47,900 of fill all the no-ops. 319 00:22:49,160 --> 00:22:50,600 Like this little for loop here. 320 00:22:50,860 --> 00:22:52,740 If you want to be nasty, what you do is, 321 00:22:52,960 --> 00:22:55,200 you create your little table of what you want to be your no-op codes, 322 00:22:55,340 --> 00:22:56,760 and do a random lookup. 323 00:22:56,920 --> 00:22:58,120 Every time you run your script, 324 00:22:58,700 --> 00:23:00,560 you'll have a different signature on the wire. 325 00:23:02,700 --> 00:23:04,820 Even if I'm looking for certain patterns of no-ops, 326 00:23:04,880 --> 00:23:05,540 it still won't work, 327 00:23:05,580 --> 00:23:07,500 because there are different patterns every single time. 328 00:23:09,400 --> 00:23:12,700 The reason this affects network-based intrusion detection systems 329 00:23:12,700 --> 00:23:15,720 is that they're mostly based upon the packet grep technology, 330 00:23:16,040 --> 00:23:18,340 which is bring in a packet, look for a pattern. 331 00:23:20,560 --> 00:23:21,840 Alternative technology that, 332 00:23:21,840 --> 00:23:23,440 I know at least one company is using, 333 00:23:23,600 --> 00:23:25,120 is protocol decoding. 334 00:23:25,460 --> 00:23:28,580 It doesn't really care about the exact pattern that you're using. 335 00:23:28,920 --> 00:23:31,520 What it cares about is that you're doing something suspicious. 336 00:23:32,120 --> 00:23:34,820 In this case, if you're doing a buffer overflow attack 337 00:23:34,820 --> 00:23:36,520 against a POP3 server, 338 00:23:38,400 --> 00:23:40,820 rather than looking for the actual overflow itself, 339 00:23:41,140 --> 00:23:43,720 you say, hey, he's just entered in a username 340 00:23:43,720 --> 00:23:45,140 that's a thousand characters long. 341 00:23:45,380 --> 00:23:47,140 And it's got some binary in the username. 342 00:23:47,580 --> 00:23:49,360 This is something extremely suspicious. 343 00:23:50,620 --> 00:23:54,100 Now, you can evade that actual pattern 344 00:23:54,100 --> 00:23:55,720 of buffer overflow all you want, 345 00:23:55,800 --> 00:23:57,540 but you still detect the fact that you've got 346 00:23:57,540 --> 00:23:58,760 the suspiciously long username. 347 00:24:03,040 --> 00:24:04,640 As I mentioned before, 348 00:24:04,880 --> 00:24:06,280 a lot of these intrusion detection systems 349 00:24:06,280 --> 00:24:09,040 have a long list of ports that are suspicious ports. 350 00:24:09,440 --> 00:24:11,520 My back orifice is 31337. 351 00:24:13,000 --> 00:24:14,680 Sub7 uses two different ports. 352 00:24:15,180 --> 00:24:17,580 But these things can run on any port. 353 00:24:19,360 --> 00:24:21,820 If you look on your firewall logs right now, 354 00:24:21,940 --> 00:24:26,420 you'll see lots of scans for port 27374 and 1243 355 00:24:27,000 --> 00:24:29,080 for the Sub7 Trojan horse. 356 00:24:29,320 --> 00:24:31,900 And you're seeing lots and lots and lots of these scans. 357 00:24:32,000 --> 00:24:34,280 So you're thinking, I see so many of these scans, 358 00:24:34,360 --> 00:24:37,100 it must be that everyone's running Sub7 on the default ports. 359 00:24:38,180 --> 00:24:42,080 But actually, looking at our own, what we've seen on the net, 360 00:24:42,260 --> 00:24:45,680 is that most successful compromisers are actually 361 00:24:46,320 --> 00:24:49,060 at non-default ports with non-default passwords. 362 00:24:50,580 --> 00:24:52,240 And we can see this sort of stuff 363 00:24:52,240 --> 00:24:54,040 because we run on some ISP backbones, 364 00:24:54,180 --> 00:24:56,280 and our customer base actually sends us 365 00:24:56,280 --> 00:24:57,520 a large number of these files 366 00:24:57,520 --> 00:24:59,920 when our proxy texts the fact that they've been exploited. 367 00:25:02,300 --> 00:25:06,540 So the real danger is that you've got these Trojan horses 368 00:25:06,540 --> 00:25:08,020 running on non-default ports, 369 00:25:08,240 --> 00:25:11,640 and the default ports are just noise. 370 00:25:11,940 --> 00:25:13,340 And the reason they're so common 371 00:25:13,340 --> 00:25:15,180 is not because people are running at those ports, 372 00:25:15,300 --> 00:25:19,160 it's because the Sub7 itself contains 373 00:25:19,360 --> 00:25:20,140 a built-in scanner. 374 00:25:20,380 --> 00:25:22,900 I compromise one person, and the first thing I do 375 00:25:22,900 --> 00:25:24,680 is I tell that one person to scan the whole internet 376 00:25:24,680 --> 00:25:27,560 looking for other possible victims. 377 00:25:28,380 --> 00:25:30,840 It rarely finds them, though, at the default ports. 378 00:25:33,200 --> 00:25:35,200 The way these Trojan infections work 379 00:25:35,940 --> 00:25:39,140 is that a hacker wants to get the Trojan on your computer. 380 00:25:39,640 --> 00:25:42,520 It might do so by posting to Usenet. 381 00:25:44,200 --> 00:25:46,840 Some victim somewhere in the world, unrelated to the hacker, 382 00:25:46,960 --> 00:25:48,600 goes to the Usenet group, says, 383 00:25:48,600 --> 00:25:51,240 hey, this is a great new porn picture viewer or something, 384 00:25:51,920 --> 00:25:54,380 downloads the program, runs it, and infects themselves. 385 00:25:56,260 --> 00:25:59,700 Now, if it's during a non-default port or a non-default password, 386 00:25:59,940 --> 00:26:01,960 one way that the hacker can find who that is 387 00:26:02,600 --> 00:26:05,160 is by telling the Trojan horse to notify them. 388 00:26:05,860 --> 00:26:07,340 Now, you can't notify the hacker directly 389 00:26:07,340 --> 00:26:09,640 because then it's like a clear finger-pointing 390 00:26:09,640 --> 00:26:10,520 for the feds to follow. 391 00:26:10,960 --> 00:26:13,680 So instead, the hacker has them notify a third party, 392 00:26:13,800 --> 00:26:17,520 which can be done with email, IRC, ICQ, 393 00:26:17,520 --> 00:26:18,680 or a number of other options. 394 00:26:19,480 --> 00:26:21,860 The hacker then logs on to that third party system 395 00:26:21,860 --> 00:26:25,000 and finds the victims that have all notified themselves to him. 396 00:26:25,220 --> 00:26:27,660 At that point, he uses the password and port number 397 00:26:27,660 --> 00:26:29,880 to break into the victim's machine. 398 00:26:32,820 --> 00:26:36,480 This is the Sub7 Edit Server program, 399 00:26:36,820 --> 00:26:38,420 which sets all these values 400 00:26:38,420 --> 00:26:40,780 of how it's going to actually compromise the person. 401 00:26:41,460 --> 00:26:45,240 You can see that it will notify via ICQ, via IRC, 402 00:26:45,300 --> 00:26:47,060 which IRC servers, 403 00:26:48,680 --> 00:26:50,720 email systems, and so forth. 404 00:26:51,260 --> 00:26:53,120 One of the cool things it has is that 405 00:26:53,120 --> 00:26:55,800 it can use a random port on startup, 406 00:26:56,680 --> 00:26:58,340 which means every time it runs, 407 00:26:58,340 --> 00:26:59,480 it's going to run at a different port, 408 00:27:00,100 --> 00:27:02,640 so that there's no amount of scanning for ports 409 00:27:02,640 --> 00:27:03,820 that will ever find this system, 410 00:27:03,860 --> 00:27:05,120 because it will always run at some other port. 411 00:27:05,460 --> 00:27:07,360 But yet, having an IRC notify 412 00:27:07,360 --> 00:27:12,180 will always tell the hacker exactly which port's currently in use. 413 00:27:12,700 --> 00:27:15,600 So even if you're a user with a notebook computer, 414 00:27:15,700 --> 00:27:17,280 maybe, on the road, dialing up, 415 00:27:17,520 --> 00:27:18,840 every time you dial up, 416 00:27:18,920 --> 00:27:21,040 you notify the hacker where you are, 417 00:27:21,100 --> 00:27:21,980 and he'll come find you. 418 00:27:23,920 --> 00:27:25,360 From our own evidence, 419 00:27:25,560 --> 00:27:27,960 it looks like the IRC is the most popular way 420 00:27:27,960 --> 00:27:29,200 for notifying the hacker. 421 00:27:33,560 --> 00:27:36,080 So those are the standard evasion techniques 422 00:27:36,080 --> 00:27:37,340 that people are using today. 423 00:27:37,480 --> 00:27:38,540 They're very simple to use. 424 00:27:39,980 --> 00:27:41,620 It's not really too difficult. 425 00:27:41,980 --> 00:27:45,500 Now we get into some uber evasion techniques. 426 00:27:45,500 --> 00:27:48,160 The first is the theory. 427 00:27:48,620 --> 00:27:49,980 As I mentioned before, 428 00:27:51,400 --> 00:27:54,460 packet grep systems are looking on the wire for patterns. 429 00:27:56,180 --> 00:27:57,960 Logically, according to the OSI model, 430 00:27:58,660 --> 00:28:00,580 that belongs in the presentation layer. 431 00:28:01,600 --> 00:28:04,860 The OSI model was this model developed back in the 80s. 432 00:28:04,860 --> 00:28:06,640 It's a very big bureaucratic process, 433 00:28:06,760 --> 00:28:09,200 and it's supposed to be the overall end-all 434 00:28:09,200 --> 00:28:11,900 of describing how technologies like this should work. 435 00:28:12,320 --> 00:28:14,400 It tries to define, okay, layer one, 436 00:28:14,400 --> 00:28:15,320 you're worried about cabling, 437 00:28:15,380 --> 00:28:16,620 getting the bits across the wire. 438 00:28:17,080 --> 00:28:20,420 Label two is getting two machines to actually talk 439 00:28:20,420 --> 00:28:21,580 and send data to each other 440 00:28:22,540 --> 00:28:24,940 and getting frames, what they call, across the wire. 441 00:28:25,220 --> 00:28:27,460 Layer three is getting IP end-to-end 442 00:28:27,460 --> 00:28:29,520 across the entire Internet, not just locally. 443 00:28:30,360 --> 00:28:32,740 TCP is getting two applications to talk to each other. 444 00:28:33,820 --> 00:28:35,620 The session layer is this meaningless thing 445 00:28:35,620 --> 00:28:37,900 that ever and actually never turned out to be worthwhile in practice, 446 00:28:38,000 --> 00:28:38,880 and no one ever uses it. 447 00:28:39,780 --> 00:28:41,440 The presentation layer... 448 00:28:41,440 --> 00:28:43,240 By the way, there's lots of books 449 00:28:43,240 --> 00:28:44,360 about the OSI model, 450 00:28:44,820 --> 00:28:46,920 and when you look for the description of the session layer, 451 00:28:47,020 --> 00:28:48,320 it always comes down to two things. 452 00:28:48,460 --> 00:28:50,020 The session layer is something that manages sessions. 453 00:28:50,580 --> 00:28:51,380 Well, what's a session? 454 00:28:51,540 --> 00:28:53,820 Well, it's one of these things that you get in the session layer. 455 00:28:54,960 --> 00:28:56,880 And so I've looked... 456 00:28:56,880 --> 00:28:58,540 Every time I find a new book on the OSI model, 457 00:28:58,820 --> 00:29:00,880 I look to see if they've actually defined it any way. 458 00:29:00,940 --> 00:29:01,540 It's not circular. 459 00:29:01,740 --> 00:29:02,620 I never found one that does. 460 00:29:02,980 --> 00:29:04,520 Well, I found one a long time ago, 461 00:29:04,880 --> 00:29:07,560 and really the session layer came from these old teletype, 462 00:29:07,560 --> 00:29:08,660 terminal-type things, 463 00:29:08,820 --> 00:29:10,140 and there are some concepts in there 464 00:29:10,140 --> 00:29:11,720 that never apply outside of that environment. 465 00:29:12,740 --> 00:29:14,780 So then there's the presentation layer. 466 00:29:15,160 --> 00:29:16,600 And back in the OSI model, 467 00:29:16,840 --> 00:29:19,200 they wanted to negotiate the presentation layer. 468 00:29:19,420 --> 00:29:22,040 But really, lots of protocols have a presentation layer, 469 00:29:22,180 --> 00:29:24,220 even though it's not really a separate entity. 470 00:29:24,520 --> 00:29:26,000 And all it's specifying 471 00:29:26,000 --> 00:29:28,100 is how data is formatted across the network. 472 00:29:30,200 --> 00:29:31,640 For example, in SMTP, 473 00:29:31,840 --> 00:29:32,800 it might be the MIME encoding, 474 00:29:32,980 --> 00:29:34,900 sort of a presentation layer-type concept. 475 00:29:35,320 --> 00:29:37,100 And the application layer is the mail, 476 00:29:37,240 --> 00:29:40,200 the IRC, FTP, web, and so forth. 477 00:29:44,340 --> 00:29:48,260 RPC has a very distinctive presentation layer. 478 00:29:49,240 --> 00:29:52,460 One of the lesser-known things about that layer 479 00:29:52,460 --> 00:29:53,940 is something called record marking. 480 00:29:54,900 --> 00:29:58,180 When you send RPC packets across a TCP connection, 481 00:29:58,660 --> 00:30:01,220 TCP creates this virtual byte stream, 482 00:30:01,460 --> 00:30:05,020 so you must know when a command ends and begins. 483 00:30:05,460 --> 00:30:08,240 And so they do that with this record marking code. 484 00:30:08,940 --> 00:30:10,180 Now, lots of protocols 485 00:30:10,200 --> 00:30:14,200 do this, but what RPC has added to that whole mix 486 00:30:14,840 --> 00:30:17,860 is the ability to fragment the records. 487 00:30:18,220 --> 00:30:20,260 So most protocols, when running over TCP, 488 00:30:20,600 --> 00:30:21,440 they have a length field. 489 00:30:21,580 --> 00:30:23,420 That's the first field that says the length of the command. 490 00:30:23,740 --> 00:30:26,640 So even though TCP might segment it out into multiple packets, 491 00:30:26,900 --> 00:30:29,280 they know exactly how many bytes are in that command. 492 00:30:30,120 --> 00:30:32,060 TCP adds something where you can send 493 00:30:32,060 --> 00:30:35,160 multiple of these length-encoded items 494 00:30:35,160 --> 00:30:39,540 that all then combine back into the common original record. 495 00:30:42,560 --> 00:30:44,040 And the way that would work 496 00:30:44,040 --> 00:30:46,760 is in this little diagram here, 497 00:30:46,820 --> 00:30:47,740 I have the normal record, 498 00:30:48,320 --> 00:30:50,020 which is the RPC command in white, 499 00:30:50,200 --> 00:30:52,520 which is prefixed with a 4-byte length field. 500 00:30:54,000 --> 00:30:56,060 The top bit of that length field 501 00:30:56,060 --> 00:30:58,960 says whether there will be another, 502 00:30:59,140 --> 00:31:02,800 whether it's the last fragment of this record, 503 00:31:02,940 --> 00:31:05,460 or whether more fragments follow across the TCP connection. 504 00:31:06,720 --> 00:31:09,080 So I split, in this case, in this diagram, 505 00:31:09,540 --> 00:31:11,980 that white command into two fragments, 506 00:31:12,240 --> 00:31:13,980 each with its own record mark. 507 00:31:14,960 --> 00:31:18,680 The first one says that another record fragment follows, 508 00:31:18,820 --> 00:31:19,720 and the last one says 509 00:31:20,510 --> 00:31:22,080 that's the last fragment in the whole stream. 510 00:31:23,420 --> 00:31:25,800 Now, if you want to be nasty, 511 00:31:25,920 --> 00:31:28,640 you want to randomly combine 512 00:31:28,640 --> 00:31:31,620 the TCP layer segmenting 513 00:31:31,620 --> 00:31:34,600 and the RPC layer record marking. 514 00:31:36,440 --> 00:31:39,100 And then one of the cool things is, 515 00:31:39,100 --> 00:31:40,640 normally, in normal traffic, 516 00:31:40,880 --> 00:31:42,540 these things are always working together. 517 00:31:42,780 --> 00:31:44,680 You see a TCP segment across the wire, 518 00:31:44,900 --> 00:31:46,580 it always starts with a record mark, 519 00:31:46,720 --> 00:31:47,880 but doesn't have to be. 520 00:31:48,480 --> 00:31:50,340 So in this third little diagram here, 521 00:31:50,380 --> 00:31:51,620 I show where I fragmented 522 00:31:52,300 --> 00:31:54,180 the TCP segment separately 523 00:31:54,180 --> 00:31:55,660 from the record marking segment. 524 00:31:55,800 --> 00:31:58,080 So I'm sending four TCP segments 525 00:31:59,920 --> 00:32:01,340 for that original request. 526 00:32:06,100 --> 00:32:07,820 So the upshot of that is, 527 00:32:07,820 --> 00:32:09,660 is that you're not going to find 528 00:32:09,660 --> 00:32:11,180 a traditional RPC pattern 529 00:32:12,520 --> 00:32:14,080 in that TCP connection. 530 00:32:15,680 --> 00:32:16,880 So I wrote a little code. 531 00:32:17,140 --> 00:32:20,000 I'll be posting this to my website after DEF CON. 532 00:32:20,960 --> 00:32:22,440 And what it does is you replace 533 00:32:22,440 --> 00:32:24,700 your traditional socket send function 534 00:32:24,700 --> 00:32:26,360 that sends the data across the wire 535 00:32:26,360 --> 00:32:29,300 in your exploit script with mysend. 536 00:32:29,760 --> 00:32:32,200 What mysend does is it randomizes 537 00:32:32,200 --> 00:32:34,400 where it's going to record mark and fragment the stuff 538 00:32:34,400 --> 00:32:37,620 and where it's going to segment at the TCP layer. 539 00:32:39,080 --> 00:32:41,300 If you're familiar with RPC, 540 00:32:41,720 --> 00:32:45,420 it has, XDR has this very distinctive rule 541 00:32:45,420 --> 00:32:48,180 that everything has to be fragmented on four, 542 00:32:48,180 --> 00:32:50,180 or everything has to be on four byte boundaries. 543 00:32:50,660 --> 00:32:52,760 So all integers must be four bytes. 544 00:32:52,860 --> 00:32:53,960 You can't have a three byte integer. 545 00:32:54,660 --> 00:32:57,700 A string of someone's name that's nine bytes long 546 00:32:57,700 --> 00:33:00,400 has to be padded out to an even 12 bytes 547 00:33:00,400 --> 00:33:01,780 with nulls at the end. 548 00:33:02,860 --> 00:33:05,220 But that XDR restriction does not apply 549 00:33:05,220 --> 00:33:06,020 to record marking. 550 00:33:06,020 --> 00:33:08,260 I point this out because the first time 551 00:33:08,260 --> 00:33:11,880 I did the anti-evasion stuff in Black Ice, 552 00:33:12,040 --> 00:33:13,800 I made the assumption that was XDR. 553 00:33:14,600 --> 00:33:15,900 And then I played around with the spec, 554 00:33:15,960 --> 00:33:17,220 realized it didn't have to apply, 555 00:33:17,520 --> 00:33:18,760 tried it out on the exploit script, 556 00:33:18,860 --> 00:33:19,660 and sure enough, it evaded, 557 00:33:19,680 --> 00:33:21,320 so I had to change my code yet again. 558 00:33:23,120 --> 00:33:24,920 So anyway, so we call the mysend function, 559 00:33:25,040 --> 00:33:26,140 instead of your normal send function 560 00:33:26,140 --> 00:33:27,780 that you have as part of your exploit script, 561 00:33:28,700 --> 00:33:30,680 it calls the mysend upper function, 562 00:33:30,820 --> 00:33:33,760 which adds the record marking stuff to it 563 00:33:34,940 --> 00:33:36,540 with a random length field, 564 00:33:37,380 --> 00:33:39,420 and then passes it to the TCP layer, 565 00:33:40,180 --> 00:33:42,560 where I again then randomize 566 00:33:42,560 --> 00:33:45,000 how long the TCP segment is going to be. 567 00:33:45,240 --> 00:33:47,180 I also put a little random sleep time there, 568 00:33:47,280 --> 00:33:50,620 so if you're trying to find the traffic over time, 569 00:33:50,760 --> 00:33:51,940 that messes up too. 570 00:33:53,260 --> 00:33:54,780 And what I come up with is something 571 00:33:54,780 --> 00:33:55,660 that looks like this, 572 00:33:55,700 --> 00:33:57,840 is randomize where I'm going to record frag 573 00:33:57,840 --> 00:33:59,680 and randomize where I'm going to TCP segment. 574 00:34:02,120 --> 00:34:03,140 So if my, 575 00:34:04,400 --> 00:34:06,440 original command is like a port dump command. 576 00:34:06,900 --> 00:34:08,920 Port dump is a scanning technique. 577 00:34:09,040 --> 00:34:11,440 You scan an RPC server and ask it 578 00:34:11,440 --> 00:34:12,660 what services are running. 579 00:34:12,960 --> 00:34:14,380 This is how you hunt down to see 580 00:34:14,380 --> 00:34:15,320 which ones might be vulnerable 581 00:34:15,320 --> 00:34:16,080 that you're going to exploit 582 00:34:16,080 --> 00:34:17,440 with buffer overflow exploits. 583 00:34:19,080 --> 00:34:21,520 This is what the packet looks like in hex. 584 00:34:22,040 --> 00:34:23,680 Right below it is a decode. 585 00:34:23,720 --> 00:34:25,860 The first four bytes are that record frag. 586 00:34:26,380 --> 00:34:29,060 The first byte is that little bit 587 00:34:29,060 --> 00:34:32,340 saying it's the last record frag in the sequence. 588 00:34:33,760 --> 00:34:36,220 Because it normally doesn't record frag on requests. 589 00:34:36,860 --> 00:34:38,980 Then you have the XID, the message type, 590 00:34:39,060 --> 00:34:40,720 it calls as RPC version two, 591 00:34:40,800 --> 00:34:42,160 which is all RPC we use today. 592 00:34:42,700 --> 00:34:45,460 Support map command is port map version two. 593 00:34:45,600 --> 00:34:46,760 The procedure is dump, 594 00:34:46,880 --> 00:34:48,040 which is procedure number four. 595 00:34:48,280 --> 00:34:49,920 There's no authentication or verification. 596 00:34:51,560 --> 00:34:52,660 Here's what it looks like 597 00:34:52,660 --> 00:34:54,540 after it gets through the my send functions. 598 00:34:55,180 --> 00:34:58,420 The first packet has a TCP segment of zero and zero. 599 00:34:58,960 --> 00:35:01,860 The next packet has a TCP segment of zero, 600 00:35:01,980 --> 00:35:03,740 five, and so on and so forth. 601 00:35:03,760 --> 00:35:05,820 Those first four bytes, of course, 602 00:35:05,860 --> 00:35:07,640 are the record marking stuff, 603 00:35:07,900 --> 00:35:09,080 where I've randomly chosen 604 00:35:09,080 --> 00:35:10,980 that the first record's going to be five bytes long. 605 00:35:12,560 --> 00:35:15,720 By the randomization of the packet, 606 00:35:16,040 --> 00:35:17,700 even that record mark itself 607 00:35:17,700 --> 00:35:19,380 was segmented in the TCP segments. 608 00:35:20,180 --> 00:35:22,080 I have about one, two, three, four, 609 00:35:22,180 --> 00:35:23,940 five, six, seven, eight, nine, ten, 610 00:35:24,000 --> 00:35:26,140 11, 12, 13, 14, 15, 16, 17. 611 00:35:26,160 --> 00:35:27,640 I've got 17 packets there 612 00:35:27,640 --> 00:35:29,720 where originally I had only one packet. 613 00:35:30,460 --> 00:35:32,720 It's also about 70 bytes long 614 00:35:32,720 --> 00:35:35,340 where the original packet was about 40 bytes long. 615 00:35:37,100 --> 00:35:39,420 This, of course, gives IDSs fits. 616 00:35:40,120 --> 00:35:42,960 Most IDSs still don't reassemble TCP streams, 617 00:35:43,160 --> 00:35:43,940 but even if they did, 618 00:35:44,780 --> 00:35:45,980 the stream wouldn't look like anything 619 00:35:45,980 --> 00:35:47,500 like they've ever seen with RPC. 620 00:35:48,480 --> 00:35:50,520 They don't detect the port map attack. 621 00:35:51,080 --> 00:35:53,760 I've tried this against a number of the other IDSs. 622 00:35:53,780 --> 00:35:55,540 Sure enough, they detect the normal one, 623 00:35:55,600 --> 00:35:57,180 but they don't detect the evaded one. 624 00:36:00,600 --> 00:36:02,080 This is particularly important 625 00:36:02,080 --> 00:36:02,600 because, 626 00:36:02,720 --> 00:36:05,560 because of the way that a lot of IDSs work, 627 00:36:05,700 --> 00:36:08,500 well, I assume they work with RPC, 628 00:36:09,160 --> 00:36:11,800 is RPC runs its services at random ports, 629 00:36:12,000 --> 00:36:13,280 like CMSD, 630 00:36:13,380 --> 00:36:14,700 Calendar Messenger Service, 631 00:36:14,860 --> 00:36:17,160 an exploit that a lot of Solaris machines 632 00:36:17,160 --> 00:36:19,160 fell victim to last year, 633 00:36:19,280 --> 00:36:21,460 runs at a randomly chosen port. 634 00:36:21,920 --> 00:36:22,920 When it starts up, 635 00:36:22,920 --> 00:36:24,000 it registers with port mapper 636 00:36:24,000 --> 00:36:25,260 at the well-known port of 1.11 637 00:36:25,260 --> 00:36:27,400 and tells it which port it's running at. 638 00:36:29,380 --> 00:36:30,600 Back at Network General 639 00:36:30,600 --> 00:36:31,540 when we worked on the sniffer, 640 00:36:31,540 --> 00:36:32,840 the way we got around this fact 641 00:36:32,840 --> 00:36:35,020 was by using a heuristic called smells-like, 642 00:36:35,140 --> 00:36:37,080 where we looked at an RPC request and said, 643 00:36:37,140 --> 00:36:38,640 does this look like an RPC request? 644 00:36:39,700 --> 00:36:40,820 RPC is kind of cool 645 00:36:41,300 --> 00:36:42,600 because it's very distinctive. 646 00:36:42,760 --> 00:36:43,780 You have that record mark. 647 00:36:43,940 --> 00:36:45,800 You have the XID, which is random. 648 00:36:46,260 --> 00:36:48,040 The message type is either 0 or 1, 649 00:36:48,100 --> 00:36:48,920 so you've got four bytes 650 00:36:48,920 --> 00:36:50,200 that are either going to be 0 or 1. 651 00:36:50,700 --> 00:36:52,280 RPC version is always 2, 652 00:36:52,340 --> 00:36:53,400 so that field must be 2, 653 00:36:53,520 --> 00:36:55,000 and so on and so forth. 654 00:36:55,160 --> 00:36:58,240 We can really distinctively say 99.9% of the time 655 00:36:58,240 --> 00:36:58,960 whether it's RPC. 656 00:37:01,500 --> 00:37:03,200 But in this packet, 657 00:37:03,320 --> 00:37:04,560 those rules don't apply. 658 00:37:04,720 --> 00:37:05,980 It looks nothing like RPC anymore 659 00:37:05,980 --> 00:37:07,040 according to those heuristics. 660 00:37:08,700 --> 00:37:10,480 Heuristics that try to deal with the record mark 661 00:37:10,480 --> 00:37:11,740 can always be evaded 662 00:37:11,740 --> 00:37:13,140 by carefully constructing your record 663 00:37:13,140 --> 00:37:14,580 to look like something else. 664 00:37:17,240 --> 00:37:18,840 The only way to get around that 665 00:37:18,840 --> 00:37:22,660 is the IDS needs to not use those heuristics 666 00:37:22,660 --> 00:37:24,480 and must instead keep a lot more state around. 667 00:37:24,720 --> 00:37:26,640 It must profile the target to say, 668 00:37:26,760 --> 00:37:28,860 I see a port mapper response come back. 669 00:37:28,860 --> 00:37:30,240 Therefore, I know which ports 670 00:37:30,240 --> 00:37:31,440 all the services are running at. 671 00:37:34,340 --> 00:37:35,780 That's RPC record fragging. 672 00:37:35,920 --> 00:37:38,440 That was suggested to me by Doug Song, 673 00:37:38,640 --> 00:37:40,000 who wrote the original Frag Router. 674 00:37:40,140 --> 00:37:41,780 He's working on a Frag Proxy, 675 00:37:41,800 --> 00:37:43,180 or I'm not quite sure what he's working on, 676 00:37:43,380 --> 00:37:45,220 that will do this automatically for you, 677 00:37:45,260 --> 00:37:47,360 whereas my code you have to add to your script 678 00:37:47,360 --> 00:37:48,800 and change the script. 679 00:37:52,240 --> 00:37:54,100 The next one is something that I discovered myself, 680 00:37:54,420 --> 00:37:57,540 where I'm using the Telnet channel 681 00:37:57,540 --> 00:37:58,880 on FTP. 682 00:37:59,240 --> 00:38:00,940 If you read the FTP specification, 683 00:38:01,340 --> 00:38:04,700 it says that the control channel is really Telnet. 684 00:38:05,700 --> 00:38:08,440 Now, the later on host requirements RPC says, 685 00:38:08,560 --> 00:38:09,500 no, it's really not Telnet. 686 00:38:09,680 --> 00:38:11,600 It's just something that looks a lot like Telnet 687 00:38:12,400 --> 00:38:14,720 using the same option strings, 688 00:38:14,860 --> 00:38:16,240 the out-of-band option communication. 689 00:38:17,580 --> 00:38:20,540 What Telnet has is strings that start with FF, 690 00:38:21,240 --> 00:38:22,220 a byte with all ones, 691 00:38:22,980 --> 00:38:25,340 followed by either one or two bytes of the option code. 692 00:38:26,020 --> 00:38:27,460 In the Telnet usage, 693 00:38:27,540 --> 00:38:28,360 it's really complex. 694 00:38:28,660 --> 00:38:30,360 You can negotiate which terminal you are, 695 00:38:30,580 --> 00:38:32,460 what your backspace character is going to be, 696 00:38:32,640 --> 00:38:33,640 and a lot of other stuff. 697 00:38:35,540 --> 00:38:37,220 In the normal Telnet environment, 698 00:38:37,440 --> 00:38:38,340 the issue is so bad, 699 00:38:38,500 --> 00:38:40,600 you can basically avoid any IDS detection 700 00:38:40,600 --> 00:38:41,540 on the Telnet channel. 701 00:38:41,640 --> 00:38:44,000 You can reconfigure your backspace character 702 00:38:44,000 --> 00:38:45,440 to be Q or something like that. 703 00:38:45,820 --> 00:38:47,460 So your IDS is seeing a string of Qs, 704 00:38:47,460 --> 00:38:50,340 but the target system is seeing a string of backspaces. 705 00:38:51,660 --> 00:38:53,100 But in the FTP case, 706 00:38:54,100 --> 00:38:55,420 none of that can be negotiated. 707 00:38:55,640 --> 00:38:57,380 All they can negotiate is whether to use the abort 708 00:38:57,540 --> 00:38:57,820 option, 709 00:38:58,340 --> 00:39:00,040 the abort Telnet option code. 710 00:39:00,220 --> 00:39:01,680 Everything else is a null option. 711 00:39:02,120 --> 00:39:04,220 So an FF followed by any other byte 712 00:39:04,220 --> 00:39:07,180 is pretty much ignored in the FTP command channel. 713 00:39:08,580 --> 00:39:10,160 So when you log on as, 714 00:39:10,360 --> 00:39:10,980 in this case, 715 00:39:10,980 --> 00:39:11,520 user rob, 716 00:39:12,020 --> 00:39:14,580 you can put in that FF and then another byte. 717 00:39:14,880 --> 00:39:17,380 The F1 is the Telnet no-op code. 718 00:39:18,640 --> 00:39:19,900 But any byte will do, 719 00:39:19,940 --> 00:39:21,380 because it will strip it out and ignore it. 720 00:39:21,740 --> 00:39:23,260 So instead of seeing user rob, 721 00:39:23,340 --> 00:39:25,220 you see this user garbage rob, 722 00:39:25,360 --> 00:39:27,040 and it's pass-like garbage, 723 00:39:27,040 --> 00:39:27,800 and foo. 724 00:39:29,180 --> 00:39:30,520 And this is a lot like, 725 00:39:31,200 --> 00:39:32,380 conceptually like RPC. 726 00:39:32,580 --> 00:39:34,820 It's at the presentation layer of the OSI model. 727 00:39:35,080 --> 00:39:37,440 I'm changing how I'm formatting this stuff. 728 00:39:39,520 --> 00:39:41,700 So you think through all of the, 729 00:39:42,540 --> 00:39:44,260 the exploits that FTP can do, 730 00:39:44,360 --> 00:39:45,920 they're all pretty much run across the, 731 00:39:45,940 --> 00:39:47,000 the control channel. 732 00:39:47,360 --> 00:39:48,520 Like bounce scans, 733 00:39:48,720 --> 00:39:49,260 the tar compress, 734 00:39:49,640 --> 00:39:50,720 execute bug, 735 00:39:50,860 --> 00:39:51,740 buffer overflows, 736 00:39:52,080 --> 00:39:53,920 change working directory to root, 737 00:39:54,880 --> 00:39:57,020 logging on with username and password, 738 00:39:57,020 --> 00:39:58,080 site exec, 739 00:39:58,260 --> 00:39:59,760 there's been a lot of site exec holes lately, 740 00:40:00,320 --> 00:40:01,540 printf style format bugs, 741 00:40:01,780 --> 00:40:02,820 shell characters and so forth. 742 00:40:05,280 --> 00:40:07,420 Now as I was working on this and testing it out, 743 00:40:07,460 --> 00:40:08,480 I found a number of problems. 744 00:40:09,860 --> 00:40:11,280 Unix supports this three, 745 00:40:11,300 --> 00:40:12,620 this three character do, 746 00:40:12,700 --> 00:40:13,100 don't, 747 00:40:13,100 --> 00:40:14,020 command negotiation. 748 00:40:14,800 --> 00:40:16,860 Where the client logs on and says, 749 00:40:16,960 --> 00:40:18,420 I want to do something or other. 750 00:40:19,180 --> 00:40:20,780 And the server comes back and says, 751 00:40:20,800 --> 00:40:21,720 no, I don't support that, 752 00:40:21,780 --> 00:40:22,660 or I do support it. 753 00:40:24,480 --> 00:40:25,880 And the cool thing about that is, 754 00:40:25,920 --> 00:40:27,000 is you can desynchronize, 755 00:40:27,020 --> 00:40:27,720 and IDS, 756 00:40:27,720 --> 00:40:29,180 because you can start up and say, 757 00:40:29,280 --> 00:40:30,300 send the do command, 758 00:40:31,140 --> 00:40:32,480 FTP comes back and says, 759 00:40:32,560 --> 00:40:32,820 won't. 760 00:40:33,140 --> 00:40:33,900 The FTP, 761 00:40:34,040 --> 00:40:34,360 by the way, 762 00:40:34,440 --> 00:40:36,620 the specification now with host requirements RFC, 763 00:40:36,720 --> 00:40:38,960 says that it should respond with the won't for everything. 764 00:40:39,220 --> 00:40:41,100 Because it shouldn't really support telnet. 765 00:40:42,640 --> 00:40:43,080 So, 766 00:40:43,120 --> 00:40:43,740 you can send, 767 00:40:43,800 --> 00:40:45,020 you can pepper your code with these, 768 00:40:45,160 --> 00:40:47,200 like you can send a command like user password, 769 00:40:47,540 --> 00:40:48,840 and in the middle of that user string, 770 00:40:48,960 --> 00:40:50,580 send the do command, 771 00:40:51,060 --> 00:40:52,920 and you'll get back to this don't command, 772 00:40:53,580 --> 00:40:55,600 and it'll really confuse the IDS. 773 00:40:56,560 --> 00:40:57,000 Unfortunately, 774 00:40:57,020 --> 00:40:59,560 Windows FTP implementation from Microsoft 775 00:41:00,200 --> 00:41:02,220 doesn't support the three character code, 776 00:41:02,300 --> 00:41:04,240 only the two character evasion stuff. 777 00:41:05,640 --> 00:41:08,040 It also has that same null problem with, 778 00:41:08,060 --> 00:41:09,520 as Whisker does with the string copy. 779 00:41:09,720 --> 00:41:11,300 So you can send a null to it, 780 00:41:11,380 --> 00:41:12,700 prefixed by the option code, 781 00:41:12,940 --> 00:41:14,440 then it'll stop processing the string, 782 00:41:14,560 --> 00:41:16,520 and anything after it won't be interpreted by the server. 783 00:41:17,940 --> 00:41:18,380 Now, 784 00:41:18,420 --> 00:41:20,140 if the IDS interprets that string, 785 00:41:20,360 --> 00:41:22,200 it will no longer figure out what the users, 786 00:41:22,320 --> 00:41:23,440 or the hacker is really doing. 787 00:41:23,820 --> 00:41:24,560 But of course, 788 00:41:24,560 --> 00:41:26,940 if it does do the same logic as the Windows NT stuff, 789 00:41:26,940 --> 00:41:28,520 then it will no longer be able to detect 790 00:41:28,520 --> 00:41:30,460 all the attacks against the Unix FTP server. 791 00:41:32,160 --> 00:41:32,580 Now, 792 00:41:32,600 --> 00:41:35,060 there's also the problem that a lot of Windows FTP servers 793 00:41:35,060 --> 00:41:36,600 you might download off the web 794 00:41:36,600 --> 00:41:38,360 don't support any of this option stuff at all. 795 00:41:39,920 --> 00:41:40,340 So, 796 00:41:40,460 --> 00:41:41,660 what you really need to do 797 00:41:41,660 --> 00:41:42,900 is to profile the target, 798 00:41:43,000 --> 00:41:43,440 and figure out 799 00:41:43,440 --> 00:41:45,620 what kind of FTP server is the target running, 800 00:41:45,840 --> 00:41:48,760 and then adjust your IDS algorithms accordingly. 801 00:41:50,900 --> 00:41:51,320 Also, 802 00:41:51,500 --> 00:41:52,560 if you're writing the exploit scripts, 803 00:41:52,740 --> 00:41:54,460 you equally have to profile the target. 804 00:41:54,660 --> 00:41:55,420 For example, 805 00:41:55,420 --> 00:41:58,060 a lot of scripts run across the anonymous authentication, 806 00:41:58,560 --> 00:41:59,740 so the first thing you should do is 807 00:41:59,740 --> 00:42:00,940 encode the user string. 808 00:42:01,320 --> 00:42:02,200 If you get back an error, 809 00:42:02,380 --> 00:42:03,860 you know it's not handling the option code. 810 00:42:04,120 --> 00:42:04,720 If you say, 811 00:42:04,920 --> 00:42:06,700 okay, anonymous is allowed to log in, 812 00:42:06,840 --> 00:42:09,180 or guest accounts allowed to log in, 813 00:42:09,320 --> 00:42:11,840 then you know that it did accept the option code, 814 00:42:11,940 --> 00:42:13,340 and you should use option codes from then on. 815 00:42:14,000 --> 00:42:15,280 You can use the same technique 816 00:42:15,280 --> 00:42:17,320 back used in the RPC record fragging, 817 00:42:17,380 --> 00:42:18,920 is randomize the whole thing. 818 00:42:19,200 --> 00:42:20,140 Like, just every character 819 00:42:20,140 --> 00:42:21,620 is either randomly the original character, 820 00:42:22,020 --> 00:42:25,240 or one prefixed by the option evasion. 821 00:42:27,420 --> 00:42:28,820 So here's an example 822 00:42:28,820 --> 00:42:30,040 of where I do the 823 00:42:30,040 --> 00:42:31,560 change current working directory to root. 824 00:42:32,500 --> 00:42:33,940 A logon is anonymous, 825 00:42:34,280 --> 00:42:37,300 and I send that corruption in the user string, 826 00:42:37,480 --> 00:42:39,780 but the server supports FTP, 827 00:42:39,940 --> 00:42:40,880 or telnet options, 828 00:42:41,120 --> 00:42:43,560 and says, great, guest account log in okay, 829 00:42:43,780 --> 00:42:44,640 continue on. 830 00:42:46,100 --> 00:42:47,520 I then do the exploit, 831 00:42:47,740 --> 00:42:49,280 change current working directory to root, 832 00:42:49,440 --> 00:42:51,780 and I insert my little option codes in there 833 00:42:51,780 --> 00:42:53,020 so it doesn't look anything like 834 00:42:53,020 --> 00:42:54,520 change current working directory to root, 835 00:42:54,620 --> 00:42:55,320 and 836 00:42:55,420 --> 00:42:55,660 indeed, 837 00:42:56,140 --> 00:42:58,540 all the other IDSs fail to detect this. 838 00:42:58,880 --> 00:42:59,820 Though on the server, 839 00:43:00,040 --> 00:43:01,420 I got back 250 success, 840 00:43:02,320 --> 00:43:03,500 meaning I actually was able to change 841 00:43:03,500 --> 00:43:04,580 my current working directory to root, 842 00:43:04,700 --> 00:43:06,540 and I can grab any file off the server I want. 843 00:43:10,800 --> 00:43:11,800 A similar technique, 844 00:43:11,960 --> 00:43:15,380 using sort of the presentation formatting of the data, 845 00:43:15,920 --> 00:43:17,120 is within DNS. 846 00:43:18,220 --> 00:43:20,140 First of all, you have the case sensitivity issue. 847 00:43:20,740 --> 00:43:22,960 I notice that a lot of IDSs assume that 848 00:43:22,960 --> 00:43:25,400 the case will be either all uppercase or all lowercase, 849 00:43:25,400 --> 00:43:25,620 which is the case. 850 00:43:26,680 --> 00:43:27,900 The second thing is, 851 00:43:27,920 --> 00:43:30,320 is that DNS supports this name compression thing, 852 00:43:30,820 --> 00:43:32,360 where it splits up names 853 00:43:33,280 --> 00:43:36,040 in order to compress responses and requests. 854 00:43:36,840 --> 00:43:39,200 This has long been used to crash IDSs 855 00:43:39,200 --> 00:43:40,120 and to crash sniffers, 856 00:43:40,240 --> 00:43:42,640 because you can cause it to reference itself 857 00:43:42,640 --> 00:43:43,700 in an infinite loop. 858 00:43:44,980 --> 00:43:46,500 The way this compression works 859 00:43:46,500 --> 00:43:48,240 is that you have like one name, 860 00:43:49,100 --> 00:43:52,560 maybe I try to reference www.yahoo.com, 861 00:43:53,140 --> 00:43:54,320 it comes back and says, 862 00:43:54,320 --> 00:43:57,380 well actually there's lots of servers there at www.yahoo.com, 863 00:43:57,560 --> 00:44:00,180 they're like ww1, ww2, and so forth. 864 00:44:01,040 --> 00:44:03,340 Now, in order to compress that DNS response, 865 00:44:03,740 --> 00:44:06,040 the first one says the full yahoo.com, 866 00:44:06,340 --> 00:44:08,240 and the second ones have a pointer saying, 867 00:44:08,720 --> 00:44:12,680 continue on now with the rest of the original yahoo.com. 868 00:44:13,660 --> 00:44:15,640 So when you look at the text decode of it, 869 00:44:15,700 --> 00:44:17,080 you see something that looks a lot like this. 870 00:44:17,140 --> 00:44:19,580 You see in the clear text the first name 871 00:44:19,580 --> 00:44:22,280 followed by a lot of other fractions of the name. 872 00:44:23,220 --> 00:44:24,300 And this is where you can create 873 00:44:24,320 --> 00:44:26,520 and crash an IDS or a sniffer, 874 00:44:26,660 --> 00:44:30,000 is where you make that self-referential loop, 875 00:44:30,200 --> 00:44:31,760 saying reference myself and continue here. 876 00:44:31,980 --> 00:44:34,140 And it'll continue to continue here and hang. 877 00:44:34,580 --> 00:44:36,820 Or you can tell it to point off to Never Never Land 878 00:44:36,820 --> 00:44:37,520 where it will crash. 879 00:44:40,680 --> 00:44:41,200 Oops. 880 00:44:43,420 --> 00:44:46,080 So I wrote a little version bind scanner. 881 00:44:46,940 --> 00:44:49,460 In the bind Berkeley Internet Name Demon, 882 00:44:49,520 --> 00:44:52,360 which services like 90% of all name requests on the Internet, 883 00:44:52,360 --> 00:44:55,440 you can query which version of the software is running. 884 00:44:56,180 --> 00:44:59,140 And you have a special record called a text record 885 00:44:59,140 --> 00:45:02,000 that's in the chaos class with the string 886 00:45:02,000 --> 00:45:03,580 that you're looking up, version.bind. 887 00:45:03,920 --> 00:45:06,260 And that's like hard coding to the code as an Easter egg 888 00:45:06,260 --> 00:45:08,000 that returns what version it's running, 889 00:45:08,140 --> 00:45:12,440 like 8.22 or 4.31 or something like that. 890 00:45:14,200 --> 00:45:16,340 Well, a lot of IDSs detect this 891 00:45:16,340 --> 00:45:17,760 because it's a common scanning thing you do 892 00:45:17,760 --> 00:45:19,000 when you're attacking a DNS server. 893 00:45:20,120 --> 00:45:21,680 So I did two evasions here. 894 00:45:21,680 --> 00:45:24,560 One of which is I changed the name to be capital V 895 00:45:24,560 --> 00:45:28,020 and small version, capital B and small ind. 896 00:45:29,460 --> 00:45:31,860 And I played around with this for a couple of days. 897 00:45:32,080 --> 00:45:34,360 And I couldn't, I used all sorts of different arrangements 898 00:45:34,360 --> 00:45:35,520 by using this name compression 899 00:45:35,520 --> 00:45:37,800 by taking the second part of the name 900 00:45:37,800 --> 00:45:39,300 and pointing it off somewhere else in the packet. 901 00:45:40,020 --> 00:45:41,720 And I finally came down to the only way 902 00:45:41,720 --> 00:45:42,880 I could figure out how to get it to work, 903 00:45:42,980 --> 00:45:44,980 by going to the source code of bind, of course, 904 00:45:45,480 --> 00:45:49,560 was to put the dot bind after the end, 905 00:45:49,680 --> 00:45:51,600 logical end of the DNS portion 906 00:45:51,680 --> 00:45:52,120 of the packet. 907 00:45:53,620 --> 00:45:55,320 So that I see version, 908 00:45:55,400 --> 00:45:57,320 where you see that plus here in the text decode, 909 00:45:57,500 --> 00:45:59,520 it's actually specifying the offset 910 00:45:59,520 --> 00:46:00,320 where to find bind. 911 00:46:01,120 --> 00:46:03,320 And the web server will paste this back together 912 00:46:03,320 --> 00:46:05,380 to version dot bind and return you the correct string. 913 00:46:05,860 --> 00:46:07,680 But if you're looking for version dot bind 914 00:46:07,680 --> 00:46:09,540 in the packet, you're not going to see that 915 00:46:09,540 --> 00:46:11,960 as a contiguous signature that you can trigger on. 916 00:46:14,820 --> 00:46:17,620 So I'll be posting that DNS scanner to my website 917 00:46:17,620 --> 00:46:19,640 as an example after DEF CON. 918 00:46:21,680 --> 00:46:23,200 The problem is I couldn't get it to quite work on Linux. 919 00:46:23,360 --> 00:46:26,040 I throttle it for bulk scanning 920 00:46:26,040 --> 00:46:28,800 and the clock function on Linux wasn't quite working. 921 00:46:28,880 --> 00:46:31,520 I don't know why it would stop incrementing after a while. 922 00:46:34,380 --> 00:46:35,720 All of these evasion techniques, 923 00:46:35,880 --> 00:46:37,900 which I discovered after I wrote the presentation here, 924 00:46:38,540 --> 00:46:40,500 are at the OSI presentation layer. 925 00:46:41,040 --> 00:46:43,120 Like HTTP, RPC, FTP, DNS, 926 00:46:43,340 --> 00:46:45,040 they're all changing how the data is formatted 927 00:46:45,040 --> 00:46:46,100 but not the meaning of the data. 928 00:46:48,880 --> 00:46:50,980 So I decided that it would be kind of cool 929 00:46:50,980 --> 00:46:53,260 to actually add these directly into Nmap 930 00:46:53,260 --> 00:46:55,760 so that Nmap's FTP bounce scans 931 00:46:55,760 --> 00:46:57,660 will automatically evade 932 00:46:57,660 --> 00:46:59,800 and RPC null proc evade, 933 00:46:59,840 --> 00:47:03,000 all the null proc stuff it does to detect RPC services 934 00:47:03,000 --> 00:47:04,680 will also evade the IDS. 935 00:47:07,400 --> 00:47:08,660 So today's networks, 936 00:47:08,960 --> 00:47:11,980 the most popular way you can exploit a site 937 00:47:11,980 --> 00:47:13,820 is through DNS, through bind. 938 00:47:14,000 --> 00:47:16,560 A huge number of bind exploits over the past year. 939 00:47:17,200 --> 00:47:20,060 FTP, you know, there's a new one discovered every week. 940 00:47:20,980 --> 00:47:21,880 New exploit into FTP. 941 00:47:22,520 --> 00:47:26,060 RPC services, Sun Solaris machines and Linux boxes 942 00:47:26,060 --> 00:47:29,880 have been exploited with RPC a lot in the last few years. 943 00:47:30,360 --> 00:47:33,540 Of course, HTTP with all this CGI stuff will never end. 944 00:47:33,580 --> 00:47:35,320 You'll always be able to break into boxes with that. 945 00:47:35,560 --> 00:47:36,940 And of course, Trojan horses. 946 00:47:37,760 --> 00:47:39,180 So these are the most popular ways 947 00:47:39,180 --> 00:47:41,420 that people are actually hacking into systems today. 948 00:47:42,720 --> 00:47:44,840 And of course, the easiest way of evading IDSs 949 00:47:44,840 --> 00:47:47,400 are using those protocols that I've just demonstrated. 950 00:47:48,140 --> 00:47:50,000 I like to do this, you know, back and forth, 951 00:47:50,000 --> 00:47:52,560 along with the frag and the flood and the jam techniques 952 00:47:52,560 --> 00:47:57,560 of either fragmenting any attack with fragmentation 953 00:47:57,560 --> 00:48:00,380 or flooding or jamming the IDS sensor, bringing it down. 954 00:48:02,820 --> 00:48:07,260 So the idea of evading IDSs with protocols 955 00:48:07,260 --> 00:48:11,900 is still not a widely researched topic in the hacker community. 956 00:48:13,700 --> 00:48:15,520 I've been just working on a few protocols 957 00:48:15,520 --> 00:48:16,900 because they're the most commonly used 958 00:48:16,900 --> 00:48:19,620 and found I can easily add to these protocols 959 00:48:20,000 --> 00:48:23,240 the ability to evade IDSs, including black eyes, 960 00:48:23,280 --> 00:48:24,900 which is why I fixed it so it no longer works. 961 00:48:27,100 --> 00:48:31,760 Lots of protocols are vulnerable to these presentation layer attacks 962 00:48:31,760 --> 00:48:34,300 or application layer evasion. 963 00:48:35,640 --> 00:48:37,500 And the reason I'm presenting it is because 964 00:48:38,240 --> 00:48:41,200 a lot of the competitors still haven't dealt with fragmentation, 965 00:48:41,360 --> 00:48:42,480 which is like really, really old. 966 00:48:42,820 --> 00:48:44,520 They really need to be kicked in the pants and say, 967 00:48:44,660 --> 00:48:46,100 you need to add these to your products. 968 00:48:46,700 --> 00:48:48,780 As I started with the presentation here, 969 00:48:48,780 --> 00:48:51,740 the IDS vendors are selling you a tank 970 00:48:51,740 --> 00:48:54,640 that some, you know, oddball can walk up behind 971 00:48:54,640 --> 00:48:56,860 with like a grenade and blow it up. 972 00:48:57,640 --> 00:49:00,360 And this is not a really good state of the industry right now. 973 00:49:03,280 --> 00:49:04,720 So this is the end of the presentation. 974 00:49:05,020 --> 00:49:07,240 I'll be posting the slides to this URL 975 00:49:07,660 --> 00:49:09,080 on my own personal website. 976 00:49:10,780 --> 00:49:13,480 I've got a FAQ on generic network intrusion detection stuff 977 00:49:13,480 --> 00:49:14,280 at my website. 978 00:49:15,220 --> 00:49:16,620 And we'll be coming out with a Linux version 979 00:49:16,620 --> 00:49:18,720 a lot of you might be interested in beta in about a month. 980 00:49:18,780 --> 00:49:19,960 Are there any questions? 981 00:49:21,540 --> 00:49:22,260 There.