1 00:00:03,820 --> 00:00:09,320 bsd security fundamentals this is just gonna like hopefully at the end of this talk you guys will 2 00:00:09,320 --> 00:00:13,680 have a little bit better understanding of some of the security mechanisms that actually go right 3 00:00:13,680 --> 00:00:21,220 into BSD and a lot of people just don't make use of them and they're actually pretty nifty so yeah 4 00:00:21,220 --> 00:00:28,240 I'm just gonna start I'm gonna throw this presentation up you know the excuse my 5 00:00:28,240 --> 00:00:32,260 powerpoint format it's not very polished I just throw as much stuff in there so I like remember 6 00:00:32,260 --> 00:00:36,080 I don't you know so I don't leave anything out when I'm giving the talk so this will be up on 7 00:00:36,080 --> 00:00:40,920 the this is a little bit different than the one in your CD it's a couple more revisions to it so 8 00:00:40,920 --> 00:00:46,320 go ahead and the website is gonna be sub train dotnet slash presentations and you can get some 9 00:00:46,320 --> 00:00:53,780 of the other talks that the rest of the guys that I work with have done so sub train dotnet slash 10 00:00:53,780 --> 00:00:56,140 presentations okay 11 00:00:58,240 --> 00:01:03,520 okay so for this whole talk I'm pretty much gonna be focusing on free BSD that's like the main 12 00:01:03,520 --> 00:01:09,980 operating system that that my friends and I work with and it's really the most mainstream and I 13 00:01:09,980 --> 00:01:15,100 mean I'll like deviate a little bit and talk about some cool stuff with open BSD but it's mainly 14 00:01:15,100 --> 00:01:20,320 gonna be free BSD it's just gonna be it's gonna be a refresher I mean some of you guys may already 15 00:01:20,320 --> 00:01:24,340 know a lot of this stuff but I mean I'm sure everybody will pick up a couple things that they 16 00:01:24,340 --> 00:01:28,020 didn't know that things pretty cool and it's gonna it's gonna be 17 00:01:28,240 --> 00:01:28,380 cool and it's gonna be cool and it's gonna be interesting but it's gonna be fun but it's gonna be 18 00:01:28,380 --> 00:01:32,820 I'm gonna emphasize on on host base security and I'm just gonna basically show you you know using 19 00:01:32,820 --> 00:01:39,040 a defense-in-depth strategy you're able to secure a BSD server you know all the way up to the to the 20 00:01:39,040 --> 00:01:45,360 wire pretty much and and it's like it's like this is the models of the security I mean you know I 21 00:01:45,360 --> 00:01:50,700 mean you peel it away a lot of people I mean it's ridiculous with like the recent Apache chunk 22 00:01:50,700 --> 00:01:56,340 encoding stuff I mean I'm sure some of you guys came across this but a lot of people actually went 23 00:01:56,340 --> 00:01:58,220 out of their way to start up and start building your own security and then it's gonna be a lot of fun but 24 00:01:58,220 --> 00:01:59,260 Apache running as root 25 00:01:59,260 --> 00:02:02,040 because they didn't understand how 26 00:02:02,040 --> 00:02:04,140 file permissions work and sim links 27 00:02:04,140 --> 00:02:06,200 work and they just wanted Apache 28 00:02:06,200 --> 00:02:07,900 to have access to their entire directory structure 29 00:02:07,900 --> 00:02:09,900 so once they got hit by the exploit 30 00:02:09,900 --> 00:02:10,880 they were toast 31 00:02:15,920 --> 00:02:16,800 BSD is actually 32 00:02:18,060 --> 00:02:19,820 in use in quite a few 33 00:02:19,820 --> 00:02:21,060 different products 34 00:02:21,060 --> 00:02:23,500 in today's computer enterprise world 35 00:02:23,500 --> 00:02:25,400 and it's kind of behind the scenes a lot of times 36 00:02:25,400 --> 00:02:27,980 a lot of 37 00:02:27,980 --> 00:02:29,860 companies are kind of turning to open source 38 00:02:29,860 --> 00:02:31,240 right now with the current 39 00:02:31,240 --> 00:02:32,560 state of the economy 40 00:02:34,100 --> 00:02:35,940 because they don't want to pay the 41 00:02:35,940 --> 00:02:37,660 high support costs for licensing 42 00:02:37,660 --> 00:02:39,860 Microsoft software or some other commercial 43 00:02:39,860 --> 00:02:41,660 variant and a lot of times 44 00:02:41,660 --> 00:02:43,400 the quality of the software is 45 00:02:43,400 --> 00:02:45,720 as you guys know, usually better 46 00:02:46,840 --> 00:02:47,960 Nokia Firewalls 47 00:02:47,960 --> 00:02:50,100 actually they run Checkpoint 48 00:02:50,740 --> 00:02:51,980 they use what's 49 00:02:51,980 --> 00:02:53,940 called the Ipsil operating system which is like a hardened 50 00:02:53,940 --> 00:02:56,160 version of FreeBSD 3.2 51 00:02:56,780 --> 00:02:59,280 and they've just went ahead and done some extra 52 00:02:59,280 --> 00:03:01,020 like file locking and stuff 53 00:03:01,020 --> 00:03:03,380 and they've got some proprietary stuff that they've added 54 00:03:03,380 --> 00:03:03,940 it's pretty cool 55 00:03:04,620 --> 00:03:06,060 and then all the Juniper 56 00:03:06,060 --> 00:03:08,820 all the backbone routers and stuff 57 00:03:08,820 --> 00:03:11,000 they all run FreeBSD, I think it's called Olive 58 00:03:11,480 --> 00:03:12,200 is the 59 00:03:12,200 --> 00:03:14,440 is the name of the product 60 00:03:14,440 --> 00:03:17,220 but it's more or less a BSD machine 61 00:03:17,220 --> 00:03:19,180 you can do package add on it and all kinds of stuff 62 00:03:19,180 --> 00:03:19,680 they're pretty cool 63 00:03:19,680 --> 00:03:23,140 and of course everybody knows Yahoo uses FreeBSD 64 00:03:23,140 --> 00:03:23,740 clustered machines 65 00:03:23,940 --> 00:03:25,660 to power all their web stuff 66 00:03:25,660 --> 00:03:26,280 and their mail stuff 67 00:03:26,280 --> 00:03:32,060 alright so 68 00:03:32,600 --> 00:03:34,220 let's get started with the basics 69 00:03:34,220 --> 00:03:35,400 I mean everybody should know this 70 00:03:35,400 --> 00:03:36,620 but I thought I'd just go over it anyways 71 00:03:37,860 --> 00:03:39,740 if you're messing with a system 72 00:03:39,740 --> 00:03:41,380 that's in a production environment, make backups 73 00:03:42,720 --> 00:03:44,460 don't make any changes you're not comfortable with 74 00:03:44,460 --> 00:03:45,340 you don't know what it's going to do 75 00:03:46,460 --> 00:03:47,960 go through your INID comp file 76 00:03:47,960 --> 00:03:49,780 and RC comp file and just turn off 77 00:03:49,780 --> 00:03:50,640 what you're not using 78 00:03:52,400 --> 00:03:53,800 FreeBSD especially has gotten 79 00:03:53,800 --> 00:03:54,440 really good lately 80 00:03:54,820 --> 00:03:56,040 in the last couple releases 81 00:03:56,040 --> 00:03:58,600 and I think all the way back to like 4.3 82 00:03:59,080 --> 00:04:01,240 they've just turned almost everything off by default 83 00:04:01,780 --> 00:04:02,940 in INID which is like 84 00:04:02,940 --> 00:04:05,920 I mean they're really like setting the pace for other vendors 85 00:04:06,420 --> 00:04:06,920 because I mean 86 00:04:07,380 --> 00:04:09,060 up till just like maybe a year ago 87 00:04:09,060 --> 00:04:10,920 the standard was just you know 88 00:04:11,440 --> 00:04:12,720 vendors were more concerned about 89 00:04:13,360 --> 00:04:14,740 making stuff work out of the box 90 00:04:14,740 --> 00:04:15,440 rather than 91 00:04:16,080 --> 00:04:17,880 you know emphasizing security 92 00:04:17,880 --> 00:04:20,380 so I mean they would just turn everything on by default 93 00:04:20,380 --> 00:04:21,640 to make it easier for the customer 94 00:04:22,080 --> 00:04:23,780 which didn't turn out to be a very good security structure 95 00:04:23,800 --> 00:04:23,940 strategy 96 00:04:25,460 --> 00:04:27,560 if you're running a machine and 97 00:04:28,160 --> 00:04:29,880 all you need to do is send mail 98 00:04:30,560 --> 00:04:30,800 locally 99 00:04:31,400 --> 00:04:34,180 you can actually disable send mail 100 00:04:34,780 --> 00:04:36,300 disable the daemon mode of send mail 101 00:04:36,300 --> 00:04:38,720 in the RC comp file with some flags 102 00:04:38,720 --> 00:04:41,200 and you can also turn off the submission port 103 00:04:41,840 --> 00:04:43,900 send mail comes default with FreeBSD in case 104 00:04:43,900 --> 00:04:45,040 some of you guys didn't know that 105 00:04:45,040 --> 00:04:46,760 the submission port is just another 106 00:04:47,380 --> 00:04:50,320 I think it's new to like send mail 107 00:04:50,660 --> 00:04:52,780 like late versions 8.11 and 8.12 108 00:04:52,780 --> 00:04:56,460 and most mail servers don't make use of it 109 00:04:56,460 --> 00:04:59,520 so you can firewall it off or disable it in the RC comp 110 00:04:59,520 --> 00:05:01,660 I'll get into how to do that specifically in a little bit 111 00:05:01,660 --> 00:05:04,580 and obviously I mean you're going to want to track 112 00:05:04,580 --> 00:05:06,640 the most stable version of the operating system 113 00:05:07,660 --> 00:05:09,680 if you're working in a production environment 114 00:05:09,680 --> 00:05:12,660 I would say probably rebuild the system 115 00:05:12,660 --> 00:05:13,920 and rebuild the kernel 116 00:05:13,920 --> 00:05:15,460 like every two months 117 00:05:15,460 --> 00:05:17,420 or maybe every month and a half 118 00:05:18,100 --> 00:05:19,240 obviously make exceptions 119 00:05:19,240 --> 00:05:22,420 and I just recently had some problems 120 00:05:22,420 --> 00:05:22,760 with open source system 121 00:05:22,780 --> 00:05:26,540 open SSH and the FreeBSD team 122 00:05:26,540 --> 00:05:29,520 got the 3.4 stuff with the privilege separation 123 00:05:30,180 --> 00:05:32,420 put into the stable tree pretty quickly after that 124 00:05:32,420 --> 00:05:34,640 even though stable wasn't actually affected 125 00:05:34,640 --> 00:05:37,180 by the recent off by one 126 00:05:37,180 --> 00:05:39,040 and some of the other remote open SSH stuff 127 00:05:39,040 --> 00:05:39,800 that's been floating around 128 00:05:40,760 --> 00:05:43,360 if you're a hobbyist 129 00:05:43,360 --> 00:05:45,220 I'd say go for it as much as possible 130 00:05:45,220 --> 00:05:47,960 I think I could probably count on one hand 131 00:05:47,960 --> 00:05:49,500 in the past three or four years 132 00:05:49,500 --> 00:05:51,320 the times that I've seen the stable tree 133 00:05:51,320 --> 00:05:52,520 really broken to the point where 134 00:05:52,520 --> 00:05:54,700 you couldn't kind of figure out what was wrong 135 00:05:54,700 --> 00:05:57,420 or maybe somebody just made a fat finger 136 00:05:57,420 --> 00:05:58,580 or something when they did their commit 137 00:05:58,580 --> 00:06:00,320 and it got taken care of 138 00:06:00,980 --> 00:06:02,980 within 30 minutes or an hour or so 139 00:06:04,000 --> 00:06:05,340 I'm not sure about this 140 00:06:05,340 --> 00:06:07,860 I'm not sure if they've gotten rid of this 141 00:06:07,860 --> 00:06:09,160 but there's another branch 142 00:06:09,160 --> 00:06:10,220 called the security branch 143 00:06:10,880 --> 00:06:11,760 and basically 144 00:06:13,060 --> 00:06:14,840 that's like an option for you 145 00:06:14,840 --> 00:06:16,480 if you're running a production system 146 00:06:16,480 --> 00:06:17,640 and you don't want to 147 00:06:20,540 --> 00:06:22,500 you don't think stable is really stable 148 00:06:22,520 --> 00:06:22,720 basically 149 00:06:22,720 --> 00:06:24,280 but you want all the security fixes 150 00:06:24,280 --> 00:06:26,080 and all they do is commit anything 151 00:06:26,080 --> 00:06:28,400 like the recent IO smash stuff 152 00:06:28,400 --> 00:06:31,040 they just commit patches to that 153 00:06:31,040 --> 00:06:32,920 and that's all you get 154 00:06:32,920 --> 00:06:34,880 and a lot of people prefer that 155 00:06:34,880 --> 00:06:36,680 if they're looking to run a really stable environment 156 00:06:37,480 --> 00:06:39,760 and there's the recent open SSL stuff 157 00:06:39,760 --> 00:06:41,120 that I was checking out 158 00:06:41,120 --> 00:06:43,280 before I headed out to Black Hat this week 159 00:06:43,280 --> 00:06:44,640 but it looks like 160 00:06:45,160 --> 00:06:46,920 there have been five or six new vulnerabilities 161 00:06:46,920 --> 00:06:48,100 found in open SSL 162 00:06:48,100 --> 00:06:50,200 so rebuild your systems when you get home 163 00:06:54,960 --> 00:06:55,480 okay 164 00:06:55,480 --> 00:06:56,740 encrypted communications 165 00:06:57,840 --> 00:06:59,180 especially at Defcon 166 00:06:59,180 --> 00:07:00,840 I was really amazed at the amount of people 167 00:07:00,840 --> 00:07:02,280 that were still popping their mail 168 00:07:02,280 --> 00:07:04,420 at Defcon 10 169 00:07:04,420 --> 00:07:05,260 it's kind of ridiculous 170 00:07:05,260 --> 00:07:09,180 more or less 171 00:07:09,180 --> 00:07:10,580 I don't think there's an excuse 172 00:07:10,580 --> 00:07:12,660 to not encrypt stuff that you're doing 173 00:07:13,860 --> 00:07:15,140 between SSH tunnels 174 00:07:15,140 --> 00:07:16,680 or using S-Tunnel 175 00:07:16,680 --> 00:07:18,620 to wrap stuff with SSL 176 00:07:19,700 --> 00:07:21,400 what's your excuse for not doing that 177 00:07:21,400 --> 00:07:21,760 you know 178 00:07:21,760 --> 00:07:22,500 open SSL 179 00:07:22,500 --> 00:07:24,760 SSH has been included in the FreeBSD 180 00:07:24,760 --> 00:07:26,500 base since, I think, 181 00:07:26,520 --> 00:07:27,560 FreeBSD 4.0. 182 00:07:28,700 --> 00:07:30,640 A lot of people have chosen 183 00:07:30,640 --> 00:07:32,540 to track the port, though, and use 184 00:07:32,540 --> 00:07:33,940 port upgrade to just keep it current. 185 00:07:34,880 --> 00:07:36,600 And you can actually, there's an 186 00:07:36,600 --> 00:07:38,260 RC com variable, I think it's 187 00:07:38,260 --> 00:07:40,340 SSHD underscore daemon, 188 00:07:40,440 --> 00:07:42,340 and you can just specify the path to your 189 00:07:42,340 --> 00:07:44,220 SSH daemon, so you can 190 00:07:44,220 --> 00:07:45,400 put it wherever you want. 191 00:07:46,600 --> 00:07:48,480 Personally, I just stick with what's instable. 192 00:07:48,600 --> 00:07:49,720 I never had a problem with it. 193 00:07:51,400 --> 00:07:52,100 Even if 194 00:07:52,100 --> 00:07:54,120 with some of the recent 195 00:07:54,120 --> 00:07:55,840 open SSH disclosures, 196 00:07:56,520 --> 00:07:57,760 people were kind of muddy as to 197 00:07:57,760 --> 00:08:00,380 what was affected, where, and under 198 00:08:00,380 --> 00:08:02,300 what circumstances. So, I mean, 199 00:08:02,320 --> 00:08:04,500 I just recommend going through and upgrading all your systems 200 00:08:04,500 --> 00:08:05,860 to 3.4 201 00:08:07,460 --> 00:08:08,500 and disabling 202 00:08:08,500 --> 00:08:09,720 SSH version 1 203 00:08:09,720 --> 00:08:12,160 where you can on some older systems, 204 00:08:13,120 --> 00:08:14,560 especially some legacy stuff. 205 00:08:15,360 --> 00:08:16,140 Like, I know 206 00:08:17,280 --> 00:08:18,460 PixFirewalls and stuff, they only 207 00:08:18,460 --> 00:08:20,580 listen to SSH 208 00:08:20,580 --> 00:08:22,080 version 1 for the protocol. 209 00:08:22,100 --> 00:08:24,600 So, I mean, that might be a problem, but 210 00:08:24,600 --> 00:08:26,220 on your BSD systems, you really 211 00:08:26,700 --> 00:08:28,360 have no excuse 212 00:08:28,360 --> 00:08:30,300 not to. And you can turn on privilege separation. 213 00:08:30,560 --> 00:08:32,420 It's not enabled by default 214 00:08:32,820 --> 00:08:33,740 with 3.4. 215 00:08:34,380 --> 00:08:36,420 You have to go in there and turn it on. It's an option 216 00:08:36,420 --> 00:08:38,100 in the SSHD config file. 217 00:08:38,340 --> 00:08:40,360 And it's just like, I think it's enable or use 218 00:08:40,360 --> 00:08:42,300 privilege separation. And 219 00:08:42,920 --> 00:08:44,540 basically, that'll just fork off a process 220 00:08:44,540 --> 00:08:46,520 when somebody authenticates 221 00:08:46,520 --> 00:08:48,480 to your machine successfully, and it'll 222 00:08:48,480 --> 00:08:50,500 drop some privileges. I'll get 223 00:08:50,500 --> 00:08:52,080 into that a little bit later as to how to do that. 224 00:08:52,100 --> 00:08:52,820 How some of that stuff works. 225 00:08:54,900 --> 00:08:55,380 SFTP, 226 00:08:56,360 --> 00:08:57,800 this is kind of recent. I think it's like 227 00:08:58,340 --> 00:08:59,540 OpenSSH 2.9 228 00:09:00,680 --> 00:09:01,580 brought it in 229 00:09:01,580 --> 00:09:03,980 to the tree as a standard thing, but 230 00:09:04,520 --> 00:09:05,700 it's just basically a 231 00:09:06,200 --> 00:09:07,080 way to 232 00:09:08,740 --> 00:09:10,020 connect to your system 233 00:09:10,020 --> 00:09:12,040 to transfer files over SSH. 234 00:09:13,240 --> 00:09:14,200 And obviously, 235 00:09:14,480 --> 00:09:15,940 I mean, the problems with FTP, everybody 236 00:09:15,940 --> 00:09:17,780 knows. Some of you guys may have caught 237 00:09:17,780 --> 00:09:20,080 JBeal's talk yesterday about 238 00:09:20,080 --> 00:09:21,140 hardening FTP. 239 00:09:22,820 --> 00:09:24,020 But FTP is 240 00:09:24,020 --> 00:09:26,280 20 years old and passes stuff in the 241 00:09:26,280 --> 00:09:27,440 clear and uses an 242 00:09:28,060 --> 00:09:29,660 unauthenticated channel for data and everything. 243 00:09:29,940 --> 00:09:32,180 It's just, this way it's encrypted. 244 00:09:32,400 --> 00:09:33,380 This has full 245 00:09:33,380 --> 00:09:35,520 public key support. 246 00:09:36,040 --> 00:09:38,180 So, I mean, it's basically 247 00:09:38,180 --> 00:09:39,880 just like you're making an administrative 248 00:09:39,880 --> 00:09:42,200 connection into the machine. And there's 249 00:09:42,200 --> 00:09:43,180 some new clients for Windows 250 00:09:44,240 --> 00:09:45,500 like SecureFX, and 251 00:09:45,500 --> 00:09:48,100 I'm not sure if Putty has a file transfer client 252 00:09:48,100 --> 00:09:49,960 or not, but it's a lot more 253 00:09:49,960 --> 00:09:50,740 secure than using 254 00:09:52,080 --> 00:09:53,040 regular FTP. 255 00:09:55,460 --> 00:09:56,980 Okay, public key authentication. 256 00:09:57,360 --> 00:09:58,940 Just talking about this a little bit. 257 00:10:00,480 --> 00:10:01,920 Really, what's going to get you? 258 00:10:02,400 --> 00:10:02,860 I mean, 259 00:10:04,020 --> 00:10:05,260 most people are pretty good 260 00:10:05,260 --> 00:10:06,900 keeping their systems patched 261 00:10:07,680 --> 00:10:09,220 that are in the security industry. 262 00:10:09,660 --> 00:10:11,140 And, you know, 263 00:10:11,140 --> 00:10:13,320 are they a security engineer at their company or what have you? 264 00:10:13,400 --> 00:10:14,760 I mean, they understand the importance of 265 00:10:14,760 --> 00:10:16,960 rolling patches out in a timely manner. 266 00:10:17,360 --> 00:10:19,120 But what's going to get you 267 00:10:19,120 --> 00:10:19,900 are your users. 268 00:10:20,740 --> 00:10:21,780 Usually with weak passwords. 269 00:10:22,260 --> 00:10:24,140 And so I'm going to talk quite a bit about 270 00:10:24,140 --> 00:10:25,780 how to secure your user accounts. 271 00:10:27,000 --> 00:10:28,760 And what it comes down to is 272 00:10:29,940 --> 00:10:31,400 users don't really give a crap 273 00:10:31,400 --> 00:10:31,920 about security. 274 00:10:32,540 --> 00:10:34,300 And that's just the way it is. 275 00:10:34,360 --> 00:10:36,300 I don't know if that will ever change because, I mean, 276 00:10:36,340 --> 00:10:38,620 people want convenience and they want to be able to use their system 277 00:10:38,620 --> 00:10:40,540 and security and 278 00:10:41,840 --> 00:10:42,920 security and convenience 279 00:10:42,920 --> 00:10:44,100 are just kind of like opposites. 280 00:10:44,220 --> 00:10:44,380 So, 281 00:10:46,300 --> 00:10:47,260 I'm going to talk about 282 00:10:48,300 --> 00:10:49,220 public key authentication 283 00:10:49,940 --> 00:10:50,560 and I'm going to 284 00:10:50,560 --> 00:10:51,260 heavily recommend 285 00:10:52,640 --> 00:10:53,740 switching all users 286 00:10:53,740 --> 00:10:54,620 to public key authentication 287 00:10:54,620 --> 00:10:57,000 if your users are savvy enough to handle it. 288 00:10:57,620 --> 00:10:58,620 You know, you may have to 289 00:10:58,620 --> 00:10:59,560 have them set up, 290 00:10:59,600 --> 00:11:00,340 help them set up the 291 00:11:00,340 --> 00:11:01,840 public-private key pair and everything. 292 00:11:01,980 --> 00:11:02,680 But once you do it, 293 00:11:03,180 --> 00:11:05,140 you can actually star out their password fields 294 00:11:05,140 --> 00:11:06,380 in the password database 295 00:11:07,260 --> 00:11:08,100 and, you know, 296 00:11:08,100 --> 00:11:09,080 they won't be able to log in 297 00:11:09,620 --> 00:11:12,060 with a Unix password scheme anymore. 298 00:11:12,480 --> 00:11:13,480 If you can't do that, 299 00:11:13,580 --> 00:11:15,180 I've got some alternatives later in the talk 300 00:11:15,180 --> 00:11:16,260 that I'll get into. 301 00:11:20,000 --> 00:11:20,360 Okay. 302 00:11:20,560 --> 00:11:20,960 So, 303 00:11:20,960 --> 00:11:21,820 I'm just going to 304 00:11:21,820 --> 00:11:23,120 get started, like, 305 00:11:23,720 --> 00:11:24,540 as you're installing, 306 00:11:24,800 --> 00:11:25,500 like, you know, 307 00:11:25,500 --> 00:11:26,680 you're setting up a new machine or whatever, 308 00:11:27,440 --> 00:11:29,220 it's always good to consider security 309 00:11:29,220 --> 00:11:30,940 right as you're building the system 310 00:11:30,940 --> 00:11:33,240 and how your partition scheme looks 311 00:11:33,240 --> 00:11:34,600 is really important to that. 312 00:11:36,640 --> 00:11:38,300 As much as you can, 313 00:11:38,340 --> 00:11:40,560 break it up into different partitions. 314 00:11:40,720 --> 00:11:41,980 So, at the minimum here, 315 00:11:42,020 --> 00:11:42,980 I've got, like, a root partition, 316 00:11:43,520 --> 00:11:44,920 user var, temp, 317 00:11:45,100 --> 00:11:46,120 as a minimum. 318 00:11:46,700 --> 00:11:48,580 Slash home should definitely be considered 319 00:11:48,580 --> 00:11:49,520 as a separate partition. 320 00:11:50,560 --> 00:11:51,820 Just because, I mean, 321 00:11:51,820 --> 00:11:54,420 depending on the level of security 322 00:11:54,420 --> 00:11:55,900 you're looking for on your BSD machine, 323 00:11:56,680 --> 00:11:58,180 with some of the mount options 324 00:11:58,180 --> 00:12:01,300 and some of the other stuff you can do, 325 00:12:01,340 --> 00:12:03,460 you can really restrict 326 00:12:03,460 --> 00:12:04,680 what users can and can't do 327 00:12:04,680 --> 00:12:06,060 on the file system. 328 00:12:07,860 --> 00:12:09,680 So, like, anything except user 329 00:12:09,680 --> 00:12:11,880 or slash because of Sbin, 330 00:12:11,960 --> 00:12:14,360 you can mount those with a no suid argument 331 00:12:15,280 --> 00:12:16,780 and, basically, that's just going to, 332 00:12:16,840 --> 00:12:17,560 if there's a file 333 00:12:17,960 --> 00:12:19,780 with a suid bit set on it, 334 00:12:19,780 --> 00:12:20,780 it won't execute 335 00:12:20,780 --> 00:12:23,100 with that flag pass through mount. 336 00:12:23,320 --> 00:12:24,520 And I would also recommend 337 00:12:24,520 --> 00:12:26,300 setting that on your home partition, too, 338 00:12:27,100 --> 00:12:28,180 just because, you know, 339 00:12:28,200 --> 00:12:29,960 users, if they're messing around with something 340 00:12:29,960 --> 00:12:30,880 and it's suid, 341 00:12:30,900 --> 00:12:32,040 especially if it's suid root, 342 00:12:32,120 --> 00:12:33,060 you know, you don't really know 343 00:12:33,060 --> 00:12:33,460 what they're doing. 344 00:12:35,600 --> 00:12:37,140 Go through your file system 345 00:12:37,580 --> 00:12:38,800 and remove suid bits. 346 00:12:38,880 --> 00:12:40,420 I was looking through the FreeBSD 347 00:12:42,560 --> 00:12:43,880 handbook just to see what the 348 00:12:46,260 --> 00:12:47,720 project's stance was on this 349 00:12:47,720 --> 00:12:48,960 and they say, you know, 350 00:12:48,960 --> 00:12:49,640 anything that's set, 351 00:12:50,580 --> 00:12:52,280 suid in the default installation 352 00:12:52,280 --> 00:12:53,620 is probably pretty safe. 353 00:12:54,020 --> 00:12:55,520 But if you're not using stuff, 354 00:12:57,200 --> 00:12:58,080 for example, 355 00:12:58,180 --> 00:13:00,740 if any of the UUCP stuff, 356 00:13:01,080 --> 00:13:02,820 I mean, you can actually strip that right out 357 00:13:02,820 --> 00:13:04,080 in your make.conf file. 358 00:13:04,200 --> 00:13:05,880 You can just say don't build UUCP 359 00:13:05,880 --> 00:13:06,720 because, you know, 360 00:13:06,760 --> 00:13:07,520 who uses that anymore? 361 00:13:08,180 --> 00:13:09,660 But just go through your file system 362 00:13:10,620 --> 00:13:13,860 and look for suid and SGID files 363 00:13:13,860 --> 00:13:15,220 and just get rid of those. 364 00:13:15,520 --> 00:13:16,620 Anything you don't use, 365 00:13:17,340 --> 00:13:18,600 either just remove the bit 366 00:13:18,600 --> 00:13:18,960 or, 367 00:13:19,860 --> 00:13:21,560 just set the file 0, 0, 0, 368 00:13:21,600 --> 00:13:23,400 so if nobody's using it. 369 00:13:25,420 --> 00:13:26,600 The ch flag stuff, 370 00:13:26,700 --> 00:13:28,560 I'm going to get into that right now 371 00:13:28,980 --> 00:13:30,160 in the next couple slides. 372 00:13:31,040 --> 00:13:31,840 Like extended, 373 00:13:31,980 --> 00:13:34,040 most people actually don't really know about this. 374 00:13:34,080 --> 00:13:34,800 It was kind of interesting to me 375 00:13:34,800 --> 00:13:36,360 that most people didn't find out about this, 376 00:13:36,440 --> 00:13:40,080 but this is like other variables 377 00:13:40,080 --> 00:13:41,240 you can set on a file 378 00:13:42,460 --> 00:13:44,900 that when you're using kernel secure levels, 379 00:13:45,440 --> 00:13:47,640 you can like restrict access to the file. 380 00:13:48,120 --> 00:13:49,460 A couple of the ones I've got here, 381 00:13:49,460 --> 00:13:51,160 like the S append, 382 00:13:51,300 --> 00:13:52,260 like a log file, 383 00:13:52,640 --> 00:13:53,700 that would be like a log file 384 00:13:53,700 --> 00:13:54,840 or a text file type of a thing 385 00:13:54,840 --> 00:13:56,960 where you've got data incrementing to the file, 386 00:13:57,180 --> 00:13:59,100 but you don't want anything else, 387 00:14:00,840 --> 00:14:01,980 you don't want someone going in there 388 00:14:01,980 --> 00:14:03,560 and erasing their tracks or something. 389 00:14:03,760 --> 00:14:05,300 So all they can do is append data. 390 00:14:05,940 --> 00:14:07,920 All the file system will let them do is append data. 391 00:14:08,000 --> 00:14:08,700 You can't do anything else. 392 00:14:09,000 --> 00:14:10,460 And the SCHG bit, 393 00:14:11,160 --> 00:14:13,320 you can set on binaries, system binaries, 394 00:14:14,640 --> 00:14:15,540 and that will basically, 395 00:14:15,680 --> 00:14:17,160 that will just prevent modification, 396 00:14:18,120 --> 00:14:18,760 overwriting, deleting, 397 00:14:19,120 --> 00:14:19,440 and so on. 398 00:14:19,460 --> 00:14:22,480 And as long as you're running in a secure level 399 00:14:22,480 --> 00:14:23,400 of one or higher, 400 00:14:24,200 --> 00:14:25,740 not even root can modify that. 401 00:14:25,880 --> 00:14:27,520 So it kind of makes it a pain 402 00:14:27,520 --> 00:14:28,720 if you're rebuilding your system 403 00:14:28,720 --> 00:14:31,740 because you have to reboot into a non-secure mode 404 00:14:31,740 --> 00:14:33,240 and then clear all those, 405 00:14:33,240 --> 00:14:35,140 or rebuild your system or whatever, 406 00:14:35,300 --> 00:14:36,140 overwrite the binaries 407 00:14:36,140 --> 00:14:38,060 and then reset all the flags 408 00:14:38,640 --> 00:14:39,800 to whatever you had before. 409 00:14:40,340 --> 00:14:43,320 So, I mean, it depends on the amount of time 410 00:14:43,320 --> 00:14:46,760 that you want to spend configuring this stuff. 411 00:14:46,860 --> 00:14:47,660 If you get really granular, 412 00:14:48,340 --> 00:14:49,220 the only, 413 00:14:49,440 --> 00:14:51,400 actually, the interesting thing I ran into was 414 00:14:51,400 --> 00:14:53,520 people were complaining that, you know, 415 00:14:53,520 --> 00:14:54,740 if you set your whole, like, 416 00:14:54,740 --> 00:14:56,060 S bin and bin directories 417 00:14:56,060 --> 00:14:57,500 with the SCHG flag, 418 00:14:57,640 --> 00:14:59,700 you couldn't tell if somebody had broken into your system 419 00:14:59,700 --> 00:15:01,180 because they weren't able to modify data. 420 00:15:01,380 --> 00:15:02,480 People were getting pissed off 421 00:15:02,480 --> 00:15:04,000 because they weren't getting any tripwire reports 422 00:15:04,000 --> 00:15:05,640 because nobody could modify the files. 423 00:15:08,500 --> 00:15:08,940 Thanks. 424 00:15:14,460 --> 00:15:16,120 Okay, so kernel secure levels, 425 00:15:17,200 --> 00:15:19,320 basically, you can change these. 426 00:15:19,340 --> 00:15:20,980 These are variables you can change on the fly. 427 00:15:21,240 --> 00:15:24,200 You can't lower them, though, 428 00:15:24,260 --> 00:15:26,240 once the system is in multi-user mode. 429 00:15:26,800 --> 00:15:29,160 The only real fault with kernel secure levels 430 00:15:29,160 --> 00:15:33,520 is that the secure level doesn't get set 431 00:15:33,520 --> 00:15:35,440 until very late in the boot process. 432 00:15:35,920 --> 00:15:39,080 So if you're kind of paranoid about that 433 00:15:39,080 --> 00:15:41,200 and you think maybe one of your startup scripts 434 00:15:41,200 --> 00:15:42,000 has been modified 435 00:15:42,000 --> 00:15:43,940 and somebody's doing something nasty 436 00:15:43,940 --> 00:15:45,880 before your secure level gets raised, 437 00:15:46,340 --> 00:15:47,520 it's always best to, like, 438 00:15:47,600 --> 00:15:50,920 set that SCHG bit on your RC files 439 00:15:50,920 --> 00:15:52,520 or some of your other startup files 440 00:15:52,520 --> 00:15:54,220 to prevent modification of those. 441 00:15:55,060 --> 00:15:57,200 So the levels go from negative one to three. 442 00:15:57,620 --> 00:15:59,520 Negative one and zero are kind of the same thing. 443 00:15:59,580 --> 00:16:00,480 They're just in secure mode. 444 00:16:03,500 --> 00:16:06,460 And secure level one is, you know, 445 00:16:06,480 --> 00:16:09,340 you can set, like, the append and the SCHG flags, 446 00:16:10,020 --> 00:16:12,980 and you can't disable them once they're set, 447 00:16:13,100 --> 00:16:14,640 and you can't load any LKMs, 448 00:16:14,640 --> 00:16:16,160 load kernel modules. 449 00:16:16,480 --> 00:16:19,360 You can't load or unload those in secure level one. 450 00:16:20,140 --> 00:16:21,640 Secure level two is the same thing, 451 00:16:21,740 --> 00:16:25,520 but you can't write to disks in a raw fashion 452 00:16:25,520 --> 00:16:26,180 except for mount. 453 00:16:26,640 --> 00:16:28,840 And also, time changes, 454 00:16:29,960 --> 00:16:31,800 any changes to the system clock 455 00:16:31,800 --> 00:16:34,340 are clamped to plus or minus one second change. 456 00:16:34,600 --> 00:16:37,320 So if you're running, like, a PC or something 457 00:16:37,320 --> 00:16:39,160 that doesn't keep time very well, 458 00:16:39,340 --> 00:16:40,580 you know, when you reboot your system 459 00:16:40,580 --> 00:16:43,800 to drop it into secure level zero 460 00:16:43,800 --> 00:16:44,760 to rebuild your system, 461 00:16:44,900 --> 00:16:45,940 you're going to want to go ahead 462 00:16:45,940 --> 00:16:46,820 and set your clock then, 463 00:16:47,240 --> 00:16:48,020 because if you don't, 464 00:16:48,040 --> 00:16:50,440 you'll just get errors in your log files 465 00:16:50,440 --> 00:16:52,820 about the time changes clamped to one second. 466 00:16:55,660 --> 00:16:57,420 Okay, so, yeah, we talked about that, 467 00:16:57,440 --> 00:16:59,020 setting the SCHG flag 468 00:16:59,020 --> 00:17:03,500 on some of your system binary directories. 469 00:17:03,840 --> 00:17:05,260 Okay, this is a lot of data, I know. 470 00:17:05,560 --> 00:17:07,360 And if you can't read it, that's cool. 471 00:17:07,820 --> 00:17:08,740 Just grab the... 472 00:17:08,740 --> 00:17:10,140 This is all on the CD, 473 00:17:10,220 --> 00:17:11,660 and this is going to be up on the website, too. 474 00:17:14,000 --> 00:17:16,340 Basically, the sysctl variables, 475 00:17:17,020 --> 00:17:19,920 that's also the secure level configurations 476 00:17:19,920 --> 00:17:22,140 for FreeBSD is a sysctl variable, 477 00:17:23,240 --> 00:17:25,980 and it's just a numerical value, negative one to three. 478 00:17:26,040 --> 00:17:27,680 But these are some other settings 479 00:17:27,680 --> 00:17:30,360 that a lot of people don't really know about 480 00:17:30,980 --> 00:17:33,560 that can actually kind of help you 481 00:17:33,560 --> 00:17:35,660 strengthen your network stack a little bit 482 00:17:35,660 --> 00:17:37,840 and kind of keep people guessing 483 00:17:37,840 --> 00:17:38,660 as to what you're running, 484 00:17:38,780 --> 00:17:40,640 and it kind of pisses people off 485 00:17:40,640 --> 00:17:41,640 that are trying to port scan you. 486 00:17:43,080 --> 00:17:44,760 The TCP black hole variable 487 00:17:44,760 --> 00:17:45,900 is the first one I'll talk about, 488 00:17:46,020 --> 00:17:47,640 and you can set that to zero, one, or two. 489 00:17:49,480 --> 00:17:51,220 Basically, I'm just going to recommend two 490 00:17:51,220 --> 00:17:52,580 in almost any case, 491 00:17:53,460 --> 00:17:56,200 which is a totally silent mode 492 00:17:56,200 --> 00:17:57,840 where it's just not going to generate 493 00:17:57,840 --> 00:17:59,440 reset packets back to the source 494 00:17:59,440 --> 00:18:00,920 on any connection attempts 495 00:18:01,580 --> 00:18:03,960 to a port that has no socket open, 496 00:18:04,040 --> 00:18:04,600 nothing listening. 497 00:18:05,200 --> 00:18:07,740 So if somebody throws a port scan at you 498 00:18:07,740 --> 00:18:09,560 that opens up ports zero through 10,000, 499 00:18:09,680 --> 00:18:10,620 you know, you've got, like, 500 00:18:10,640 --> 00:18:13,180 three things running on those 10,000 ports. 501 00:18:13,340 --> 00:18:14,100 They're just going to get... 502 00:18:14,560 --> 00:18:15,540 You're just going to sit there, 503 00:18:15,560 --> 00:18:16,300 and they're in timeout. 504 00:18:16,360 --> 00:18:17,140 They're just going to be waiting 505 00:18:17,140 --> 00:18:18,160 for a reset packet back 506 00:18:18,160 --> 00:18:20,180 to see if your port is closed or not. 507 00:18:21,880 --> 00:18:25,360 And there's the same setting for UDP, 508 00:18:26,220 --> 00:18:28,960 and basically that's the same procedure, 509 00:18:29,220 --> 00:18:29,720 same idea, 510 00:18:29,800 --> 00:18:32,300 except that it won't generate 511 00:18:32,300 --> 00:18:34,080 an ICMP port unreachable message 512 00:18:34,680 --> 00:18:36,260 on a port with no socket listening. 513 00:18:36,420 --> 00:18:36,940 So same thing. 514 00:18:37,320 --> 00:18:39,760 That will break trace route to your system, 515 00:18:39,760 --> 00:18:41,620 so if you care about people 516 00:18:41,620 --> 00:18:42,800 being able to trace route to you, 517 00:18:42,820 --> 00:18:45,060 you may want to drop that to zero 518 00:18:45,060 --> 00:18:46,140 or disable it, but... 519 00:18:47,760 --> 00:18:49,640 So here's some other RCConf settings 520 00:18:49,640 --> 00:18:50,400 that you can do. 521 00:18:50,520 --> 00:18:52,160 This is how you turn on secure levels. 522 00:18:54,200 --> 00:18:55,880 In the main RCConf file, 523 00:18:56,020 --> 00:18:58,500 you have to enable it, specify enable it, 524 00:18:58,540 --> 00:18:59,960 and then set the number that you want. 525 00:19:02,060 --> 00:19:04,180 Secure level three is the same thing 526 00:19:04,180 --> 00:19:05,200 as secure level two, 527 00:19:05,240 --> 00:19:07,900 except you can't modify IPFW rules, 528 00:19:08,020 --> 00:19:09,000 which can kind of be a pain 529 00:19:09,000 --> 00:19:11,020 if you're initially building your system 530 00:19:11,020 --> 00:19:12,560 or something or you're adding services, 531 00:19:12,700 --> 00:19:14,180 because you're going to have to bounce the machine 532 00:19:14,180 --> 00:19:15,400 if you want to make any changes 533 00:19:15,400 --> 00:19:16,600 to your firewall rule base. 534 00:19:17,040 --> 00:19:18,300 So that's just maybe something 535 00:19:18,300 --> 00:19:18,960 you want to keep in mind 536 00:19:18,960 --> 00:19:19,720 as you're setting that up. 537 00:19:21,940 --> 00:19:23,180 ICMP drop redirect. 538 00:19:23,900 --> 00:19:28,300 This is going to drop any redirect packets 539 00:19:28,300 --> 00:19:30,020 from supposedly... 540 00:19:30,020 --> 00:19:31,140 They're supposed to come from a router, 541 00:19:31,200 --> 00:19:32,700 but it's just going to drop them from anywhere, 542 00:19:32,780 --> 00:19:34,400 and it's just going to prevent people 543 00:19:34,400 --> 00:19:35,840 from modifying the path 544 00:19:35,840 --> 00:19:38,600 that your traffic is taking. 545 00:19:40,680 --> 00:19:43,200 And then there's the TCP drop SYNFIN, 546 00:19:43,220 --> 00:19:45,240 and that's just going to drop any packets 547 00:19:46,180 --> 00:19:48,240 with the SYN and the FIN bit sets, 548 00:19:48,460 --> 00:19:50,820 and it does break in RFC technically. 549 00:19:51,260 --> 00:19:52,420 It's not RFC compliant, 550 00:19:52,580 --> 00:19:56,360 but there's no legitimate use for traffic 551 00:19:56,360 --> 00:19:58,160 with both of those bits set at the same time, 552 00:19:58,280 --> 00:20:01,260 so I would recommend enabling it anyways. 553 00:20:01,860 --> 00:20:03,340 Clear temp enable is kind of cool. 554 00:20:04,060 --> 00:20:05,660 It'll just go through and wipe stuff 555 00:20:05,660 --> 00:20:07,340 in your temp directory on reboot. 556 00:20:07,720 --> 00:20:08,600 And one other one, 557 00:20:08,660 --> 00:20:08,980 I don't know if you've heard of it, 558 00:20:09,000 --> 00:20:10,120 if I put it in here later or not, 559 00:20:10,240 --> 00:20:15,000 is fsck underscore y underscore enable equals yes. 560 00:20:15,280 --> 00:20:16,340 It's a really handy setting 561 00:20:16,340 --> 00:20:18,460 if your machine is co-located or something 562 00:20:18,460 --> 00:20:20,440 and you don't have physical access to it. 563 00:20:20,680 --> 00:20:22,260 If your machine gets bounced 564 00:20:22,260 --> 00:20:23,960 or if it crashes or something 565 00:20:23,960 --> 00:20:25,140 and it comes back up 566 00:20:25,140 --> 00:20:29,200 and starts up fsck to check out your file systems, 567 00:20:29,420 --> 00:20:32,440 this will just automatically, you know, 568 00:20:32,440 --> 00:20:34,820 accept any changes that fsck is going to make, 569 00:20:34,940 --> 00:20:36,380 so you won't have to call somebody up 570 00:20:36,380 --> 00:20:37,420 and go, hey, go over to the console 571 00:20:37,420 --> 00:20:38,840 and press YYY a few times. 572 00:20:38,840 --> 00:20:39,800 Go ahead. 573 00:20:41,680 --> 00:20:49,100 Yeah, yeah, it's fsck underscore y underscore enable equals yes. 574 00:20:54,480 --> 00:20:55,060 Go ahead. 575 00:21:00,240 --> 00:21:02,280 I've heard of people compiling, like, 576 00:21:02,280 --> 00:21:04,460 the riserfs stuff under BSD, 577 00:21:04,560 --> 00:21:06,520 but that's all, like, I've got a friend of mine 578 00:21:06,520 --> 00:21:08,720 in the UK that works on the current stuff a lot, 579 00:21:08,720 --> 00:21:10,860 and he's really into, like, the cutting-edge stuff. 580 00:21:12,380 --> 00:21:13,540 I've heard that they're thinking 581 00:21:13,540 --> 00:21:17,240 of integrating journaling stuff into UFS for 5.0, 582 00:21:17,300 --> 00:21:19,540 but I haven't confirmed that yet, so... 583 00:21:19,540 --> 00:21:21,500 So this is now real-time? 584 00:21:21,860 --> 00:21:23,520 Not by default, I don't think. 585 00:21:23,720 --> 00:21:24,260 Go ahead. 586 00:21:24,540 --> 00:21:25,280 Soft updates? 587 00:21:25,580 --> 00:21:28,840 There's just paper and stuff like that? 588 00:21:29,100 --> 00:21:30,540 Well, yeah, soft, it's kind of a, 589 00:21:30,580 --> 00:21:31,380 it's a philosophical, 590 00:21:31,540 --> 00:21:34,780 this guy pointed out soft updates is an option 591 00:21:34,780 --> 00:21:36,020 that you can set on your file systems. 592 00:21:36,240 --> 00:21:37,700 Soft updates is kind of interesting. 593 00:21:37,700 --> 00:21:39,940 In the way that it writes to the disk, 594 00:21:40,040 --> 00:21:42,680 sometimes it won't actually write changes to the disk 595 00:21:42,680 --> 00:21:43,340 for up to a minute, 596 00:21:43,920 --> 00:21:46,800 and so it's kind of a trade-off 597 00:21:46,800 --> 00:21:47,980 if you want to enable that or not. 598 00:21:48,100 --> 00:21:50,520 If you're doing a lot, like, heavy disk-intensive stuff, 599 00:21:51,240 --> 00:21:53,240 FreeBSD recommends you turn on soft updates, 600 00:21:53,380 --> 00:21:55,440 and I think it actually turns it on by default 601 00:21:55,440 --> 00:21:56,540 when you set up a partition. 602 00:21:57,260 --> 00:21:58,280 Where does it start at? 603 00:21:59,460 --> 00:22:00,620 Where does it start at? 604 00:22:01,080 --> 00:22:01,840 Where does it start at? 605 00:22:02,220 --> 00:22:04,060 Those updates in the data. 606 00:22:05,160 --> 00:22:07,280 Those, he says, where the, 607 00:22:07,280 --> 00:22:09,440 where the update's stored, they're in memory, 608 00:22:09,580 --> 00:22:11,640 and they're just waiting to be written to the disk. 609 00:22:11,860 --> 00:22:12,860 So if the machine crashes? 610 00:22:13,660 --> 00:22:14,960 Right, if your machine crashes, 611 00:22:14,960 --> 00:22:17,340 your SOL for whatever data was written up to a minute, 612 00:22:17,500 --> 00:22:19,240 or prior to a minute. 613 00:22:23,540 --> 00:22:23,980 Okay. 614 00:22:25,560 --> 00:22:29,060 I mean, the two kind of, like, duh parts of this talk 615 00:22:29,060 --> 00:22:31,880 are encrypting your traffic 616 00:22:31,880 --> 00:22:35,500 and starting services in a jail environment. 617 00:22:35,800 --> 00:22:37,140 I mean, so many services 618 00:22:37,140 --> 00:22:38,440 that you're going to see run nowadays 619 00:22:38,960 --> 00:22:40,780 have either native support for a jail, 620 00:22:40,880 --> 00:22:42,660 like Bind or Apache, 621 00:22:43,020 --> 00:22:45,260 or you can actually, you can use, 622 00:22:45,280 --> 00:22:47,480 there's a jail functionality built into FreeBSD. 623 00:22:47,660 --> 00:22:49,660 You can build a separate jail for, 624 00:22:49,660 --> 00:22:52,120 for any service that you're running, pretty much. 625 00:22:52,400 --> 00:22:53,980 And, I mean, you can lock that down 626 00:22:53,980 --> 00:22:55,360 to a specific part of the file system 627 00:22:55,360 --> 00:22:56,700 and restrict people. 628 00:22:57,380 --> 00:23:00,120 And, I mean, by default, 629 00:23:00,620 --> 00:23:02,840 I mean, and SSH is kind of the newest one to do this 630 00:23:02,840 --> 00:23:04,360 with the privilege separation and kind of, 631 00:23:04,360 --> 00:23:06,880 and fork off a separate process for each user. 632 00:23:07,900 --> 00:23:08,920 But by default, 633 00:23:09,140 --> 00:23:11,140 I think that probably services like Bind, 634 00:23:11,280 --> 00:23:12,960 and Apache's already done this where 635 00:23:12,960 --> 00:23:15,140 when you do a FreeBSD install, 636 00:23:15,420 --> 00:23:17,920 you're going to get the, the WWW user. 637 00:23:18,100 --> 00:23:21,700 And I think the Apache ports tree is updated now 638 00:23:21,700 --> 00:23:24,720 where the default username and group name 639 00:23:24,720 --> 00:23:26,640 that Apache runs under is WWW. 640 00:23:26,680 --> 00:23:29,880 So, I mean, people have been using Nobody for a while, 641 00:23:30,000 --> 00:23:31,540 but people didn't really understand 642 00:23:31,540 --> 00:23:32,440 that if you use Nobody 643 00:23:32,440 --> 00:23:35,460 and you run four or five different services as Nobody, 644 00:23:35,680 --> 00:23:37,120 it's not an unprovoked service. 645 00:23:37,140 --> 00:23:37,840 It's not a privileged user anymore. 646 00:23:38,660 --> 00:23:41,600 So, I mean, you definitely need to break it out 647 00:23:41,600 --> 00:23:42,280 into separate users. 648 00:23:44,160 --> 00:23:46,260 And with SSH, they've also, 649 00:23:46,320 --> 00:23:48,160 they've added an SSH user 650 00:23:48,160 --> 00:23:52,660 and the jail for that is slash bar slash empty. 651 00:23:55,660 --> 00:23:57,200 Okay, for login vein, 652 00:23:57,800 --> 00:23:59,440 this is, this is kind of like, 653 00:23:59,500 --> 00:24:01,020 this will pop up in your DMessage 654 00:24:01,020 --> 00:24:04,160 and you can configure this to drop into your messages file 655 00:24:04,160 --> 00:24:05,540 through syslog. 656 00:24:06,100 --> 00:24:08,340 This is just going to show any connections to your machine 657 00:24:08,700 --> 00:24:09,920 on ports that aren't listening. 658 00:24:10,540 --> 00:24:12,840 So, obviously, this is going to sort of conflict 659 00:24:12,840 --> 00:24:14,500 with some of the black hole stuff 660 00:24:14,500 --> 00:24:15,900 that I was talking about a few slides back. 661 00:24:16,460 --> 00:24:18,740 But if, if you set this, you're, you know, 662 00:24:18,760 --> 00:24:19,540 you're quickly going to tell 663 00:24:19,540 --> 00:24:20,780 if somebody's port scanning you or something, 664 00:24:20,860 --> 00:24:22,120 you're going to see a bunch of connections on, 665 00:24:22,140 --> 00:24:23,800 on ports that you aren't even listening on. 666 00:24:24,700 --> 00:24:26,240 So, this is, and it's definitely, 667 00:24:26,380 --> 00:24:28,680 a lot of people kind of mistake this, this, 668 00:24:30,320 --> 00:24:35,520 this RCConf variable for some kind of packet filtering stuff. 669 00:24:35,540 --> 00:24:36,080 It's not that. 670 00:24:36,120 --> 00:24:38,520 All it does is report people connecting on, 671 00:24:38,520 --> 00:24:40,700 on ports that you're not using. 672 00:24:40,800 --> 00:24:42,560 So, you know, use it in conjunction 673 00:24:42,560 --> 00:24:45,120 with a nice IPF or IPFW rule set. 674 00:24:47,300 --> 00:24:50,680 Okay, so the next, the next thing is, 675 00:24:50,700 --> 00:24:53,060 is using IPF on, on almost any system. 676 00:24:53,140 --> 00:24:56,900 And, and a lot of people take the, the mindset that, 677 00:24:56,920 --> 00:24:58,620 you know, they're, they're behind their fire, 678 00:24:58,660 --> 00:24:59,420 their corporate firewall. 679 00:24:59,780 --> 00:25:01,660 You know, they're inside their, their, 680 00:25:01,760 --> 00:25:03,180 their office network. 681 00:25:03,360 --> 00:25:05,420 You know, nobody really malicious is doing anything. 682 00:25:05,540 --> 00:25:08,680 But even if it's just, you know, your laptop or something, 683 00:25:08,840 --> 00:25:12,120 I mean, it can't hurt to throw a nice IPFW rule set 684 00:25:12,120 --> 00:25:14,100 on your laptop and, and keep people out. 685 00:25:14,160 --> 00:25:16,100 I'm sure a lot of people had that pay off 686 00:25:16,100 --> 00:25:17,320 at DEF CON this year, you know. 687 00:25:17,660 --> 00:25:20,000 I mean, and it's, it's really easy. 688 00:25:20,060 --> 00:25:23,160 If you go to, if you look at, in the ETC directory, 689 00:25:23,640 --> 00:25:26,500 there's an RC firewall file, 690 00:25:26,600 --> 00:25:27,840 and I think I'll get into that later on, 691 00:25:27,880 --> 00:25:29,160 but I can't, can't get ahead of it. 692 00:25:29,260 --> 00:25:29,640 Oh, go ahead. 693 00:25:30,080 --> 00:25:31,620 What is the performance impact 694 00:25:31,620 --> 00:25:32,740 that you've been having 695 00:25:32,740 --> 00:25:34,440 celebrating with those tools 696 00:25:34,440 --> 00:25:35,800 on a busy system? 697 00:25:36,720 --> 00:25:37,500 He, he says, 698 00:25:37,560 --> 00:25:39,260 what's the, the performance impact on a, 699 00:25:39,260 --> 00:25:42,200 a couple dozen rule set IPFW 700 00:25:42,900 --> 00:25:44,320 set up on a busy system? 701 00:25:44,360 --> 00:25:46,220 It depends what you define as a busy system, 702 00:25:46,400 --> 00:25:48,840 and it depends how fast your link speed is, 703 00:25:48,940 --> 00:25:51,120 and it depends on the specs of the machine. 704 00:25:52,700 --> 00:25:55,200 Personally, I've seen a, a machine take 705 00:25:57,580 --> 00:25:59,340 like 80 or 90 megabits 706 00:26:00,380 --> 00:26:02,140 of traffic that it was filtering, 707 00:26:02,380 --> 00:26:03,920 and it was like a, 708 00:26:03,960 --> 00:26:04,420 it was like a, 709 00:26:04,440 --> 00:26:06,320 a one gigahertz Pentium 3 or something, 710 00:26:06,500 --> 00:26:08,400 and you could tell that the load is noticeable. 711 00:26:08,500 --> 00:26:10,820 I don't really have any measurable data to give you, 712 00:26:10,920 --> 00:26:12,440 but I would say probably like a, 713 00:26:12,440 --> 00:26:13,800 a 20 or 30% impact, 714 00:26:14,240 --> 00:26:16,860 but that's, that's with the full out 80 megabit 715 00:26:17,460 --> 00:26:19,600 right, right across a, a fast Ethernet link. 716 00:26:21,080 --> 00:26:22,920 It was dropping every single packet, so. 717 00:26:28,560 --> 00:26:28,960 Okay. 718 00:26:29,040 --> 00:26:31,000 A lot of people have, have kind of, 719 00:26:31,520 --> 00:26:32,660 they say, you know, it's, 720 00:26:32,660 --> 00:26:33,980 I'd like SFTP and everything, 721 00:26:33,980 --> 00:26:36,120 but I'm either, I'm running an anonymous file archive, 722 00:26:36,200 --> 00:26:39,460 or I've got users who need FTP. 723 00:26:39,680 --> 00:26:41,400 They don't want to learn a new client 724 00:26:41,400 --> 00:26:43,500 even though it's kind of transparent as to the differences. 725 00:26:43,760 --> 00:26:45,840 You know, they have some old scripts or something 726 00:26:45,840 --> 00:26:47,520 that are using FTP that they can convert, 727 00:26:47,620 --> 00:26:48,080 whatever reason. 728 00:26:49,380 --> 00:26:51,920 I would not recommend using FTP really anymore 729 00:26:51,920 --> 00:26:53,500 unless you're running an anonymous archive, 730 00:26:54,060 --> 00:26:55,600 and I'll kind of show you how to, 731 00:26:55,600 --> 00:26:58,320 how to lock it down, but you know, 732 00:26:58,340 --> 00:27:00,740 if, if you've got any users logging in individually, 733 00:27:02,200 --> 00:27:03,880 put their, put their username in the, 734 00:27:03,880 --> 00:27:06,880 the ETC FTP chroot file, 735 00:27:07,400 --> 00:27:09,160 and that's just going to basically restrict them 736 00:27:09,160 --> 00:27:09,960 to their home directory. 737 00:27:10,940 --> 00:27:12,440 By default, they're not going to be restricted. 738 00:27:12,700 --> 00:27:14,040 They're going to just be able to move all, 739 00:27:14,040 --> 00:27:14,960 all around the file system, 740 00:27:15,120 --> 00:27:16,960 and so if you've been kind of lax 741 00:27:16,960 --> 00:27:18,460 with your file permissions somewhere else, 742 00:27:19,200 --> 00:27:20,660 you know, they may have access to something 743 00:27:20,660 --> 00:27:21,860 that you don't want them to have access to. 744 00:27:23,620 --> 00:27:26,720 If you start FTP from iNetD, 745 00:27:26,900 --> 00:27:29,540 you can go in and stick all, 746 00:27:29,580 --> 00:27:31,580 some of these flags right at, 747 00:27:31,600 --> 00:27:32,280 right at the end, 748 00:27:32,280 --> 00:27:35,380 and dash L twice will enable extended logging, 749 00:27:35,580 --> 00:27:37,680 and then you actually have to turn on logging 750 00:27:37,680 --> 00:27:39,520 for the FTP facility in syslog. 751 00:27:40,840 --> 00:27:43,900 That's, that's going to give you each connection, 752 00:27:44,760 --> 00:27:48,220 each user's connecting, you know, time and date, 753 00:27:48,340 --> 00:27:50,840 and also any files that they're uploading or downloading, 754 00:27:51,000 --> 00:27:52,960 and so the files can be kind of verbose. 755 00:27:53,020 --> 00:27:55,300 It's kind of similar to the X for log functionality in Linux. 756 00:27:57,360 --> 00:27:59,120 If you're running an anonymous archive, 757 00:27:59,660 --> 00:28:01,220 use like capital dash A, 758 00:28:02,560 --> 00:28:03,600 and dash R, 759 00:28:03,780 --> 00:28:07,300 and capital A is only going to allow anonymous connections, 760 00:28:07,520 --> 00:28:08,960 nothing else, which is handy, 761 00:28:09,080 --> 00:28:10,800 because nobody's going to figure out 762 00:28:10,800 --> 00:28:12,000 that they can FTP into your machine 763 00:28:12,000 --> 00:28:13,120 when you really don't want them to, 764 00:28:13,160 --> 00:28:14,360 even though they're a legitimate user. 765 00:28:14,840 --> 00:28:16,540 And dash R is read-only mode, 766 00:28:16,660 --> 00:28:20,800 where the daemon will actually restrict itself 767 00:28:20,800 --> 00:28:24,300 from making any right calls to the system at all. 768 00:28:24,680 --> 00:28:27,100 So in the event that somebody figures out 769 00:28:27,100 --> 00:28:28,860 how to overflow your, 770 00:28:28,900 --> 00:28:31,220 because FTPD runs as root, so, you know, 771 00:28:31,220 --> 00:28:32,660 if somebody figures out how to overflow that, 772 00:28:32,740 --> 00:28:34,920 it's not going to be able to write anything to the machine. 773 00:28:38,680 --> 00:28:40,400 Okay, logging is obviously very important, 774 00:28:41,260 --> 00:28:42,520 keeping track of your system, 775 00:28:42,640 --> 00:28:44,640 and before I get into any of this, you know, 776 00:28:44,660 --> 00:28:47,520 obviously logging, you have to spend the time 777 00:28:47,520 --> 00:28:48,940 looking at your logs on your system 778 00:28:48,940 --> 00:28:51,660 so you know what's routine and you know what's not routine, 779 00:28:51,820 --> 00:28:54,660 because if you see something out of the ordinary 780 00:28:55,240 --> 00:28:56,440 that kind of looks out of the ordinary 781 00:28:57,140 --> 00:28:58,820 just because you say that's not really right, 782 00:28:58,900 --> 00:29:01,140 if you don't have, like, data to back that up, you know, 783 00:29:01,220 --> 00:29:03,420 say, I haven't seen something like that in a month or something, 784 00:29:03,480 --> 00:29:04,660 or I've never seen that before, 785 00:29:04,860 --> 00:29:07,120 that's going to be a lot, you know, more of a clue into you 786 00:29:07,120 --> 00:29:08,800 that, hey, something funny is going on. 787 00:29:09,820 --> 00:29:13,700 If you start, if you're running, like, a regular workstation, 788 00:29:13,860 --> 00:29:17,480 I would recommend to start syslog with the dash SS flags, 789 00:29:17,660 --> 00:29:20,100 and that's just going to prevent the daemon from opening 790 00:29:21,020 --> 00:29:22,720 the UDP port 514. 791 00:29:23,540 --> 00:29:27,900 By default, FreeBSD won't let any users connect to 792 00:29:27,900 --> 00:29:31,200 your syslog daemon to log, and, you know, 793 00:29:31,200 --> 00:29:33,760 a lot of operating systems didn't use to do that, 794 00:29:33,840 --> 00:29:35,800 and so people could, you know, fill up your logs, 795 00:29:35,880 --> 00:29:38,700 or at the very worst, fill up your whole file system 796 00:29:38,700 --> 00:29:40,180 if you didn't have permissions set up right. 797 00:29:41,240 --> 00:29:44,180 Someone would just allow unauthenticated connections from anywhere. 798 00:29:45,660 --> 00:29:47,940 This is just going to keep anybody from being able 799 00:29:47,940 --> 00:29:49,200 to connect to your syslogd at all. 800 00:29:51,300 --> 00:29:54,600 I would recommend setting up a centralized syslog file, 801 00:29:54,700 --> 00:29:56,040 especially if you're running an enterprise, 802 00:29:56,920 --> 00:29:59,220 and you've got, you know, 10 or 20 different servers maybe. 803 00:29:59,860 --> 00:30:03,400 It's much easier to send all the data to a central place, 804 00:30:03,600 --> 00:30:07,080 and then, you know, maybe even pull the data into some kind of a, 805 00:30:07,540 --> 00:30:10,220 you know, an Excel spreadsheet or something for quick sorting 806 00:30:10,220 --> 00:30:10,800 or a database. 807 00:30:11,520 --> 00:30:13,200 This is the syntax to do it. 808 00:30:13,320 --> 00:30:16,980 You just, this is the wild card right here is just saying 809 00:30:16,980 --> 00:30:21,500 log anything on any facility to remotehost.org, 810 00:30:21,620 --> 00:30:24,060 and you can obviously fill that in with a local IP address 811 00:30:24,060 --> 00:30:24,400 or something. 812 00:30:24,800 --> 00:30:27,660 You will not be able to use this dash SS thing up here, though, 813 00:30:27,700 --> 00:30:29,200 with this machine that you're setting up. 814 00:30:29,220 --> 00:30:30,240 If you're sending the logs to, obviously, 815 00:30:30,240 --> 00:30:33,580 it needs to have that port open to be able to accept the logs. 816 00:30:36,940 --> 00:30:40,520 In your syslog.conf file, add this var log FTPD 817 00:30:40,520 --> 00:30:43,660 or whatever you want to call it if you're running an FTP server 818 00:30:43,660 --> 00:30:46,600 so that you can, you know, you get more information 819 00:30:46,600 --> 00:30:47,840 about what's going on with FTP. 820 00:30:47,960 --> 00:30:51,120 I think by default it doesn't log anything that's going on with FTP at all, 821 00:30:51,180 --> 00:30:54,060 or maybe it drops it into messages, which is kind of kludgy 822 00:30:54,060 --> 00:30:56,000 because there's so much other stuff going on in that file. 823 00:30:56,160 --> 00:30:57,280 It's kind of hard to keep track. 824 00:30:59,220 --> 00:31:02,400 In the security file, IPFW uses the security facility 825 00:31:02,400 --> 00:31:04,380 and so do a few other applications, 826 00:31:04,640 --> 00:31:08,900 but at the end of your IPFW rule base, 827 00:31:09,700 --> 00:31:12,100 drop like a, you know, because it will just do, 828 00:31:12,200 --> 00:31:13,680 it just goes down the rule base, 829 00:31:13,780 --> 00:31:16,700 and if a packet doesn't match, it will drop to the next rule. 830 00:31:16,900 --> 00:31:19,340 At the end, put like a log any rule, 831 00:31:19,740 --> 00:31:24,100 and anything that didn't match any of your other packets 832 00:31:24,100 --> 00:31:26,200 is going to go ahead and get dropped into that file. 833 00:31:27,940 --> 00:31:28,960 There's a, there's a, 834 00:31:29,340 --> 00:31:30,740 I'm sure most of you guys have heard of this, 835 00:31:30,760 --> 00:31:32,780 there's a DShield.org project, 836 00:31:33,860 --> 00:31:38,100 and they have a client framework for IPFW logs, 837 00:31:38,260 --> 00:31:41,040 and it's like, it's just a Perl script that goes through and parses it out 838 00:31:41,040 --> 00:31:45,280 and changes the data into the DShield compatible data, 839 00:31:45,440 --> 00:31:47,960 and then you can set up a cron script or something 840 00:31:47,960 --> 00:31:50,160 to email that data every night or something, 841 00:31:50,520 --> 00:31:52,160 you know, people connecting to your machine, 842 00:31:52,760 --> 00:31:55,520 and then you can go and log in through the web and take a look at it, 843 00:31:55,600 --> 00:31:57,620 and you can coordinate it with other people, 844 00:31:57,620 --> 00:31:59,200 other people submit their logs all around the world, 845 00:31:59,220 --> 00:31:59,720 it's pretty cool. 846 00:32:05,120 --> 00:32:05,440 . 847 00:32:07,140 --> 00:32:07,460 Yeah? 848 00:32:09,560 --> 00:32:09,880 . 849 00:32:14,100 --> 00:32:14,420 Right. 850 00:32:15,800 --> 00:32:16,120 . 851 00:32:19,920 --> 00:32:21,920 Uh-huh, yeah, and, and, 852 00:32:23,020 --> 00:32:25,120 what is it, he said the FTP users file, 853 00:32:25,200 --> 00:32:27,800 you can drop users in there that you don't want to be able to use FTP at all, 854 00:32:27,800 --> 00:32:30,020 and so obviously you're going to want to drop, like, root, 855 00:32:30,180 --> 00:32:32,520 and, and obviously any privileged user, 856 00:32:32,680 --> 00:32:34,900 you know, you don't want them passing their password in clear text, 857 00:32:35,080 --> 00:32:38,540 and that's, that's, that's a good add-on to, to the rest of the FTP stuff, 858 00:32:38,600 --> 00:32:40,100 the FTP chroot and everything else. 859 00:32:41,060 --> 00:32:43,360 Um, some of this stuff is kind of interesting, 860 00:32:43,480 --> 00:32:47,660 this isn't, uh, this isn't default with BSD, 861 00:32:48,240 --> 00:32:50,200 but, uh, I ran across a couple of these projects, 862 00:32:50,260 --> 00:32:51,600 just doing a little bit of research, 863 00:32:51,780 --> 00:32:53,300 uh, trojanproof.org, 864 00:32:54,060 --> 00:32:56,760 um, they actually have a really cool white paper on their web page 865 00:32:56,760 --> 00:32:58,560 about how they developed, uh, this tool, 866 00:32:58,700 --> 00:33:01,000 but, uh, I think they started with OpenBSD 867 00:33:01,000 --> 00:33:02,660 and they moved to FreeBSD for development, 868 00:33:04,740 --> 00:33:06,780 and it's kind of like, it's almost like Tripwire, 869 00:33:06,980 --> 00:33:07,960 uh, but in the kernel, 870 00:33:08,060 --> 00:33:10,940 and it can tell you if there are any, uh, 871 00:33:11,540 --> 00:33:13,360 mb5 variations, if something's changed, 872 00:33:13,500 --> 00:33:16,140 uh, with files that are executing on your system, 873 00:33:16,220 --> 00:33:18,100 so as they're executing, it goes ahead and, 874 00:33:18,100 --> 00:33:20,100 and does the hash on the file to see if it's changed, 875 00:33:20,840 --> 00:33:24,120 and it, it, uh, they have some performance specs, 876 00:33:24,260 --> 00:33:26,120 because a lot of people were concerned about performance 877 00:33:26,120 --> 00:33:26,580 on a, 878 00:33:27,000 --> 00:33:29,140 on a, you know, an enterprise machine, obviously, 879 00:33:29,140 --> 00:33:31,620 and, and I think to benchmark it, 880 00:33:31,700 --> 00:33:32,940 they, like, built the kernel with, 881 00:33:33,840 --> 00:33:35,540 uh, this enabled in the kernel, 882 00:33:35,640 --> 00:33:36,300 and then this without, 883 00:33:36,420 --> 00:33:38,900 and I think there's like a 12 second difference, 884 00:33:38,980 --> 00:33:40,140 or, or a 2 second difference, 885 00:33:40,360 --> 00:33:41,140 I can't remember which, 886 00:33:41,260 --> 00:33:42,500 but it really wasn't that bad. 887 00:33:43,160 --> 00:33:44,960 And so, that kind of works well with, 888 00:33:45,020 --> 00:33:47,480 with another file integrity tool like Tripwire, 889 00:33:48,520 --> 00:33:49,800 um, and that's just gonna, 890 00:33:51,620 --> 00:33:52,840 that's just gonna give you the, 891 00:33:52,900 --> 00:33:55,800 the kernel level, uh, mb5 checking, 892 00:33:55,800 --> 00:33:57,900 and, and go ahead and check out the, 893 00:33:57,920 --> 00:33:58,700 the website, they've got, 894 00:33:59,100 --> 00:34:00,680 they can explain it much better than I can, 895 00:34:00,760 --> 00:34:03,260 as far as if you're interested in the specifics of how it works. 896 00:34:03,820 --> 00:34:04,940 Uh, the next one is, 897 00:34:04,960 --> 00:34:06,440 is server.sf.net, 898 00:34:07,320 --> 00:34:08,440 uh, this does, like, 899 00:34:08,880 --> 00:34:10,220 sys, system call interception, 900 00:34:10,780 --> 00:34:13,120 and logging of, uh, any, 901 00:34:13,180 --> 00:34:15,940 what you might deem potentially dangerous system calls, 902 00:34:16,560 --> 00:34:18,360 so, uh, I've got a few listed here, 903 00:34:18,480 --> 00:34:20,540 execve, ptrace, setuid, 904 00:34:20,660 --> 00:34:23,080 you can configure every single one of these, 905 00:34:23,140 --> 00:34:24,660 uh, through sysctl commands, 906 00:34:25,280 --> 00:34:26,760 so, you can say, you know, 907 00:34:26,760 --> 00:34:30,100 I think that, that, uh, setuid calls really dangerous, 908 00:34:30,200 --> 00:34:31,680 alert, or, and block it, 909 00:34:31,760 --> 00:34:33,860 or you can say, I think ptrace, 910 00:34:33,880 --> 00:34:35,920 I just wanna log any of that, 911 00:34:36,080 --> 00:34:39,000 um, or I don't wanna do anything with execve, for example. 912 00:34:39,200 --> 00:34:41,740 So, I mean, you can configure it to whatever settings you want, 913 00:34:41,840 --> 00:34:44,300 and, um, the author actually has some, 914 00:34:44,320 --> 00:34:46,820 some recommended settings if you're not really sure what's what. 915 00:34:46,980 --> 00:34:49,060 You really kind of have to tweak it for your environment 916 00:34:49,060 --> 00:34:50,000 to see, you know, what, 917 00:34:50,060 --> 00:34:52,580 what your system is using, and, um, 918 00:34:54,120 --> 00:34:56,240 there's a, uh, there's a tool called systrace 919 00:34:56,240 --> 00:34:58,280 that was actually written for OpenBSD, 920 00:34:58,420 --> 00:35:01,560 and, um, a guy at Black Hat this, this week showed 921 00:35:01,560 --> 00:35:03,220 that he, he ported it to FreeBSD, 922 00:35:03,360 --> 00:35:04,960 and what systrace does is, 923 00:35:05,500 --> 00:35:07,400 it'll basically log system calls 924 00:35:07,400 --> 00:35:09,080 that are being used by a, uh, 925 00:35:09,760 --> 00:35:11,500 particular process, and then, 926 00:35:11,620 --> 00:35:14,460 um, block ones that are not 927 00:35:14,460 --> 00:35:16,540 in what's called, like, a rules file for it, 928 00:35:16,560 --> 00:35:19,420 so you initially set it up, and you run it with, uh, 929 00:35:19,480 --> 00:35:21,140 like a wrapper, like a TCP wrapper, 930 00:35:22,020 --> 00:35:24,200 uh, so you execute systrace, and then, 931 00:35:24,300 --> 00:35:25,500 I think it's like dash A, 932 00:35:25,980 --> 00:35:27,280 and then the, the daemon, 933 00:35:27,360 --> 00:35:30,040 and it'll start up and it'll log the syscalls that it uses, 934 00:35:30,100 --> 00:35:32,160 so you can go through, go ahead and put it through its paces, 935 00:35:32,260 --> 00:35:34,160 we'll say for SSH, you log in, 936 00:35:34,480 --> 00:35:36,780 you know, do an SCP, copy a file over, whatever, 937 00:35:37,200 --> 00:35:40,100 and then, uh, it'll, it'll drop all that stuff 938 00:35:40,100 --> 00:35:41,840 into a text file that's like a rules file, 939 00:35:42,020 --> 00:35:43,980 and then you can say, okay, that's everything that it can do, 940 00:35:44,040 --> 00:35:45,740 don't let it do anything else, and so, 941 00:35:46,380 --> 00:35:48,640 you know, if, if you'd attempt, like, an off-by-one 942 00:35:49,140 --> 00:35:51,000 exploit or something on your SSH daemon, 943 00:35:51,140 --> 00:35:54,160 uh, it's gonna, if it uses a system call that isn't used by 944 00:35:54,700 --> 00:35:56,060 SSH legitimately, it's gonna, 945 00:35:56,460 --> 00:35:57,720 it's just gonna drop it, so, 946 00:35:58,120 --> 00:35:58,880 that's kinda nifty. 947 00:36:00,880 --> 00:36:03,980 Um, BPF in your kernel is, is enabled by default, 948 00:36:04,620 --> 00:36:08,700 uh, I think it's, you're only allowed two concurrent BPF filters, 949 00:36:08,900 --> 00:36:11,080 uh, in the generic kernel, but, uh, 950 00:36:11,180 --> 00:36:12,780 if you're running a production machine, 951 00:36:12,920 --> 00:36:14,980 you have no need, uh, for promiscuous mode, 952 00:36:15,160 --> 00:36:19,460 or any kind of, uh, real raw packet sniffing type stuff on your, your system, 953 00:36:19,580 --> 00:36:20,960 you should probably turn this off, 954 00:36:21,140 --> 00:36:24,480 um, can, if you do this in conjunction with 955 00:36:24,480 --> 00:36:25,960 setting secure levels on your machine, 956 00:36:26,120 --> 00:36:30,020 so, uh, an intruder couldn't load a kernel module 957 00:36:30,020 --> 00:36:32,600 or something to, uh, to make a change, 958 00:36:32,780 --> 00:36:34,520 uh, that's just gonna prevent people from, 959 00:36:34,520 --> 00:36:35,660 from sniffing on your wire. 960 00:36:35,980 --> 00:36:38,220 And another thing that you may wanna do is, 961 00:36:38,260 --> 00:36:42,100 is, uh, write a script to check your DMessage output 962 00:36:42,100 --> 00:36:45,400 to see if anyone's put your interface into promiscuous mode 963 00:36:45,400 --> 00:36:46,340 and you don't know about it, 964 00:36:46,380 --> 00:36:48,120 so you could use, like, swatch or something 965 00:36:48,120 --> 00:36:49,740 to monitor the logs and send an email. 966 00:36:51,620 --> 00:36:54,040 But, I mean, BPF is used by other things, 967 00:36:54,200 --> 00:36:59,040 uh, any kind of, like, some, like, real raw IP stuff may use it, 968 00:36:59,080 --> 00:37:00,840 so you probably wanna test it out on, uh, 969 00:37:01,640 --> 00:37:03,760 uh, non-production system before you do that on, 970 00:37:03,800 --> 00:37:05,940 on anything that, that's production. 971 00:37:08,220 --> 00:37:08,620 Okay. 972 00:37:09,680 --> 00:37:11,960 This part's called keeping people out, and it's, 973 00:37:11,960 --> 00:37:13,740 it's, some of it's pretty basic, but, uh, 974 00:37:14,620 --> 00:37:16,840 a lot of people don't really use TCP wrappers, 975 00:37:16,940 --> 00:37:18,320 that, and they should, for, 976 00:37:19,280 --> 00:37:22,040 for non-public services, for, like, SSH authentication, 977 00:37:23,340 --> 00:37:25,380 um, stuff that people aren't connecting to 978 00:37:26,120 --> 00:37:27,680 anonymous, honestly, for example, like, 979 00:37:27,760 --> 00:37:29,840 people sending you an email connecting to your SMTP server 980 00:37:29,840 --> 00:37:32,980 or, or, you know, browsing the, you know, 981 00:37:32,980 --> 00:37:34,800 your website or whatever, I mean, you can't do, 982 00:37:34,860 --> 00:37:36,760 you can't use TCP wrappers with that stuff, obviously, 983 00:37:36,820 --> 00:37:38,500 because you don't know who's coming, but, 984 00:37:38,600 --> 00:37:42,120 uh, for SSH and FTP, if you, you know, 985 00:37:42,120 --> 00:37:44,040 you've only got a select group of people using FTP, 986 00:37:44,440 --> 00:37:46,520 I mean, the more you lock it down, the better you're off, 987 00:37:46,580 --> 00:37:48,300 and, and so, like, TCP wrappers can, like, 988 00:37:48,320 --> 00:37:51,460 combined with a nice, uh, IPFW rule set, 989 00:37:51,860 --> 00:37:53,460 it's just gonna give you that defense in depth, 990 00:37:54,200 --> 00:37:56,180 and, you know, you never know when it can pay off, so. 991 00:37:56,620 --> 00:37:58,760 The next one is, is allow users and allow groups, 992 00:37:58,920 --> 00:38:02,480 um, arguments in, in the SSH deconfig file. 993 00:38:02,800 --> 00:38:05,400 You can specify certain users or certain groups, 994 00:38:05,420 --> 00:38:08,280 respectively, that are allowed to connect to SSH, 995 00:38:08,800 --> 00:38:11,560 uh, using SSH, so, if, you know, 996 00:38:11,560 --> 00:38:13,000 you've got a user who's an FTP user, 997 00:38:13,400 --> 00:38:15,280 and you need to give him a shell for some reason, 998 00:38:15,320 --> 00:38:16,840 but you don't want him to come in through SSH, 999 00:38:16,840 --> 00:38:19,720 you know, you'd obviously use this to not allow them, 1000 00:38:19,820 --> 00:38:22,580 uh, I think it's, it's disallow users to not allow. 1001 00:38:23,280 --> 00:38:24,700 Uh, you probably want to double check that. 1002 00:38:25,520 --> 00:38:26,640 Uh, so, go ahead. 1003 00:38:26,680 --> 00:38:28,460 This works well with, with TCP wrapper usage 1004 00:38:28,460 --> 00:38:30,460 and, and privilege separation in OpenSSH. 1005 00:38:31,080 --> 00:38:33,280 And this, this last one is give users, uh, 1006 00:38:34,160 --> 00:38:36,580 people that are, are only FTPing to the machine, 1007 00:38:36,680 --> 00:38:37,620 give them a no login shell. 1008 00:38:37,660 --> 00:38:39,100 Obviously, people have been doing that for years. 1009 00:38:39,200 --> 00:38:39,740 That's pretty basic. 1010 00:38:43,480 --> 00:38:45,400 So, these are some tools that you can use to, 1011 00:38:45,400 --> 00:38:46,540 to check your system. 1012 00:38:46,640 --> 00:38:48,560 And, and if you don't know what M, MF is, 1013 00:38:48,660 --> 00:38:49,940 you're, you're probably in the wrong building. 1014 00:38:50,380 --> 00:38:52,920 Uh, uh, Whiskr is, is pretty cool. 1015 00:38:53,000 --> 00:38:55,920 There's a new, uh, Whiskr version 2 that RFP is developing. 1016 00:38:56,040 --> 00:38:56,540 That's the author. 1017 00:38:56,700 --> 00:38:58,820 And, and, uh, it's a little more modular. 1018 00:38:59,220 --> 00:39:01,780 So, his, his website is wiretrip.net. 1019 00:39:02,360 --> 00:39:03,640 Uh, you may want to check that out. 1020 00:39:03,680 --> 00:39:06,540 But the one in the ports tree is, is, uh, Whiskr 1.4, 1021 00:39:06,620 --> 00:39:09,700 which is, and it works okay for, for auditing real basic stuff. 1022 00:39:09,920 --> 00:39:13,840 Uh, you know, if, if you've got an old PHF vulnerability 1023 00:39:13,840 --> 00:39:14,840 on your network or something. 1024 00:39:15,400 --> 00:39:18,440 Uh, Tripwire, uh, Tripwire's a commercial entity now, 1025 00:39:18,540 --> 00:39:21,300 but what's called the academic source release of Tripwire 1026 00:39:21,300 --> 00:39:22,600 is still available for free use. 1027 00:39:24,380 --> 00:39:26,960 Uh, and all you have to do is go in the ports tree and build it. 1028 00:39:27,040 --> 00:39:29,100 And you actually have to go get the source yourself. 1029 00:39:29,200 --> 00:39:30,920 It doesn't use the traditional disk files, 1030 00:39:31,000 --> 00:39:32,760 uh, ports distribution method, 1031 00:39:32,840 --> 00:39:34,380 just because of the way the licensing works. 1032 00:39:35,000 --> 00:39:37,420 Uh, but you can, I mean, Tripwire, you know, 1033 00:39:37,420 --> 00:39:39,980 install it on your system, uh, generate the database, 1034 00:39:40,240 --> 00:39:43,220 and then keep the database on a, a floppy disk or something, 1035 00:39:43,260 --> 00:39:45,360 and, and go through and just verify that, you know, 1036 00:39:45,400 --> 00:39:46,960 anything that's been changed, you know, you know about. 1037 00:39:47,300 --> 00:39:49,640 And that can give you real peace of mind as far as, 1038 00:39:49,640 --> 00:39:50,920 as what's going on on your system. 1039 00:39:51,160 --> 00:39:53,200 But it, again, it's only as granular as, 1040 00:39:53,200 --> 00:39:55,600 as how you make it and how many files you have it check. 1041 00:39:55,840 --> 00:39:57,100 And if you have it look at everything, 1042 00:39:57,200 --> 00:39:59,100 you're gonna drive yourself crazy just cause the amount of 1043 00:39:59,100 --> 00:40:01,200 file changes that get, take place that you, 1044 00:40:01,220 --> 00:40:02,160 you know, you don't really realize. 1045 00:40:03,520 --> 00:40:07,000 And Snort, uh, a lot of people are using Snort on their, 1046 00:40:07,400 --> 00:40:09,120 their, just their host machines now because 1047 00:40:10,220 --> 00:40:12,340 it's a lot easier than, you know, 1048 00:40:12,340 --> 00:40:14,840 kind of doing the combined, like, log analysis or everything. 1049 00:40:14,840 --> 00:40:16,980 And looking at some of the other, uh, 1050 00:40:18,000 --> 00:40:20,180 you know, your, your firewall logs and everything else 1051 00:40:20,180 --> 00:40:21,840 with Snort, I mean, if something trips a signature, 1052 00:40:22,000 --> 00:40:23,800 you're kind of interested in, in what's going on. 1053 00:40:23,940 --> 00:40:24,380 Go ahead. 1054 00:40:24,560 --> 00:40:26,560 Uh, I use a lot of Snort and, uh, 1055 00:40:26,640 --> 00:40:28,460 Google Assistant, but, uh, 1056 00:40:29,300 --> 00:40:31,520 I want something that, I guess, 1057 00:40:31,520 --> 00:40:33,060 you can work in conjunction with it 1058 00:40:33,060 --> 00:40:35,060 that actually provides a little bit of defense 1059 00:40:35,060 --> 00:40:35,560 . 1060 00:40:36,140 --> 00:40:37,600 Yeah, actually, um, he asked, 1061 00:40:37,740 --> 00:40:40,460 can I use Snort for any kind of a defensive mechanism? 1062 00:40:40,880 --> 00:40:43,320 And, uh, there's a tool called Hogwash, 1063 00:40:43,320 --> 00:40:47,500 and the, uh, address for it is hogwash.sourceforge.net. 1064 00:40:48,040 --> 00:40:50,560 And, uh, it's written, or co-written 1065 00:40:50,560 --> 00:40:51,840 by one of the Snort developers. 1066 00:40:52,900 --> 00:40:54,780 And, uh, it's actually being integrated 1067 00:40:54,780 --> 00:40:57,500 into the Snort CVS tree right now for Snort 1.9. 1068 00:40:57,680 --> 00:40:59,080 It's going to be called Inline Snort. 1069 00:40:59,140 --> 00:41:00,440 It's just going to be a compile time option. 1070 00:41:01,120 --> 00:41:03,240 But, basically, instead of, like, an alert, 1071 00:41:04,100 --> 00:41:05,560 you know, you write a Snort rule, 1072 00:41:05,640 --> 00:41:07,660 instead of the alert variable to, like, you know, 1073 00:41:07,660 --> 00:41:09,620 alert and write to a file or something, 1074 00:41:09,740 --> 00:41:10,800 you can do drops. 1075 00:41:11,020 --> 00:41:13,300 And so for a TCP connection, it'll, uh, 1076 00:41:13,320 --> 00:41:15,500 it'll send a reset back as soon as it realizes 1077 00:41:15,500 --> 00:41:18,220 that the packet matches the payload 1078 00:41:18,220 --> 00:41:19,920 for, say, like, a Code Red attack or something. 1079 00:41:20,220 --> 00:41:22,640 Uh, and it also has content replacement. 1080 00:41:23,020 --> 00:41:25,120 So, you know, going back to Code Red, you could say, 1081 00:41:25,220 --> 00:41:28,520 replace cmd.exe with xyz.com, 1082 00:41:28,560 --> 00:41:30,880 or replace the first, you know, 1083 00:41:31,660 --> 00:41:34,180 four or five bytes of the shellcode slide 1084 00:41:34,180 --> 00:41:35,740 or something with nulls. 1085 00:41:35,740 --> 00:41:37,380 And those, you know, even if, 1086 00:41:38,060 --> 00:41:40,560 even if your, uh, your system isn't patched, 1087 00:41:40,600 --> 00:41:42,380 you're still going to be protected to an extent. 1088 00:41:43,320 --> 00:41:45,400 Because you're just basically screwing up the exploit. 1089 00:41:45,560 --> 00:41:48,160 And, and it kind of, it kind of confuses the attacker 1090 00:41:48,160 --> 00:41:51,040 because if they're sending, like, a cmd.exe request, 1091 00:41:51,140 --> 00:41:53,200 they're just going to get back, you know, 1092 00:41:53,200 --> 00:41:55,580 a 404 or something because their request 1093 00:41:55,580 --> 00:41:56,920 is being modified halfway through. 1094 00:41:57,360 --> 00:42:00,380 So it, it can, uh, it, it, 1095 00:42:00,380 --> 00:42:01,900 and that's kind of a, a mixed blessing 1096 00:42:01,900 --> 00:42:04,480 because if they really get clever and they start going, 1097 00:42:04,600 --> 00:42:05,620 well, hey, what's going on? 1098 00:42:05,660 --> 00:42:07,480 I know that I was able to get to that, you know, 1099 00:42:07,500 --> 00:42:08,680 two days ago or something. 1100 00:42:08,800 --> 00:42:10,020 They start digging in deeper. 1101 00:42:10,080 --> 00:42:11,640 They may be able to figure out that you're running something 1102 00:42:11,640 --> 00:42:12,860 like hogwash on your network. 1103 00:42:13,080 --> 00:42:14,740 But a lot of people are actually deploying that 1104 00:42:14,740 --> 00:42:17,260 outside their firewall to grab stuff, uh, 1105 00:42:17,380 --> 00:42:18,860 before it hits their DMZ. 1106 00:42:19,020 --> 00:42:20,080 And it's pretty effective. 1107 00:42:23,820 --> 00:42:24,460 Go ahead. 1108 00:42:28,440 --> 00:42:28,960 Right. 1109 00:42:32,740 --> 00:42:35,040 Yeah, you just mentioned AIDE is another 1110 00:42:35,640 --> 00:42:36,620 file integrity tool. 1111 00:42:37,720 --> 00:42:38,240 I... 1112 00:42:42,300 --> 00:42:42,660 Right. 1113 00:42:42,960 --> 00:42:44,760 Um, I really like Tripwire. 1114 00:42:44,820 --> 00:42:45,820 I like the signature syntax. 1115 00:42:46,240 --> 00:42:48,280 It's really flexible and, and it's pretty easy to, 1116 00:42:48,320 --> 00:42:50,180 to write some pretty custom rules really fast. 1117 00:42:54,240 --> 00:42:56,240 Okay, just some miscellaneous stuff. 1118 00:42:56,540 --> 00:42:58,700 Um, you should throw these on all your machines. 1119 00:42:58,780 --> 00:43:00,160 Like, throw it, you know, use NTP date, 1120 00:43:00,300 --> 00:43:02,740 uh, crontab it and have it sync time with, 1121 00:43:02,840 --> 00:43:04,580 you know, an internal time server or something 1122 00:43:04,580 --> 00:43:05,840 out on the internet so you, you know, 1123 00:43:05,860 --> 00:43:07,640 your logs are always in sync and up to date. 1124 00:43:08,000 --> 00:43:09,760 I know all, some of this stuff seems basic, 1125 00:43:09,800 --> 00:43:11,080 but a lot of people don't do it. 1126 00:43:11,080 --> 00:43:14,400 In the TTYs file, uh, change the secure flag 1127 00:43:14,400 --> 00:43:18,060 to insecure on all your local, uh, TTYs. 1128 00:43:19,000 --> 00:43:21,300 And that's just basically gonna prevent Root 1129 00:43:21,300 --> 00:43:22,320 from logging in directly. 1130 00:43:22,560 --> 00:43:24,180 So you're just gonna have to force somebody 1131 00:43:24,180 --> 00:43:25,980 to log in as themself and then, like, 1132 00:43:26,000 --> 00:43:27,920 SU to Root or use sudo or something. 1133 00:43:28,960 --> 00:43:32,040 Uh, and also in SSHD config, 1134 00:43:32,500 --> 00:43:34,100 there's a permit Root login, 1135 00:43:34,280 --> 00:43:35,560 and I think by default it's yes. 1136 00:43:35,780 --> 00:43:37,520 So obviously, you know, change that to no. 1137 00:43:37,580 --> 00:43:39,980 You don't want people logging into your system as Root. 1138 00:43:39,980 --> 00:43:42,060 I mean, never, whenever possible, 1139 00:43:42,780 --> 00:43:44,160 don't use the Root password 1140 00:43:44,160 --> 00:43:45,560 for some kind of authentication 1141 00:43:45,560 --> 00:43:48,200 that, that the, the very most use it, 1142 00:43:48,240 --> 00:43:49,480 you know, SU to Root or something. 1143 00:43:49,900 --> 00:43:51,260 But if you can, use sudo, 1144 00:43:52,400 --> 00:43:53,980 because it's, you just can be able to restrict 1145 00:43:53,980 --> 00:43:55,960 the, who knows the Root password on your system 1146 00:43:55,960 --> 00:43:58,020 and you can granularly lock down, you know, 1147 00:43:58,040 --> 00:43:59,140 who can do what on your machine, 1148 00:43:59,260 --> 00:44:00,560 and they don't need the Root password. 1149 00:44:02,840 --> 00:44:05,000 Uh, the last one is, is a kernel configuration 1150 00:44:05,000 --> 00:44:05,840 that you can do. 1151 00:44:06,180 --> 00:44:07,940 Uh, it's a sudo device that you can enable 1152 00:44:07,940 --> 00:44:09,680 called the SNP, SNP device. 1153 00:44:10,540 --> 00:44:12,780 And, uh, you can go ahead and, and, 1154 00:44:12,780 --> 00:44:13,960 and use that. 1155 00:44:14,020 --> 00:44:15,100 I think the tool is called watch, 1156 00:44:15,860 --> 00:44:17,940 uh, in, in the user S bin directory. 1157 00:44:18,220 --> 00:44:20,700 And you can attach to a TTY on your machine 1158 00:44:20,700 --> 00:44:22,220 and it's non-interactive. 1159 00:44:22,280 --> 00:44:23,100 You can't type back, 1160 00:44:23,200 --> 00:44:24,760 but you can watch what somebody's doing 1161 00:44:24,760 --> 00:44:27,340 and you can, you can monitor them as they're, uh, 1162 00:44:28,060 --> 00:44:29,220 as they're going along. 1163 00:44:32,160 --> 00:44:34,320 Okay, so, so here's some, some related stuff. 1164 00:44:34,500 --> 00:44:36,160 Uh, here's the link that the, 1165 00:44:36,180 --> 00:44:37,880 this presentation's gonna be available at, 1166 00:44:37,940 --> 00:44:39,700 uh, with some of the updated info. 1167 00:44:40,280 --> 00:44:43,200 Uh, and FreeBSD.org slash security, 1168 00:44:43,540 --> 00:44:45,140 I mean, you definitely want to bookmark that 1169 00:44:45,140 --> 00:44:47,500 and, and, and check that out pretty often 1170 00:44:47,500 --> 00:44:49,180 because, uh, that's where they post 1171 00:44:49,180 --> 00:44:50,340 all the security advisories. 1172 00:44:50,440 --> 00:44:55,000 And they also, uh, there's like a security how-to 1173 00:44:55,000 --> 00:44:56,060 that was, it's kind of outdated. 1174 00:44:56,180 --> 00:44:57,020 It was written a few years ago, 1175 00:44:57,080 --> 00:44:57,880 but it's got some good info. 1176 00:44:58,340 --> 00:45:00,040 Um, and I've got some free stuff for you guys, 1177 00:45:00,160 --> 00:45:02,140 uh, from the FreeBSD mall guys. 1178 00:45:02,780 --> 00:45:05,180 Um, I, I think I've almost got enough 1179 00:45:05,180 --> 00:45:06,260 for every single person in here. 1180 00:45:07,980 --> 00:45:08,860 Um, and so, 1181 00:45:10,200 --> 00:45:12,460 yeah, Murray, Murray the guy who runs FreeBSD mall 1182 00:45:12,940 --> 00:45:14,540 heard I was gonna be talking about FreeBSD 1183 00:45:14,540 --> 00:45:15,260 and so we're talking. 1184 00:45:16,000 --> 00:45:17,820 Um, if you guys want to come up, I've got, 1185 00:45:17,920 --> 00:45:19,980 uh, well actually hang on, let me do t-shirts first. 1186 00:45:26,260 --> 00:45:27,260 Everybody likes t-shirts. 1187 00:45:28,120 --> 00:45:29,280 All right, hang on, hang on. 1188 00:45:30,240 --> 00:45:32,100 I've got, I've got, I've got to give my plug first. 1189 00:45:32,200 --> 00:45:33,600 These are, these are made by my friend Tim 1190 00:45:33,600 --> 00:45:36,400 and he works for a company called Hacksawware.com 1191 00:45:36,780 --> 00:45:38,320 and nobody else has these t-shirts. 1192 00:45:38,420 --> 00:45:39,440 These are all like zero-day, so. 1193 00:45:41,760 --> 00:45:43,160 Hold on, hold on, hold on, hold on, hold on. 1194 00:45:43,400 --> 00:45:44,060 Hold on, hold on, hold on, hold on, hold on. 1195 00:45:44,060 --> 00:45:44,680 Let's take one. 1196 00:45:48,020 --> 00:45:48,380 Sir? 1197 00:45:51,040 --> 00:45:51,840 Too late, babe. 1198 00:45:55,060 --> 00:45:56,200 What was your question, sir? 1199 00:45:58,080 --> 00:45:59,260 What was his comment, ma'am? 1200 00:46:02,220 --> 00:46:04,120 That's what happens when you resist arrest. 1201 00:46:05,400 --> 00:46:06,180 Very good, sir. 1202 00:46:06,220 --> 00:46:06,980 You must be a cop. 1203 00:46:08,460 --> 00:46:09,320 Next year, folks, 1204 00:46:09,320 --> 00:46:10,420 spot the fed. 1205 00:46:14,260 --> 00:46:15,480 But we're out of shirts, so.