bsd security fundamentals this is just gonna like hopefully at the end of this talk you guys will have a little bit better understanding of some of the security mechanisms that actually go right into BSD and a lot of people just don't make use of them and they're actually pretty nifty so yeah I'm just gonna start I'm gonna throw this presentation up you know the excuse my powerpoint format it's not very polished I just throw as much stuff in there so I like remember I don't you know so I don't leave anything out when I'm giving the talk so this will be up on the this is a little bit different than the one in your CD it's a couple more revisions to it so go ahead and the website is gonna be sub train dotnet slash presentations and you can get some of the other talks that the rest of the guys that I work with have done so sub train dotnet slash presentations okay okay so for this whole talk I'm pretty much gonna be focusing on free BSD that's like the main operating system that that my friends and I work with and it's really the most mainstream and I mean I'll like deviate a little bit and talk about some cool stuff with open BSD but it's mainly gonna be free BSD it's just gonna be it's gonna be a refresher I mean some of you guys may already know a lot of this stuff but I mean I'm sure everybody will pick up a couple things that they didn't know that things pretty cool and it's gonna it's gonna be cool and it's gonna be cool and it's gonna be interesting but it's gonna be fun but it's gonna be I'm gonna emphasize on on host base security and I'm just gonna basically show you you know using a defense-in-depth strategy you're able to secure a BSD server you know all the way up to the to the wire pretty much and and it's like it's like this is the models of the security I mean you know I mean you peel it away a lot of people I mean it's ridiculous with like the recent Apache chunk encoding stuff I mean I'm sure some of you guys came across this but a lot of people actually went out of their way to start up and start building your own security and then it's gonna be a lot of fun but Apache running as root because they didn't understand how file permissions work and sim links work and they just wanted Apache to have access to their entire directory structure so once they got hit by the exploit they were toast BSD is actually in use in quite a few different products in today's computer enterprise world and it's kind of behind the scenes a lot of times a lot of companies are kind of turning to open source right now with the current state of the economy because they don't want to pay the high support costs for licensing Microsoft software or some other commercial variant and a lot of times the quality of the software is as you guys know, usually better Nokia Firewalls actually they run Checkpoint they use what's called the Ipsil operating system which is like a hardened version of FreeBSD 3.2 and they've just went ahead and done some extra like file locking and stuff and they've got some proprietary stuff that they've added it's pretty cool and then all the Juniper all the backbone routers and stuff they all run FreeBSD, I think it's called Olive is the is the name of the product but it's more or less a BSD machine you can do package add on it and all kinds of stuff they're pretty cool and of course everybody knows Yahoo uses FreeBSD clustered machines to power all their web stuff and their mail stuff alright so let's get started with the basics I mean everybody should know this but I thought I'd just go over it anyways if you're messing with a system that's in a production environment, make backups don't make any changes you're not comfortable with you don't know what it's going to do go through your INID comp file and RC comp file and just turn off what you're not using FreeBSD especially has gotten really good lately in the last couple releases and I think all the way back to like 4.3 they've just turned almost everything off by default in INID which is like I mean they're really like setting the pace for other vendors because I mean up till just like maybe a year ago the standard was just you know vendors were more concerned about making stuff work out of the box rather than you know emphasizing security so I mean they would just turn everything on by default to make it easier for the customer which didn't turn out to be a very good security structure strategy if you're running a machine and all you need to do is send mail locally you can actually disable send mail disable the daemon mode of send mail in the RC comp file with some flags and you can also turn off the submission port send mail comes default with FreeBSD in case some of you guys didn't know that the submission port is just another I think it's new to like send mail like late versions 8.11 and 8.12 and most mail servers don't make use of it so you can firewall it off or disable it in the RC comp I'll get into how to do that specifically in a little bit and obviously I mean you're going to want to track the most stable version of the operating system if you're working in a production environment I would say probably rebuild the system and rebuild the kernel like every two months or maybe every month and a half obviously make exceptions and I just recently had some problems with open source system open SSH and the FreeBSD team got the 3.4 stuff with the privilege separation put into the stable tree pretty quickly after that even though stable wasn't actually affected by the recent off by one and some of the other remote open SSH stuff that's been floating around if you're a hobbyist I'd say go for it as much as possible I think I could probably count on one hand in the past three or four years the times that I've seen the stable tree really broken to the point where you couldn't kind of figure out what was wrong or maybe somebody just made a fat finger or something when they did their commit and it got taken care of within 30 minutes or an hour or so I'm not sure about this I'm not sure if they've gotten rid of this but there's another branch called the security branch and basically that's like an option for you if you're running a production system and you don't want to you don't think stable is really stable basically but you want all the security fixes and all they do is commit anything like the recent IO smash stuff they just commit patches to that and that's all you get and a lot of people prefer that if they're looking to run a really stable environment and there's the recent open SSL stuff that I was checking out before I headed out to Black Hat this week but it looks like there have been five or six new vulnerabilities found in open SSL so rebuild your systems when you get home okay encrypted communications especially at Defcon I was really amazed at the amount of people that were still popping their mail at Defcon 10 it's kind of ridiculous more or less I don't think there's an excuse to not encrypt stuff that you're doing between SSH tunnels or using S-Tunnel to wrap stuff with SSL what's your excuse for not doing that you know open SSL SSH has been included in the FreeBSD base since, I think, FreeBSD 4.0. A lot of people have chosen to track the port, though, and use port upgrade to just keep it current. And you can actually, there's an RC com variable, I think it's SSHD underscore daemon, and you can just specify the path to your SSH daemon, so you can put it wherever you want. Personally, I just stick with what's instable. I never had a problem with it. Even if with some of the recent open SSH disclosures, people were kind of muddy as to what was affected, where, and under what circumstances. So, I mean, I just recommend going through and upgrading all your systems to 3.4 and disabling SSH version 1 where you can on some older systems, especially some legacy stuff. Like, I know PixFirewalls and stuff, they only listen to SSH version 1 for the protocol. So, I mean, that might be a problem, but on your BSD systems, you really have no excuse not to. And you can turn on privilege separation. It's not enabled by default with 3.4. You have to go in there and turn it on. It's an option in the SSHD config file. And it's just like, I think it's enable or use privilege separation. And basically, that'll just fork off a process when somebody authenticates to your machine successfully, and it'll drop some privileges. I'll get into that a little bit later as to how to do that. How some of that stuff works. SFTP, this is kind of recent. I think it's like OpenSSH 2.9 brought it in to the tree as a standard thing, but it's just basically a way to connect to your system to transfer files over SSH. And obviously, I mean, the problems with FTP, everybody knows. Some of you guys may have caught JBeal's talk yesterday about hardening FTP. But FTP is 20 years old and passes stuff in the clear and uses an unauthenticated channel for data and everything. It's just, this way it's encrypted. This has full public key support. So, I mean, it's basically just like you're making an administrative connection into the machine. And there's some new clients for Windows like SecureFX, and I'm not sure if Putty has a file transfer client or not, but it's a lot more secure than using regular FTP. Okay, public key authentication. Just talking about this a little bit. Really, what's going to get you? I mean, most people are pretty good keeping their systems patched that are in the security industry. And, you know, are they a security engineer at their company or what have you? I mean, they understand the importance of rolling patches out in a timely manner. But what's going to get you are your users. Usually with weak passwords. And so I'm going to talk quite a bit about how to secure your user accounts. And what it comes down to is users don't really give a crap about security. And that's just the way it is. I don't know if that will ever change because, I mean, people want convenience and they want to be able to use their system and security and security and convenience are just kind of like opposites. So, I'm going to talk about public key authentication and I'm going to heavily recommend switching all users to public key authentication if your users are savvy enough to handle it. You know, you may have to have them set up, help them set up the public-private key pair and everything. But once you do it, you can actually star out their password fields in the password database and, you know, they won't be able to log in with a Unix password scheme anymore. If you can't do that, I've got some alternatives later in the talk that I'll get into. Okay. So, I'm just going to get started, like, as you're installing, like, you know, you're setting up a new machine or whatever, it's always good to consider security right as you're building the system and how your partition scheme looks is really important to that. As much as you can, break it up into different partitions. So, at the minimum here, I've got, like, a root partition, user var, temp, as a minimum. Slash home should definitely be considered as a separate partition. Just because, I mean, depending on the level of security you're looking for on your BSD machine, with some of the mount options and some of the other stuff you can do, you can really restrict what users can and can't do on the file system. So, like, anything except user or slash because of Sbin, you can mount those with a no suid argument and, basically, that's just going to, if there's a file with a suid bit set on it, it won't execute with that flag pass through mount. And I would also recommend setting that on your home partition, too, just because, you know, users, if they're messing around with something and it's suid, especially if it's suid root, you know, you don't really know what they're doing. Go through your file system and remove suid bits. I was looking through the FreeBSD handbook just to see what the project's stance was on this and they say, you know, anything that's set, suid in the default installation is probably pretty safe. But if you're not using stuff, for example, if any of the UUCP stuff, I mean, you can actually strip that right out in your make.conf file. You can just say don't build UUCP because, you know, who uses that anymore? But just go through your file system and look for suid and SGID files and just get rid of those. Anything you don't use, either just remove the bit or, just set the file 0, 0, 0, so if nobody's using it. The ch flag stuff, I'm going to get into that right now in the next couple slides. Like extended, most people actually don't really know about this. It was kind of interesting to me that most people didn't find out about this, but this is like other variables you can set on a file that when you're using kernel secure levels, you can like restrict access to the file. A couple of the ones I've got here, like the S append, like a log file, that would be like a log file or a text file type of a thing where you've got data incrementing to the file, but you don't want anything else, you don't want someone going in there and erasing their tracks or something. So all they can do is append data. All the file system will let them do is append data. You can't do anything else. And the SCHG bit, you can set on binaries, system binaries, and that will basically, that will just prevent modification, overwriting, deleting, and so on. And as long as you're running in a secure level of one or higher, not even root can modify that. So it kind of makes it a pain if you're rebuilding your system because you have to reboot into a non-secure mode and then clear all those, or rebuild your system or whatever, overwrite the binaries and then reset all the flags to whatever you had before. So, I mean, it depends on the amount of time that you want to spend configuring this stuff. If you get really granular, the only, actually, the interesting thing I ran into was people were complaining that, you know, if you set your whole, like, S bin and bin directories with the SCHG flag, you couldn't tell if somebody had broken into your system because they weren't able to modify data. People were getting pissed off because they weren't getting any tripwire reports because nobody could modify the files. Thanks. Okay, so kernel secure levels, basically, you can change these. These are variables you can change on the fly. You can't lower them, though, once the system is in multi-user mode. The only real fault with kernel secure levels is that the secure level doesn't get set until very late in the boot process. So if you're kind of paranoid about that and you think maybe one of your startup scripts has been modified and somebody's doing something nasty before your secure level gets raised, it's always best to, like, set that SCHG bit on your RC files or some of your other startup files to prevent modification of those. So the levels go from negative one to three. Negative one and zero are kind of the same thing. They're just in secure mode. And secure level one is, you know, you can set, like, the append and the SCHG flags, and you can't disable them once they're set, and you can't load any LKMs, load kernel modules. You can't load or unload those in secure level one. Secure level two is the same thing, but you can't write to disks in a raw fashion except for mount. And also, time changes, any changes to the system clock are clamped to plus or minus one second change. So if you're running, like, a PC or something that doesn't keep time very well, you know, when you reboot your system to drop it into secure level zero to rebuild your system, you're going to want to go ahead and set your clock then, because if you don't, you'll just get errors in your log files about the time changes clamped to one second. Okay, so, yeah, we talked about that, setting the SCHG flag on some of your system binary directories. Okay, this is a lot of data, I know. And if you can't read it, that's cool. Just grab the... This is all on the CD, and this is going to be up on the website, too. Basically, the sysctl variables, that's also the secure level configurations for FreeBSD is a sysctl variable, and it's just a numerical value, negative one to three. But these are some other settings that a lot of people don't really know about that can actually kind of help you strengthen your network stack a little bit and kind of keep people guessing as to what you're running, and it kind of pisses people off that are trying to port scan you. The TCP black hole variable is the first one I'll talk about, and you can set that to zero, one, or two. Basically, I'm just going to recommend two in almost any case, which is a totally silent mode where it's just not going to generate reset packets back to the source on any connection attempts to a port that has no socket open, nothing listening. So if somebody throws a port scan at you that opens up ports zero through 10,000, you know, you've got, like, three things running on those 10,000 ports. They're just going to get... You're just going to sit there, and they're in timeout. They're just going to be waiting for a reset packet back to see if your port is closed or not. And there's the same setting for UDP, and basically that's the same procedure, same idea, except that it won't generate an ICMP port unreachable message on a port with no socket listening. So same thing. That will break trace route to your system, so if you care about people being able to trace route to you, you may want to drop that to zero or disable it, but... So here's some other RCConf settings that you can do. This is how you turn on secure levels. In the main RCConf file, you have to enable it, specify enable it, and then set the number that you want. Secure level three is the same thing as secure level two, except you can't modify IPFW rules, which can kind of be a pain if you're initially building your system or something or you're adding services, because you're going to have to bounce the machine if you want to make any changes to your firewall rule base. So that's just maybe something you want to keep in mind as you're setting that up. ICMP drop redirect. This is going to drop any redirect packets from supposedly... They're supposed to come from a router, but it's just going to drop them from anywhere, and it's just going to prevent people from modifying the path that your traffic is taking. And then there's the TCP drop SYNFIN, and that's just going to drop any packets with the SYN and the FIN bit sets, and it does break in RFC technically. It's not RFC compliant, but there's no legitimate use for traffic with both of those bits set at the same time, so I would recommend enabling it anyways. Clear temp enable is kind of cool. It'll just go through and wipe stuff in your temp directory on reboot. And one other one, I don't know if you've heard of it, if I put it in here later or not, is fsck underscore y underscore enable equals yes. It's a really handy setting if your machine is co-located or something and you don't have physical access to it. If your machine gets bounced or if it crashes or something and it comes back up and starts up fsck to check out your file systems, this will just automatically, you know, accept any changes that fsck is going to make, so you won't have to call somebody up and go, hey, go over to the console and press YYY a few times. Go ahead. Yeah, yeah, it's fsck underscore y underscore enable equals yes. Go ahead. I've heard of people compiling, like, the riserfs stuff under BSD, but that's all, like, I've got a friend of mine in the UK that works on the current stuff a lot, and he's really into, like, the cutting-edge stuff. I've heard that they're thinking of integrating journaling stuff into UFS for 5.0, but I haven't confirmed that yet, so... So this is now real-time? Not by default, I don't think. Go ahead. Soft updates? There's just paper and stuff like that? Well, yeah, soft, it's kind of a, it's a philosophical, this guy pointed out soft updates is an option that you can set on your file systems. Soft updates is kind of interesting. In the way that it writes to the disk, sometimes it won't actually write changes to the disk for up to a minute, and so it's kind of a trade-off if you want to enable that or not. If you're doing a lot, like, heavy disk-intensive stuff, FreeBSD recommends you turn on soft updates, and I think it actually turns it on by default when you set up a partition. Where does it start at? Where does it start at? Where does it start at? Those updates in the data. Those, he says, where the, where the update's stored, they're in memory, and they're just waiting to be written to the disk. So if the machine crashes? Right, if your machine crashes, your SOL for whatever data was written up to a minute, or prior to a minute. Okay. I mean, the two kind of, like, duh parts of this talk are encrypting your traffic and starting services in a jail environment. I mean, so many services that you're going to see run nowadays have either native support for a jail, like Bind or Apache, or you can actually, you can use, there's a jail functionality built into FreeBSD. You can build a separate jail for, for any service that you're running, pretty much. And, I mean, you can lock that down to a specific part of the file system and restrict people. And, I mean, by default, I mean, and SSH is kind of the newest one to do this with the privilege separation and kind of, and fork off a separate process for each user. But by default, I think that probably services like Bind, and Apache's already done this where when you do a FreeBSD install, you're going to get the, the WWW user. And I think the Apache ports tree is updated now where the default username and group name that Apache runs under is WWW. So, I mean, people have been using Nobody for a while, but people didn't really understand that if you use Nobody and you run four or five different services as Nobody, it's not an unprovoked service. It's not a privileged user anymore. So, I mean, you definitely need to break it out into separate users. And with SSH, they've also, they've added an SSH user and the jail for that is slash bar slash empty. Okay, for login vein, this is, this is kind of like, this will pop up in your DMessage and you can configure this to drop into your messages file through syslog. This is just going to show any connections to your machine on ports that aren't listening. So, obviously, this is going to sort of conflict with some of the black hole stuff that I was talking about a few slides back. But if, if you set this, you're, you know, you're quickly going to tell if somebody's port scanning you or something, you're going to see a bunch of connections on, on ports that you aren't even listening on. So, this is, and it's definitely, a lot of people kind of mistake this, this, this RCConf variable for some kind of packet filtering stuff. It's not that. All it does is report people connecting on, on ports that you're not using. So, you know, use it in conjunction with a nice IPF or IPFW rule set. Okay, so the next, the next thing is, is using IPF on, on almost any system. And, and a lot of people take the, the mindset that, you know, they're, they're behind their fire, their corporate firewall. You know, they're inside their, their, their office network. You know, nobody really malicious is doing anything. But even if it's just, you know, your laptop or something, I mean, it can't hurt to throw a nice IPFW rule set on your laptop and, and keep people out. I'm sure a lot of people had that pay off at DEF CON this year, you know. I mean, and it's, it's really easy. If you go to, if you look at, in the ETC directory, there's an RC firewall file, and I think I'll get into that later on, but I can't, can't get ahead of it. Oh, go ahead. What is the performance impact that you've been having celebrating with those tools on a busy system? He, he says, what's the, the performance impact on a, a couple dozen rule set IPFW set up on a busy system? It depends what you define as a busy system, and it depends how fast your link speed is, and it depends on the specs of the machine. Personally, I've seen a, a machine take like 80 or 90 megabits of traffic that it was filtering, and it was like a, it was like a, a one gigahertz Pentium 3 or something, and you could tell that the load is noticeable. I don't really have any measurable data to give you, but I would say probably like a, a 20 or 30% impact, but that's, that's with the full out 80 megabit right, right across a, a fast Ethernet link. It was dropping every single packet, so. Okay. A lot of people have, have kind of, they say, you know, it's, I'd like SFTP and everything, but I'm either, I'm running an anonymous file archive, or I've got users who need FTP. They don't want to learn a new client even though it's kind of transparent as to the differences. You know, they have some old scripts or something that are using FTP that they can convert, whatever reason. I would not recommend using FTP really anymore unless you're running an anonymous archive, and I'll kind of show you how to, how to lock it down, but you know, if, if you've got any users logging in individually, put their, put their username in the, the ETC FTP chroot file, and that's just going to basically restrict them to their home directory. By default, they're not going to be restricted. They're going to just be able to move all, all around the file system, and so if you've been kind of lax with your file permissions somewhere else, you know, they may have access to something that you don't want them to have access to. If you start FTP from iNetD, you can go in and stick all, some of these flags right at, right at the end, and dash L twice will enable extended logging, and then you actually have to turn on logging for the FTP facility in syslog. That's, that's going to give you each connection, each user's connecting, you know, time and date, and also any files that they're uploading or downloading, and so the files can be kind of verbose. It's kind of similar to the X for log functionality in Linux. If you're running an anonymous archive, use like capital dash A, and dash R, and capital A is only going to allow anonymous connections, nothing else, which is handy, because nobody's going to figure out that they can FTP into your machine when you really don't want them to, even though they're a legitimate user. And dash R is read-only mode, where the daemon will actually restrict itself from making any right calls to the system at all. So in the event that somebody figures out how to overflow your, because FTPD runs as root, so, you know, if somebody figures out how to overflow that, it's not going to be able to write anything to the machine. Okay, logging is obviously very important, keeping track of your system, and before I get into any of this, you know, obviously logging, you have to spend the time looking at your logs on your system so you know what's routine and you know what's not routine, because if you see something out of the ordinary that kind of looks out of the ordinary just because you say that's not really right, if you don't have, like, data to back that up, you know, say, I haven't seen something like that in a month or something, or I've never seen that before, that's going to be a lot, you know, more of a clue into you that, hey, something funny is going on. If you start, if you're running, like, a regular workstation, I would recommend to start syslog with the dash SS flags, and that's just going to prevent the daemon from opening the UDP port 514. By default, FreeBSD won't let any users connect to your syslog daemon to log, and, you know, a lot of operating systems didn't use to do that, and so people could, you know, fill up your logs, or at the very worst, fill up your whole file system if you didn't have permissions set up right. Someone would just allow unauthenticated connections from anywhere. This is just going to keep anybody from being able to connect to your syslogd at all. I would recommend setting up a centralized syslog file, especially if you're running an enterprise, and you've got, you know, 10 or 20 different servers maybe. It's much easier to send all the data to a central place, and then, you know, maybe even pull the data into some kind of a, you know, an Excel spreadsheet or something for quick sorting or a database. This is the syntax to do it. You just, this is the wild card right here is just saying log anything on any facility to remotehost.org, and you can obviously fill that in with a local IP address or something. You will not be able to use this dash SS thing up here, though, with this machine that you're setting up. If you're sending the logs to, obviously, it needs to have that port open to be able to accept the logs. In your syslog.conf file, add this var log FTPD or whatever you want to call it if you're running an FTP server so that you can, you know, you get more information about what's going on with FTP. I think by default it doesn't log anything that's going on with FTP at all, or maybe it drops it into messages, which is kind of kludgy because there's so much other stuff going on in that file. It's kind of hard to keep track. In the security file, IPFW uses the security facility and so do a few other applications, but at the end of your IPFW rule base, drop like a, you know, because it will just do, it just goes down the rule base, and if a packet doesn't match, it will drop to the next rule. At the end, put like a log any rule, and anything that didn't match any of your other packets is going to go ahead and get dropped into that file. There's a, there's a, I'm sure most of you guys have heard of this, there's a DShield.org project, and they have a client framework for IPFW logs, and it's like, it's just a Perl script that goes through and parses it out and changes the data into the DShield compatible data, and then you can set up a cron script or something to email that data every night or something, you know, people connecting to your machine, and then you can go and log in through the web and take a look at it, and you can coordinate it with other people, other people submit their logs all around the world, it's pretty cool. . Yeah? . Right. . Uh-huh, yeah, and, and, what is it, he said the FTP users file, you can drop users in there that you don't want to be able to use FTP at all, and so obviously you're going to want to drop, like, root, and, and obviously any privileged user, you know, you don't want them passing their password in clear text, and that's, that's, that's a good add-on to, to the rest of the FTP stuff, the FTP chroot and everything else. Um, some of this stuff is kind of interesting, this isn't, uh, this isn't default with BSD, but, uh, I ran across a couple of these projects, just doing a little bit of research, uh, trojanproof.org, um, they actually have a really cool white paper on their web page about how they developed, uh, this tool, but, uh, I think they started with OpenBSD and they moved to FreeBSD for development, and it's kind of like, it's almost like Tripwire, uh, but in the kernel, and it can tell you if there are any, uh, mb5 variations, if something's changed, uh, with files that are executing on your system, so as they're executing, it goes ahead and, and does the hash on the file to see if it's changed, and it, it, uh, they have some performance specs, because a lot of people were concerned about performance on a, on a, you know, an enterprise machine, obviously, and, and I think to benchmark it, they, like, built the kernel with, uh, this enabled in the kernel, and then this without, and I think there's like a 12 second difference, or, or a 2 second difference, I can't remember which, but it really wasn't that bad. And so, that kind of works well with, with another file integrity tool like Tripwire, um, and that's just gonna, that's just gonna give you the, the kernel level, uh, mb5 checking, and, and go ahead and check out the, the website, they've got, they can explain it much better than I can, as far as if you're interested in the specifics of how it works. Uh, the next one is, is server.sf.net, uh, this does, like, sys, system call interception, and logging of, uh, any, what you might deem potentially dangerous system calls, so, uh, I've got a few listed here, execve, ptrace, setuid, you can configure every single one of these, uh, through sysctl commands, so, you can say, you know, I think that, that, uh, setuid calls really dangerous, alert, or, and block it, or you can say, I think ptrace, I just wanna log any of that, um, or I don't wanna do anything with execve, for example. So, I mean, you can configure it to whatever settings you want, and, um, the author actually has some, some recommended settings if you're not really sure what's what. You really kind of have to tweak it for your environment to see, you know, what, what your system is using, and, um, there's a, uh, there's a tool called systrace that was actually written for OpenBSD, and, um, a guy at Black Hat this, this week showed that he, he ported it to FreeBSD, and what systrace does is, it'll basically log system calls that are being used by a, uh, particular process, and then, um, block ones that are not in what's called, like, a rules file for it, so you initially set it up, and you run it with, uh, like a wrapper, like a TCP wrapper, uh, so you execute systrace, and then, I think it's like dash A, and then the, the daemon, and it'll start up and it'll log the syscalls that it uses, so you can go through, go ahead and put it through its paces, we'll say for SSH, you log in, you know, do an SCP, copy a file over, whatever, and then, uh, it'll, it'll drop all that stuff into a text file that's like a rules file, and then you can say, okay, that's everything that it can do, don't let it do anything else, and so, you know, if, if you'd attempt, like, an off-by-one exploit or something on your SSH daemon, uh, it's gonna, if it uses a system call that isn't used by SSH legitimately, it's gonna, it's just gonna drop it, so, that's kinda nifty. Um, BPF in your kernel is, is enabled by default, uh, I think it's, you're only allowed two concurrent BPF filters, uh, in the generic kernel, but, uh, if you're running a production machine, you have no need, uh, for promiscuous mode, or any kind of, uh, real raw packet sniffing type stuff on your, your system, you should probably turn this off, um, can, if you do this in conjunction with setting secure levels on your machine, so, uh, an intruder couldn't load a kernel module or something to, uh, to make a change, uh, that's just gonna prevent people from, from sniffing on your wire. And another thing that you may wanna do is, is, uh, write a script to check your DMessage output to see if anyone's put your interface into promiscuous mode and you don't know about it, so you could use, like, swatch or something to monitor the logs and send an email. But, I mean, BPF is used by other things, uh, any kind of, like, some, like, real raw IP stuff may use it, so you probably wanna test it out on, uh, uh, non-production system before you do that on, on anything that, that's production. Okay. This part's called keeping people out, and it's, it's, some of it's pretty basic, but, uh, a lot of people don't really use TCP wrappers, that, and they should, for, for non-public services, for, like, SSH authentication, um, stuff that people aren't connecting to anonymous, honestly, for example, like, people sending you an email connecting to your SMTP server or, or, you know, browsing the, you know, your website or whatever, I mean, you can't do, you can't use TCP wrappers with that stuff, obviously, because you don't know who's coming, but, uh, for SSH and FTP, if you, you know, you've only got a select group of people using FTP, I mean, the more you lock it down, the better you're off, and, and so, like, TCP wrappers can, like, combined with a nice, uh, IPFW rule set, it's just gonna give you that defense in depth, and, you know, you never know when it can pay off, so. The next one is, is allow users and allow groups, um, arguments in, in the SSH deconfig file. You can specify certain users or certain groups, respectively, that are allowed to connect to SSH, uh, using SSH, so, if, you know, you've got a user who's an FTP user, and you need to give him a shell for some reason, but you don't want him to come in through SSH, you know, you'd obviously use this to not allow them, uh, I think it's, it's disallow users to not allow. Uh, you probably want to double check that. Uh, so, go ahead. This works well with, with TCP wrapper usage and, and privilege separation in OpenSSH. And this, this last one is give users, uh, people that are, are only FTPing to the machine, give them a no login shell. Obviously, people have been doing that for years. That's pretty basic. So, these are some tools that you can use to, to check your system. And, and if you don't know what M, MF is, you're, you're probably in the wrong building. Uh, uh, Whiskr is, is pretty cool. There's a new, uh, Whiskr version 2 that RFP is developing. That's the author. And, and, uh, it's a little more modular. So, his, his website is wiretrip.net. Uh, you may want to check that out. But the one in the ports tree is, is, uh, Whiskr 1.4, which is, and it works okay for, for auditing real basic stuff. Uh, you know, if, if you've got an old PHF vulnerability on your network or something. Uh, Tripwire, uh, Tripwire's a commercial entity now, but what's called the academic source release of Tripwire is still available for free use. Uh, and all you have to do is go in the ports tree and build it. And you actually have to go get the source yourself. It doesn't use the traditional disk files, uh, ports distribution method, just because of the way the licensing works. Uh, but you can, I mean, Tripwire, you know, install it on your system, uh, generate the database, and then keep the database on a, a floppy disk or something, and, and go through and just verify that, you know, anything that's been changed, you know, you know about. And that can give you real peace of mind as far as, as what's going on on your system. But it, again, it's only as granular as, as how you make it and how many files you have it check. And if you have it look at everything, you're gonna drive yourself crazy just cause the amount of file changes that get, take place that you, you know, you don't really realize. And Snort, uh, a lot of people are using Snort on their, their, just their host machines now because it's a lot easier than, you know, kind of doing the combined, like, log analysis or everything. And looking at some of the other, uh, you know, your, your firewall logs and everything else with Snort, I mean, if something trips a signature, you're kind of interested in, in what's going on. Go ahead. Uh, I use a lot of Snort and, uh, Google Assistant, but, uh, I want something that, I guess, you can work in conjunction with it that actually provides a little bit of defense . Yeah, actually, um, he asked, can I use Snort for any kind of a defensive mechanism? And, uh, there's a tool called Hogwash, and the, uh, address for it is hogwash.sourceforge.net. And, uh, it's written, or co-written by one of the Snort developers. And, uh, it's actually being integrated into the Snort CVS tree right now for Snort 1.9. It's going to be called Inline Snort. It's just going to be a compile time option. But, basically, instead of, like, an alert, you know, you write a Snort rule, instead of the alert variable to, like, you know, alert and write to a file or something, you can do drops. And so for a TCP connection, it'll, uh, it'll send a reset back as soon as it realizes that the packet matches the payload for, say, like, a Code Red attack or something. Uh, and it also has content replacement. So, you know, going back to Code Red, you could say, replace cmd.exe with xyz.com, or replace the first, you know, four or five bytes of the shellcode slide or something with nulls. And those, you know, even if, even if your, uh, your system isn't patched, you're still going to be protected to an extent. Because you're just basically screwing up the exploit. And, and it kind of, it kind of confuses the attacker because if they're sending, like, a cmd.exe request, they're just going to get back, you know, a 404 or something because their request is being modified halfway through. So it, it can, uh, it, it, and that's kind of a, a mixed blessing because if they really get clever and they start going, well, hey, what's going on? I know that I was able to get to that, you know, two days ago or something. They start digging in deeper. They may be able to figure out that you're running something like hogwash on your network. But a lot of people are actually deploying that outside their firewall to grab stuff, uh, before it hits their DMZ. And it's pretty effective. Go ahead. Right. Yeah, you just mentioned AIDE is another file integrity tool. I... Right. Um, I really like Tripwire. I like the signature syntax. It's really flexible and, and it's pretty easy to, to write some pretty custom rules really fast. Okay, just some miscellaneous stuff. Um, you should throw these on all your machines. Like, throw it, you know, use NTP date, uh, crontab it and have it sync time with, you know, an internal time server or something out on the internet so you, you know, your logs are always in sync and up to date. I know all, some of this stuff seems basic, but a lot of people don't do it. In the TTYs file, uh, change the secure flag to insecure on all your local, uh, TTYs. And that's just basically gonna prevent Root from logging in directly. So you're just gonna have to force somebody to log in as themself and then, like, SU to Root or use sudo or something. Uh, and also in SSHD config, there's a permit Root login, and I think by default it's yes. So obviously, you know, change that to no. You don't want people logging into your system as Root. I mean, never, whenever possible, don't use the Root password for some kind of authentication that, that the, the very most use it, you know, SU to Root or something. But if you can, use sudo, because it's, you just can be able to restrict the, who knows the Root password on your system and you can granularly lock down, you know, who can do what on your machine, and they don't need the Root password. Uh, the last one is, is a kernel configuration that you can do. Uh, it's a sudo device that you can enable called the SNP, SNP device. And, uh, you can go ahead and, and, and use that. I think the tool is called watch, uh, in, in the user S bin directory. And you can attach to a TTY on your machine and it's non-interactive. You can't type back, but you can watch what somebody's doing and you can, you can monitor them as they're, uh, as they're going along. Okay, so, so here's some, some related stuff. Uh, here's the link that the, this presentation's gonna be available at, uh, with some of the updated info. Uh, and FreeBSD.org slash security, I mean, you definitely want to bookmark that and, and, and check that out pretty often because, uh, that's where they post all the security advisories. And they also, uh, there's like a security how-to that was, it's kind of outdated. It was written a few years ago, but it's got some good info. Um, and I've got some free stuff for you guys, uh, from the FreeBSD mall guys. Um, I, I think I've almost got enough for every single person in here. Um, and so, yeah, Murray, Murray the guy who runs FreeBSD mall heard I was gonna be talking about FreeBSD and so we're talking. Um, if you guys want to come up, I've got, uh, well actually hang on, let me do t-shirts first. Everybody likes t-shirts. All right, hang on, hang on. I've got, I've got, I've got to give my plug first. These are, these are made by my friend Tim and he works for a company called Hacksawware.com and nobody else has these t-shirts. These are all like zero-day, so. Hold on, hold on, hold on, hold on, hold on. Hold on, hold on, hold on, hold on, hold on. Let's take one. Sir? Too late, babe. What was your question, sir? What was his comment, ma'am? That's what happens when you resist arrest. Very good, sir. You must be a cop. Next year, folks, spot the fed. But we're out of shirts, so.