1 00:00:13,020 --> 00:00:20,660 Yeah. Please raise your hand if you're hung over. Thank you. Please raise your hand if 2 00:00:20,660 --> 00:00:28,920 you wish you were hung over. Okay, thanks. This is DEF CON, baby. Okay. So I'm going 3 00:00:28,920 --> 00:00:34,300 to talk to you about locking down OSX. I've got an OSX machine. I'm only projecting. I've got 4 00:00:34,300 --> 00:00:39,660 two laptops, but one of them is on both projectors. So we're going to primarily stay on 5 00:00:39,660 --> 00:00:46,020 the slides, and I'll demo as we have time and energy and desire. So you guys can indicate 6 00:00:46,020 --> 00:00:51,960 desire by shouting at me, yelling at me. Don't throw things, because I know you will. But 7 00:00:51,960 --> 00:00:58,520 I'll tell you about basically locking down OSX. I got a nice little OSX machine a while ago. 8 00:00:58,640 --> 00:00:58,900 It's a nice little OSX machine. It's a nice little OSX machine. It's a nice little OSX 9 00:00:58,900 --> 00:01:03,140 machine. And I started playing around with it and said, you know, it would really be nice to 10 00:01:03,140 --> 00:01:08,360 have a machine that might, you know, I don't know, run Word or something like that, or maybe 11 00:01:08,360 --> 00:01:12,640 just, you know, I could lend it to my girlfriend, and she'd like not break it. It'd still be 12 00:01:12,640 --> 00:01:17,260 easy to use, not the Linux box. But at the same time, wouldn't break itself Windows style, 13 00:01:17,380 --> 00:01:22,900 just, you know, crashing every six to 12 hours like clockwork. So I got one of these things and 14 00:01:22,900 --> 00:01:28,540 tried it out, and the first thing I did was locked it down, and you'll see basically my experience 15 00:01:28,540 --> 00:01:35,460 is in locking it down right here. Okay, so what I'm going to talk to you about is first auditing the 16 00:01:35,460 --> 00:01:40,380 operating system and then locking the sucker down, and I'll tell you about how we've made Bestio 17 00:01:40,380 --> 00:01:46,460 Linux do some of this automatically for you. Okay, so what do you get in one hour of lockdown? 18 00:01:46,700 --> 00:01:51,620 Well, you don't get something massively complete, but you do get something probably safe enough to 19 00:01:51,620 --> 00:01:55,820 bring to DEF CON, provided you don't want to, like, use it as a web server, like you want to use it 20 00:01:55,820 --> 00:01:58,520 as a laptop. Okay, so what are we going to do? We're going to lock it down. We're going to lock it 21 00:01:59,020 --> 00:02:06,620 down. Basically, in terms of quick lockdown pre-DEF CON, and I understand this is post-DEF CON, 22 00:02:06,840 --> 00:02:12,240 but, you know, you've still got a good six hours or so to get hacked here, what would you be doing? 23 00:02:12,380 --> 00:02:16,300 One is that you would stop somebody from coming and booting your laptop in a single user mode, 24 00:02:16,500 --> 00:02:20,000 starting out as root, changing all your passwords, copying all your data, and then deleting the 25 00:02:20,000 --> 00:02:25,800 drive if they feel like it. Okay, that's called boot security. The next thing you do is actually 26 00:02:25,800 --> 00:02:28,520 do what's called a daemon audit and a network daemon audit. That's where you're, you know, 27 00:02:28,540 --> 00:02:32,660 turning off, that's where you're turning off network daemons in general and programs in general 28 00:02:32,660 --> 00:02:37,520 that you're not using that could turn out to be vulnerable later on and get your laptop hacked. 29 00:02:37,900 --> 00:02:44,060 Okay, other things you might look at, I'll tell you about these if we've got time, set UID audit. 30 00:02:44,620 --> 00:02:47,940 That's where you're looking at the programs on the system that an ordinary user can run, 31 00:02:48,610 --> 00:02:53,100 where it runs as root, where it gives them root privilege for a specific operation. That's things 32 00:02:53,100 --> 00:02:58,480 like changing your password. We'll talk about cron jobs, all the shit that runs automatically, 33 00:02:58,540 --> 00:03:04,120 for you. And then actually talk about the last bit of stuff that we, you know, you don't have time 34 00:03:04,120 --> 00:03:08,320 for in one hour, which is actually going and taking daemons that are on the box, like a web server, 35 00:03:08,500 --> 00:03:13,460 like a DNS server, and going and configuring it for better security. That's what you do in a 36 00:03:13,460 --> 00:03:21,620 lockdown if you wanted to do something very complete and comprehensive. Okay, so OSX. OSX seems 37 00:03:21,620 --> 00:03:27,400 to kind of be a hodgepodge of things to me. I like it. It's useful. It feels like it's got this whole 38 00:03:27,400 --> 00:03:28,520 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 39 00:03:28,520 --> 00:03:34,260 BSD infrastructure. It's got this whole mock kernel going on. Basically, it feels like BSD 40 00:03:34,260 --> 00:03:39,800 Unix to me. On the other hand, it's got some weird Next stuff thrown in, and that seems to be 41 00:03:39,800 --> 00:03:45,180 because Apple bought Next and brought Steve Jobs, and he was like, hi, we made some stuff. Can we 42 00:03:45,180 --> 00:03:54,120 put it in, too? So you'll see that as we go through. Okay. The thing you need to understand, for 43 00:03:54,120 --> 00:03:58,500 the first part, in terms of how any kiddy here is, you know, is going to be able to do a lot of 44 00:03:58,520 --> 00:04:02,300 things. So if you leave them with your laptop for 30 seconds, it's rooting your laptop to understand 45 00:04:02,300 --> 00:04:08,880 how the boot process works. Okay. So basically, what goes on is you've got your machine and you turn 46 00:04:08,880 --> 00:04:15,980 it on, and you've got a bootloader. Okay. That's like your BIOS on a PC machine. Sorry. You've got 47 00:04:15,980 --> 00:04:24,600 a hardware loader. That's whatever. EEPROM here, BIOS. EEPROM on Sun. EEPROM here, BIOS on Intel 48 00:04:24,600 --> 00:04:28,500 machines. That starts a bootloader. That starts your kernel. And then you've got a bootloader. And 49 00:04:28,960 --> 00:04:35,300 your kernel on this thing is what's called your kernel's going to start. Your kernel's mock. And 50 00:04:35,300 --> 00:04:40,620 what mock starts is a process called mock init. Everyone know what an init is? Raise your hand if 51 00:04:40,620 --> 00:04:46,980 you know what an init is. Yes. Mostly. All the way. Okay. Cool. So mock init is this weird little 52 00:04:46,980 --> 00:04:50,380 process. We're all used to, like, the kernel starting an init and that just being it. Well, 53 00:04:50,560 --> 00:04:55,400 Apple's, like, making things a little weird. So the kernel starts mock init, and mock init actually 54 00:04:55,400 --> 00:04:58,500 goes and starts an init. And it's, like, the one ‑‑ it's, like, the one ‑‑ it's, like, the 55 00:04:58,520 --> 00:05:05,640 first one. Or at least it's number one. And all the other stuff on the system, like, gets started 56 00:05:05,640 --> 00:05:12,640 by an init. So the way that works here is init starts, runs RC ‑‑ runs a script called RC.boot 57 00:05:12,640 --> 00:05:17,860 and a script called RC. And then RC.boot is important for single user mode. We can take a 58 00:05:17,860 --> 00:05:23,260 look at it. RC actually goes and runs a program called system starter. And I'll show you that 59 00:05:23,260 --> 00:05:28,500 system starter is actually how ‑‑ system starter is ‑‑ OSX is kind of ‑‑ it's a 60 00:05:28,520 --> 00:05:35,180 standard RC script. It's, you know, it's the RC3, RC4, RC5 type stuff from SIS5 or, you know, 61 00:05:35,200 --> 00:05:43,920 standard RC scripts from DSD. Anyway, let's take a look at it. What I would do with my Apple 62 00:05:43,920 --> 00:05:48,840 laptop if it was up here and you wanted me to and we had lots of time would be I'd hold down 63 00:05:48,840 --> 00:05:54,460 that slide. In your slides, that little square box, that's an open Apple. Okay. If you take 64 00:05:54,460 --> 00:05:58,380 this system and it's turned off and you hold down open Apple S. 65 00:05:58,520 --> 00:06:03,460 When you turn it on, your system boots directly into single user mode. Okay. This is, you 66 00:06:03,460 --> 00:06:07,280 know, if you've forgotten your root password, this is number one way to get it. If you find 67 00:06:07,280 --> 00:06:12,280 somebody's OSX system sitting on a table, you know, maybe you're at root foo and somebody goes 68 00:06:12,280 --> 00:06:18,280 off and runs to the bathroom and is like, hey, watch my laptop. You're like, sure. Okay. Open 69 00:06:18,280 --> 00:06:24,360 Apple S. Boom. Single user mode. Change passwords. Create yourself an account. You know. Let 70 00:06:24,360 --> 00:06:28,500 the thing boot up normally. Your buddy gets back. It's probably all done in, yeah, two or three 71 00:06:28,500 --> 00:06:34,880 minutes or so. Okay. So this open Apple S thing, that's not as much fun as you'd think if 72 00:06:34,880 --> 00:06:39,380 you're the guy who actually went to the bathroom. So if you're the guy who went to the bathroom, 73 00:06:39,500 --> 00:06:44,780 what you'd want to do ahead of time was change this RC.boot script to require some kind of 74 00:06:44,780 --> 00:06:49,060 authentication before it just lets boot continue. By the way, if you think this is kind of like a 75 00:06:49,060 --> 00:06:53,040 weird little Apple thing, a lot of operating systems do this. Red Hat's been doing this for 76 00:06:53,040 --> 00:06:57,740 years. If you start up a machine and type Linux single, okay, you know, you're the LILO prompt, 77 00:06:58,500 --> 00:07:03,500 you type Linux single and boom, it drops you to single user mode. Same basic thing. Operating 78 00:07:03,500 --> 00:07:06,800 system vendor thinks this might be a useful way to handle those calls when somebody calls up and 79 00:07:06,800 --> 00:07:12,000 says, I lost my root password. What do I do? Can you all hear me back there? I'm a little 80 00:07:12,000 --> 00:07:23,500 hoarse. In the back, you can hear yes. Okay. Cool. So what can you do? There is, there is, for 81 00:07:23,500 --> 00:07:27,740 those of you who have got a machine in the room, something to test would be there is an etc tty's 82 00:07:28,500 --> 00:07:33,320 file. And in the etc tty's file, you can find the console line and change it from insecure to 83 00:07:33,320 --> 00:07:37,920 secure. And theoretically, from what the documentation says, that should fix this. It should 84 00:07:37,920 --> 00:07:43,880 make single user mode inaccessible by that method. On my build, that has not worked, and so I 85 00:07:43,880 --> 00:07:49,500 went Googling. And what did I find? I found somebody wrote this script called secure it. And 86 00:07:49,500 --> 00:07:56,260 what secure it does is you run this things install program, and it inserts a little thing into 87 00:07:56,260 --> 00:07:58,480 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. 88 00:07:58,500 --> 00:08:02,940 If there's a single user, if this is a single user boot, then run a program called password.pl, 89 00:08:03,080 --> 00:08:08,240 which is a Perl script. And that Perl script basically is just going to check a password. And 90 00:08:08,240 --> 00:08:13,100 if you've got the right password, if you've got the right password, then you're allowed through. 91 00:08:13,220 --> 00:08:20,540 And if you're not, it forces a reboot. Okay. So basically, the way password.pl works is when 92 00:08:20,540 --> 00:08:24,520 you install this, it asks you for a password. You give it a password. This should not be a root 93 00:08:24,520 --> 00:08:26,600 password. It should just be an independent password. 94 00:08:28,500 --> 00:08:32,740 It encrypts the password and stores it. And then whenever someone tries to boot in a single 95 00:08:32,740 --> 00:08:38,860 user mode, it asks for that boot password. Okay. Let's call it your secure it password. And so if 96 00:08:38,860 --> 00:08:46,720 you type the right one, you're in. And if you don't, it reboots. Okay. There's another thing 97 00:08:46,720 --> 00:08:52,020 you could do, and I really don't like this so much, but I did find this when I was Googling. You 98 00:08:52,020 --> 00:08:57,940 can actually replace your entire kernel with one that doesn't boot into single user mode at all. Okay. 99 00:08:58,500 --> 00:09:05,520 So if you haven't checked this out, my guess is it basically skips rc.boot entirely. Okay. Go for it if 100 00:09:05,520 --> 00:09:10,520 you want to. My problem is that, you know, I have to be assisted in sometimes, and having my first 101 00:09:10,520 --> 00:09:14,540 hardware failure come up and finding that single user mode is a little hard to get into, a little 102 00:09:14,540 --> 00:09:20,320 bit of a pain in the butt. So I don't know if, you know, I don't know if you want to eradicate 103 00:09:20,320 --> 00:09:24,900 single user mode entirely. If you're really paranoid mofo and this is your laptop and you're 104 00:09:24,900 --> 00:09:28,480 really concerned, maybe that's something you want to do. All right. All right. All right. All right. 105 00:09:28,480 --> 00:09:36,900 Any questions so far? Yeah. Is there any way to boot, to disable booting from CD? You think I 106 00:09:36,900 --> 00:09:50,360 planted him there. Hey, Steve. Gee, wow. Thank you. Okay. So the nice thing is that, okay, that 107 00:09:50,360 --> 00:09:54,060 single user mode, it's really great when you can just walk up to a machine, no CD in hand, 108 00:09:54,160 --> 00:09:58,180 nothing, no tools, nothing, and just grab root real quick while somebody runs off to the bathroom. 109 00:09:58,480 --> 00:10:02,520 It's really great if they're, like, really fast, okay? Although the way they put the bathrooms in 110 00:10:02,520 --> 00:10:07,900 Lexus Park, it's going to take them ten minutes to get out there and back. So supposing that you did 111 00:10:07,900 --> 00:10:13,180 have that ten minutes and you were carrying around an Apple boot CD in your pocket, it's kind 112 00:10:13,180 --> 00:10:17,320 of cool. You can take the CD, stick it in the drive, and what you do is you hold down the option 113 00:10:17,320 --> 00:10:22,340 key. You hold down the option key and turn the machine on. And what will happen is the Apple will 114 00:10:22,340 --> 00:10:25,960 come up. It'll take a little while, but the Apple will come up with a graphical menu. It'll show 115 00:10:25,960 --> 00:10:31,080 your hard disk. It'll show your CD-ROM. And if you've got any FireWire drives, if you've got any 116 00:10:31,080 --> 00:10:36,020 FireWire drives plugged in, including, say, an iPod, it'll actually show you that, be like, hey, 117 00:10:36,080 --> 00:10:41,980 which of these do you want to boot from, okay? So the deal is, one of the cool things is that if 118 00:10:41,980 --> 00:10:46,760 you do that with the normal, with the install media, okay, normally with install media, you have 119 00:10:46,760 --> 00:10:49,880 to have a clue, right? You, like, boot from install media, you have to go and remount the 120 00:10:49,880 --> 00:10:54,680 drives, read and write, go and, you know, look at the right password file, et cetera, change the 121 00:10:54,680 --> 00:10:55,320 password file. 122 00:10:55,960 --> 00:11:00,100 Et cetera. You maybe have to, maybe you'll cheroot into the, you'll cheroot into slash mount 123 00:11:00,100 --> 00:11:05,440 slash CD and change password from there, whatever. Here it's actually nice and easy. They actually 124 00:11:05,440 --> 00:11:10,380 include a password utility. So you can take, when you boot from CD, you can go up to this little 125 00:11:10,380 --> 00:11:14,800 nice little menu, and you can go to the password utility, and it'll be like, hi, which drive do you 126 00:11:14,800 --> 00:11:20,280 want to change the password on? And you're like, this one. And it says, which account? So it 127 00:11:20,280 --> 00:11:22,820 doesn't have to be a root account issue. It's like, which account would you like to change the 128 00:11:22,820 --> 00:11:25,940 password for? And you're like, no, that one. And it's like, okay, what's the password for? And 129 00:11:25,960 --> 00:11:31,720 you type it in. And congratulations, it's a new password. Now, you could also just boot from CD and, 130 00:11:31,820 --> 00:11:36,220 you know, do all the normal foo you normally do, but this kind of makes things nice and easy. Again, 131 00:11:36,420 --> 00:11:42,360 when you're looking for the 10 minute bathroom break attack, this is excellent. Okay, so what's 132 00:11:42,360 --> 00:11:47,560 the countermeasure? Well, the countermeasure is that the thing was, booting from CD is, you know, 133 00:11:47,580 --> 00:11:51,840 one of those, one of those pre-bootloader things. This is the firmware. So if the issue is that 134 00:11:51,840 --> 00:11:55,940 we were able to talk to the firmware and have it boot from CD or FireWire or whatever the hell, we're 135 00:11:55,960 --> 00:11:57,740 able to boot from CD or FireWire or whatever the hell, then maybe what we want to do is we want to 136 00:11:57,740 --> 00:12:02,600 stick a password on firmware. So what you can do is you can boot into firmware. You just, as you're 137 00:12:02,600 --> 00:12:06,060 turning the machine on, this starts getting easier and easier. And this starts getting harder and 138 00:12:06,060 --> 00:12:11,200 harder. You're holding down the option key, the Apple, the open Apple key, and O F for open 139 00:12:11,200 --> 00:12:15,780 firmware. Okay. And then once that boots up, you get a prompt. And at that prompt, you type 140 00:12:15,780 --> 00:12:20,640 password and it says, hey, what's your password? And you set a boot password. This could be the 141 00:12:20,640 --> 00:12:24,800 same one you use for secure it. If you're like me, you probably use yet another password here, 142 00:12:24,880 --> 00:12:25,940 just in case something goes wrong. And then once that's done, you're able to boot from CD or FireWire 143 00:12:25,940 --> 00:12:28,500 or ScriptureVisual. Okay. And when somebody gets root access on the system and can read secure 144 00:12:28,500 --> 00:12:33,640 its file or whatever, I don't know. Okay. Type in a password. You typed in a password for the 145 00:12:33,640 --> 00:12:40,060 boot loader. And now you type set n security mode command. Okay. What command means is that 146 00:12:40,060 --> 00:12:44,280 allow the system to boot normally unless they want to boot from alternate media, and if they 147 00:12:44,280 --> 00:12:49,840 want to boot from alternate media, require a password. Okay. On the other hand, if you want, 148 00:12:49,900 --> 00:12:53,800 you can also, instead of command, you can write full. And what that means is don't freaking bo 149 00:12:53,800 --> 00:12:55,920 t unless they know the password. Don't boot from it the wrong trce, doesn't matter if it's 150 00:12:55,920 --> 00:13:03,900 anything. Just don't boot. Okay. How many people have set this on their Sun boxes? Full? Full? Who 151 00:13:03,900 --> 00:13:07,160 set full? Okay. Of the people raising their hands, there aren't that many people in the room who 152 00:13:07,160 --> 00:13:11,460 raised their hands. Has anybody forgotten both the root password and the EEPROM password at the 153 00:13:11,460 --> 00:13:19,360 same time? Anybody? No one's going to admit to that, huh? You know, if you go on eBay, you will 154 00:13:19,360 --> 00:13:24,780 often find a very steady trade in replacement EEPROMs for Suns, because if you forget both 155 00:13:24,780 --> 00:13:31,120 the root password and the EEPROM password, you know, you might be in a, and you've set it to 156 00:13:31,120 --> 00:13:34,980 full, so it won't even boot to a hard drive without this. You're quite possibly going to be 157 00:13:34,980 --> 00:13:38,300 in the situation where you need to replace the EEPROM. People have been doing this for years. 158 00:13:38,460 --> 00:13:44,060 eBay's selling tons of these. Okay. Whatever. When you're done with this set end, either full or 159 00:13:44,060 --> 00:13:48,760 command, type reset all, you reboot the system. Congratulations. Nobody gets the disk without 160 00:13:48,760 --> 00:13:54,520 getting past the password. Now, the next question is, well, Jay, what's the next attack? What's 161 00:13:54,520 --> 00:13:54,760 the next attack? What's the next attack? What's the next attack? What's the next attack? 162 00:13:54,780 --> 00:13:58,440 What's the next attack on the boot process? You know, can you get past this? And my answer is, 163 00:13:58,480 --> 00:14:04,320 eh, I don't know. Okay. And you say, is he a lamer? And I'm like, yeah, I'm a lamer. But no, 164 00:14:04,320 --> 00:14:08,580 no, no. It's, it's, the issue is, some of you are like, wait a second, how come there has to be 165 00:14:08,580 --> 00:14:12,540 an attack? And it's like, well, there always will be, right? There'll always be another way. 166 00:14:12,660 --> 00:14:17,900 There'll always be potentially another way to, you know, violate the boot process and grab root. 167 00:14:18,000 --> 00:14:22,160 That's just, that's just part of operating system security. There's attacks, there's defenses, 168 00:14:22,260 --> 00:14:24,660 there's attacks, there's defenses, and somebody freaking clever is coming, 169 00:14:24,780 --> 00:14:29,120 up with attacks. So when I hear about the next one, maybe I'll come up with a defense or someone 170 00:14:29,120 --> 00:14:36,220 else will come up with a defense. What else? What else makes, what else makes apples easier, 171 00:14:36,280 --> 00:14:52,720 hard to break into? Yeah. Question over there. Sweet. Okay. We have a new, we have a new, 172 00:14:52,720 --> 00:14:54,460 we have a new attack. Okay. 173 00:14:54,780 --> 00:15:01,040 I am told by my colleague over there with the nice, shiny laptop that you can, you can change the open 174 00:15:01,040 --> 00:15:07,120 firmware password if you just pop open the machine, pop open, pop open the machine, add in more RAM, 175 00:15:07,220 --> 00:15:11,640 pull out RAM. If you change the amount of RAM, you can change the open firmware password. That sucks. 176 00:15:18,960 --> 00:15:19,840 Rearrange the RAM. 177 00:15:27,980 --> 00:15:44,280 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. 178 00:15:48,540 --> 00:15:53,420 Ask these guys. Does this include taking the RAM out and popping it back in? My guess is no, but ask these guys. 179 00:15:54,780 --> 00:15:55,180 Anybody? 180 00:15:59,480 --> 00:16:00,680 I'll go over here first. 181 00:16:01,700 --> 00:16:05,040 No, you have to move the RAM. Question. Yeah. 182 00:16:09,600 --> 00:16:14,240 Anybody know this? Are there any, are there any user space tools for modifying open firmware while booted? 183 00:16:15,160 --> 00:16:21,560 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? 184 00:16:23,140 --> 00:16:24,200 Now, have you been able to find? 185 00:16:27,360 --> 00:16:29,560 Right. You can set the password from user space tools. 186 00:16:32,040 --> 00:16:33,720 Okay. So, no. 187 00:16:34,680 --> 00:16:37,160 Okay, so what else can you do? What else? 188 00:16:39,500 --> 00:16:47,660 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. 189 00:16:47,880 --> 00:16:52,660 You know, I like, I like started up, I turned the machine on and asked me for a first user, a first password. 190 00:16:53,580 --> 00:16:54,740 What did it do? It was like, oh. 191 00:16:54,780 --> 00:16:58,900 okay, cool. And now whenever I turn the machine on, it auto-logs in for me. And that's kind of 192 00:16:58,900 --> 00:17:02,660 nice. But, you know, again, one of those things where it's like, if you leave this thing turned 193 00:17:02,660 --> 00:17:07,660 on, you lock your screen, you step away, somebody walks up, turns the machine off, turns it back on, 194 00:17:07,720 --> 00:17:14,840 it comes up, logs directly in as you. That was an easy screensaver hack. So in terms of turning 195 00:17:14,840 --> 00:17:20,080 that back off, in terms of turning auto-logging off if you've never turned it off, you can 196 00:17:20,080 --> 00:17:24,740 actually do that with a GUI. You just go to system preferences, accounts, users, and then 197 00:17:24,740 --> 00:17:30,800 you've got a little checkbox that says log in automatically as user, and you can specify user. 198 00:17:30,960 --> 00:17:37,980 So if you just turn that off, your auto-logging is toast, which is good. Okay. Restart and 199 00:17:37,980 --> 00:17:44,580 shutdown. If you're at a log-in prompt, if you're at the graphical log-in thing, okay, this thing 200 00:17:44,580 --> 00:17:48,440 will let you, it'll let you cleanly shut down the system and start it back up. Some people think 201 00:17:48,440 --> 00:17:50,060 of that as, some people think of that as, you know, like, you know, like, you know, like, you 202 00:17:50,060 --> 00:17:54,540 know, like, there's a weakness, some people don't. Okay. So if you want to change that, system 203 00:17:54,540 --> 00:18:00,560 preferences, accounts, log-in options, and you can click on hide the restart and shutdown buttons. 204 00:18:02,060 --> 00:18:04,900 Okay. Additionally, there's another way to do this. You can change this in this 205 00:18:04,900 --> 00:18:11,040 etc.tuis file. You find the console line, and you add in the parameter power off disabled, yes. 206 00:18:15,120 --> 00:18:20,040 Okay. So do an okay on time. Okay. So in terms of, you know, you can change the 207 00:18:20,060 --> 00:18:20,220 settings, you can change the time, you can change the time, you can change the time of code. 208 00:18:20,220 --> 00:18:21,280 So you can use this. Okay. So what I've found is that, you know, in terms of, the next thing, 209 00:18:21,340 --> 00:18:25,220 the next thing, that's basically boot security. That's the quickie boot security audit. The next 210 00:18:25,220 --> 00:18:28,960 thing to do is to take a look at other programs that are running on the system and then also 211 00:18:28,960 --> 00:18:32,120 network daemons that are running on the system. And the network daemons are really what's most 212 00:18:32,120 --> 00:18:36,860 important to me because I want to have this system not listening on the network quite so much. 213 00:18:37,740 --> 00:18:43,720 Okay. So what I've got is that remember, we had, we had the kernel starting machinit. Machinit 214 00:18:43,720 --> 00:18:50,040 started init, init started rc.boot, and rc, and rc is normally what we think of as the network 215 00:18:50,040 --> 00:18:55,520 you know, as the script that's going to start everything else, okay, parent isn't it, but 216 00:18:56,160 --> 00:19:05,420 rc runs rc.com, and it's going to run rc.com to do some general stuff, and also, importantly 217 00:19:05,420 --> 00:19:11,440 to us, to host a file called, I mean, to source a file called etc host config, okay, and then 218 00:19:11,440 --> 00:19:15,920 what rc does is it runs system starter, and system starter is kind of the replacement 219 00:19:15,920 --> 00:19:23,500 here for the bsd and sys5 normal boot methods, and I'll show you that. What system starter 220 00:19:23,500 --> 00:19:28,300 does, and this kind of, this is, you know, this thing's very bsd, but system starter 221 00:19:28,300 --> 00:19:32,900 feels sys5 to me, what system starter does is it looks through two directories, and let's 222 00:19:32,900 --> 00:19:35,400 just look at the, we're only going to look at the first one here, because the second 223 00:19:35,400 --> 00:19:39,600 one is something you're supposed to populate, and that first directory has slash system 224 00:19:39,600 --> 00:19:44,140 slash library slash startup items, and inside that directory, inside that startup items 225 00:19:44,140 --> 00:19:45,900 directory, there'll be a script called system starter, and inside that directory, there'll 226 00:19:45,900 --> 00:19:50,340 be a script called, you know, say, it'll be a script called, you know, apache slash 227 00:19:50,340 --> 00:19:54,400 apache, I mean, there'll be a directory called apache, and in that directory, there'll be 228 00:19:54,400 --> 00:19:59,180 a script called apache, and what system starter is doing is it's looking at all those sub 229 00:19:59,840 --> 00:20:03,240 directories for scripts of the same name, and then it's going to run all of them, and 230 00:20:03,240 --> 00:20:07,540 actually, you know, sys5, they all got run in a numerical order, bsd, they all got run 231 00:20:07,540 --> 00:20:12,040 in the order that they were in a long script, okay, here, system starter actually determines 232 00:20:12,040 --> 00:20:15,700 the order dynamically, and it's kind of cool, okay. 233 00:20:15,900 --> 00:20:21,900 So, basically, if we're looking at system library startup items, apache, apache, that 234 00:20:21,900 --> 00:20:26,940 directory apache has some other files in it, and one of those files is startup parameters 235 00:20:26,940 --> 00:20:34,280 dot plist, and what startup parameters dot plist is, is it's a bunch of stuff, let me 236 00:20:34,280 --> 00:20:40,160 see if I've got a slide on this, yeah, I do, okay, what startup parameters dot plist 237 00:20:40,160 --> 00:20:45,140 dot has is a bunch of stuff that says, that helps it, helps systems sort of decide what 238 00:20:45,140 --> 00:20:45,880 order to run this stuff. 239 00:20:45,900 --> 00:20:51,600 Okay, so we've got a description, apache web server, we've got provides and requires 240 00:20:51,600 --> 00:20:58,440 and uses, provides is, you know, what's going to be, what service, you know, what thing 241 00:20:58,440 --> 00:21:03,520 is going to be there for the other things to require and use after we start, after this 242 00:21:03,520 --> 00:21:09,800 gets started, requires is what's got to be running before this will go, okay, uses things 243 00:21:09,800 --> 00:21:14,720 that this uses, that might be useful to be on, okay. 244 00:21:14,720 --> 00:21:21,180 Order preference, order preference can be none, it can be first, it can be last, it 245 00:21:21,180 --> 00:21:26,480 can be early, I think the other one's late, okay, and what that says is, this is roughly 246 00:21:26,480 --> 00:21:28,080 when I'd like to go, I'd like to go first. 247 00:21:28,400 --> 00:21:32,420 System sort of doesn't have to actually obey any of that order preference stuff, okay, 248 00:21:32,460 --> 00:21:34,060 it, it can at its own option. 249 00:21:34,740 --> 00:21:38,000 So when you're creating scripts of your own, this is kind of the way you're doing this, 250 00:21:38,120 --> 00:21:41,780 so in terms of what order things get run on, that's chosen, that's basically dynamically 251 00:21:41,780 --> 00:21:42,820 generated on each boot. 252 00:21:44,920 --> 00:21:50,920 Okay, so if you want to start turning this off, like we said before, rc.com gets run 253 00:21:50,920 --> 00:21:56,080 by every, by basically every single system starter script, and that, it does that, each 254 00:21:56,080 --> 00:22:00,140 of the system starter scripts do that, so that they can source, so that they can source 255 00:22:00,140 --> 00:22:06,220 host config, so if you want to turn off daemons, you can actually go and hack on the scripts 256 00:22:06,220 --> 00:22:10,100 yourself, but the preferable way, of course, vendor supported would be to go and modify 257 00:22:10,100 --> 00:22:10,900 etsy host config. 258 00:22:11,300 --> 00:22:14,280 Most of the time we can do that, some of the stuff we want to turn off, we can't turn 259 00:22:14,280 --> 00:22:14,700 off through. 260 00:22:14,720 --> 00:22:22,540 Okay, so if we look at, let me see if I've got a slide with this script listed, or whether 261 00:22:22,540 --> 00:22:24,740 this was something I was really hoping we had access for. 262 00:22:26,020 --> 00:22:30,900 Okay, if we look at system library startup items, nfs, nfs, that's one of the scripts, 263 00:22:32,520 --> 00:22:37,920 it starts, one of the programs that gets started is called auto-mount, okay, auto, auto-mount 264 00:22:37,920 --> 00:22:42,360 runs, auto-mount's going to run by default, okay, but you can deactivate it by turning 265 00:22:42,780 --> 00:22:44,700 off auto-mount, by setting auto-mount to equal. 266 00:22:46,900 --> 00:22:52,060 Okay, auto-mount is just the, it's just, it's an nfs, it's an nfs client daemon, and 267 00:22:52,060 --> 00:22:57,520 you use it if you want to have nfs, if you want to have given directories mounted remotely 268 00:22:57,520 --> 00:23:02,320 from nfs servers as your users use them, and unmounted whenever they've been idle 269 00:23:02,320 --> 00:23:07,260 for a while, okay, so if we're an nfs client, we're going to, we might want to keep this 270 00:23:07,260 --> 00:23:12,020 on, if we're not an nfs client, I want it off, right, if we are an nfs client, I might 271 00:23:12,020 --> 00:23:13,800 use this, I might not, I have to decide. 272 00:23:14,720 --> 00:23:17,900 But in terms of locking it down, that's a good part of what locking down a system is, 273 00:23:17,980 --> 00:23:21,440 is deciding what the system is being used for, and adjusting it accordingly. 274 00:23:24,020 --> 00:23:33,240 Okay, so, what else, nfs, we've got this script, nfs, nfs, the nfs script, it starts, it starts 275 00:23:33,240 --> 00:23:37,920 the auto-mount, it also starts nfsd and mountd, but it only starts them if you've actually 276 00:23:37,920 --> 00:23:41,380 got, if you've actually got stuff listed in etc exports, if you're actually exporting 277 00:23:41,380 --> 00:23:42,100 directories. 278 00:23:42,200 --> 00:23:43,840 That's kind of cool, it's a pretty smart script. 279 00:23:44,260 --> 00:23:44,700 Okay. 280 00:23:44,720 --> 00:23:51,400 So, if you've got stuff in etc exports, or if you're actually, if neto info, which we'll 281 00:23:51,400 --> 00:23:55,840 talk about later, says that you've got things, says that you've got things that you're exporting 282 00:23:55,840 --> 00:23:59,660 and sharing with other systems, then these things run, if they don't, they don't run. 283 00:24:00,940 --> 00:24:05,180 The other weird thing though, is there's another program that gets run by this script called 284 00:24:05,180 --> 00:24:11,500 nfs iod, and basically the nfs iod daemon runs whether you like it or not, it runs whether 285 00:24:11,500 --> 00:24:12,700 you're an nfs client or not. 286 00:24:12,880 --> 00:24:14,340 So, you can turn off auto-mount. 287 00:24:14,720 --> 00:24:19,780 And you can, you know, you can have nothing, you can have no nfs to share out, but the 288 00:24:20,400 --> 00:24:25,620 nfs iod is a, is an nfs client daemon, okay, and that runs no matter what. 289 00:24:26,600 --> 00:24:30,700 There's no way to really turn that off through etsy host config, okay. 290 00:24:32,520 --> 00:24:38,140 So, what we can do, what I do with that particular one, is you actually go into the script and 291 00:24:38,140 --> 00:24:41,160 you just comment the sucker out, okay. 292 00:24:41,240 --> 00:24:44,700 Does that, now, now there's an obvious question, if I'm going to go and, if I'm going to go 293 00:24:44,720 --> 00:24:47,980 and start modifying start scripts, what's my obvious question? 294 00:24:49,840 --> 00:24:50,600 Is that cool? 295 00:24:52,240 --> 00:24:54,660 Anybody, system in the room, what's that? 296 00:24:56,940 --> 00:24:58,120 What happens when I upgrade? 297 00:24:58,400 --> 00:24:59,520 Okay, what happens when I upgrade? 298 00:24:59,760 --> 00:25:02,560 The other thing I was looking for is what happens when I patch, okay. 299 00:25:02,820 --> 00:25:07,080 So, when I patch, when I upgrade, there's some very good chance the vendor is going 300 00:25:07,080 --> 00:25:13,120 to go and smack, you know, new or updated or the original boot scripts right back on 301 00:25:13,120 --> 00:25:13,520 the system. 302 00:25:14,720 --> 00:25:17,160 If they do, well, then I'm kind of, you know, I'm kind of, yes. 303 00:25:21,220 --> 00:25:26,320 Nfs daemon is off by default, nfs client daemon is on, nfs iod, that's on, right? 304 00:25:29,120 --> 00:25:29,620 I'm sorry? 305 00:25:31,140 --> 00:25:40,680 Auto mounter is, auto disk mount is started by default, I know that, hold on, let me check 306 00:25:40,680 --> 00:25:41,120 my system. 307 00:25:41,260 --> 00:25:41,800 You could be right. 308 00:25:41,940 --> 00:25:42,460 Let's check. 309 00:25:43,840 --> 00:25:44,200 Okay. 310 00:26:07,500 --> 00:26:08,020 . 311 00:26:09,300 --> 00:26:14,700 So, on my straight build, I've got auto mount, I've got auto mount set on my system. 312 00:26:14,720 --> 00:26:19,400 that's a yes by default so it gets started it might close up like we can go look at the script 313 00:26:50,900 --> 00:26:57,020 this is this is i can tell you this is a default install because i rebuilt it last night i can't 314 00:27:03,360 --> 00:27:04,300 10-2-3 315 00:27:06,940 --> 00:27:08,460 10-2-3 i'm sorry 316 00:27:11,560 --> 00:27:12,240 i'm sorry 317 00:27:17,740 --> 00:27:24,100 no 10-3 right which which which is the 10-3 is and i've looked at 10-3 and actually 318 00:27:24,100 --> 00:27:28,800 i've got i have i got an install of 10-3 on a system back at home 319 00:27:30,580 --> 00:27:37,480 this has changed in 10-2-4 okay so your fair speaker has his default cd 320 00:27:37,480 --> 00:27:41,660 and this is 10-2-3 this is what apple sold me 321 00:27:43,580 --> 00:27:44,480 and i didn't 322 00:27:44,480 --> 00:27:44,580 me 323 00:27:44,720 --> 00:27:50,260 updated. No, I didn't immediately update it because I was looking for issues. No, I didn't 324 00:27:50,260 --> 00:28:03,880 immediately update it to 10.2.4. Okay. Are you guys Apple? Okay, just checking. Who shouted 325 00:28:03,880 --> 00:28:19,520 what? I didn't hear. L-S-O-F minus I. Yeah, the gentlemen are saying that quite possibly, are you 326 00:28:19,520 --> 00:28:27,240 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 327 00:28:27,240 --> 00:28:28,160 have anything listening there? 328 00:28:33,880 --> 00:28:39,700 Okay, I'm not going to argue this if I'm completely and totally wrong. Slam me after the talk and, 329 00:28:39,840 --> 00:28:48,380 you know, heck out. But I've got a 50-minute talk that I've got 22 minutes left of. Okay, yeah. If 330 00:28:48,380 --> 00:28:59,260 I'm an ignorant slut, you can call me on it. Okay, so on my reference 10.2.3 system, on a fresh 331 00:28:59,260 --> 00:29:03,860 install, NFS IOD starts whether I like it or not. I get multiple instances I remember. I get 332 00:29:03,880 --> 00:29:09,320 multiple instances I remember that. So, I can edit the script to turn this off, but it's not 333 00:29:09,320 --> 00:29:14,780 accessible or it wasn't accessible. Let's stick with, I'll try to stick with past tense, guys. Okay, it 334 00:29:14,780 --> 00:29:20,280 wasn't accessible via host config. Okay, I am not busting on the operating system here. I'm just 335 00:29:20,280 --> 00:29:24,100 telling you how to harden it. If they're going to come out of the gate perfect for me, I mean 336 00:29:24,100 --> 00:29:30,880 completely perfect for me, that's great. Okay, some of them do. But, you know, I don't expect it to. I 337 00:29:30,880 --> 00:29:33,600 expect to have to do some amount of configuration on the system. 338 00:29:35,740 --> 00:29:40,920 I don't know. I have stuff that I still do to OpenBSD, you know, and they've got a pretty good 339 00:29:40,920 --> 00:29:47,640 attitude about this stuff. Okay. If you really wanted to do a thorough audit, I mean, what I 340 00:29:47,640 --> 00:29:51,860 encourage, if you really want to do a thorough audit, you should read your boot script start to 341 00:29:51,860 --> 00:29:55,480 finish. I mean, you should just go through and basically trace what the system is starting, when 342 00:29:55,480 --> 00:29:59,600 it's starting, if it's starting, et cetera. Okay. If you want to do a thorough audit, that's 343 00:29:59,600 --> 00:30:03,860 what you do. Okay. What we're going to do is go and change, that's the host config. I'm going to go 344 00:30:03,880 --> 00:30:08,600 to the host config, turn stuff off that we want off, and then go and look at, you know, if we wanted 345 00:30:08,600 --> 00:30:15,580 to reboot, whatever, look at what's still running at that point, and go and find out how that got 346 00:30:15,580 --> 00:30:21,340 started and turn that off. Okay. That's kind of the applied and quick audit. Okay. If I look at 347 00:30:21,340 --> 00:30:27,940 this file, what do I have that's on? Auto mounters. The auto mounter's on by default in 10.2.3. 348 00:30:28,220 --> 00:30:33,860 Okay. I can turn that off. What else is on? Okay. Well, I just want to, I'll just show you what 349 00:30:33,880 --> 00:30:39,240 we've got CUPS on. We've got IPv6 on. We can turn that off. Net info server set to automatic. RPC 350 00:30:39,240 --> 00:30:46,080 server set to automatic. Time sync is set to yes. Okay. So we can look at each of those. So the 351 00:30:46,080 --> 00:30:50,220 first thing is we know we can set auto mounter to no. Okay. We know we can set auto mounter to 352 00:30:50,220 --> 00:30:55,940 no if we're not using that. Okay. What else? Well, we've got a variable called CUPS, and what 353 00:30:55,940 --> 00:31:00,280 CUPS does is it's actually controlling whether printing services, printing services runs CUPSD by 354 00:31:00,280 --> 00:31:01,900 default or not. Okay. 355 00:31:02,840 --> 00:31:03,820 If we are 356 00:31:03,880 --> 00:31:07,660 not printing from this system, if we're not ever, you know, if this is, if this is a machine that's 357 00:31:07,660 --> 00:31:12,600 serving as a little web server, you know, I know this is a laptop, but suppose, suppose for a 358 00:31:12,600 --> 00:31:16,020 second it's a little machine that's serving as a web server in my dorm room, you know, it's not 359 00:31:16,020 --> 00:31:20,480 doing anything else. I might turn off printing. If I want to turn off printing, that's easy 360 00:31:20,480 --> 00:31:25,380 enough. I can change the CUPS variable. Okay. I can run that script. I can run the print, 361 00:31:25,380 --> 00:31:31,580 printing services, printing services with stop. Okay. And that'll stop. If I want, I can, what I 362 00:31:31,580 --> 00:31:33,740 really should do to make sure that it's really going to be off on the next 363 00:31:33,880 --> 00:31:39,080 boot is I should change that variable, and I should pass it restart so that it stops, or I can pass it 364 00:31:39,080 --> 00:31:44,680 stop, make sure it's off, then run start to make sure that when I, when the script gets started that 365 00:31:45,200 --> 00:31:54,160 CUPSD doesn't actually run. And that's what I'd say is the safest thing to do here. Okay. So I've 366 00:31:54,160 --> 00:32:00,320 got a typo on this slide, updated slides on the web, on the, on the DEF CON website. Net info 367 00:32:00,320 --> 00:32:03,860 server is another variable, and I don't remember the script, but I'm going to go ahead and type it. 368 00:32:03,860 --> 00:32:09,600 I don't remember the script name that it's actually looking at. But basically controls whether NI, 369 00:32:09,780 --> 00:32:16,940 basically this, net info server is going to control whether NI bind D or net, or net info D gets 370 00:32:16,940 --> 00:32:24,240 started. Okay. And if it's set to automatic, it starts NI bind D if I actually need to, if I 371 00:32:24,240 --> 00:32:29,020 actually need to offer net, if I actually need to get net info information off the network. Okay. 372 00:32:29,080 --> 00:32:33,840 And starts net info D if I don't. Okay. If you've got an OSX system, if you've got an OSX system, 373 00:32:33,860 --> 00:32:38,600 to my knowledge, what you're doing is all your password information, your shadow information, 374 00:32:39,060 --> 00:32:44,460 exports, et cetera, this is all maintained through net info. Okay. I don't know tons about net info. 375 00:32:44,640 --> 00:32:50,580 I know it came from Next. I know it's a useful thing. I know it smells like NIS to me. I know 376 00:32:50,580 --> 00:33:00,920 that my system basically requires it. Okay. I can't turn it off. What else? Time sync. Okay. That 377 00:33:00,920 --> 00:33:03,840 time sync variable. It controls whether this system runs or not. Okay. And it's going to control whether 378 00:33:04,680 --> 00:33:12,400 this system runs NTP. Okay. And whether it's actually updating time very precisely. Okay. You 379 00:33:12,400 --> 00:33:15,920 might turn this off if you're really paranoid, if you're running around a hacker conference, 380 00:33:16,100 --> 00:33:21,820 whatever. On the other hand, if you're, you know, if you're looking at IDS logs and firewall logs 381 00:33:21,820 --> 00:33:25,300 and machines that have been broken into and you want to correlate all the information you got out 382 00:33:25,300 --> 00:33:31,720 of that, okay, or even, you know, in the case of a penetration, or even you just want to see, hey, 383 00:33:31,860 --> 00:33:33,840 one of the, it looks like one of the servers is dead. You want to see, hey, one of the servers is 384 00:33:33,860 --> 00:33:38,060 down and see what time an event happened and see that multiple logs in different places, you 385 00:33:38,060 --> 00:33:42,460 really may very much want time sync and you may want time, you may want your time synchronized very 386 00:33:42,460 --> 00:33:48,400 closely. So it's kind of your call. If I'm running around DEF CON, you know, I probably shut 387 00:33:48,400 --> 00:33:53,420 this off. If I'm not, you know, if I'm, if I'm in my normal operational environment, I'd 388 00:33:53,420 --> 00:33:59,760 probably leave it on. It's all depending on your paranoia. Okay. So if I'm going through and as 389 00:33:59,760 --> 00:34:03,600 I'm shutting these down, I can either do one of two things. I can do, I can go and run the 390 00:34:03,860 --> 00:34:09,840 app scripts or I can reboot the system. Once I'm done, once I'm done with that, what I want to do 391 00:34:09,840 --> 00:34:15,540 is start this thing back up and see what's left. Okay. And I can run PS and look at all the 392 00:34:15,540 --> 00:34:19,740 processes that are left and start deciding whether I want them or not. Okay. The first one 393 00:34:19,740 --> 00:34:25,320 that caught my eye when I looked at a PS listing on a 10.2.3 system and this will not show up, 394 00:34:25,460 --> 00:34:33,840 10.2.4, it went away, right? 10.2.4 or 10.3? They stopped INETD listening. Okay. That's 395 00:34:33,840 --> 00:34:45,440 cool. Debating that? Still listening. Okay. Well, so INETD, if we look at the IP services 396 00:34:45,440 --> 00:34:52,140 script, IP services starts both INETD and XINETD. Okay. XINETD and INETD, XINETD is a 397 00:34:52,140 --> 00:34:56,820 replacement for INETD. They can both run at the same time on a system as long as they listen on 398 00:34:56,820 --> 00:35:03,660 separate ports. So Apple by default has a really nice default here. INETD has got every single 399 00:35:03,840 --> 00:35:07,700 line, every single line commented out. If you grep that file for non commented lines, I 400 00:35:07,700 --> 00:35:12,220 don't think you will ever get any blank lines. I think it is actually a perfect file, okay. But 401 00:35:12,220 --> 00:35:16,480 there's nothing in INETD's configuration file that everything in XINETD is supposed to be 402 00:35:16,480 --> 00:35:21,900 listened for. That's all turned off by default, too. It turns out that XINETD if it has nothing 403 00:35:21,900 --> 00:35:28,540 to run, it immediately exits. INETD if it has nothing to run, it, you know, keeps running but 404 00:35:28,540 --> 00:35:33,420 it is actually not listening on any ports. So, it is not that INETD is listening, it is just 405 00:35:33,420 --> 00:35:33,820 that it says it's listening to me now and I've put anything else in there. Is that a problem? Oh, 406 00:35:33,820 --> 00:35:40,180 kind of running, taking up a couple cycles here and there. Okay. So this isn't, again, 407 00:35:40,280 --> 00:35:44,680 something that I can control through host config. So the best thing I can think of as far as INETD 408 00:35:44,680 --> 00:35:51,200 goes, sorry, this is our slide. The best thing I can do as far as INETD goes is to maybe write 409 00:35:51,200 --> 00:35:55,300 some shellcode. And that shellcode that's at the bottom of there, it's not the most, you know, 410 00:35:55,360 --> 00:36:00,560 it's not, you could do something that was a lot smarter than this. Okay. But what I've done is 411 00:36:00,560 --> 00:36:03,980 basically, you know, you could wrap it in some shellcode so that INETD only runs if there's 412 00:36:03,980 --> 00:36:08,540 something in the file. Okay. That's a decent thing to do. If you know that you're going to 413 00:36:08,540 --> 00:36:13,600 be admitting this system and, you know, you just want to, if you want to, what I would do is, you 414 00:36:13,600 --> 00:36:21,600 know, you could comment INETD out entirely and turn it back on if you want to. You know, you could 415 00:36:21,600 --> 00:36:26,900 put an exit, you could put an exit at the top of the script. Again, did we ever solve the question 416 00:36:26,900 --> 00:36:29,640 of what we were going to do if our, did we ever solve the question of what we were going to do 417 00:36:29,640 --> 00:36:30,540 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. 418 00:36:36,940 --> 00:36:45,600 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 419 00:36:45,600 --> 00:36:48,180 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 420 00:36:48,180 --> 00:36:48,660 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 421 00:36:48,660 --> 00:36:49,200 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. 422 00:36:49,200 --> 00:36:51,200 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. 423 00:36:51,480 --> 00:37:00,360 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 424 00:37:00,360 --> 00:37:06,840 you apply patches that will go and make your hand changes again. I would definitely try 425 00:37:06,840 --> 00:37:11,220 to automate this. That's the best thing that I can think of. If you're using something 426 00:37:11,220 --> 00:37:16,720 at your site already, like CFEngine or some other solution, you can use that. Some kind 427 00:37:16,720 --> 00:37:22,300 of automation that brings you back after patches. If anybody else has any easy solutions for 428 00:37:22,300 --> 00:37:43,060 this, let me know. What's that in the back? What's that? Binary is replaced on the patch. 429 00:37:43,280 --> 00:37:48,640 What if the binary is replaced on the patch? Good point. So the installer will overwrite 430 00:37:48,640 --> 00:37:50,080 your binary. I mean, it's, you know. 431 00:37:52,440 --> 00:37:52,980 What's that? 432 00:37:59,100 --> 00:37:59,820 S-change. 433 00:38:02,400 --> 00:38:06,860 Yeah, it's just like an immutable bit or a locked bit. Yeah. So S-change bit. How does 434 00:38:06,860 --> 00:38:12,240 my installer react to that? Okay, so we don't know. 435 00:38:14,440 --> 00:38:21,240 Okay, x-initd.com was empty of anything. If we want to look at x-initd and see the same 436 00:38:21,240 --> 00:38:22,280 thing, we're going to have to look at x-initd.com. 437 00:38:22,300 --> 00:38:28,040 We just look at, this is a sample x-initd configuration file. If you look at them all, they all have 438 00:38:28,040 --> 00:38:31,780 a disable line, and the disable line says yes. We know in x-initd.com, if every line's 439 00:38:31,780 --> 00:38:36,180 commented out, nothing's going to get listened on. With x-initd, we're looking for disable 440 00:38:36,180 --> 00:38:40,720 lines. If there's no disable line, the service gets run. If there is a disable line and it's 441 00:38:40,720 --> 00:38:47,440 yes, the service doesn't get run. So if we look through on our reference system, we find 442 00:38:47,440 --> 00:38:51,880 that x-initd's got every single thing in x-initd.d. 443 00:38:52,300 --> 00:38:56,140 Every single file's got disable equals yes, then we know it's off, and we don't worry 444 00:38:56,140 --> 00:39:04,260 about it. Next slide. Okay, so if we're looking at our PS listing, we're looking at what other 445 00:39:04,260 --> 00:39:09,760 programs are left. We're doing something quick. Okay, one of the other things that stands 446 00:39:09,760 --> 00:39:14,000 out is auto-disk mount. Okay, what's auto-disk mount for? Auto-disk mount's actually pretty 447 00:39:14,000 --> 00:39:20,260 darn useful. Okay, auto-disk mount is, I take my CD-ROM, I stick it in the drive, it mounts 448 00:39:20,260 --> 00:39:21,660 up automatically, it appears on there. 449 00:39:22,300 --> 00:39:28,560 It appears on my screen, I can click on it, I can get a finder listing of it, etc. What 450 00:39:28,560 --> 00:39:32,840 else is it for? Well, it's for floppies, yes, but what else is it for on top of that? Well, 451 00:39:32,920 --> 00:39:38,400 if I'm downloading disk image files, okay, one of the big ways you install software is 452 00:39:38,400 --> 00:39:42,440 you download a disk image file, you click on it, and it basically comes up as, you know, 453 00:39:42,460 --> 00:39:45,580 as if you were mounting a little, as if you were mounting an external hard drive, except 454 00:39:45,580 --> 00:39:50,440 it's not, it's just a disk image file. Feels like an ISO to me, but, you know, if I've 455 00:39:50,440 --> 00:39:52,280 got a disk image file, I can click on it, and it'll show me the disk image file, and 456 00:39:52,300 --> 00:39:56,560 auto-disk mounts what's actually, what's actually opening that up for me. Okay, what's 457 00:39:56,560 --> 00:40:02,180 showing that as, as a, what's, what's mounting that for me, and so that I can just pop it 458 00:40:02,180 --> 00:40:06,720 up, see directory, and get, and have it nice and easy. Okay, again, whether I leave this 459 00:40:06,720 --> 00:40:11,520 on or not depends on how I'm using the system. Okay, if this system is, you know, if I want 460 00:40:11,520 --> 00:40:16,460 to, I can turn off auto-disk mount between times when I'm using that functionality. Okay, 461 00:40:16,520 --> 00:40:21,260 or I can leave it in place. What else? 462 00:40:22,300 --> 00:40:26,800 DNS responder, MDNS responder, multicast DNS responder. So, okay, we talked about 463 00:40:26,800 --> 00:40:32,240 auto-disk mount, and if you wanted to turn off auto-disk mount, okay, you can basically 464 00:40:32,240 --> 00:40:37,080 just go into disks, into the disk script, and comment it out. Again, that's one of those 465 00:40:37,080 --> 00:40:45,240 things that's not host config accessible in 10.2.3. Okay. MDNS responder used for rendezvous. 466 00:40:46,000 --> 00:40:49,700 Okay, rendezvous, what's rendezvous do? Who knows what rendezvous does? I know you guys 467 00:40:49,700 --> 00:40:49,920 do. 468 00:40:51,440 --> 00:40:53,920 Here, anybody? Anybody? Yeah. 469 00:41:10,700 --> 00:41:16,060 Okay, automatic host discovery, it's basically his way of finding people to chat with, to 470 00:41:16,060 --> 00:41:19,360 do iChat. Okay, finding people who are on the local area land. 471 00:41:21,640 --> 00:41:25,980 I'm sorry, I can't hear you. Very nice for iTunes sharing. Anybody else have 472 00:41:25,980 --> 00:41:27,680 favorite things to do with rendezvous? 473 00:41:29,600 --> 00:41:30,160 I'm sorry? 474 00:41:35,160 --> 00:41:39,580 I didn't know about that one. What's hydro do? What's hydro do? 475 00:41:41,480 --> 00:41:44,660 Everyone can work on the document at the same time? They're just on the local area land? 476 00:41:46,700 --> 00:41:47,500 Wow. Okay. 477 00:41:47,760 --> 00:41:49,320 So as far as... 478 00:41:49,320 --> 00:41:52,520 as far as rendezvous goes, sounds like really useful 479 00:41:52,520 --> 00:41:56,200 functionality. I'm scared out of my wits having this on at 480 00:41:56,200 --> 00:42:04,080 DEF CON. So if you also are scared, thank you, if you also 481 00:42:04,080 --> 00:42:07,380 are scared, you can turn that off by commenting or deleting it 482 00:42:07,380 --> 00:42:11,180 out of MDNS responder. Again, this would be nice. This is 483 00:42:11,180 --> 00:42:13,480 stuff where we're going to hope that it's all going to be in 484 00:42:13,480 --> 00:42:15,980 host config later on. For now, we're just commenting it out. 485 00:42:18,120 --> 00:42:21,740 Okay. So like I said, to do a thorough audit, you'd read 486 00:42:21,740 --> 00:42:24,000 through all the start scripts and decide what to turn off. I 487 00:42:24,000 --> 00:42:26,960 do a more thorough audit in this article that I'm going to post 488 00:42:26,960 --> 00:42:36,480 up on my website probably come Monday. So in terms of where you 489 00:42:36,480 --> 00:42:39,840 go from here, we've gone through some of the scripts. In terms of 490 00:42:39,840 --> 00:42:41,720 where you go from here, the first thing I'm going to do is 491 00:42:41,720 --> 00:42:44,580 actually go and run netstat and get a list of what's listening 492 00:42:44,580 --> 00:42:45,260 on different ports. 493 00:42:45,980 --> 00:42:48,560 Okay. I'll use netstat to get a list of what's listening. I'll 494 00:42:48,560 --> 00:42:51,920 use LSOF to tell me what programs. Netstat gives me a list 495 00:42:51,920 --> 00:42:55,540 of listening ports. LSOF gives me, you know, for a given port, 496 00:42:55,660 --> 00:43:00,420 what's actually listening on it. Okay. So what I might do is I 497 00:43:00,420 --> 00:43:04,540 might go and use netstat and I see port 1033 is listening on 498 00:43:04,540 --> 00:43:07,700 local host. And if I see that, I'll run LSOF and it'll say net 499 00:43:07,700 --> 00:43:10,620 info D is listening on that port. And I'll say that's okay. I need 500 00:43:10,620 --> 00:43:14,540 that. That's fine. I need net info. I can't turn it off. Okay. 501 00:43:14,660 --> 00:43:15,440 That's fine with me. 502 00:43:15,980 --> 00:43:18,460 And the fact that it only listens on loopback makes it a little less 503 00:43:18,460 --> 00:43:23,320 dangerous anyway. Okay. UDP. If I'm going and doing a UDP audit, 504 00:43:23,400 --> 00:43:26,940 these are the ports that came up listening. Okay. 1033 is also net 505 00:43:26,940 --> 00:43:31,920 info. I can go through each port with LSOF. Okay. And I see there 506 00:43:31,920 --> 00:43:36,740 are different pieces of the operating system. And I can go and 507 00:43:36,740 --> 00:43:40,020 actually look at what each one is and decide whether I want to keep 508 00:43:40,020 --> 00:43:45,060 it or not. Okay. I'm keeping lookup D. I'm keeping net info D. I'm 509 00:43:45,980 --> 00:43:48,240 keeping Syslog. But why the heck is Syslog listening on the network? 510 00:43:49,820 --> 00:43:52,800 Okay. If I go and look at the man page for Syslog, and that's what we 511 00:43:53,200 --> 00:43:57,120 do time permitting, if I look at the man page for Syslog, Syslog says 512 00:43:57,120 --> 00:44:00,680 you have to have, you know, you have to have the minus T command line 513 00:44:00,680 --> 00:44:03,500 option to be listening on the network. And it says, hey, this is, you 514 00:44:03,500 --> 00:44:06,020 know, kind of an old, insecure thing and you're going to open a DOS 515 00:44:06,020 --> 00:44:12,180 attack. And so then what do I do? Well, I notice that this, that if I 516 00:44:12,180 --> 00:44:15,860 do a PS, Syslog isn't being run with minus T. If I look at the script, 517 00:44:15,980 --> 00:44:21,240 Syslog isn't being run with that option. So, I'm sorry, minus U. What 518 00:44:21,240 --> 00:44:27,280 do I do? I say, it says that it's listening on the port, but my, my, my 519 00:44:27,280 --> 00:44:30,420 man page, my start script doesn't indicate that it's listening on the 520 00:44:30,420 --> 00:44:35,040 port, that it should be, that it should be accepting remote logs. So, 521 00:44:35,200 --> 00:44:40,560 I'm sorry, what I do, I thought I had a slide on that. What I do is I 522 00:44:40,560 --> 00:44:44,500 fire off my, my, my, my Syslog client and just start firing off logs at 523 00:44:44,500 --> 00:44:45,960 the box. And I fire off logs at the box. And I fire off logs at the box. 524 00:44:45,980 --> 00:44:47,960 And I start firing them off from different IP addresses and seeing 525 00:44:47,960 --> 00:44:51,400 what happens. And I find, oh, hey, I can't get this thing to log, to log 526 00:44:51,400 --> 00:44:56,220 anything. Okay. It'd be nice if it didn't listen on the port, but it's 527 00:44:56,220 --> 00:45:00,280 going to. So, is there anything, is there anything you guys can think of 528 00:45:00,280 --> 00:45:05,620 that I can do about it if I'm still paranoid about this? IPFW. Exactly. 529 00:45:06,300 --> 00:45:10,040 So, I can make sure that IPFW is currently blocking all access to the 530 00:45:10,040 --> 00:45:15,960 port. Okay. What else? I find port 68 is locked. Okay. So, what else? 531 00:45:15,980 --> 00:45:20,760 Port 68, I find that's config d. Port 68, that's my DHCP client port. I need 532 00:45:20,760 --> 00:45:25,460 that there. That's okay. I might use IPFW to make sure that it only gets, I 533 00:45:25,460 --> 00:45:28,380 might use IPFW to make sure that it only gets communication from the known 534 00:45:28,380 --> 00:45:33,640 DHCP server on the network, otherwise I need it because the systems doing DHCP. 535 00:45:33,920 --> 00:45:38,640 I can also go static route and not worry about it. Okay. From there, what 536 00:45:38,640 --> 00:45:41,840 are my next steps? My next steps are doing a set Jack you- conhews 537 00:45:41,840 --> 00:45:45,780 uid audit. Doing a set guid audit. Dominic Okay. My next audit kron job 538 00:45:45,780 --> 00:45:45,960 obsession. Graphic area in here also 539 00:45:45,980 --> 00:45:52,040 look at DMA configurations, do a permissions audit. In terms of a set UIDR, these are the 540 00:45:52,040 --> 00:45:57,880 commands I'd use. And what I'm looking for, what I'm looking for are programs that let ordinary 541 00:45:57,880 --> 00:46:02,680 users and potentially every ordinary user on the system run as root. Am I really out of time? 542 00:46:03,220 --> 00:46:09,480 Okay, I'm out of time. So I'm going to show you the slides and stop. Okay, so there's my 543 00:46:09,480 --> 00:46:15,820 commands for a set UIDR audit. I'll look at cron jobs. Cron runs periodic, periodic runs a 544 00:46:15,820 --> 00:46:21,920 bunch of stuff out of the directories, etsy, periodic, daily, monthly, weekly. I'll go through 545 00:46:21,920 --> 00:46:26,220 and actually look at daemon configurations later on if I have time. Any daemons I actually still 546 00:46:26,220 --> 00:46:30,440 want to run, I'll make better configurations, read references on this. Some of them are on my 547 00:46:30,440 --> 00:46:34,780 website. Permissions audit. I'll actually go and look at the system and see what somebody could 548 00:46:34,780 --> 00:46:38,900 do in terms of world writable files and directories replacing data or replacing executables. 549 00:46:39,980 --> 00:46:45,600 Okay, there's commands to do that. Bastio Linux. Bastio Linux is an increasingly misnamed 550 00:46:46,520 --> 00:46:51,280 program that is a hardening script that'll actually go through and do some lockdown. You can do a much 551 00:46:51,280 --> 00:46:55,600 better job always by hand because you're a boatload smarter than a Perl script. But this 552 00:46:55,600 --> 00:46:59,400 might help you in terms of automation, in terms of getting a first start, in terms of doing this 553 00:46:59,400 --> 00:47:05,080 for lots of systems. Bastio Linux works on HPUX and OSX and 5Linux distros. I've got articles you 554 00:47:05,080 --> 00:47:07,860 might read on lockdown. There they are. And we're out of slides. 555 00:47:08,720 --> 00:47:09,460 Was this useful? 556 00:47:10,320 --> 00:47:11,540 Except for the people who are going to fillet me?