1 00:00:02,380 --> 00:00:09,620 Here's Jay Beale. He is with JJB Consulting. He is best known for the Bastille Linux scripts, 2 00:00:09,980 --> 00:00:17,620 available in all the usual mirrors. Jay is going to be talking today about hacking and securing 3 00:00:17,620 --> 00:00:25,620 FTP. So, take it away. Jay is also not going to be up here. He's going to be down here. That's 4 00:00:25,620 --> 00:00:37,160 Jay. I'm Jay. Oh, my God, that's a nice mic. Yeah. So, yeah, I'll be down here. It's slightly 5 00:00:37,160 --> 00:00:42,320 harder to see, but I'm trying to do a little bit of demonstration here today. So, this is the only 6 00:00:42,320 --> 00:00:55,520 way I see my screen. Someone say, speak up. Okay, cool. Stand. Anybody got a baseball bat? 7 00:00:56,180 --> 00:01:07,720 Okay. So, basically, the talk's kind of simple. There are a bunch of exploits against FTP servers, 8 00:01:08,080 --> 00:01:16,240 because FTP servers, especially real FTP, but most of the rest, too, have been bad. And by bad, 9 00:01:16,280 --> 00:01:22,820 I mean they have loved giving out root access remotely to anybody who can go and pick up scripts. 10 00:01:23,380 --> 00:01:25,600 So, what I want to do is... 11 00:01:25,620 --> 00:01:29,840 So, what I want to do is show you how to configure an FTP daemon so that it'll actually, you know, 12 00:01:29,860 --> 00:01:35,260 so that for most of the attacks that would have worked, the attack fails to work. This is not 13 00:01:35,260 --> 00:01:40,760 black magic. This is really simple hardening steps that you can take. And so, the idea is the 14 00:01:40,760 --> 00:01:45,360 next time that an exploit comes out, even if your version of the software is vulnerable, maybe you 15 00:01:45,360 --> 00:01:50,760 aren't vulnerable. Okay? Or maybe the attack doesn't get very far. And as far as I'm concerned, 16 00:01:50,860 --> 00:01:54,640 that's a good thing. Okay. 17 00:01:55,620 --> 00:02:02,640 So, the very first and the very last slide in these talks is often one encouraging you to just throw out your FTP daemon. 18 00:02:02,780 --> 00:02:09,220 Get rid of it. Delete it. Remove it. You know your vendor. Ask them to remove it from the CD. Well, maybe not go that far, 19 00:02:09,320 --> 00:02:15,500 but try to get it off... try to get off it yourself. Okay? FTP is, you know, is probably like some of the lesser drugs. 20 00:02:15,740 --> 00:02:22,260 It's a little, you know, it's really convenient, and it's definitely hard to get off of. I guess it's kind of like caffeine, you know? 21 00:02:22,660 --> 00:02:25,600 It turns out to be useful, but then you find that it was bad for you. So, you know, it's really hard to get off of. I guess it's kind of like caffeine, you know? 22 00:02:25,600 --> 00:02:28,980 Okay. No, caffeine's not bad. It's okay. Keep drinking. 23 00:02:30,700 --> 00:02:37,840 Okay. So, why is FTP bad? Because me just saying it's bad doesn't sound, you know, it doesn't sound so good. 24 00:02:37,920 --> 00:02:45,880 So, the first is FTP, it's clear text. If you are typing a name and password, okay, if you're typing a name and password, 25 00:02:46,060 --> 00:02:55,580 especially, who's hooked into the wireless right now? We don't have wireless in here, do we? Okay. Well, if we were in the wireless, if you are right now typing, you're starting to get a call, 26 00:02:55,600 --> 00:03:00,120 up an FTP session, even some files up or down from some account somewhere, somebody else 27 00:03:00,120 --> 00:03:05,540 in this room, probably about 25 somebody else's, is probably right now collecting your username 28 00:03:06,000 --> 00:03:11,420 and password. They'll be back on your server later tonight. Thank you very much. So as 29 00:03:11,420 --> 00:03:15,700 far as I'm concerned, that's enough. That's enough for me to just throw out my FTP server. 30 00:03:16,700 --> 00:03:20,880 The next reason, which is not on here, and we're going to spend all day, well, not all 31 00:03:20,880 --> 00:03:25,200 day, but the next 40 minutes talking about it, is that FTP servers continue to get rooted 32 00:03:25,200 --> 00:03:29,820 eight ways from Sunday. And this seems to happen on the regular in recurring business. 33 00:03:30,080 --> 00:03:35,100 It seems to happen no matter what FTP server you're running. And it's very fun for everyone 34 00:03:35,500 --> 00:03:38,540 who's using it, not very fun for all of us who are getting nailed by the attacks. 35 00:03:40,580 --> 00:03:46,400 Okay, why is FTP bad? Why do all these bugs show up? One of the reasons is the damn thing 36 00:03:46,400 --> 00:03:50,800 was designed by a committee. Okay, I don't know how big a committee it was. It was probably 37 00:03:50,800 --> 00:03:54,600 one of those, you know, it was probably, it was designed in RFC, so probably it ended 38 00:03:54,600 --> 00:03:55,060 up starting. 39 00:03:55,200 --> 00:03:58,780 Now it's small and getting bigger and bigger, as everyone threw in their own pet feature. 40 00:03:59,120 --> 00:04:03,840 Okay, anything that has everyone's own pet feature get thrown in here and there and 41 00:04:03,840 --> 00:04:08,240 here and there willy-nilly is generally going to end up having a good number of vulnerabilities, 42 00:04:08,460 --> 00:04:16,280 or at least one or two. Okay, why else is FTP bad? Okay, anybody ever notice that when 43 00:04:16,280 --> 00:04:20,840 you're using an FTP client, the data comes to you through a second channel, there's a 44 00:04:20,840 --> 00:04:24,420 second port. If you've ever, if you've ever run into our last problem, that it's hard 45 00:04:24,420 --> 00:04:24,880 to firewall. 46 00:04:24,920 --> 00:04:25,180 Okay, so if you've ever run into our last problem, that it's hard to firewall. 47 00:04:25,200 --> 00:04:29,820 Okay, especially when you've got a stateful firewall and you've experienced this, you 48 00:04:30,240 --> 00:04:34,540 know, you've authenticated. You've told the server who you are. It's sending you, you 49 00:04:34,540 --> 00:04:38,380 know, it's responding, everything's good. You ask it to send you a file. It goes to 50 00:04:38,380 --> 00:04:43,700 send you a file. Well, that second channel in FTP session isn't authenticated. Okay, 51 00:04:43,860 --> 00:04:47,640 which means there are some nice tools out there to help you steal other people's FTP 52 00:04:47,640 --> 00:04:54,680 file transfers. Okay, now, each of these could definitely be defeated if you used something 53 00:04:54,680 --> 00:04:59,680 like, if you used something like SSH, SFTP, there are Windows clients, there are Mac 54 00:04:59,680 --> 00:05:05,080 clients. There's really virtually no reason not to use it. But, you know, if you use something 55 00:05:05,080 --> 00:05:08,760 like this, you dodge all this. One of the issues is it's all encrypted, so they can't 56 00:05:08,760 --> 00:05:12,400 steal your name and password. It's all encrypted, so they can't steal your data on the way. 57 00:05:12,580 --> 00:05:17,760 So it's, you know, it's pretty nice. It's also pretty easy to firewall properly, so 58 00:05:17,760 --> 00:05:19,120 we all get to be happy. 59 00:05:20,960 --> 00:05:24,400 Okay, so now what I want to do is show you a bunch of vulnerabilities. I'm only going 60 00:05:24,400 --> 00:05:27,500 to demo one, but I want to show you a bunch of vulnerabilities and talk about how you 61 00:05:27,500 --> 00:05:35,600 can defeat each one of them. Okay? The first one, the first one, FTP conversion, the first 62 00:05:35,600 --> 00:05:41,160 one basically the way it worked was anybody ever gone into like, I don't know, Packet 63 00:05:41,160 --> 00:05:47,340 Storm, you know, to an FTP site like Packet Storm, and, you know, you want everything 64 00:05:47,340 --> 00:05:52,860 in the directory. So instead of pulling it down, you say, you know, get directory.tar 65 00:05:52,860 --> 00:05:54,380 and it builds you a tar ball and sends you a directory. And you get a directory.tar 66 00:05:54,400 --> 00:06:00,720 for the tar ball. Anybody use that? Raise your hand if you have. Okay, five, six, seven. 67 00:06:00,920 --> 00:06:05,600 Okay, so a few of us have used this. Eight, eight, I'm happy. Okay, so this thing is 68 00:06:05,600 --> 00:06:11,640 getting used. This was a nice little feature that was added into FTP service. Unfortunately, 69 00:06:11,840 --> 00:06:19,120 in this case, and this was room 24 through 260. So this was a while ago for Red Hat and 70 00:06:19,120 --> 00:06:24,260 SUSE and Immunix, but they are, who's running Red Hat before, before 6.2, 6.2 earlier right 71 00:06:24,400 --> 00:06:29,960 now. Oh, come on, someone is. Okay, we got one. How's your FTP server, dude? No, I'm 72 00:06:29,960 --> 00:06:35,080 just playing. Okay, so I want to show you how this works. I'm going to show you on the 73 00:06:35,080 --> 00:06:39,900 slides and then I'll actually demo it because it's a lot easier to just talk about it. Okay, 74 00:06:39,980 --> 00:06:45,740 the first is what we've got to do, it turns out if you tell the FTP server, if you can 75 00:06:45,740 --> 00:06:51,020 pass the FTP server a real weird file name, okay, if you can pass a real weird file name, 76 00:06:51,020 --> 00:06:54,380 you ask for that file name back, that file name ends up getting passed to tar.tar.tar. 77 00:06:54,380 --> 00:06:58,460 Because when your FTP server creates a tar ball for you, it actually, it's actually running 78 00:06:58,460 --> 00:07:03,120 the tar command. Okay, it's running tar. So it runs tar, if we can get it to run tar and 79 00:07:03,120 --> 00:07:08,120 pass it, you know, pass it something to, pass it a weird, you know, pass it a, just 80 00:07:08,120 --> 00:07:12,160 something that the original user, the original designers of the FTP program didn't think 81 00:07:12,160 --> 00:07:16,680 of, then we can have some fun. Okay, so the first thing you do to make this exploit work 82 00:07:17,280 --> 00:07:21,900 is you've got to build, you've got to build a single backdoor program or script that you 83 00:07:21,900 --> 00:07:24,360 can run. Okay, you've got to be, it, it, it, it, it, it, it, it, it, it, it, it, it, 84 00:07:24,360 --> 00:07:28,160 you can't pass it any options. Okay, you can't pass it any options, or at least I 85 00:07:28,160 --> 00:07:31,840 can't make it, I can't pass it any options. So I'm building a backdoor, which is just 86 00:07:31,840 --> 00:07:35,760 a shell script called script, and what that script's going to do is it's going to run 87 00:07:35,760 --> 00:07:41,300 netcat, it's going to tell it to listen on port 6666, nice and easy to remember, and 88 00:07:41,300 --> 00:07:45,060 to run a root shell. Well, I mean, not to run a root shell, but to run a shell. Okay, 89 00:07:46,000 --> 00:07:50,580 that'll be as whatever user I'm at. What I'm going to do is I need that program to 90 00:07:50,580 --> 00:07:54,340 be executable, and I'll talk about this later a little bit if you ask me to. I'm going to 91 00:07:54,360 --> 00:07:59,680 So I tar that, I tar up a copy of netcat, and that script, into a little tar ball, okay, 92 00:07:59,740 --> 00:08:04,760 called b.tar, and the last thing is, this is blah, is the script name we'll be seeing. 93 00:08:04,880 --> 00:08:11,640 I create a script called blah that says, untar my tar ball, and run the back, run my backdoor, 94 00:08:11,660 --> 00:08:17,940 run my backdoor script. Okay, you're going to get to see this a second time. The next 95 00:08:17,940 --> 00:08:23,180 thing is, I create a special file name that the FTP, that the FTP server people were not 96 00:08:23,180 --> 00:08:24,160 expecting me to create. 97 00:08:24,500 --> 00:08:30,160 Which is, minus, minus, use, minus, compress, minus, program, equals, bash, blah. The deal 98 00:08:30,160 --> 00:08:34,060 is, if I can pass that, if I can pass that option, if I can pass that option to, to, 99 00:08:34,060 --> 00:08:38,860 to tar, and what I'm doing is saying, hey, by the way, you know, I'd like to, I'd like 100 00:08:38,860 --> 00:08:43,380 to run tar and pull down a directory, but actually, while we're at it, you know, I'm 101 00:08:43,380 --> 00:08:46,560 kind of, I'm kind of chintzy about the bandwidth, why don't you, why don't you compress it? 102 00:08:46,640 --> 00:08:49,920 Why don't you compress it? Use this program I've got called bash, blah. You know, just 103 00:08:49,920 --> 00:08:54,200 use that one. Okay, and tar would be happy to do that for you, okay, because tar's not 104 00:08:54,360 --> 00:08:58,160 expecting that you're, you know, that you're running this remotely, okay? So tar would 105 00:08:58,160 --> 00:09:01,340 be happy to do that for us. And what we're going to do is we're going to FTP up to the 106 00:09:01,340 --> 00:09:05,400 target, as I'll show you. We're going to put our, put our, put b.tar, which is basically 107 00:09:05,400 --> 00:09:09,620 our backdoor. We're going to put the blah script there. We're going to put this weird 108 00:09:09,620 --> 00:09:12,660 file name, and then we're going to ask it, we're going to ask us to get that file name 109 00:09:12,660 --> 00:09:17,460 back, but with a .tar on the end. And so what'll happen is, okay, what'll happen is 110 00:09:17,460 --> 00:09:21,720 the server will run our little script. They'll end up running bash, blah. Okay, that'll 111 00:09:21,720 --> 00:09:24,340 run blah. And what blah will do, it'll run bash, blah. And then it'll run bash, blah. 112 00:09:26,720 --> 00:09:32,720 Not that. What blah will do, if we all remember, is it'll open up that tar ball and run our 113 00:09:32,720 --> 00:09:36,920 backdoor. Okay? So it's a little convoluted, but actually that's the way a lot of these 114 00:09:36,920 --> 00:09:43,500 exploits end up being, as some of you have probably found out on your own. Okay. So 115 00:09:43,500 --> 00:09:52,040 what I'll do is I've got to switch to another screen. Oh, no. Sorry. Freaking Microsoft. 116 00:10:00,640 --> 00:10:08,980 Okay. So I'm going to connect to the FTP server to show you how this works. Oh, or not. Okay, 117 00:10:08,980 --> 00:10:16,780 as soon as that, this is, we're running VMware, so it takes a couple seconds. We'll see. 118 00:10:24,340 --> 00:10:36,540 So jay, password, jay, right? Okay. We pick nice, strong passwords here. So put, blah, 119 00:10:38,460 --> 00:10:53,860 put, b.tar, put, minus, minus, use, compress, program, equals, bash, blah. 120 00:10:55,420 --> 00:10:59,560 It takes that. Mistake number one. It shouldn't be taking a file name that looks like that. 121 00:11:00,600 --> 00:11:09,720 Okay. And now let's get it with the dot tar. Oh, no. That's not good. 122 00:11:25,760 --> 00:11:28,680 What's that? They say fix the dashes as soon as you back the code. 123 00:11:30,320 --> 00:11:32,100 Oh, yeah. No, no, no. I need the double dash. 124 00:11:33,640 --> 00:11:36,120 Period. It's a period. You can't bash the clock. 125 00:11:39,900 --> 00:11:47,140 Period. Oh, come on. 126 00:11:48,800 --> 00:11:49,300 What's wrong with this? 127 00:11:49,680 --> 00:11:49,820 . 128 00:11:53,580 --> 00:11:55,220 Well, let's run our put. 129 00:11:59,220 --> 00:11:59,820 It's there. 130 00:12:07,780 --> 00:12:08,700 Okay, there we go. 131 00:12:10,680 --> 00:12:13,020 I'm sure I missed why it didn't work the first time. 132 00:12:13,100 --> 00:12:14,040 It's worked this time. 133 00:12:14,300 --> 00:12:14,980 I'm happy. 134 00:12:15,960 --> 00:12:16,360 Okay. 135 00:12:16,800 --> 00:12:17,840 What's happening now? 136 00:12:17,840 --> 00:12:20,520 Okay, the FTP server's not doing anything. 137 00:12:20,840 --> 00:12:22,100 So it's doing the transfer. 138 00:12:22,200 --> 00:12:22,960 It's just hanging there. 139 00:12:23,140 --> 00:12:23,860 Okay, why is it hanging? 140 00:12:24,320 --> 00:12:25,480 I didn't crash it. 141 00:12:25,540 --> 00:12:26,360 No, it's not that. 142 00:12:26,800 --> 00:12:27,620 It's the right now. 143 00:12:27,660 --> 00:12:29,640 It's waiting for that tar command to finish running. 144 00:12:29,940 --> 00:12:32,640 Because it's, you know, it's tarring up whatever directory we just asked for. 145 00:12:32,720 --> 00:12:34,480 So it's waiting for the tar command to finish running. 146 00:12:34,580 --> 00:12:38,620 That tar command, well, that tar command's waiting for the, it's waiting for Netcat 147 00:12:38,620 --> 00:12:39,360 to finish running. 148 00:12:39,840 --> 00:12:43,420 Okay, well, Netcat is, Netcat's waiting for us. 149 00:12:46,420 --> 00:12:47,680 Okay, so let's move that 150 00:12:47,840 --> 00:12:48,200 screen up. 151 00:12:49,060 --> 00:12:55,960 We'll Netcat 192.168.3.129.4.666. 152 00:12:56,540 --> 00:12:56,940 Oh. 153 00:12:59,280 --> 00:13:02,040 Okay, I have a, I have a specially compiled version of Netcat. 154 00:13:02,260 --> 00:13:03,780 Okay, so I get a blank. 155 00:13:03,980 --> 00:13:04,800 What is that blank? 156 00:13:05,320 --> 00:13:08,220 That, believe it or not, guys, is my little prompt. 157 00:13:08,340 --> 00:13:08,940 I promise. 158 00:13:09,360 --> 00:13:10,960 This is, this is the real deal. 159 00:13:11,220 --> 00:13:12,840 You're welcome to try this out later on. 160 00:13:13,180 --> 00:13:15,280 Okay, so now what I have right now is user j. 161 00:13:15,980 --> 00:13:17,820 Okay, this exploit gets you whatever user j is. 162 00:13:17,820 --> 00:13:21,460 So you're able to log in as, if you log in anonymous, you end up getting an FTP. 163 00:13:22,400 --> 00:13:26,240 Okay, but we got user j because it's a lot easier to show this version of the exploit. 164 00:13:26,760 --> 00:13:27,980 So we got user j. 165 00:13:28,040 --> 00:13:29,100 Well, that's kind of no fun. 166 00:13:29,300 --> 00:13:32,000 I mean, it is fun, but we'd like to have a little bit more. 167 00:13:36,520 --> 00:13:37,040 Yeah, okay. 168 00:13:38,580 --> 00:13:38,940 Thanks. 169 00:13:40,880 --> 00:13:45,040 Okay, so we've got j. 170 00:13:45,720 --> 00:13:46,920 We'd like to have a little bit more. 171 00:13:47,240 --> 00:13:47,800 I have a little bit more. 172 00:13:47,820 --> 00:13:54,220 I happen to know that I'm, I happen to know just from my Nmap scan or how Telnet was running 173 00:13:54,220 --> 00:13:58,440 on this machine, too, and the banner told me I'm actually talking to a Red Hat 6.1 box. 174 00:13:59,400 --> 00:14:03,400 Okay, so if I know I'm on a Red Hat 6.1 box, it turns out there's a program on the 175 00:14:03,400 --> 00:14:04,560 box called User Helper. 176 00:14:04,900 --> 00:14:10,340 And User Helper has a problem, and we've got a tool to help it, to help exploit that 177 00:14:10,340 --> 00:14:12,120 problem, and that tool is called User Rooter. 178 00:14:12,500 --> 00:14:15,840 By the way, as long as I'm at DEF CON, did anybody in this room write that tool? 179 00:14:17,020 --> 00:14:17,420 Okay. 180 00:14:17,840 --> 00:14:19,160 Well, just in case. 181 00:14:19,600 --> 00:14:21,360 I've had that happen a few times here. 182 00:14:21,820 --> 00:14:24,660 Said the person who wrote the, the person who wrote the tool is like, yeah, yeah, I 183 00:14:24,660 --> 00:14:25,120 wrote that one. 184 00:14:25,220 --> 00:14:25,780 Thanks, dude. 185 00:14:26,280 --> 00:14:26,640 Okay. 186 00:14:27,920 --> 00:14:32,960 So, the tool is called User Rooter, and it's a real, it's a real simple script. 187 00:14:33,480 --> 00:14:37,380 And the reason it works is there's a program called User Helper, it's like User Bin User 188 00:14:37,380 --> 00:14:39,760 Helper, that has a vulnerability in it. 189 00:14:39,900 --> 00:14:41,540 And it's a really dumb little vulnerability. 190 00:14:41,600 --> 00:14:43,820 I could explain it to you sometime, but not right now. 191 00:14:44,120 --> 00:14:44,480 Okay. 192 00:14:44,760 --> 00:14:46,360 But anyway, it's a dumb little vulnerability. 193 00:14:46,360 --> 00:14:50,020 I got a tool that exploits it, and because we can find that file, and we can run that 194 00:14:50,020 --> 00:14:54,700 file, the way this thing works is it runs User Helper, passes it some weird data, and 195 00:14:54,700 --> 00:14:58,060 User Helper goes and craps out and gives us a, gives us a root shell. 196 00:14:59,320 --> 00:15:05,720 And this is another one of those root shells that doesn't come with a prompt, but that's 197 00:15:05,720 --> 00:15:06,220 all I need. 198 00:15:06,280 --> 00:15:06,760 I'm happy. 199 00:15:07,280 --> 00:15:07,680 Okay. 200 00:15:08,160 --> 00:15:12,460 Just in case I'm still wondering, do whatever I want in the box. 201 00:15:12,820 --> 00:15:14,260 There's Jay's encrypted password. 202 00:15:14,480 --> 00:15:15,620 There's Root's encrypted password. 203 00:15:15,620 --> 00:15:18,440 If anybody's got crack, we can go and find out what those are for fun. 204 00:15:18,620 --> 00:15:21,060 But we're Root, so we can do all kinds of stuff on this system. 205 00:15:21,500 --> 00:15:22,580 But we're not going to. 206 00:15:22,620 --> 00:15:25,840 I know we could spend, like, the entire talk just, you know, how are we going to nail 207 00:15:25,840 --> 00:15:28,300 this guy, Jay, but let's leave his box alone. 208 00:15:29,440 --> 00:15:29,800 Please. 209 00:15:33,420 --> 00:15:33,780 Okay. 210 00:15:34,380 --> 00:15:35,640 So this is what we did. 211 00:15:35,880 --> 00:15:37,500 We netcatted into our target. 212 00:15:37,620 --> 00:15:38,640 We got a remote shell. 213 00:15:43,600 --> 00:15:43,960 Okay. 214 00:15:43,960 --> 00:15:45,660 We got a remote shell. 215 00:15:48,300 --> 00:15:49,620 We ran User Rooter. 216 00:15:50,160 --> 00:15:50,560 Okay. 217 00:15:50,660 --> 00:15:54,460 What I've done is I've shown you how we can add, we can add User Rooter to the tarball. 218 00:15:54,580 --> 00:15:56,760 When we send up the tarball, just add User Rooter to it. 219 00:15:56,960 --> 00:16:03,160 So we run netcat, we connect to the port, and we grab Root, which is very nice. 220 00:16:03,400 --> 00:16:04,380 It was very helpful. 221 00:16:04,660 --> 00:16:05,240 Much joy. 222 00:16:05,600 --> 00:16:05,860 Woo! 223 00:16:06,800 --> 00:16:07,200 Okay. 224 00:16:07,820 --> 00:16:10,780 This exploit is actually a lot harder to pull off anonymously. 225 00:16:11,160 --> 00:16:11,560 Okay. 226 00:16:11,620 --> 00:16:12,360 So I'm not going to. 227 00:16:12,360 --> 00:16:14,440 You're going to have to get into the server. 228 00:16:15,360 --> 00:16:15,760 You're going to have to get into the server. 229 00:16:16,260 --> 00:16:18,860 It's a pain in the butt to get from there to Root. 230 00:16:19,220 --> 00:16:19,620 Okay. 231 00:16:19,760 --> 00:16:21,200 It is tougher to pull off. 232 00:16:21,740 --> 00:16:22,140 Okay. 233 00:16:22,220 --> 00:16:25,580 And one of the big reasons it's tougher to pull off is whenever you're on a real FTP 234 00:16:25,580 --> 00:16:29,060 server and you connect anonymously, it sticks you in a directory. 235 00:16:29,240 --> 00:16:30,800 It sticks you in a cheroot prison. 236 00:16:31,060 --> 00:16:31,460 Okay. 237 00:16:31,520 --> 00:16:33,300 On Red Hat, that's home FTP. 238 00:16:33,560 --> 00:16:35,100 You can't get out of home FTP. 239 00:16:35,640 --> 00:16:36,040 Okay. 240 00:16:36,180 --> 00:16:36,880 Kind of. 241 00:16:37,120 --> 00:16:37,780 I'm lying. 242 00:16:37,920 --> 00:16:40,980 But the way it's designed, you can't get out of home FTP. 243 00:16:41,140 --> 00:16:42,340 You're stuck as a non-Rooter. 244 00:16:42,340 --> 00:16:43,300 It's user FTP. 245 00:16:43,860 --> 00:16:48,340 And there's no fun toys to use, either to hit others systems, although I guess you 246 00:16:48,340 --> 00:16:52,340 could bring some with you, but there's no fun toys in the system to give you more privileges. 247 00:16:53,000 --> 00:16:54,380 We can't get to user help. 248 00:16:54,440 --> 00:16:55,320 We're stuck in this prison. 249 00:16:55,800 --> 00:16:56,200 Okay. 250 00:16:56,240 --> 00:16:56,620 That sucks. 251 00:16:56,900 --> 00:16:58,640 We end up with user FTP or user J. 252 00:16:58,760 --> 00:16:59,540 What's the point of that? 253 00:16:59,820 --> 00:17:05,660 I mean yeah we can read J's email, it's kind of good, but we can't actually you know 254 00:17:05,660 --> 00:17:07,480 knock that much havoc on the box. 255 00:17:08,220 --> 00:17:08,620 Okay. 256 00:17:08,760 --> 00:17:12,320 So as defenders, one of the things we're going to talk about is how we can use these 257 00:17:12,320 --> 00:17:18,200 you some of that shrewding stuff to every user. Now, how can we avoid the attack entirely? 258 00:17:18,600 --> 00:17:21,960 Well, we can avoid the attack entirely if we tell people they're not allowed to use 259 00:17:21,960 --> 00:17:26,920 tar. No, you can't ask for a tar ball in the directory. And you're not allowed to use the 260 00:17:26,920 --> 00:17:31,000 compress feature. You're not allowed to say, give me a GZIP version of that tar ball. Now, 261 00:17:31,020 --> 00:17:35,460 since there's only eight people in this room, I'd say that we're kind of the more and most 262 00:17:35,460 --> 00:17:38,980 knowledgeable of users because we're hanging out at conferences instead of doing what other 263 00:17:38,980 --> 00:17:45,080 people do. You know, there may be even fewer people in the general population who are still 264 00:17:45,080 --> 00:17:50,720 using FTP who are going to try to use tar and GZIP or whatever anyway through the FTP 265 00:17:50,720 --> 00:17:56,120 server. Okay? So what we can do, one of the ways we can break this exploit is we can just 266 00:17:56,120 --> 00:18:02,680 make it so that you can't actually get the FTP server to run tar. Okay? And get it so 267 00:18:02,680 --> 00:18:06,980 you can't run tar. You can get it so you can't run GZIP. Okay? There's other things 268 00:18:06,980 --> 00:18:08,900 you can do. Okay? One of them is... 269 00:18:08,980 --> 00:18:12,600 As far as the anonymous attack, we can make sure that any time an anonymous user puts 270 00:18:12,600 --> 00:18:17,200 files on the server, they can't pull the mic back down. Okay? And we're going to talk 271 00:18:17,200 --> 00:18:20,820 about how that's, you know, how that's really useful. The biggest issue is it stops you 272 00:18:20,820 --> 00:18:24,500 from getting turned into a... into a RARES or DivX site. Okay? People aren't going to 273 00:18:24,500 --> 00:18:30,300 use your FTP server if they find it randomly to... to exchange MP3 files. Okay? You may 274 00:18:30,300 --> 00:18:33,560 not like that because you're probably getting some good ones. But what we can do is we can 275 00:18:33,560 --> 00:18:37,920 say that so someone can't download any files that they put up right afterwards. The last 276 00:18:37,920 --> 00:18:38,960 thing we'll do is we'll put a password in there. We'll put a password in there. We'll 277 00:18:38,960 --> 00:18:42,380 put a tag filter. The reason that a tag worked was there was a... there was a minus-minus 278 00:18:42,380 --> 00:18:46,940 use compress. Dude, people shouldn't be giving us any files that begin in minus-minus. Okay? 279 00:18:47,040 --> 00:18:49,860 That, you know, if they want to, they can find some other way to give us those files. 280 00:18:50,000 --> 00:18:53,820 But I haven't found anybody who calls all their Word documents or, you know, whatever 281 00:18:53,820 --> 00:18:58,900 we do, any of their C programs, minus-minus. By the way, before you think that J-Man is 282 00:18:58,900 --> 00:19:03,220 a... is a... is a Microsoft lover, it's... we're just using PowerPoint because it worked. 283 00:19:03,340 --> 00:19:06,580 Okay? Don't... don't... don't be throwing anything at me. 284 00:19:09,320 --> 00:19:13,780 Laughed at a DEF CON. Okay. So, anyway, what we're going to be doing is we're going to 285 00:19:13,780 --> 00:19:18,660 play with the FTP access file. Sounds like it's the access control for... access control 286 00:19:18,660 --> 00:19:22,880 configuration file for FTP. Yeah, it is. It's about the only one, too. Okay? This is 287 00:19:22,880 --> 00:19:27,140 about the only configuration file for FTP. I don't know if the most FTP servers even 288 00:19:27,140 --> 00:19:30,860 came with this originally. I... I wouldn't know. But, you know, I... I strongly doubt 289 00:19:30,860 --> 00:19:34,540 it. This stuff probably got added. Anyway, what I'm going to do is I'm going to show 290 00:19:34,540 --> 00:19:38,140 you how we're going to be changing that file. So the first thing that we can do in that file 291 00:19:38,960 --> 00:19:42,840 is remember that these fi... that these six... six lines, six lines, I can count, six lines 292 00:19:42,840 --> 00:19:45,920 are there. Okay? If they are... if they are there, then they look different. We'll just 293 00:19:45,920 --> 00:19:49,920 change them to this. And what this says is anyone who's using the FTP client can't ask 294 00:19:49,920 --> 00:19:53,840 for compression, they can't ask for tarring, they can't change the... they can't change 295 00:19:53,840 --> 00:19:57,680 the permission bits on a file, they can't delete any files, they can't overwrite them, 296 00:19:57,700 --> 00:20:01,440 and they cannot rename them. Okay? Because the... some of that renaming would be really 297 00:20:01,440 --> 00:20:04,760 useful to us. We could upload a file with a different name and then rename it to dash-dash. 298 00:20:04,820 --> 00:20:08,940 So, rename's bad. So, we're just turning that stuff on. Okay? So, we're going to... we're 299 00:20:08,940 --> 00:20:12,680 off. We actually got pretty far. I've also included instructions on how you can make 300 00:20:12,680 --> 00:20:16,640 an anonymous upload area that we're not going to let anyone write to. I'm not going to go 301 00:20:16,640 --> 00:20:20,220 through each of the lines here. Okay? But I... I... I'm just giving them to use to... 302 00:20:20,220 --> 00:20:26,580 to be useful. Okay? And in the... basically, there... there's... there's two lines that 303 00:20:26,580 --> 00:20:30,120 we do. What we do is we're going to... we... we create an incoming directory. Okay? In 304 00:20:30,120 --> 00:20:33,600 home FTP, the place that all the anonymous users get stuck in, we can create another 305 00:20:33,600 --> 00:20:37,520 directory called incoming. And so, you can put files in there. Files go in. They don't 306 00:20:37,520 --> 00:20:38,400 go back out. Okay? 307 00:20:38,400 --> 00:20:43,000 And put files in there. You can't pull them back down. And the idea behind that is you 308 00:20:43,000 --> 00:20:48,200 don't get used as a Wares trading site unless you want to. You don't get used... you don't 309 00:20:48,200 --> 00:20:52,460 get... and you don't... you don't end up having exploits like this work. Okay? So, 310 00:20:52,560 --> 00:20:56,980 what if you want to exchange files? Well, the deal is people upload them. You have somebody 311 00:20:57,520 --> 00:21:02,120 or some proscript, okay, that goes and moves them over. Maybe after inspecting them, maybe 312 00:21:02,120 --> 00:21:06,700 not your call. Okay? But at least you stop the exploits and maybe you stop people you 313 00:21:06,700 --> 00:21:08,380 don't want to use... want to use them. 314 00:21:08,400 --> 00:21:22,760 I used to say in this case, you should stop using FTP. I'm putting this up when I was 315 00:21:22,760 --> 00:21:23,840 leaving. And now, I'm putting this up during a call, that's not the most effective way. 316 00:21:23,840 --> 00:21:34,800 I'm done. So, I can't put that file in. I can't put that file in here. I can't do 317 00:21:34,800 --> 00:21:34,820 Okay. 318 00:21:34,820 --> 00:21:54,120 Okay? Or by user FTP or whatever. And then finally, any file that's put on there may be readable. It's writable by you, but you can't run it. Okay? So if you're going to upload backdoors, you're going to have to find some other way to run it. Okay? The last trick did not depend on this UMASC, but this is just a decent thing to do. Okay? 319 00:21:54,120 --> 00:22:07,480 So another vulnerability, this one was a denial of service vulnerability. This is quoted, the exploit's quoted directly from security focus. And what this will do is it'll slam the UFTP server down. Okay? Maybe it'll reboot the box. 320 00:22:08,220 --> 00:22:23,820 Okay, this works on RADAT 6.2 and SUSE 7.3. It also works on OS X 10 and 10.01. It works on Solaris 8. It works on the latest version of HPUX. Yes, there are still a lot of extremely vulnerable HPUX boxes out there. 321 00:22:24,120 --> 00:22:26,040 More on that later. Okay? 322 00:22:27,460 --> 00:22:38,280 You can stop this. The only thing we can do in terms of stopping this attack, well, the one is we can contain it. Okay? We can contain it by making sure by putting in some resource limits. 323 00:22:38,380 --> 00:22:46,340 So if the FTP server, in a pattern that it can't resolve, okay, then, you know, it doesn't take over the entire, it doesn't take over all the runtime on the system, which is nice. 324 00:22:46,700 --> 00:22:53,900 Because any of you in the era of sysadmins on a, you know, on a busy shop passes the FTP server weird command. You'd rather just have the FTP server fall down. 325 00:22:54,120 --> 00:23:01,260 And you can take it back, you can bring it back up in the morning. You don't want to get called in because the whole machine hung, and whatever it is that's vital on that thing, like the web server. 326 00:23:01,420 --> 00:23:09,460 How to avoid it is a path filter. Path filter is an actual filter on what file names are allowed to be uploaded and downloaded from the FTP server. 327 00:23:11,460 --> 00:23:11,820 Okay? 328 00:23:12,120 --> 00:23:16,020 We tell FTP to run at a high NICE level. Tell it to be very NICE to other processes. 329 00:23:16,520 --> 00:23:20,040 Okay? The NICE command says, don't suck up all the CPU, darn it. 330 00:23:20,500 --> 00:23:20,860 Okay? 331 00:23:21,720 --> 00:23:23,440 I gave you 10. You can put it outside. 332 00:23:24,120 --> 00:23:25,000 I didn't do it. 333 00:23:25,180 --> 00:23:25,800 We're near the airport. 334 00:23:26,100 --> 00:23:27,160 Okay, we're near the airport. 335 00:23:27,520 --> 00:23:30,700 You can also, this is on a Linux box, there's a file called limits.conf. 336 00:23:30,860 --> 00:23:32,860 FC security limits.conf. 337 00:23:33,220 --> 00:23:41,840 And what you can do in there is actually go and put some really, really fine-tuned limits on how much memory, how much CPU that this thing can use. 338 00:23:42,440 --> 00:23:44,680 I don't have good numbers to recommend to you. 339 00:23:44,720 --> 00:23:47,160 They seem to vary very much by implementation and site. 340 00:23:47,360 --> 00:23:53,300 And if I had good numbers that I tested for me a lot, I still don't think I'd give them to you because I might break something and you might get really mad at me. 341 00:23:53,300 --> 00:24:01,940 So, you can use the proc info command on a running FTP process, or any process, to kind of find out how much memory it's using and so on, and try to set good limits. 342 00:24:02,480 --> 00:24:06,060 And once you do, these are the kind of limits you can set in limits.conf. 343 00:24:06,280 --> 00:24:06,640 Okay? 344 00:24:07,360 --> 00:24:12,180 Basically, most of them deal with how much memory, with how much, with how much memory and what kind of memory the thing can use. 345 00:24:13,960 --> 00:24:14,320 Okay? 346 00:24:16,340 --> 00:24:19,900 Another exploit, there was an FTP, there was another, there was another globbing vulnerability. 347 00:24:20,060 --> 00:24:23,280 Globbing is whenever you put star in, or question mark in, and it matches. 348 00:24:23,300 --> 00:24:24,120 It changes different file names. 349 00:24:24,300 --> 00:24:27,180 It changes those stars and it expands them into a bunch of file names. 350 00:24:27,260 --> 00:24:27,920 It's called globbing. 351 00:24:28,120 --> 00:24:28,520 Okay? 352 00:24:28,540 --> 00:24:30,940 Globbing is something we can't turn off or I'd be telling you how to. 353 00:24:31,340 --> 00:24:31,740 Okay? 354 00:24:32,260 --> 00:24:35,800 Real FTP 261 had another, had another vulnerability in the globbing code. 355 00:24:36,420 --> 00:24:36,820 Okay? 356 00:24:37,640 --> 00:24:40,140 It was in, it was in up through 261. 357 00:24:40,260 --> 00:24:43,000 Red Hat 7.2, SUSE 7.3, Mandrake 8.1. 358 00:24:43,280 --> 00:24:47,060 There are a lot of those systems out there right now that probably, probably a good number of them are vulnerable. 359 00:24:47,540 --> 00:24:53,140 This slide originally said exploit is, is, is, is out, is believed to be in circulation but not publicly available. 360 00:24:53,300 --> 00:25:01,600 I got a really good, I got it on a, on a very trustable, on a very trustable not word yesterday that there actually is an exploit out. 361 00:25:01,900 --> 00:25:02,820 Does anybody have it? 362 00:25:04,260 --> 00:25:07,100 If anybody has that exploit, I'd really appreciate getting it. 363 00:25:07,120 --> 00:25:07,440 I'm serious. 364 00:25:07,600 --> 00:25:09,840 I'd really appreciate giving it because I could show it to other people. 365 00:25:10,220 --> 00:25:11,680 Or, or just see it. 366 00:25:11,900 --> 00:25:12,560 Or something. 367 00:25:13,080 --> 00:25:13,480 Okay? 368 00:25:13,680 --> 00:25:20,680 You can test to see whether a server is vulnerable and I, I recommend you try this with your printers or whatever if you've got, if you've got printers with FTP servers. 369 00:25:21,080 --> 00:25:23,280 By the way, if you've got a printer attached to your network and you've got a FTP server, 370 00:25:23,300 --> 00:25:26,620 you think it doesn't have an FTP server, most of the time the answer is think again. 371 00:25:27,000 --> 00:25:32,140 A lot of them do and they, and, and they're running old, they're running old FTP servers that have a whole bunch of vulnerabilities. 372 00:25:34,180 --> 00:25:39,960 If you run this, you just ls tilde, tilde left bracket, you'll see the FTP server hang. 373 00:25:40,540 --> 00:25:40,940 Okay? 374 00:25:41,320 --> 00:25:42,940 Like I said, this isn't a robbing code. 375 00:25:43,040 --> 00:25:44,080 We can't shut it off. 376 00:25:44,560 --> 00:25:50,060 The best thing you can do is since somebody needs an authenticated session to actually run that, don't let them have one. 377 00:25:50,460 --> 00:25:50,860 Okay? 378 00:25:50,960 --> 00:25:53,220 If you, if you're not using the, the anonymous mode, 379 00:25:53,300 --> 00:25:59,620 you're running your FTP server or if you decide as a result of this talk or others that instead of running, instead of running that part of the FTP, 380 00:25:59,780 --> 00:26:04,540 you're going to do it out of the web server, turn anonymous mode off and you don't get nailed by this unless someone steals an account. 381 00:26:05,220 --> 00:26:10,560 Now note, the way we did it was, you know, the way we did the export that I showed you was we assumed that I'd stolen Jay's account. 382 00:26:11,400 --> 00:26:11,720 Okay? 383 00:26:11,840 --> 00:26:19,080 That might have been a weak, that might have been a weak assumption, but in this room, it's probably not that weak because maybe Jay's sitting in the front row and he's, 384 00:26:19,080 --> 00:26:22,680 and he's FTPing away and I'm like, name and password, really good, okay, I know where to go. 385 00:26:23,300 --> 00:26:23,560 Okay? 386 00:26:23,820 --> 00:26:29,580 So, you can't necessarily stop someone from stealing an account, especially if you, especially if you're at a university. 387 00:26:29,800 --> 00:26:31,600 How many people in here work at universities? 388 00:26:32,900 --> 00:26:33,340 Okay? 389 00:26:34,080 --> 00:26:38,300 For those of you at universities, how many stolen accounts do you guys think you see in a month? 390 00:26:39,840 --> 00:26:40,320 Don't know? 391 00:26:41,140 --> 00:26:41,580 Okay. 392 00:26:41,700 --> 00:26:44,920 When I was at a university, we saw, we saw a big number. 393 00:26:44,980 --> 00:26:50,360 Yes, I gave this talk at Black Hat as well and the answer, the answer somebody gave me was about 20 a month. 394 00:26:50,820 --> 00:26:51,260 Okay? 395 00:26:52,040 --> 00:26:53,280 Let's just say it happens every day. 396 00:26:53,300 --> 00:26:55,000 It happens probably often enough for the university. 397 00:26:55,220 --> 00:26:57,580 It happens often enough anywhere you've got people using FTP. 398 00:26:59,640 --> 00:27:02,720 One of the best things you can do is try to stop those accounts from getting stolen. 399 00:27:03,020 --> 00:27:04,020 That one's hard. 400 00:27:04,500 --> 00:27:16,580 In terms of actually containing the attack, okay, this one, this one is a DOS, but actually, the other thing it can do, I don't have the exploit, but if I did, what it could do is actually run remote code as root. 401 00:27:17,140 --> 00:27:17,580 Okay? 402 00:27:17,940 --> 00:27:19,520 It can run remote code as root. 403 00:27:19,940 --> 00:27:20,740 That's no fun. 404 00:27:21,240 --> 00:27:23,280 This, this attack, just like another one, 405 00:27:23,300 --> 00:27:29,720 is actually able to get the FTP server, which is supposed to, which is supposed to drop down from root, to go back up. 406 00:27:30,460 --> 00:27:30,860 Okay? 407 00:27:30,920 --> 00:27:35,560 And when it goes back up, you're able to break out of it, you're also able to break out of the troop jail if you're stuck in one. 408 00:27:36,040 --> 00:27:36,440 Okay? 409 00:27:36,480 --> 00:27:47,080 The deal is, you can stop this, and I'm going to show you how to do this in a couple slides, but you can stop this kind of attack from giving somebody root by never running the FTP server as root in the first place. 410 00:27:47,600 --> 00:27:48,000 Okay? 411 00:27:48,180 --> 00:27:50,640 An FTP server is run by INETD or XINETD. 412 00:27:50,960 --> 00:27:51,360 Okay? 413 00:27:51,360 --> 00:27:57,920 That program runs as root, and it passes off, when it gets connections in on the FTP port, it starts up the FTP program. 414 00:27:58,240 --> 00:28:02,480 And it passes in a connection, and it runs it as whatever user it's told to run it as, which is generally root. 415 00:28:02,940 --> 00:28:12,040 The reason it's going to run as root is if I log in, if I log in as user J, it has to be able to switch over to user J and only let me write files and get files that J should be allowed to get. 416 00:28:12,360 --> 00:28:15,920 If it stayed as root, I could just like say, hey, give me the shadow password, you know? 417 00:28:16,160 --> 00:28:20,400 Oh, by the way, while you're at it, why don't you put up this replacement shadow file for me, you know? 418 00:28:21,840 --> 00:28:25,420 So, we don't want to, we don't, it doesn't run as root. 419 00:28:25,520 --> 00:28:26,940 It starts as root, drops down. 420 00:28:27,240 --> 00:28:38,500 The deal is if you're only using FTP for anonymous, I don't know how many of you are running FTP and are running it as, you know, running it to help users out, to allow ordinary users to log in and push up their files and pull their files down. 421 00:28:38,660 --> 00:28:46,900 But if you're not, and you're only using anonymous mode, then you can set this thing to just start as root and stay, I mean, start as user FTP and stay as FTP. 422 00:28:47,140 --> 00:28:49,960 Because remember, when somebody logs in anonymous, the server is switching. 423 00:28:49,960 --> 00:28:53,380 It's switching into user FTP and it's staying there until they disconnect. 424 00:28:53,820 --> 00:28:57,980 And the next person logs in, starts as root, switches to user FTP. 425 00:28:58,500 --> 00:28:59,880 Again, it keeps going like that. 426 00:28:59,960 --> 00:29:02,400 Well, you can just start it as FTP and leave it that way. 427 00:29:02,620 --> 00:29:13,280 Because if it does, then any attacker that would have given somebody root, that would have had the FTP server go and give them root directly by going up, by going straight up from one user up to root, that won't work. 428 00:29:13,340 --> 00:29:15,360 Because it can't go up to a privilege that it never had. 429 00:29:15,780 --> 00:29:16,980 That's just the way Unix works. 430 00:29:17,400 --> 00:29:17,780 Okay? 431 00:29:18,100 --> 00:29:19,220 So, I'll show you how to do that. 432 00:29:19,960 --> 00:29:25,000 I just want to show you one more vulnerability where this kind of defensive measure is useful. 433 00:29:25,680 --> 00:29:25,800 Okay? 434 00:29:26,000 --> 00:29:27,860 WooFTP had a format string vulnerability. 435 00:29:28,000 --> 00:29:32,300 Back when all the format string vulnerabilities came out, it had a format string vulnerability. 436 00:29:32,480 --> 00:29:33,680 These things are still getting discovered. 437 00:29:33,780 --> 00:29:35,160 I'm sure they're not all out yet. 438 00:29:35,560 --> 00:29:35,920 Okay? 439 00:29:36,200 --> 00:29:39,580 The nice thing was that you could log in as anonymous and go directly to root. 440 00:29:39,960 --> 00:29:40,320 Okay? 441 00:29:40,340 --> 00:29:42,980 You didn't have to use any privilege escalation, nothing like that. 442 00:29:43,300 --> 00:29:44,900 Start as anonymous, go to root. 443 00:29:45,060 --> 00:29:45,500 It's great. 444 00:29:45,680 --> 00:29:46,620 I've seen the code. 445 00:29:46,720 --> 00:29:48,660 I've got the code if anybody wants to look at it after the talk. 446 00:29:48,660 --> 00:29:49,820 It's really nice. 447 00:29:50,000 --> 00:29:50,360 Okay? 448 00:29:50,460 --> 00:29:54,000 One of the things it does is it says, hey, can you switch me back to root? 449 00:29:54,100 --> 00:29:54,780 I mean, we were just root. 450 00:29:54,900 --> 00:29:55,800 So, can't we just go back? 451 00:29:56,000 --> 00:29:58,820 So, you know, it switches the FTP server back to root. 452 00:29:59,360 --> 00:30:00,220 Breaks out of the root. 453 00:30:00,320 --> 00:30:02,380 Prisoner was stuck in and has your root shell. 454 00:30:02,960 --> 00:30:04,780 Very, very, very useful thing. 455 00:30:05,540 --> 00:30:05,900 Okay? 456 00:30:07,000 --> 00:30:11,120 The TASO's got a vulnerability from what I called 7350, root.c. 457 00:30:11,500 --> 00:30:11,860 Okay? 458 00:30:12,660 --> 00:30:18,020 And like I said, you can use this to get back to root even when you're logging in as 459 00:30:18,020 --> 00:30:18,580 user FTP. 460 00:30:18,580 --> 00:30:21,100 So, if you're logging in as user FTP through anonymous session, the nice thing about this 461 00:30:21,100 --> 00:30:25,780 particular thing is if it's run by the script kiddies in its default mode, when FTP server 462 00:30:25,780 --> 00:30:29,100 asks you for a password on anonymous mode, it says, hey, give me your email address as 463 00:30:29,100 --> 00:30:29,480 your password. 464 00:30:29,640 --> 00:30:30,920 It just gives it Mozilla at. 465 00:30:31,620 --> 00:30:31,940 Okay? 466 00:30:31,960 --> 00:30:34,440 The nice thing about Mozilla at is that's not a real email address. 467 00:30:34,820 --> 00:30:37,540 You know, you've all typed, you know, if you've all gone to an anonymous FTP site 468 00:30:37,540 --> 00:30:40,820 and it says, you know, give me, you know, you type in, it says anonymous access. 469 00:30:40,920 --> 00:30:41,240 Okay. 470 00:30:41,540 --> 00:30:43,620 Type, you know, type your email address as a password. 471 00:30:44,140 --> 00:30:44,460 Okay? 472 00:30:44,520 --> 00:30:48,560 Well, most of them, if you type in, you know, screw you, it's like, yeah, it's a password. 473 00:30:48,560 --> 00:30:53,400 Yeah, okay, I'll screw myself and you can have access just next time, please, be nicer. 474 00:30:53,900 --> 00:30:57,300 So, what we can do is we can tell it, one of the things I'll show you how to do is we 475 00:30:57,300 --> 00:30:58,000 can tell it no. 476 00:30:58,240 --> 00:31:01,440 And we accept something if it actually looks like a real FTP, a real email address. 477 00:31:01,840 --> 00:31:05,020 It doesn't have to be a real email address, but it has to look like one. 478 00:31:05,420 --> 00:31:05,780 Okay? 479 00:31:05,880 --> 00:31:10,040 So, if it looks like one, if we tell it, if we enforce this, this exploit breaks. 480 00:31:10,840 --> 00:31:11,200 Okay? 481 00:31:11,280 --> 00:31:12,140 It's really kind of cool. 482 00:31:12,340 --> 00:31:17,280 Additionally, if we start the FTP server off as user FTP, this exploit will still work, 483 00:31:17,340 --> 00:31:18,280 but it won't give you root. 484 00:31:18,360 --> 00:31:18,540 It'll give you a password. 485 00:31:18,540 --> 00:31:19,300 It'll give you user FTP. 486 00:31:19,900 --> 00:31:20,260 Okay? 487 00:31:20,260 --> 00:31:23,540 It'll give you user FTP, and while people have figured out easily how to get root to 488 00:31:23,540 --> 00:31:27,940 break out of true root presence, as user FTP, I don't know of any techniques. 489 00:31:28,120 --> 00:31:30,940 It doesn't mean that somebody in this room doesn't have one, so if you do, please don't 490 00:31:30,940 --> 00:31:31,660 throw anything at me. 491 00:31:31,900 --> 00:31:32,260 Okay? 492 00:31:32,560 --> 00:31:36,960 But it means that at least I don't know about it, and it's not widely publicized, which 493 00:31:36,960 --> 00:31:41,320 is great for us, because we're getting attacked by tons of people who don't have the coolest 494 00:31:41,320 --> 00:31:42,380 new tools. 495 00:31:43,880 --> 00:31:44,580 Another airplane. 496 00:31:44,940 --> 00:31:45,300 Okay. 497 00:31:45,400 --> 00:31:48,480 So, I'll show you how to do each of these. 498 00:31:49,220 --> 00:31:55,200 The first is, there's usually a line in most of your FTP, FTP access files that says password 499 00:31:55,200 --> 00:32:00,100 check, RFC822, and then it says warn, or it says trivial. 500 00:32:00,780 --> 00:32:01,760 No, it says warn. 501 00:32:01,840 --> 00:32:02,360 It says warn. 502 00:32:02,620 --> 00:32:02,980 Okay? 503 00:32:03,200 --> 00:32:05,080 Remember, it's like screw you. 504 00:32:05,660 --> 00:32:09,500 Yes, I will go screw myself, you know, but be nice to you next time. 505 00:32:09,680 --> 00:32:10,340 Don't say enforce. 506 00:32:10,720 --> 00:32:11,200 Okay? 507 00:32:11,380 --> 00:32:13,400 What enforce says is don't let someone in. 508 00:32:13,520 --> 00:32:14,180 Break the connection. 509 00:32:14,520 --> 00:32:17,960 The nice thing is that when you have a script kitty who's running Terrasource exploit, 510 00:32:18,180 --> 00:32:18,520 and you have a script kitty who's running Terrasource exploit, and you have a script 511 00:32:18,540 --> 00:32:21,220 kitty who's running Terrasource exploit, when you have a worm that's running Terrasource 512 00:32:21,220 --> 00:32:25,120 exploit, each of them, well, this, I don't know what, I generally think the script kitty's 513 00:32:25,120 --> 00:32:25,960 about as smart as worms. 514 00:32:26,300 --> 00:32:27,980 If you are a script kitty, don't hurt me. 515 00:32:28,540 --> 00:32:32,060 But, you know, I think script kitty's about as smart as worms. 516 00:32:32,300 --> 00:32:35,200 Each of them generally doesn't recover from the first error very well. 517 00:32:35,320 --> 00:32:38,540 Even if the error was, what the hell, I need a real email address. 518 00:32:38,700 --> 00:32:41,600 Script kitty doesn't know how the exploit works, doesn't notice that Mozilla thing, 519 00:32:41,760 --> 00:32:44,540 says, ah, fuck it, I'll go and try another exploit. 520 00:32:44,760 --> 00:32:46,320 Or, I'll go and try another server. 521 00:32:46,760 --> 00:32:47,120 Okay? 522 00:32:47,140 --> 00:32:48,520 Either way, either thing, the exploit is working. 523 00:32:48,520 --> 00:32:50,900 Either way, we're good. 524 00:32:51,040 --> 00:32:52,420 The worm just doesn't hit you. 525 00:32:52,600 --> 00:32:52,900 Okay? 526 00:32:52,980 --> 00:32:53,320 It attacked. 527 00:32:53,540 --> 00:32:54,040 It didn't work. 528 00:32:54,120 --> 00:32:54,580 That's fine. 529 00:32:54,720 --> 00:32:57,680 It goes on from the server it was at, attacking other people. 530 00:32:57,860 --> 00:32:59,520 Hey, that's, that's all right there, mate. 531 00:33:01,060 --> 00:33:01,500 Okay? 532 00:33:01,760 --> 00:33:08,080 The site exec problem was Red Hat up to 6.2, SUSE up to 7.3, HPX, hey, their most recent 533 00:33:08,080 --> 00:33:08,800 release, 11.11. 534 00:33:09,020 --> 00:33:11,260 Very new, still got an old FTP server version. 535 00:33:11,780 --> 00:33:12,220 Okay? 536 00:33:14,440 --> 00:33:18,180 Now, site exec, again, very annoyingly, can't be deactivated. 537 00:33:18,220 --> 00:33:18,500 I've learned it. 538 00:33:18,700 --> 00:33:19,860 I can't figure out how to do it. 539 00:33:20,580 --> 00:33:22,000 You really can't do much. 540 00:33:22,100 --> 00:33:24,520 There is a command that tells it how many lines of output to give you. 541 00:33:24,580 --> 00:33:26,560 I don't know if, I don't know if we're going to get anywhere with that. 542 00:33:27,100 --> 00:33:31,160 But, what you can do is, like I said, first, do that little trick we did. 543 00:33:31,500 --> 00:33:33,440 It's going to, it's going to halt the worms, at least. 544 00:33:34,460 --> 00:33:37,940 Additionally, make the FTP server run as user FTP instead of as root. 545 00:33:38,540 --> 00:33:38,900 Okay? 546 00:33:38,940 --> 00:33:43,560 If we can do that, if we can do that, we're in good shape, because the, the, the, the 547 00:33:43,560 --> 00:33:48,220 script kitty, heck, the, you know, the real hacker, or even the worm, they all, you know, 548 00:33:48,220 --> 00:33:48,500 if they can do that, we're in good shape, because the, the, the, the script kitty, heck, 549 00:33:48,500 --> 00:33:48,520 they're in good shape, because they're in good shape. 550 00:33:48,520 --> 00:33:51,420 And, so, they can get access, they get it as, they get it as user FTP, not as root. 551 00:33:51,520 --> 00:33:54,780 They're stuck in a little cheroot prison if they got in anonymously, they don't get 552 00:33:54,780 --> 00:33:55,220 very far. 553 00:33:55,260 --> 00:33:56,220 They can't do very much. 554 00:33:56,400 --> 00:34:00,500 They try uploading programs, maybe, and running their own programs, okay, but they had to 555 00:34:00,500 --> 00:34:04,240 have made sure to upload those programs before they broke the FTP server, because the FTP 556 00:34:04,240 --> 00:34:05,160 server is broken now. 557 00:34:05,800 --> 00:34:06,160 Okay? 558 00:34:06,420 --> 00:34:07,640 Or maybe it's not. 559 00:34:07,840 --> 00:34:11,280 Okay, so they can bring programs with them, but they're not going to get anywhere, because 560 00:34:11,280 --> 00:34:15,280 no local exploit's going to work, unless, you know, the one or two programs that's in, 561 00:34:15,280 --> 00:34:17,820 that's in the cheroot prison is actually vulnerable. 562 00:34:18,100 --> 00:34:18,480 You all know that. 563 00:34:18,480 --> 00:34:24,800 understand how this true prison idea works? Anybody confused? Okay, you're liars, but 564 00:34:24,800 --> 00:34:29,720 no, no, it's cool. Okay, basically there's nothing in there, there's stuff in the directory 565 00:34:29,720 --> 00:34:34,920 that's got like six files, whatever files the FTP server needed to run, and only one 566 00:34:34,920 --> 00:34:39,600 program, and that's LS. So unless there's a vulnerability in LS, and it could be, but 567 00:34:39,600 --> 00:34:42,840 unless there's a vulnerability in LS, you don't get anywhere. And by the way, it's a 568 00:34:42,840 --> 00:34:48,140 statically linked LS, so don't give me any of that dynamically linked stuff. Okay, so 569 00:34:48,140 --> 00:34:53,020 how do we do that? How do we run this FTP server as user FTP instead of root? Well, 570 00:34:53,040 --> 00:34:58,700 if you're using root FTPD, you change user from user equals root to user equals FTP. 571 00:34:59,180 --> 00:35:06,940 If you're using an id.conf, then you just change this little thing right here, it was 572 00:35:06,940 --> 00:35:12,080 root, we change it to FTP, and we're good. Okay? Any questions so far? 573 00:35:13,900 --> 00:35:18,460 Okay, cool. Okay, now, we said before, 574 00:35:18,960 --> 00:35:22,240 truiting is going to contain, truiting, the nice thing is, truiting doesn't really contain 575 00:35:22,240 --> 00:35:26,020 someone who can get, who can get root. Okay, but root can break out of it. What we've 576 00:35:26,020 --> 00:35:29,260 done is we've just, we've just basically decided, we're not going to, we're not going 577 00:35:29,260 --> 00:35:33,580 to trust the FTP server to actually, to actually drop privilege. We're going to force it to 578 00:35:33,580 --> 00:35:36,840 have less privilege in the first place. So it doesn't have to drop privilege and maybe 579 00:35:36,840 --> 00:35:42,740 get it back, it just starts out with nothing. Okay? There's, I think this is the last, 580 00:35:42,840 --> 00:35:47,280 last vulnerability I'm going to show you, and this vulnerability is basically, you 581 00:35:47,280 --> 00:35:50,820 ever go to an FTP site and greet you with a nice little message? It says, we have 43 582 00:35:50,820 --> 00:35:55,160 users on right now, how are you doing? You know? The admin at this site is so-and-so. 583 00:35:55,380 --> 00:35:57,760 You might want to look in this other directory, because that's where all the, that's where 584 00:35:57,760 --> 00:36:01,900 all the mp3s are. Okay? If you're not using this message function, it's called message, 585 00:36:02,160 --> 00:36:06,940 if you're not using it, we can turn this off. The reason that the vulnerability exists is 586 00:36:06,940 --> 00:36:11,140 the message, the message thing is a nice feature. It's a nice little thing like, oh, hey, every 587 00:36:12,840 --> 00:36:16,220 time you send me this message, and this message can, this message can have little tags, like 588 00:36:16,220 --> 00:36:20,380 percent R, which says, whenever you see percent R, give me the client host name, because I'm 589 00:36:20,380 --> 00:36:24,820 too lazy to type the client host name myself. Or, you know, percent N, how many users are 590 00:36:24,820 --> 00:36:29,180 currently logged in. This is another feature. Okay? One of the biggest things I do when 591 00:36:29,180 --> 00:36:32,560 I'm trying to harden applications, when I'm trying to harden servers, is I try to turn 592 00:36:32,560 --> 00:36:36,540 off all the features that I'm not using. And if I can, I try to convince myself, the other 593 00:36:36,540 --> 00:36:39,940 users, that maybe there's some features that we don't need as much that we can turn off 594 00:36:39,940 --> 00:36:42,820 too. Because the big deal is, the fewer, you know, the, the, the, the, the, the, the, 595 00:36:42,840 --> 00:36:46,580 the fewer features that are actually activated, and most of us don't use them all, okay, the 596 00:36:46,580 --> 00:36:50,400 fewer features that are actually activated, the fewer attack vectors somebody has when 597 00:36:50,400 --> 00:36:53,980 they, when they find a vulnerability in a piece of software. Okay? The great thing 598 00:36:53,980 --> 00:36:57,440 here, I mean, I know you all think I'm right, but wait, I like my features. Okay? Well, 599 00:36:57,500 --> 00:37:01,680 the thing is that, you know, yeah, you like your features, choose which ones you like, 600 00:37:01,740 --> 00:37:05,820 keep those. The rest, turn them off, because maybe one of them ends up having a vulnerability, 601 00:37:06,000 --> 00:37:09,620 you'd rather not have the vulnerability, especially if it's a real, real, real word 602 00:37:09,620 --> 00:37:10,820 grab. Trust me on this. 603 00:37:12,600 --> 00:37:17,220 Okay? The bulk, there's a buffer that will flow in that feature. It can be exploited 604 00:37:17,220 --> 00:37:21,360 if somebody, if somebody can write a message file. Okay? It gives you, if you can write 605 00:37:21,360 --> 00:37:27,700 a message file. It's just pretty nice. Now, you can turn this off, because what you do 606 00:37:27,700 --> 00:37:31,400 is you just remove those two message lines. Another possibility, if you have to keep this 607 00:37:31,400 --> 00:37:34,240 functional, is you just make sure that every single freaking directory that can have a 608 00:37:34,240 --> 00:37:39,800 message file, okay, isn't writeable. Now, what else does that mean? What about the 609 00:37:39,800 --> 00:37:42,820 directories that don't exist? We have to make sure they can't make directories that don't 610 00:37:42,840 --> 00:37:46,380 have directories, because if they can make directories or upload directories, that's 611 00:37:46,380 --> 00:37:50,480 not so good, because then they can put their own message file in there and grab root. Okay? 612 00:37:50,600 --> 00:37:53,920 Well, one of the things we did with that, with that upload area, the upload instructions 613 00:37:53,920 --> 00:37:57,460 I gave you, it has something called no-dos in it, which says somebody who's uploading 614 00:37:57,460 --> 00:38:01,880 cannot create directories in the incoming area. They can't create new directories. Okay? 615 00:38:02,140 --> 00:38:05,800 All they can do is switch around and move among directories. And, you know, that's a, 616 00:38:05,880 --> 00:38:09,140 these are basically standard, you know, that kind of thing is just a standard recommendation, 617 00:38:09,460 --> 00:38:12,820 and it's to stop specifically things like this. People creating directories, they're 618 00:38:12,840 --> 00:38:17,620 going to stop, stick dot message files in. Okay? The other big way to, the other big 619 00:38:17,620 --> 00:38:20,660 way to stop this dot message file thing is with that path filter we were talking about, 620 00:38:20,720 --> 00:38:23,700 the thing that's going to, the thing that stops anybody from uploading something that 621 00:38:23,700 --> 00:38:32,940 begins in a dot or a dash. Okay? So, if we, if we can set a path filter, this is, 622 00:38:32,980 --> 00:38:36,460 this is avoidance. It's all about avoidance or containment. This is avoidance. If we 623 00:38:36,460 --> 00:38:40,260 can stop somebody from writing any file that begins in a period, they can't upload their 624 00:38:40,260 --> 00:38:42,300 own dot message file. Okay? 625 00:38:42,840 --> 00:38:46,600 This is, again, the path filter thing, if you look at the FTP man page, it's a standard, 626 00:38:46,620 --> 00:38:50,580 it's a standard recommendation. Because the idea is if somebody could FTP, if people could 627 00:38:50,580 --> 00:38:54,840 upload files that begin in a period, okay, if they could upload files that begin in a 628 00:38:54,840 --> 00:38:58,120 period, then they'd end up uploading hidden files. You wouldn't see them. Maybe they're 629 00:38:58,120 --> 00:39:01,140 real big. Maybe they're bad. Whatever. So, we don't want, you know, you don't want that 630 00:39:01,140 --> 00:39:06,860 in general. And it also helps to stop this exploit. Okay? The big message here is, okay, 631 00:39:06,940 --> 00:39:10,680 what I'm doing is I'm teaching you how to harden an FTP server. Not just to break the 632 00:39:10,680 --> 00:39:12,820 five exploits that I brought with me, but to break the five exploits that I brought with me. 633 00:39:12,840 --> 00:39:16,240 Not just to break the sixth one. The next one that comes out. The idea is when the next 634 00:39:16,240 --> 00:39:20,680 exploit comes out, and it might be out right now and most of us don't know about it. And 635 00:39:20,680 --> 00:39:25,240 there's one guy in the back of the room chuckling. You know, he's going to get J. Okay? The 636 00:39:25,240 --> 00:39:30,380 idea is to be hardened, to harden the server. Okay? So, when that guy's got his exploit, 637 00:39:30,520 --> 00:39:33,460 none of us know about it. The vendor sure as heck doesn't know about it. Whatever. The 638 00:39:33,460 --> 00:39:36,980 guy who writes FTP doesn't know about it, so then nobody's issuing a patch because nobody 639 00:39:36,980 --> 00:39:41,960 knows about it. The idea is we don't get hit. He tries it on us, it doesn't work because 640 00:39:41,960 --> 00:39:42,340 we're hardened. 641 00:39:42,840 --> 00:39:45,880 He tries it on other people, they get hit. They wonder, is there a new vulnerability 642 00:39:45,880 --> 00:39:49,960 of FTP that I don't know about? You know, and the answer is yes. So, the idea is we're 643 00:39:49,960 --> 00:39:54,340 trying to apply this stuff, best practices, whatever, ideas that J comes up with, ideas 644 00:39:54,340 --> 00:39:58,640 that somebody else came up with, to try to stop people from breaking us with vulnerabilities, 645 00:39:58,760 --> 00:40:02,340 either ones that we're vulnerable to now and we know about, or the ones we're vulnerable 646 00:40:02,340 --> 00:40:11,120 to and we don't know about yet. Y'all having fun, by the way? Okay, cool. Okay. What else 647 00:40:11,120 --> 00:40:12,820 can we do? We can also remove open message lines. We can also remove open message lines 648 00:40:12,840 --> 00:40:16,240 from the configuration file. I showed you which ones those were. Pull them the heck 649 00:40:16,240 --> 00:40:21,240 out. If we pull them the heck out, then somebody can't use this against us, which is really 650 00:40:21,240 --> 00:40:25,780 nice. Okay? It's really nice. We didn't have to do much. Just pull out those two configuration 651 00:40:25,780 --> 00:40:30,420 lines and all of a sudden we're not vulnerable anymore. I'm really liking that. Here's how 652 00:40:30,420 --> 00:40:34,200 you pull them out. There's a little grep command. It just says remove any lines that look like 653 00:40:34,200 --> 00:40:41,440 message. Okay? Avoidance is really good. If we're not able to avoid, we definitely want 654 00:40:41,440 --> 00:40:41,860 to contain. 655 00:40:42,840 --> 00:40:46,260 And I showed you, I talked at some length about how you want to do this. You want to 656 00:40:46,260 --> 00:40:51,540 just run your FTP server as user FTP. If you're only using anonymous mode, this is exactly 657 00:40:51,540 --> 00:40:56,780 what you want. Okay? I showed you how to do that. What else do we want to do? There's 658 00:40:56,780 --> 00:41:02,160 some additional stuff. Here's logging. Logging is the second most boring area of security. 659 00:41:03,060 --> 00:41:08,560 Okay? First most boring area of computer security is patching. Patching and logging. Patching 660 00:41:08,560 --> 00:41:12,260 helps you avoid this stuff. Logging helps you know when you've gotten hit by it or when 661 00:41:12,840 --> 00:41:18,040 you've gotten hit by it. You know, we want logging. I'm sorry we want it, but it's very 662 00:41:18,040 --> 00:41:22,780 useful. Logging security says logging looks like a security violation. Somebody mistypes 663 00:41:22,780 --> 00:41:26,080 their password, let me know about it. Because it might be somebody just carelessly missing 664 00:41:26,080 --> 00:41:29,700 it. But if they miss it 50 times in a row, that might be someone trying to guess a password. 665 00:41:30,060 --> 00:41:34,080 Okay? Log all the commands. What the hell? Let's be paranoid. Every time somebody types 666 00:41:34,080 --> 00:41:38,140 a command, let's log it. Disk space is cheap these days. You can cycle your logs if you're 667 00:41:38,140 --> 00:41:41,380 worried about it. Let's log it. Okay? 668 00:41:42,840 --> 00:41:46,800 What else can we do? There's an FTP users file on every system. That file says what 669 00:41:46,800 --> 00:41:50,620 users aren't allowed to use FTP. Okay? Normally one of the things I stand up here and say 670 00:41:50,620 --> 00:41:55,420 is, okay, make sure to put every single user that's like a normal, that's like a system 671 00:41:55,420 --> 00:42:00,980 user, not a human, into this file. I'm like, okay, don't miss any of them. Well, screws 672 00:42:00,980 --> 00:42:05,980 don't miss any of them. If you know the UID, if you know the user ID that the system users 673 00:42:05,980 --> 00:42:11,080 end at, you just say, deny UID. Don't let anyone log in. If they're between zero, that's 674 00:42:11,080 --> 00:42:12,680 what the lack of number means. 675 00:42:12,840 --> 00:42:18,820 Between zero and 499. On a Red Hat system, it's zero through 499. Okay? On a Solaris 676 00:42:18,820 --> 00:42:23,060 system, it's zero through 99. If you want to know on yours, you'd probably have to take 677 00:42:23,060 --> 00:42:30,180 a look. But yeah, so we set that. Okay? The last thing I want to, the last major thing 678 00:42:30,180 --> 00:42:33,700 I want to talk about is worms and auto-routers. Nice little tools that run around rooting 679 00:42:33,700 --> 00:42:37,240 boxes for you and just, you know, they just go and root a bunch of boxes and then tell 680 00:42:37,240 --> 00:42:40,720 their owner, potentially, hey, these are all the systems I got for you. What have you done 681 00:42:40,720 --> 00:42:41,900 for me? Okay? 682 00:42:42,840 --> 00:42:47,160 These give you really nice gifts. Okay, the Honey Nut project, Honey Nut project has 683 00:42:47,160 --> 00:42:50,740 a few fun statistics. One of them is, they took a machine, well, this isn't a statistic, 684 00:42:50,840 --> 00:42:55,580 it's anecdotal, right? They took a machine, installed Red Hat 6.2. They put it down, 685 00:42:55,700 --> 00:43:01,480 plugged it into the network. 92 seconds later, the system had been scanned, it had been compromised, 686 00:43:01,840 --> 00:43:06,140 and it was now working for other systems. Because a worm had come through, had gone 687 00:43:06,140 --> 00:43:12,160 and been scanning that portion of the IP address space, found it, exploited it, started 688 00:43:12,160 --> 00:43:12,600 up shop. 689 00:43:12,840 --> 00:43:16,600 Then it went up there and started going and scanning for more machines. 92 seconds, okay? 690 00:43:16,760 --> 00:43:20,980 The fastest one, the fastest time with a human was 15 minutes. So, remember, this is just 691 00:43:20,980 --> 00:43:24,980 like automated hackers. ScriptKitties will get you real quick. There are ScriptKitties 692 00:43:24,980 --> 00:43:27,400 in the room? Yeah, I know. Okay? 693 00:43:28,940 --> 00:43:36,000 Now, the nice thing is, about worms and ScriptKitties, is often they sacrifice, they sacrifice knowledge 694 00:43:36,000 --> 00:43:42,480 for intelligence for speed or for laziness or whatever. So, in the case of the worm, 695 00:43:42,480 --> 00:43:45,740 they generally do it for speed's sake or they do it because the person who's writing 696 00:43:45,740 --> 00:43:49,500 it just didn't think to write or add more. Maybe they're lazy, maybe they didn't know 697 00:43:49,500 --> 00:43:54,620 how. What Raman does is it goes around scanning FTP server banners for build dates. Not for 698 00:43:54,620 --> 00:43:58,000 version numbers, but actually for build dates. Because it knows the particular things that 699 00:43:58,000 --> 00:44:02,500 it's got working shell code for, so it's looking for them. The secret to this is actually 700 00:44:02,500 --> 00:44:06,080 we can avoid being attacked. Even when we're freaking vulnerable, we don't have to get 701 00:44:06,080 --> 00:44:09,840 attacked by this thing. The bitch just thinks that we don't have a real FTP server. Is that 702 00:44:09,840 --> 00:44:11,040 a two-minute warning or a ten-minute? 703 00:44:11,560 --> 00:44:19,260 Two minutes. Go fast, Jay. Okay? This tool, what it does, okay, there's also another one, 704 00:44:19,940 --> 00:44:25,060 auto-roo. Okay? And I don't know, anybody in the room write auto-roo? Nobody wants 705 00:44:25,060 --> 00:44:30,300 to raise their hand. Okay, fine. What this tool does is it scans, it scans big old networks 706 00:44:30,300 --> 00:44:34,880 looking for vulnerable versions. And I think that one actually looks by versions. And if 707 00:44:34,880 --> 00:44:39,340 your banner matches the right one, then it attacks you. Each of these two tools, this 708 00:44:39,340 --> 00:44:41,020 is an auto-roo. So, you fire it and it attacks you. So, you fire it and it attacks you. 709 00:44:41,040 --> 00:44:44,940 So, you fire this off. You give it a class B that you want to target. And it goes root. 710 00:44:45,040 --> 00:44:47,960 So, as many machines as account like class B, it let you know which machines you now 711 00:44:47,960 --> 00:44:54,880 own. Okay? Class B is like 65,536 addresses, few less usually. Okay? You might get a thousand 712 00:44:54,880 --> 00:45:00,360 systems, what everybody wouldn't give for a thousand systems. Okay? The nice thing is, 713 00:45:00,440 --> 00:45:05,380 if your banner doesn't look like wooFTP, this doesn't work. Okay. So, what do you do? Well, 714 00:45:05,400 --> 00:45:08,780 wooFTP will actually let you set your banner. You can say greeting tourists, which means 715 00:45:08,780 --> 00:45:11,020 don't give out your version number. Just give out the version number of the banner. And 716 00:45:11,040 --> 00:45:12,120 FTP server ready. 717 00:45:12,740 --> 00:45:14,880 Okay? Well, you can 718 00:45:14,880 --> 00:45:16,880 also give it, let it do arbitrary text. 719 00:45:17,040 --> 00:45:18,940 I don't know how many of you can read this, but what I did 720 00:45:18,940 --> 00:45:20,600 is instead of greeting 721 00:45:20,600 --> 00:45:22,680 text, I put greeting text, and now 722 00:45:22,680 --> 00:45:24,480 mine says, pro-ftpd 723 00:45:24,480 --> 00:45:26,520 1.2.0.10 server. 724 00:45:27,180 --> 00:45:28,220 Why is this nice? 725 00:45:28,680 --> 00:45:31,000 If you're a worm, this doesn't match any of your patterns. 726 00:45:31,200 --> 00:45:32,760 It doesn't have the build date you're looking for. 727 00:45:33,120 --> 00:45:34,660 Okay? It doesn't have the version 728 00:45:34,660 --> 00:45:36,060 numbers you're looking for. It doesn't even say rule. 729 00:45:36,760 --> 00:45:38,900 Okay? If you're a script kitty, or maybe 730 00:45:38,900 --> 00:45:40,060 even a hacker, 731 00:45:40,060 --> 00:45:41,820 hacker, okay, what does 732 00:45:41,820 --> 00:45:43,820 it do? It says, I'm 733 00:45:43,820 --> 00:45:45,540 pro. You're like, okay, I'll get out my pro 734 00:45:45,540 --> 00:45:48,200 tools. This one's not a rule. This one's 735 00:45:48,200 --> 00:45:49,760 not a rule server. I can't use my 736 00:45:49,760 --> 00:45:51,860 rule exploits. I'll have to come up with my pro exploits. 737 00:45:51,980 --> 00:45:54,120 So you're sitting there firing your pro exploits 738 00:45:54,120 --> 00:45:55,500 at a rule server. It's not 739 00:45:55,500 --> 00:45:57,660 vulnerable. At least if it is vulnerable 740 00:45:57,660 --> 00:45:59,260 to the same problems, it generally 741 00:45:59,260 --> 00:46:01,700 the attack has to be very, very, very 742 00:46:01,700 --> 00:46:03,180 tied to the target. 743 00:46:03,900 --> 00:46:05,800 So it doesn't get anywhere. And this is 744 00:46:05,800 --> 00:46:07,840 like really easy. How many of you are shouting 745 00:46:07,840 --> 00:46:08,860 security through obscurity? 746 00:46:08,860 --> 00:46:10,700 Security. Okay, nobody's shouting 747 00:46:10,700 --> 00:46:12,740 that. But whenever I get people to shout that, my first 748 00:46:13,180 --> 00:46:14,440 answer is, hey, it worked. 749 00:46:14,920 --> 00:46:16,760 You know? It's like, okay, I'm going to 750 00:46:16,760 --> 00:46:18,600 do everything possible I can to protect 751 00:46:18,600 --> 00:46:19,980 this thing. I'm going to do everything I can to 752 00:46:19,980 --> 00:46:22,800 keep the sucker patched. It would be really nice 753 00:46:22,800 --> 00:46:24,740 if I didn't get hit with some of 754 00:46:24,740 --> 00:46:26,700 the exploits, because whoever it was that was going to 755 00:46:26,700 --> 00:46:28,300 exploit me figured I wasn't vulnerable. 756 00:46:28,800 --> 00:46:29,680 That'd be nice, too. 757 00:46:31,220 --> 00:46:32,600 Okay? By the way, you also 758 00:46:33,080 --> 00:46:34,740 have to, that greeting banner, you also have to 759 00:46:34,740 --> 00:46:36,580 change your stat banner. Okay? Stat 760 00:46:36,580 --> 00:46:38,700 is once you log in, you can type stat. It'll tell 761 00:46:38,860 --> 00:46:40,560 you what kind of server it is. So you've got to 762 00:46:40,560 --> 00:46:42,900 make sure to get it in both places. 763 00:46:43,420 --> 00:46:44,820 Okay, quick recap of all 764 00:46:44,820 --> 00:46:46,620 the stuff we put. This is an FTP access 765 00:46:46,620 --> 00:46:48,780 file. This is the one we just built with 766 00:46:48,780 --> 00:46:50,260 all of those little things I was showing you. 767 00:46:50,600 --> 00:46:52,740 I do this so you've got something to copy and take 768 00:46:52,740 --> 00:46:54,860 home. First couple lines were already 769 00:46:54,860 --> 00:46:56,700 there. Compress, charge, mod, 770 00:46:56,780 --> 00:46:58,660 delete, overwrite, rename. You can't do any of that 771 00:46:58,660 --> 00:47:00,560 stuff? Good. Okay, most of the 772 00:47:00,560 --> 00:47:02,680 recent FTP servers don't let you do the last 773 00:47:02,680 --> 00:47:04,580 four. We're going to add the first two to that, too. 774 00:47:05,700 --> 00:47:06,840 Okay? We created 775 00:47:06,840 --> 00:47:08,360 an upload area. We said you could upload 776 00:47:08,860 --> 00:47:10,680 stuff, but you can't pull it back down. You can't 777 00:47:10,680 --> 00:47:12,700 create any directories. We're going to make 778 00:47:12,700 --> 00:47:14,680 sure you enter a real password. That means if 779 00:47:14,680 --> 00:47:16,560 one of these other routers or one of these worms run around 780 00:47:16,560 --> 00:47:18,440 and it gives out, you know, Mozilla 781 00:47:18,440 --> 00:47:20,500 as a password, it's not going to work. 782 00:47:20,600 --> 00:47:22,220 Because it's not actually going to get to log in 783 00:47:22,220 --> 00:47:24,240 to the FTP server to deliver the payload. 784 00:47:24,780 --> 00:47:26,400 Okay, what else? Tons of logging, 785 00:47:26,620 --> 00:47:28,720 like we said. Finally, 786 00:47:29,160 --> 00:47:30,360 basically, we said 787 00:47:30,360 --> 00:47:32,800 non-human users can't 788 00:47:32,800 --> 00:47:34,440 use this. Greeting text, 789 00:47:34,480 --> 00:47:36,380 stat text, we're going to call ourselves a pro-FTP 790 00:47:36,380 --> 00:47:38,260 server, just to throw people off. 791 00:47:39,240 --> 00:47:40,340 Def unasked to get good 792 00:47:40,340 --> 00:47:42,480 permissions. Nice has been set 793 00:47:42,480 --> 00:47:44,380 so if this thing gets dosed, it doesn't take down 794 00:47:44,380 --> 00:47:46,440 the whole box. Okay? I've also 795 00:47:46,440 --> 00:47:48,340 included some slides. By the way, these slides are at my 796 00:47:48,340 --> 00:47:50,480 website. I'll put it back. I'll give you 797 00:47:50,480 --> 00:47:52,300 my website again. The website basically is 798 00:47:52,740 --> 00:47:55,900 Jay's page on bastio-linux.org. 799 00:47:56,240 --> 00:47:58,180 But I've given you a pattern 800 00:47:58,180 --> 00:48:00,300 for how you can use the guest functionality 801 00:48:00,300 --> 00:48:02,520 to basically make sure that every user that logs in 802 00:48:02,520 --> 00:48:04,100 or at least every user you define as guest 803 00:48:04,100 --> 00:48:06,360 is stuck in a truited directory. So if someone 804 00:48:06,360 --> 00:48:08,560 steals one of the accounts on your 805 00:48:08,560 --> 00:48:10,320 system, okay, they stole 806 00:48:10,320 --> 00:48:12,200 an account, great, but they can't get to root because 807 00:48:12,200 --> 00:48:13,960 they can't go and find the user helper 808 00:48:13,960 --> 00:48:16,020 program that we used in the beginning of this 809 00:48:16,020 --> 00:48:18,160 to actually get root from when we just stole 810 00:48:18,160 --> 00:48:18,380 an account. 811 00:48:19,940 --> 00:48:21,920 So I've given you slides on how to do this. 812 00:48:23,400 --> 00:48:23,760 Okay? 813 00:48:24,920 --> 00:48:26,160 I have two more 814 00:48:26,160 --> 00:48:28,100 ideas. Okay? I have two more 815 00:48:28,100 --> 00:48:30,000 ideas. One of the ones I 816 00:48:30,000 --> 00:48:31,440 heard at a party the other night. 817 00:48:32,220 --> 00:48:34,220 Try it out. It's really good. Turn your 818 00:48:34,220 --> 00:48:36,220 FTP server into a virtual server. Someone has to 819 00:48:36,220 --> 00:48:38,120 know the name of the server to interact with it. 820 00:48:38,560 --> 00:48:40,480 Okay? If we turn off normal server use 821 00:48:40,480 --> 00:48:42,500 and turn this into a virtual server, someone has 822 00:48:42,500 --> 00:48:44,500 to know the name of your FTP server just to talk 823 00:48:44,500 --> 00:48:46,520 to it, much less to exploit it. If they're just 824 00:48:46,520 --> 00:48:48,540 scanning by IP address, they won't find it. 825 00:48:48,640 --> 00:48:50,540 Because your FTP server only answers 826 00:48:50,540 --> 00:48:52,580 back when someone actually talks to it 827 00:48:52,580 --> 00:48:54,640 by its right name. This virtual server 828 00:48:54,640 --> 00:48:56,220 stuff is just like on web servers. 829 00:48:56,840 --> 00:48:58,580 Okay? And what I do is I show you 830 00:48:58,580 --> 00:49:00,600 how to do this. Okay? 831 00:49:00,760 --> 00:49:01,960 The other issue is 832 00:49:01,960 --> 00:49:03,820 you can try to get rid of root. 833 00:49:04,180 --> 00:49:06,320 You can go pro or open 834 00:49:06,320 --> 00:49:08,440 BSDs, but they've each been rooted at some point. 835 00:49:08,560 --> 00:49:10,340 So that only gets you so far. 836 00:49:11,860 --> 00:49:12,300 Okay? 837 00:49:12,440 --> 00:49:15,000 The big alternative is VSFTPD. 838 00:49:15,180 --> 00:49:16,820 It's got a much, much, 839 00:49:16,840 --> 00:49:17,940 much better design. 840 00:49:18,260 --> 00:49:20,560 Design for security from 841 00:49:20,560 --> 00:49:22,260 the get-go. Okay? 842 00:49:22,320 --> 00:49:24,560 It's not that old, and so they were able to just start 843 00:49:24,560 --> 00:49:26,700 it as a small thing, not a huge number of features, 844 00:49:26,900 --> 00:49:28,700 and it shouldn't be exploited too easily. 845 00:49:29,580 --> 00:49:30,560 Basically, it's real 846 00:49:30,560 --> 00:49:32,600 simple. Lots of small little programs. 847 00:49:32,820 --> 00:49:34,520 The programs that I have privilege aren't really 848 00:49:34,520 --> 00:49:36,360 directly interacting with you, 849 00:49:36,400 --> 00:49:38,220 and it's all good. Pull it down 850 00:49:38,560 --> 00:49:40,660 beast.org. I'd love to know how they came up 851 00:49:40,660 --> 00:49:42,700 with the name. The last thing is 852 00:49:43,260 --> 00:49:44,400 try to get away from FTP. 853 00:49:44,620 --> 00:49:46,640 Like I said earlier, use SFTP. 854 00:49:46,740 --> 00:49:48,380 Use SCP. Okay? 855 00:49:48,540 --> 00:49:50,460 There are, there are, this is part 856 00:49:50,460 --> 00:49:52,540 of SSH. There are clients for MacOS. 857 00:49:52,620 --> 00:49:54,280 There are clients for Windows. They're free. 858 00:49:54,400 --> 00:49:56,140 No excuse now. Okay? 859 00:49:56,740 --> 00:49:58,600 Also, use your web server to give out 860 00:49:58,600 --> 00:50:00,260 files to everybody and their 861 00:50:00,740 --> 00:50:02,540 brother. They've been a lot better in terms of 862 00:50:02,540 --> 00:50:04,240 security history. Okay? 863 00:50:04,440 --> 00:50:06,600 So now, go in peace. My talk 864 00:50:06,600 --> 00:50:07,860 has ended. Okay? 865 00:50:08,560 --> 00:50:10,600 Um, please go, and if you're running an FTP 866 00:50:10,600 --> 00:50:12,720 server, do this stuff. Problem I always 867 00:50:12,720 --> 00:50:14,400 have is I go and I give these talks. I tell people 868 00:50:14,400 --> 00:50:16,620 to harden systems. They go home. They don't harden 869 00:50:16,620 --> 00:50:18,320 them. They call me back up later and ask me if I can do 870 00:50:18,320 --> 00:50:20,540 forensics. Okay? Yes, I'll 871 00:50:20,540 --> 00:50:22,440 do forensics for you, but I'd much rather you just 872 00:50:22,440 --> 00:50:24,200 call me up and say, thanks a lot for that talk. 873 00:50:24,420 --> 00:50:26,440 We were able to do some cool stuff. Okay? 874 00:50:26,500 --> 00:50:28,320 That's it. I'm Jay. I'm out of here. 875 00:50:28,720 --> 00:50:30,240 Next show's tomorrow. We're talking about 876 00:50:30,240 --> 00:50:32,420 Bastille Linux. Okay? 877 00:50:34,320 --> 00:50:34,960 New tomorrow, 878 00:50:35,140 --> 00:50:36,520 I'm talking about Bastille Linux 879 00:50:36,520 --> 00:50:38,420 in the, uh, well, somewhere in the hotel. 880 00:50:39,120 --> 00:50:40,180 Do you have a card? 881 00:50:40,620 --> 00:50:42,600 I got cards. Anyone who wants a card, come up 882 00:50:42,600 --> 00:50:43,640 and get one. Yeah. 883 00:51:22,880 --> 00:51:23,740 I got a card. 884 00:51:24,960 --> 00:51:25,280 I got a card. 885 00:51:25,400 --> 00:51:25,760 I got a card. 886 00:51:25,760 --> 00:51:27,120 I got a card. 887 00:51:27,200 --> 00:51:27,300 I got a card. 888 00:51:27,320 --> 00:51:27,420 I got a card. 889 00:51:27,440 --> 00:51:27,480 I got a card. 890 00:51:27,480 --> 00:51:27,560 I got a card. 891 00:51:27,560 --> 00:51:27,820 I got a card. 892 00:51:28,100 --> 00:51:28,160 I got a card. 893 00:51:28,320 --> 00:51:28,980 I got a card. 894 00:51:30,140 --> 00:51:31,100 I got a card. 895 00:51:31,460 --> 00:51:32,500 I got a card. 896 00:51:32,500 --> 00:51:33,380 I got a card. 897 00:51:33,380 --> 00:51:36,360 I got a card. 898 00:51:36,360 --> 00:51:37,940 I got a card. 899 00:51:50,400 --> 00:51:50,460 Thank you. 900 00:52:13,320 --> 00:52:16,120 Thank you.