Yeah. Please raise your hand if you're hung over. Thank you. Please raise your hand if you wish you were hung over. Okay, thanks. This is DEF CON, baby. Okay. So I'm going to talk to you about locking down OSX. I've got an OSX machine. I'm only projecting. I've got two laptops, but one of them is on both projectors. So we're going to primarily stay on the slides, and I'll demo as we have time and energy and desire. So you guys can indicate desire by shouting at me, yelling at me. Don't throw things, because I know you will. But I'll tell you about basically locking down OSX. I got a nice little OSX machine a while ago. It's a nice little OSX machine. It's a nice little OSX machine. It's a nice little OSX machine. And I started playing around with it and said, you know, it would really be nice to have a machine that might, you know, I don't know, run Word or something like that, or maybe just, you know, I could lend it to my girlfriend, and she'd like not break it. It'd still be easy to use, not the Linux box. But at the same time, wouldn't break itself Windows style, just, you know, crashing every six to 12 hours like clockwork. So I got one of these things and tried it out, and the first thing I did was locked it down, and you'll see basically my experience is in locking it down right here. Okay, so what I'm going to talk to you about is first auditing the operating system and then locking the sucker down, and I'll tell you about how we've made Bestio Linux do some of this automatically for you. Okay, so what do you get in one hour of lockdown? Well, you don't get something massively complete, but you do get something probably safe enough to bring to DEF CON, provided you don't want to, like, use it as a web server, like you want to use it as a laptop. Okay, so what are we going to do? We're going to lock it down. We're going to lock it down. Basically, in terms of quick lockdown pre-DEF CON, and I understand this is post-DEF CON, but, you know, you've still got a good six hours or so to get hacked here, what would you be doing? One is that you would stop somebody from coming and booting your laptop in a single user mode, starting out as root, changing all your passwords, copying all your data, and then deleting the drive if they feel like it. Okay, that's called boot security. The next thing you do is actually do what's called a daemon audit and a network daemon audit. That's where you're, you know, turning off, that's where you're turning off network daemons in general and programs in general that you're not using that could turn out to be vulnerable later on and get your laptop hacked. Okay, other things you might look at, I'll tell you about these if we've got time, set UID audit. That's where you're looking at the programs on the system that an ordinary user can run, where it runs as root, where it gives them root privilege for a specific operation. That's things like changing your password. We'll talk about cron jobs, all the shit that runs automatically, for you. And then actually talk about the last bit of stuff that we, you know, you don't have time for in one hour, which is actually going and taking daemons that are on the box, like a web server, like a DNS server, and going and configuring it for better security. That's what you do in a lockdown if you wanted to do something very complete and comprehensive. Okay, so OSX. OSX seems to kind of be a hodgepodge of things to me. I like it. It's useful. It feels like it's got this whole little free BSD. It's got a lot of stuff. It's got a lot of stuff. It's got a lot of stuff. It's got BSD infrastructure. It's got this whole mock kernel going on. Basically, it feels like BSD Unix to me. On the other hand, it's got some weird Next stuff thrown in, and that seems to be because Apple bought Next and brought Steve Jobs, and he was like, hi, we made some stuff. Can we put it in, too? So you'll see that as we go through. Okay. The thing you need to understand, for the first part, in terms of how any kiddy here is, you know, is going to be able to do a lot of things. So if you leave them with your laptop for 30 seconds, it's rooting your laptop to understand how the boot process works. Okay. So basically, what goes on is you've got your machine and you turn it on, and you've got a bootloader. Okay. That's like your BIOS on a PC machine. Sorry. You've got a hardware loader. That's whatever. EEPROM here, BIOS. EEPROM on Sun. EEPROM here, BIOS on Intel machines. That starts a bootloader. That starts your kernel. And then you've got a bootloader. And your kernel on this thing is what's called your kernel's going to start. Your kernel's mock. And what mock starts is a process called mock init. Everyone know what an init is? Raise your hand if you know what an init is. Yes. Mostly. All the way. Okay. Cool. So mock init is this weird little process. We're all used to, like, the kernel starting an init and that just being it. Well, Apple's, like, making things a little weird. So the kernel starts mock init, and mock init actually goes and starts an init. And it's, like, the one ‑‑ it's, like, the one ‑‑ it's, like, the first one. Or at least it's number one. And all the other stuff on the system, like, gets started by an init. So the way that works here is init starts, runs RC ‑‑ runs a script called RC.boot and a script called RC. And then RC.boot is important for single user mode. We can take a look at it. RC actually goes and runs a program called system starter. And I'll show you that system starter is actually how ‑‑ system starter is ‑‑ OSX is kind of ‑‑ it's a standard RC script. It's, you know, it's the RC3, RC4, RC5 type stuff from SIS5 or, you know, standard RC scripts from DSD. Anyway, let's take a look at it. What I would do with my Apple laptop if it was up here and you wanted me to and we had lots of time would be I'd hold down that slide. In your slides, that little square box, that's an open Apple. Okay. If you take this system and it's turned off and you hold down open Apple S. When you turn it on, your system boots directly into single user mode. Okay. This is, you know, if you've forgotten your root password, this is number one way to get it. If you find somebody's OSX system sitting on a table, you know, maybe you're at root foo and somebody goes off and runs to the bathroom and is like, hey, watch my laptop. You're like, sure. Okay. Open Apple S. Boom. Single user mode. Change passwords. Create yourself an account. You know. Let the thing boot up normally. Your buddy gets back. It's probably all done in, yeah, two or three minutes or so. Okay. So this open Apple S thing, that's not as much fun as you'd think if you're the guy who actually went to the bathroom. So if you're the guy who went to the bathroom, what you'd want to do ahead of time was change this RC.boot script to require some kind of authentication before it just lets boot continue. By the way, if you think this is kind of like a weird little Apple thing, a lot of operating systems do this. Red Hat's been doing this for years. If you start up a machine and type Linux single, okay, you know, you're the LILO prompt, you type Linux single and boom, it drops you to single user mode. Same basic thing. Operating system vendor thinks this might be a useful way to handle those calls when somebody calls up and says, I lost my root password. What do I do? Can you all hear me back there? I'm a little hoarse. In the back, you can hear yes. Okay. Cool. So what can you do? There is, there is, for those of you who have got a machine in the room, something to test would be there is an etc tty's file. And in the etc tty's file, you can find the console line and change it from insecure to secure. And theoretically, from what the documentation says, that should fix this. It should make single user mode inaccessible by that method. On my build, that has not worked, and so I went Googling. And what did I find? I found somebody wrote this script called secure it. And what secure it does is you run this things install program, and it inserts a little thing into rc.boot. It says, if there's a problem, I'm going to fix it. If there's a problem, I'm going to fix it. If there's a single user, if this is a single user boot, then run a program called password.pl, which is a Perl script. And that Perl script basically is just going to check a password. And if you've got the right password, if you've got the right password, then you're allowed through. And if you're not, it forces a reboot. Okay. So basically, the way password.pl works is when you install this, it asks you for a password. You give it a password. This should not be a root password. It should just be an independent password. It encrypts the password and stores it. And then whenever someone tries to boot in a single user mode, it asks for that boot password. Okay. Let's call it your secure it password. And so if you type the right one, you're in. And if you don't, it reboots. Okay. There's another thing you could do, and I really don't like this so much, but I did find this when I was Googling. You can actually replace your entire kernel with one that doesn't boot into single user mode at all. Okay. So if you haven't checked this out, my guess is it basically skips rc.boot entirely. Okay. Go for it if you want to. My problem is that, you know, I have to be assisted in sometimes, and having my first hardware failure come up and finding that single user mode is a little hard to get into, a little bit of a pain in the butt. So I don't know if, you know, I don't know if you want to eradicate single user mode entirely. If you're really paranoid mofo and this is your laptop and you're really concerned, maybe that's something you want to do. All right. All right. All right. All right. Any questions so far? Yeah. Is there any way to boot, to disable booting from CD? You think I planted him there. Hey, Steve. Gee, wow. Thank you. Okay. So the nice thing is that, okay, that single user mode, it's really great when you can just walk up to a machine, no CD in hand, nothing, no tools, nothing, and just grab root real quick while somebody runs off to the bathroom. It's really great if they're, like, really fast, okay? Although the way they put the bathrooms in Lexus Park, it's going to take them ten minutes to get out there and back. So supposing that you did have that ten minutes and you were carrying around an Apple boot CD in your pocket, it's kind of cool. You can take the CD, stick it in the drive, and what you do is you hold down the option key. You hold down the option key and turn the machine on. And what will happen is the Apple will come up. It'll take a little while, but the Apple will come up with a graphical menu. It'll show your hard disk. It'll show your CD-ROM. And if you've got any FireWire drives, if you've got any FireWire drives plugged in, including, say, an iPod, it'll actually show you that, be like, hey, which of these do you want to boot from, okay? So the deal is, one of the cool things is that if you do that with the normal, with the install media, okay, normally with install media, you have to have a clue, right? You, like, boot from install media, you have to go and remount the drives, read and write, go and, you know, look at the right password file, et cetera, change the password file. Et cetera. You maybe have to, maybe you'll cheroot into the, you'll cheroot into slash mount slash CD and change password from there, whatever. Here it's actually nice and easy. They actually include a password utility. So you can take, when you boot from CD, you can go up to this little nice little menu, and you can go to the password utility, and it'll be like, hi, which drive do you want to change the password on? And you're like, this one. And it says, which account? So it doesn't have to be a root account issue. It's like, which account would you like to change the password for? And you're like, no, that one. And it's like, okay, what's the password for? And you type it in. And congratulations, it's a new password. Now, you could also just boot from CD and, you know, do all the normal foo you normally do, but this kind of makes things nice and easy. Again, when you're looking for the 10 minute bathroom break attack, this is excellent. Okay, so what's the countermeasure? Well, the countermeasure is that the thing was, booting from CD is, you know, one of those, one of those pre-bootloader things. This is the firmware. So if the issue is that we were able to talk to the firmware and have it boot from CD or FireWire or whatever the hell, we're able to boot from CD or FireWire or whatever the hell, then maybe what we want to do is we want to stick a password on firmware. So what you can do is you can boot into firmware. You just, as you're turning the machine on, this starts getting easier and easier. And this starts getting harder and harder. You're holding down the option key, the Apple, the open Apple key, and O F for open firmware. Okay. And then once that boots up, you get a prompt. And at that prompt, you type password and it says, hey, what's your password? And you set a boot password. This could be the same one you use for secure it. If you're like me, you probably use yet another password here, just in case something goes wrong. And then once that's done, you're able to boot from CD or FireWire or ScriptureVisual. Okay. And when somebody gets root access on the system and can read secure its file or whatever, I don't know. Okay. Type in a password. You typed in a password for the boot loader. And now you type set n security mode command. Okay. What command means is that allow the system to boot normally unless they want to boot from alternate media, and if they want to boot from alternate media, require a password. Okay. On the other hand, if you want, you can also, instead of command, you can write full. And what that means is don't freaking bo t unless they know the password. Don't boot from it the wrong trce, doesn't matter if it's anything. Just don't boot. Okay. How many people have set this on their Sun boxes? Full? Full? Who set full? Okay. Of the people raising their hands, there aren't that many people in the room who raised their hands. Has anybody forgotten both the root password and the EEPROM password at the same time? Anybody? No one's going to admit to that, huh? You know, if you go on eBay, you will often find a very steady trade in replacement EEPROMs for Suns, because if you forget both the root password and the EEPROM password, you know, you might be in a, and you've set it to full, so it won't even boot to a hard drive without this. You're quite possibly going to be in the situation where you need to replace the EEPROM. People have been doing this for years. eBay's selling tons of these. Okay. Whatever. When you're done with this set end, either full or command, type reset all, you reboot the system. Congratulations. Nobody gets the disk without getting past the password. Now, the next question is, well, Jay, what's the next attack? What's the next attack? What's the next attack? What's the next attack? What's the next attack? What's the next attack on the boot process? You know, can you get past this? And my answer is, eh, I don't know. Okay. And you say, is he a lamer? And I'm like, yeah, I'm a lamer. But no, no, no. It's, it's, the issue is, some of you are like, wait a second, how come there has to be an attack? And it's like, well, there always will be, right? There'll always be another way. There'll always be potentially another way to, you know, violate the boot process and grab root. That's just, that's just part of operating system security. There's attacks, there's defenses, there's attacks, there's defenses, and somebody freaking clever is coming, up with attacks. So when I hear about the next one, maybe I'll come up with a defense or someone else will come up with a defense. What else? What else makes, what else makes apples easier, hard to break into? Yeah. Question over there. Sweet. Okay. We have a new, we have a new, we have a new attack. Okay. I am told by my colleague over there with the nice, shiny laptop that you can, you can change the open firmware password if you just pop open the machine, pop open, pop open the machine, add in more RAM, pull out RAM. If you change the amount of RAM, you can change the open firmware password. That sucks. Rearrange the RAM. Excellent. So, so, part one, all you got to do is rearrange the RAM. Part two, Jay, you ignorant slut. You tried this in the wrong order. You see, if you set an open firmware password and you try to boot into single user mode, you'll be required to submit the open firmware password. Thank you. Ask these guys. Does this include taking the RAM out and popping it back in? My guess is no, but ask these guys. Anybody? I'll go over here first. No, you have to move the RAM. Question. Yeah. Anybody know this? Are there any, are there any user space tools for modifying open firmware while booted? Either in, on any, on any, let's say, let's broaden the question. On any, on any, on any operating system that runs on this platform? Now, have you been able to find? Right. You can set the password from user space tools. Okay. So, no. Okay, so what else can you do? What else? So, in terms of boot security, Apple actually, my laptop came configured with this nice little option by default, and that was that the sucker just logged right in for me. You know, I like, I like started up, I turned the machine on and asked me for a first user, a first password. What did it do? It was like, oh. okay, cool. And now whenever I turn the machine on, it auto-logs in for me. And that's kind of nice. But, you know, again, one of those things where it's like, if you leave this thing turned on, you lock your screen, you step away, somebody walks up, turns the machine off, turns it back on, it comes up, logs directly in as you. That was an easy screensaver hack. So in terms of turning that back off, in terms of turning auto-logging off if you've never turned it off, you can actually do that with a GUI. You just go to system preferences, accounts, users, and then you've got a little checkbox that says log in automatically as user, and you can specify user. So if you just turn that off, your auto-logging is toast, which is good. Okay. Restart and shutdown. If you're at a log-in prompt, if you're at the graphical log-in thing, okay, this thing will let you, it'll let you cleanly shut down the system and start it back up. Some people think of that as, some people think of that as, you know, like, you know, like, you know, like, you know, like, there's a weakness, some people don't. Okay. So if you want to change that, system preferences, accounts, log-in options, and you can click on hide the restart and shutdown buttons. Okay. Additionally, there's another way to do this. You can change this in this etc.tuis file. You find the console line, and you add in the parameter power off disabled, yes. Okay. So do an okay on time. Okay. So in terms of, you know, you can change the settings, you can change the time, you can change the time, you can change the time of code. So you can use this. Okay. So what I've found is that, you know, in terms of, the next thing, the next thing, that's basically boot security. That's the quickie boot security audit. The next thing to do is to take a look at other programs that are running on the system and then also network daemons that are running on the system. And the network daemons are really what's most important to me because I want to have this system not listening on the network quite so much. Okay. So what I've got is that remember, we had, we had the kernel starting machinit. Machinit started init, init started rc.boot, and rc, and rc is normally what we think of as the network you know, as the script that's going to start everything else, okay, parent isn't it, but rc runs rc.com, and it's going to run rc.com to do some general stuff, and also, importantly to us, to host a file called, I mean, to source a file called etc host config, okay, and then what rc does is it runs system starter, and system starter is kind of the replacement here for the bsd and sys5 normal boot methods, and I'll show you that. What system starter does, and this kind of, this is, you know, this thing's very bsd, but system starter feels sys5 to me, what system starter does is it looks through two directories, and let's just look at the, we're only going to look at the first one here, because the second one is something you're supposed to populate, and that first directory has slash system slash library slash startup items, and inside that directory, inside that startup items directory, there'll be a script called system starter, and inside that directory, there'll be a script called, you know, say, it'll be a script called, you know, apache slash apache, I mean, there'll be a directory called apache, and in that directory, there'll be a script called apache, and what system starter is doing is it's looking at all those sub directories for scripts of the same name, and then it's going to run all of them, and actually, you know, sys5, they all got run in a numerical order, bsd, they all got run in the order that they were in a long script, okay, here, system starter actually determines the order dynamically, and it's kind of cool, okay. So, basically, if we're looking at system library startup items, apache, apache, that directory apache has some other files in it, and one of those files is startup parameters dot plist, and what startup parameters dot plist is, is it's a bunch of stuff, let me see if I've got a slide on this, yeah, I do, okay, what startup parameters dot plist dot has is a bunch of stuff that says, that helps it, helps systems sort of decide what order to run this stuff. Okay, so we've got a description, apache web server, we've got provides and requires and uses, provides is, you know, what's going to be, what service, you know, what thing is going to be there for the other things to require and use after we start, after this gets started, requires is what's got to be running before this will go, okay, uses things that this uses, that might be useful to be on, okay. Order preference, order preference can be none, it can be first, it can be last, it can be early, I think the other one's late, okay, and what that says is, this is roughly when I'd like to go, I'd like to go first. System sort of doesn't have to actually obey any of that order preference stuff, okay, it, it can at its own option. So when you're creating scripts of your own, this is kind of the way you're doing this, so in terms of what order things get run on, that's chosen, that's basically dynamically generated on each boot. Okay, so if you want to start turning this off, like we said before, rc.com gets run by every, by basically every single system starter script, and that, it does that, each of the system starter scripts do that, so that they can source, so that they can source host config, so if you want to turn off daemons, you can actually go and hack on the scripts yourself, but the preferable way, of course, vendor supported would be to go and modify etsy host config. Most of the time we can do that, some of the stuff we want to turn off, we can't turn off through. Okay, so if we look at, let me see if I've got a slide with this script listed, or whether this was something I was really hoping we had access for. Okay, if we look at system library startup items, nfs, nfs, that's one of the scripts, it starts, one of the programs that gets started is called auto-mount, okay, auto, auto-mount runs, auto-mount's going to run by default, okay, but you can deactivate it by turning off auto-mount, by setting auto-mount to equal. Okay, auto-mount is just the, it's just, it's an nfs, it's an nfs client daemon, and you use it if you want to have nfs, if you want to have given directories mounted remotely from nfs servers as your users use them, and unmounted whenever they've been idle for a while, okay, so if we're an nfs client, we're going to, we might want to keep this on, if we're not an nfs client, I want it off, right, if we are an nfs client, I might use this, I might not, I have to decide. But in terms of locking it down, that's a good part of what locking down a system is, is deciding what the system is being used for, and adjusting it accordingly. Okay, so, what else, nfs, we've got this script, nfs, nfs, the nfs script, it starts, it starts the auto-mount, it also starts nfsd and mountd, but it only starts them if you've actually got, if you've actually got stuff listed in etc exports, if you're actually exporting directories. That's kind of cool, it's a pretty smart script. Okay. So, if you've got stuff in etc exports, or if you're actually, if neto info, which we'll talk about later, says that you've got things, says that you've got things that you're exporting and sharing with other systems, then these things run, if they don't, they don't run. The other weird thing though, is there's another program that gets run by this script called nfs iod, and basically the nfs iod daemon runs whether you like it or not, it runs whether you're an nfs client or not. So, you can turn off auto-mount. And you can, you know, you can have nothing, you can have no nfs to share out, but the nfs iod is a, is an nfs client daemon, okay, and that runs no matter what. There's no way to really turn that off through etsy host config, okay. So, what we can do, what I do with that particular one, is you actually go into the script and you just comment the sucker out, okay. Does that, now, now there's an obvious question, if I'm going to go and, if I'm going to go and start modifying start scripts, what's my obvious question? Is that cool? Anybody, system in the room, what's that? What happens when I upgrade? Okay, what happens when I upgrade? The other thing I was looking for is what happens when I patch, okay. So, when I patch, when I upgrade, there's some very good chance the vendor is going to go and smack, you know, new or updated or the original boot scripts right back on the system. If they do, well, then I'm kind of, you know, I'm kind of, yes. Nfs daemon is off by default, nfs client daemon is on, nfs iod, that's on, right? I'm sorry? Auto mounter is, auto disk mount is started by default, I know that, hold on, let me check my system. You could be right. Let's check. Okay. . So, on my straight build, I've got auto mount, I've got auto mount set on my system. that's a yes by default so it gets started it might close up like we can go look at the script this is this is i can tell you this is a default install because i rebuilt it last night i can't 10-2-3 10-2-3 i'm sorry i'm sorry no 10-3 right which which which is the 10-3 is and i've looked at 10-3 and actually i've got i have i got an install of 10-3 on a system back at home this has changed in 10-2-4 okay so your fair speaker has his default cd and this is 10-2-3 this is what apple sold me and i didn't me updated. No, I didn't immediately update it because I was looking for issues. No, I didn't immediately update it to 10.2.4. Okay. Are you guys Apple? Okay, just checking. Who shouted what? I didn't hear. L-S-O-F minus I. Yeah, the gentlemen are saying that quite possibly, are you saying on 10.2.4 that I won't have anything listening by default there? Or is it on 10.3 that I won't have anything listening there? Okay, I'm not going to argue this if I'm completely and totally wrong. Slam me after the talk and, you know, heck out. But I've got a 50-minute talk that I've got 22 minutes left of. Okay, yeah. If I'm an ignorant slut, you can call me on it. Okay, so on my reference 10.2.3 system, on a fresh install, NFS IOD starts whether I like it or not. I get multiple instances I remember. I get multiple instances I remember that. So, I can edit the script to turn this off, but it's not accessible or it wasn't accessible. Let's stick with, I'll try to stick with past tense, guys. Okay, it wasn't accessible via host config. Okay, I am not busting on the operating system here. I'm just telling you how to harden it. If they're going to come out of the gate perfect for me, I mean completely perfect for me, that's great. Okay, some of them do. But, you know, I don't expect it to. I expect to have to do some amount of configuration on the system. I don't know. I have stuff that I still do to OpenBSD, you know, and they've got a pretty good attitude about this stuff. Okay. If you really wanted to do a thorough audit, I mean, what I encourage, if you really want to do a thorough audit, you should read your boot script start to finish. I mean, you should just go through and basically trace what the system is starting, when it's starting, if it's starting, et cetera. Okay. If you want to do a thorough audit, that's what you do. Okay. What we're going to do is go and change, that's the host config. I'm going to go to the host config, turn stuff off that we want off, and then go and look at, you know, if we wanted to reboot, whatever, look at what's still running at that point, and go and find out how that got started and turn that off. Okay. That's kind of the applied and quick audit. Okay. If I look at this file, what do I have that's on? Auto mounters. The auto mounter's on by default in 10.2.3. Okay. I can turn that off. What else is on? Okay. Well, I just want to, I'll just show you what we've got CUPS on. We've got IPv6 on. We can turn that off. Net info server set to automatic. RPC server set to automatic. Time sync is set to yes. Okay. So we can look at each of those. So the first thing is we know we can set auto mounter to no. Okay. We know we can set auto mounter to no if we're not using that. Okay. What else? Well, we've got a variable called CUPS, and what CUPS does is it's actually controlling whether printing services, printing services runs CUPSD by default or not. Okay. If we are not printing from this system, if we're not ever, you know, if this is, if this is a machine that's serving as a little web server, you know, I know this is a laptop, but suppose, suppose for a second it's a little machine that's serving as a web server in my dorm room, you know, it's not doing anything else. I might turn off printing. If I want to turn off printing, that's easy enough. I can change the CUPS variable. Okay. I can run that script. I can run the print, printing services, printing services with stop. Okay. And that'll stop. If I want, I can, what I really should do to make sure that it's really going to be off on the next boot is I should change that variable, and I should pass it restart so that it stops, or I can pass it stop, make sure it's off, then run start to make sure that when I, when the script gets started that CUPSD doesn't actually run. And that's what I'd say is the safest thing to do here. Okay. So I've got a typo on this slide, updated slides on the web, on the, on the DEF CON website. Net info server is another variable, and I don't remember the script, but I'm going to go ahead and type it. I don't remember the script name that it's actually looking at. But basically controls whether NI, basically this, net info server is going to control whether NI bind D or net, or net info D gets started. Okay. And if it's set to automatic, it starts NI bind D if I actually need to, if I actually need to offer net, if I actually need to get net info information off the network. Okay. And starts net info D if I don't. Okay. If you've got an OSX system, if you've got an OSX system, to my knowledge, what you're doing is all your password information, your shadow information, exports, et cetera, this is all maintained through net info. Okay. I don't know tons about net info. I know it came from Next. I know it's a useful thing. I know it smells like NIS to me. I know that my system basically requires it. Okay. I can't turn it off. What else? Time sync. Okay. That time sync variable. It controls whether this system runs or not. Okay. And it's going to control whether this system runs NTP. Okay. And whether it's actually updating time very precisely. Okay. You might turn this off if you're really paranoid, if you're running around a hacker conference, whatever. On the other hand, if you're, you know, if you're looking at IDS logs and firewall logs and machines that have been broken into and you want to correlate all the information you got out of that, okay, or even, you know, in the case of a penetration, or even you just want to see, hey, one of the, it looks like one of the servers is dead. You want to see, hey, one of the servers is down and see what time an event happened and see that multiple logs in different places, you really may very much want time sync and you may want time, you may want your time synchronized very closely. So it's kind of your call. If I'm running around DEF CON, you know, I probably shut this off. If I'm not, you know, if I'm, if I'm in my normal operational environment, I'd probably leave it on. It's all depending on your paranoia. Okay. So if I'm going through and as I'm shutting these down, I can either do one of two things. I can do, I can go and run the app scripts or I can reboot the system. Once I'm done, once I'm done with that, what I want to do is start this thing back up and see what's left. Okay. And I can run PS and look at all the processes that are left and start deciding whether I want them or not. Okay. The first one that caught my eye when I looked at a PS listing on a 10.2.3 system and this will not show up, 10.2.4, it went away, right? 10.2.4 or 10.3? They stopped INETD listening. Okay. That's cool. Debating that? Still listening. Okay. Well, so INETD, if we look at the IP services script, IP services starts both INETD and XINETD. Okay. XINETD and INETD, XINETD is a replacement for INETD. They can both run at the same time on a system as long as they listen on separate ports. So Apple by default has a really nice default here. INETD has got every single line, every single line commented out. If you grep that file for non commented lines, I don't think you will ever get any blank lines. I think it is actually a perfect file, okay. But there's nothing in INETD's configuration file that everything in XINETD is supposed to be listened for. That's all turned off by default, too. It turns out that XINETD if it has nothing to run, it immediately exits. INETD if it has nothing to run, it, you know, keeps running but it is actually not listening on any ports. So, it is not that INETD is listening, it is just that it says it's listening to me now and I've put anything else in there. Is that a problem? Oh, kind of running, taking up a couple cycles here and there. Okay. So this isn't, again, something that I can control through host config. So the best thing I can think of as far as INETD goes, sorry, this is our slide. The best thing I can do as far as INETD goes is to maybe write some shellcode. And that shellcode that's at the bottom of there, it's not the most, you know, it's not, you could do something that was a lot smarter than this. Okay. But what I've done is basically, you know, you could wrap it in some shellcode so that INETD only runs if there's something in the file. Okay. That's a decent thing to do. If you know that you're going to be admitting this system and, you know, you just want to, if you want to, what I would do is, you know, you could comment INETD out entirely and turn it back on if you want to. You know, you could put an exit, you could put an exit at the top of the script. Again, did we ever solve the question of what we were going to do if our, did we ever solve the question of what we were going to do when we went and handed it to the system? I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't know. I don't you apply patches that will go and make your hand changes again. I would definitely try to automate this. That's the best thing that I can think of. If you're using something at your site already, like CFEngine or some other solution, you can use that. Some kind of automation that brings you back after patches. If anybody else has any easy solutions for this, let me know. What's that in the back? What's that? Binary is replaced on the patch. What if the binary is replaced on the patch? Good point. So the installer will overwrite your binary. I mean, it's, you know. What's that? S-change. Yeah, it's just like an immutable bit or a locked bit. Yeah. So S-change bit. How does my installer react to that? Okay, so we don't know. Okay, x-initd.com was empty of anything. If we want to look at x-initd and see the same thing, we're going to have to look at x-initd.com. We just look at, this is a sample x-initd configuration file. If you look at them all, they all have a disable line, and the disable line says yes. We know in x-initd.com, if every line's commented out, nothing's going to get listened on. With x-initd, we're looking for disable lines. If there's no disable line, the service gets run. If there is a disable line and it's yes, the service doesn't get run. So if we look through on our reference system, we find that x-initd's got every single thing in x-initd.d. Every single file's got disable equals yes, then we know it's off, and we don't worry about it. Next slide. Okay, so if we're looking at our PS listing, we're looking at what other programs are left. We're doing something quick. Okay, one of the other things that stands out is auto-disk mount. Okay, what's auto-disk mount for? Auto-disk mount's actually pretty darn useful. Okay, auto-disk mount is, I take my CD-ROM, I stick it in the drive, it mounts up automatically, it appears on there. It appears on my screen, I can click on it, I can get a finder listing of it, etc. What else is it for? Well, it's for floppies, yes, but what else is it for on top of that? Well, if I'm downloading disk image files, okay, one of the big ways you install software is you download a disk image file, you click on it, and it basically comes up as, you know, as if you were mounting a little, as if you were mounting an external hard drive, except it's not, it's just a disk image file. Feels like an ISO to me, but, you know, if I've got a disk image file, I can click on it, and it'll show me the disk image file, and auto-disk mounts what's actually, what's actually opening that up for me. Okay, what's showing that as, as a, what's, what's mounting that for me, and so that I can just pop it up, see directory, and get, and have it nice and easy. Okay, again, whether I leave this on or not depends on how I'm using the system. Okay, if this system is, you know, if I want to, I can turn off auto-disk mount between times when I'm using that functionality. Okay, or I can leave it in place. What else? DNS responder, MDNS responder, multicast DNS responder. So, okay, we talked about auto-disk mount, and if you wanted to turn off auto-disk mount, okay, you can basically just go into disks, into the disk script, and comment it out. Again, that's one of those things that's not host config accessible in 10.2.3. Okay. MDNS responder used for rendezvous. Okay, rendezvous, what's rendezvous do? Who knows what rendezvous does? I know you guys do. Here, anybody? Anybody? Yeah. Okay, automatic host discovery, it's basically his way of finding people to chat with, to do iChat. Okay, finding people who are on the local area land. I'm sorry, I can't hear you. Very nice for iTunes sharing. Anybody else have favorite things to do with rendezvous? I'm sorry? I didn't know about that one. What's hydro do? What's hydro do? Everyone can work on the document at the same time? They're just on the local area land? Wow. Okay. So as far as... as far as rendezvous goes, sounds like really useful functionality. I'm scared out of my wits having this on at DEF CON. So if you also are scared, thank you, if you also are scared, you can turn that off by commenting or deleting it out of MDNS responder. Again, this would be nice. This is stuff where we're going to hope that it's all going to be in host config later on. For now, we're just commenting it out. Okay. So like I said, to do a thorough audit, you'd read through all the start scripts and decide what to turn off. I do a more thorough audit in this article that I'm going to post up on my website probably come Monday. So in terms of where you go from here, we've gone through some of the scripts. In terms of where you go from here, the first thing I'm going to do is actually go and run netstat and get a list of what's listening on different ports. Okay. I'll use netstat to get a list of what's listening. I'll use LSOF to tell me what programs. Netstat gives me a list of listening ports. LSOF gives me, you know, for a given port, what's actually listening on it. Okay. So what I might do is I might go and use netstat and I see port 1033 is listening on local host. And if I see that, I'll run LSOF and it'll say net info D is listening on that port. And I'll say that's okay. I need that. That's fine. I need net info. I can't turn it off. Okay. That's fine with me. And the fact that it only listens on loopback makes it a little less dangerous anyway. Okay. UDP. If I'm going and doing a UDP audit, these are the ports that came up listening. Okay. 1033 is also net info. I can go through each port with LSOF. Okay. And I see there are different pieces of the operating system. And I can go and actually look at what each one is and decide whether I want to keep it or not. Okay. I'm keeping lookup D. I'm keeping net info D. I'm keeping Syslog. But why the heck is Syslog listening on the network? Okay. If I go and look at the man page for Syslog, and that's what we do time permitting, if I look at the man page for Syslog, Syslog says you have to have, you know, you have to have the minus T command line option to be listening on the network. And it says, hey, this is, you know, kind of an old, insecure thing and you're going to open a DOS attack. And so then what do I do? Well, I notice that this, that if I do a PS, Syslog isn't being run with minus T. If I look at the script, Syslog isn't being run with that option. So, I'm sorry, minus U. What do I do? I say, it says that it's listening on the port, but my, my, my man page, my start script doesn't indicate that it's listening on the port, that it should be, that it should be accepting remote logs. So, I'm sorry, what I do, I thought I had a slide on that. What I do is I fire off my, my, my, my Syslog client and just start firing off logs at the box. And I fire off logs at the box. And I fire off logs at the box. And I start firing them off from different IP addresses and seeing what happens. And I find, oh, hey, I can't get this thing to log, to log anything. Okay. It'd be nice if it didn't listen on the port, but it's going to. So, is there anything, is there anything you guys can think of that I can do about it if I'm still paranoid about this? IPFW. Exactly. So, I can make sure that IPFW is currently blocking all access to the port. Okay. What else? I find port 68 is locked. Okay. So, what else? Port 68, I find that's config d. Port 68, that's my DHCP client port. I need that there. That's okay. I might use IPFW to make sure that it only gets, I might use IPFW to make sure that it only gets communication from the known DHCP server on the network, otherwise I need it because the systems doing DHCP. I can also go static route and not worry about it. Okay. From there, what are my next steps? My next steps are doing a set Jack you- conhews uid audit. Doing a set guid audit. Dominic Okay. My next audit kron job obsession. Graphic area in here also look at DMA configurations, do a permissions audit. In terms of a set UIDR, these are the commands I'd use. And what I'm looking for, what I'm looking for are programs that let ordinary users and potentially every ordinary user on the system run as root. Am I really out of time? Okay, I'm out of time. So I'm going to show you the slides and stop. Okay, so there's my commands for a set UIDR audit. I'll look at cron jobs. Cron runs periodic, periodic runs a bunch of stuff out of the directories, etsy, periodic, daily, monthly, weekly. I'll go through and actually look at daemon configurations later on if I have time. Any daemons I actually still want to run, I'll make better configurations, read references on this. Some of them are on my website. Permissions audit. I'll actually go and look at the system and see what somebody could do in terms of world writable files and directories replacing data or replacing executables. Okay, there's commands to do that. Bastio Linux. Bastio Linux is an increasingly misnamed program that is a hardening script that'll actually go through and do some lockdown. You can do a much better job always by hand because you're a boatload smarter than a Perl script. But this might help you in terms of automation, in terms of getting a first start, in terms of doing this for lots of systems. Bastio Linux works on HPUX and OSX and 5Linux distros. I've got articles you might read on lockdown. There they are. And we're out of slides. Was this useful? Except for the people who are going to fillet me?