1 00:00:01,090 --> 00:00:01,930 Wow. 2 00:00:02,230 --> 00:00:03,410 Hello everybody. 3 00:00:03,410 --> 00:00:04,690 Thank you for coming. 4 00:00:06,150 --> 00:00:08,570 Just a little survey before we start. 5 00:00:09,290 --> 00:00:16,090 Does everybody have any experience with writing viruses kind of thing for master boot records? 6 00:00:16,090 --> 00:00:17,910 Please raise your hand. 7 00:00:19,710 --> 00:00:22,210 Okay, so officer, those two guys. 8 00:00:24,630 --> 00:00:34,090 Okay, more seriously, if you have absolutely no idea what is a BIOS or what is a boot loader, maybe you should take an app or something for the next 50 minutes. 9 00:00:35,710 --> 00:00:39,630 Okay, basically we're going to talk about pre-boot authentication passwords. 10 00:00:40,150 --> 00:00:41,070 Okay, everybody see? 11 00:00:41,070 --> 00:00:41,670 Okay. 12 00:00:42,030 --> 00:00:43,450 Pre-boot authentication. 13 00:00:43,950 --> 00:00:48,350 So let's start with the initial introduction kind of thing. 14 00:00:49,150 --> 00:00:51,010 So I'm a French guy. 15 00:00:51,010 --> 00:00:52,350 I live in India. 16 00:00:52,350 --> 00:00:55,790 I work for a company named IVS Security. 17 00:00:56,310 --> 00:00:59,590 I mean, IVS Technology Solutions Private Limited. 18 00:01:00,990 --> 00:01:12,450 I would like to pass a private message kind of thing also to the girl who leaked my tattoo yesterday night at the immunity party. 19 00:01:13,110 --> 00:01:23,550 So we have not been introduced formally, but my room number is 524 at the Sahara Hotel, so you're most welcome anytime. 20 00:01:26,320 --> 00:01:30,260 Okay, so basically we're going to talk about one new class of vulnerabilities. 21 00:01:30,260 --> 00:01:38,980 It's not something affecting only one piece of software, but multiple pre-boot authentication implementations. 22 00:01:38,980 --> 00:01:42,480 We'll define later what is exactly a pre-boot authentication password. 23 00:01:42,840 --> 00:01:45,880 We focus on password-based authentication only. 24 00:01:46,520 --> 00:01:55,600 The thing that's a bit remarkable, like if you've been to Blackout or something this year, there was a talk called boot attacks. 25 00:01:56,040 --> 00:01:58,840 Here, we don't need at all physical access to the computer. 26 00:02:00,920 --> 00:02:08,800 Okay, so we'll start with a few definitions, like defining exactly what is the scope of the talk, and what is a pre-boot authentication password. 27 00:02:09,580 --> 00:02:18,700 Then we'll switch to Windows, and then to unique exploitation, and then we will see a few further enhancements to the technology we've been developing. 28 00:02:20,220 --> 00:02:34,020 Okay, so just as a reminder, I'm pretty sure all of you know the boot seconds kind of stuff, but I've read so many mistakes that just to fix the IDs, I spent some time on that. 29 00:02:34,240 --> 00:02:45,720 Then we will define the different types of passwords we're going to be attacking, and have a closer look at the bias functions to read user keyboard, user input basically. 30 00:02:46,860 --> 00:02:48,400 Okay, here we go. 31 00:02:48,880 --> 00:02:52,560 So when you start a computer, the CPU starts in read mode. 32 00:02:53,880 --> 00:03:03,400 There is pretty nothing which is known, like there is no disk, there is no RAM, there is no nothing at the very beginning. 33 00:03:03,680 --> 00:03:19,560 So while memory, I mean, control is transferred to the bias by performing a long jump kind of thing, which is basically translated via hardware, since there is no RAM, to the bias entry point. 34 00:03:20,180 --> 00:03:27,360 So the bias itself is in charge of several things, like setting up the power, initializing the clock. 35 00:03:29,520 --> 00:03:33,300 Okay, it then discovers your RAM, so we can start doing things. 36 00:03:34,080 --> 00:03:37,160 Your hard drive with the master boot record. 37 00:03:39,200 --> 00:03:45,720 Okay, one thing really important, it starts at address zero, the interrupt vector table. 38 00:03:45,980 --> 00:03:50,800 So from now on, we can basically issue interruptions, which was not the case before. 39 00:03:51,480 --> 00:03:56,860 So using interruption 19, the master boot record is mapped in RAM. 40 00:03:57,020 --> 00:03:58,840 Okay, it's basically the boot loader. 41 00:03:58,840 --> 00:04:03,120 It was in charge of loading later on the kernel. 42 00:04:03,120 --> 00:04:10,000 So if we think about it, like let's do our kind of collecting, kind of brainstorming. 43 00:04:10,180 --> 00:04:12,420 Let's say we want to code a boot loader. 44 00:04:12,620 --> 00:04:16,980 Basically, which is the API which is available to you? 45 00:04:16,980 --> 00:04:19,080 There is no kernel in memory, no nothing. 46 00:04:19,240 --> 00:04:20,580 So what can you use? 47 00:04:21,740 --> 00:04:22,680 No one? 48 00:04:23,300 --> 00:04:27,660 Okay, so all the API which is available is indeed the bias. 49 00:04:27,660 --> 00:04:33,680 The bias provides you input-output interface, okay? 50 00:04:33,700 --> 00:04:39,720 And you could use also physical ERQs, like writing directly to disk and stuff like that. 51 00:04:41,000 --> 00:04:45,180 So this is very important for the rest of the speech, right? 52 00:04:45,180 --> 00:04:47,260 We'll focus on bias stuff for a reason. 53 00:04:47,260 --> 00:04:51,800 Because basically, when you want to write a boot loader, it's the only API which is available. 54 00:04:52,760 --> 00:04:57,440 Okay, let's see a bit the different kind of passwords you can have when you boot a computer. 55 00:04:57,440 --> 00:05:04,280 By pre-boot, we mean anything that can ask for a password before there is actually a kernel in memory, right? 56 00:05:04,360 --> 00:05:07,480 So they could be of several kinds. 57 00:05:07,920 --> 00:05:13,680 Like bias passwords, you know those blue screens that pop up when you first start your computer. 58 00:05:14,060 --> 00:05:15,680 So those are one kind. 59 00:05:16,060 --> 00:05:19,080 Boot loader passwords, basically those are the most common. 60 00:05:19,080 --> 00:05:26,440 Like if you want to have a full disk encryption, or even partial disk encryption, usually it's implemented at that level. 61 00:05:26,440 --> 00:05:30,280 So it could be like Vista Boot Loader, Grub, Lilo. 62 00:05:30,440 --> 00:05:32,960 We'll see some other examples later on. 63 00:05:33,380 --> 00:05:36,640 And it could be also early stage passwords. 64 00:05:37,180 --> 00:05:47,040 Typically, when the kernel first starts in real mode, before switching in private mode, it could ask you for a password. 65 00:05:47,040 --> 00:05:50,340 So we'll see that later on also. 66 00:05:51,620 --> 00:05:56,420 Okay, let's have a closer look at the BIOS functions. 67 00:05:56,420 --> 00:05:58,740 They are used to read user input. 68 00:05:59,920 --> 00:06:10,520 Okay, there is basically one interruption for the BIOS, which is interruption 16, which has two function relevance to us. 69 00:06:10,640 --> 00:06:19,940 The first one, getsKeyStroke, is mostly used to check and retrieve one keystroke at a time. 70 00:06:19,940 --> 00:06:33,080 And the second one, when you invoke it with a parameter, I mean, AH, parameter 01, it does pretty much the same, only it does not update the carry flag. 71 00:06:33,080 --> 00:06:34,260 Zero flag, sorry. 72 00:06:34,300 --> 00:06:43,540 So this is typically used to first check if a keystroke has been entered, and then retrieve it. 73 00:06:43,540 --> 00:06:47,480 For instance, in Lilo, this is done like that. 74 00:06:47,480 --> 00:06:51,780 So you can see there are, I mean, there's two functions implemented, right? 75 00:06:51,880 --> 00:06:59,400 The first one is using function, I mean, sub-function 01, and the second one is actually retrieving the key. 76 00:07:01,300 --> 00:07:03,820 Okay, give me two second. 77 00:07:08,960 --> 00:07:28,740 Okay, so if you've been doing any kind of assembly, like especially under Windows, I mean, under MS-DOS, in the good old times, when we could actually trigger BIOS interrupts and stuff like that, because nowadays, I mean, most OSCs will prevent you to do that, 78 00:07:28,740 --> 00:07:31,440 they are running in private mode, okay? 79 00:07:31,440 --> 00:07:39,100 So they have segmentation and stuff, and obviously you cannot trigger BIOS interrupts. 80 00:07:39,900 --> 00:08:03,120 So when you code either in real mode or under MS-DOS, which is a virtual mode kind of thing, when you try to access BIOS interrupt routines, so you enter as a parameter into AX either 0 or 01, and you later on call interruption 16, and in return, okay, 81 00:08:03,120 --> 00:08:08,140 you opt to retrieve an ASCII scan code, okay, for a key that was pressed. 82 00:08:08,940 --> 00:08:16,740 Okay, you must probably know that, or in fear, that somewhere on the field, there is a keyboard. 83 00:08:16,880 --> 00:08:17,660 Fine. 84 00:08:17,660 --> 00:08:21,880 The real question is, how is it all tied together? 85 00:08:21,880 --> 00:08:23,380 Like, what's in the middle? 86 00:08:27,660 --> 00:08:34,340 Okay, so let's detail a bit how this is all working from the keyboard to the process. 87 00:08:34,440 --> 00:08:37,700 Because this is really the whole core of my presentation. 88 00:08:38,500 --> 00:08:42,260 So basically, inside the keyboard, you have the first PIC. 89 00:08:42,420 --> 00:08:45,960 So if you know PIC programming, you can actually program your keyboard. 90 00:08:45,960 --> 00:08:50,500 I mean, the data sheets are available on Intel website. 91 00:08:50,980 --> 00:08:54,860 So this one is the first one. 92 00:08:59,220 --> 00:09:07,160 Okay, that chip is responsible for triggering an event every time you press or you release a key. 93 00:09:07,260 --> 00:09:11,520 There is a second one, which is embedded inside your motherboard. 94 00:09:11,520 --> 00:09:19,300 So the first PIC sends to the other one an event every time you press or release. 95 00:09:19,320 --> 00:09:21,300 This is actually not good enough. 96 00:09:21,300 --> 00:09:25,920 Like, if you press for quite a time, you would like the key to be repeated. 97 00:09:25,920 --> 00:09:30,760 And if you just press and release, you would like it to be counted as only one key. 98 00:09:30,760 --> 00:09:50,160 So this is the role of the second PIC, which actually unifies the scan codes and sends them to interruption 09, which is also called DRQ01, which is responsible for handling the keyboard in the level. 99 00:09:50,680 --> 00:09:54,120 Okay, the interesting thing is really the next thing. 100 00:09:54,380 --> 00:10:00,040 Inside the RAM, there is a data structure called the BIOS data area. 101 00:10:00,040 --> 00:10:05,920 It contains many fields of your BIOS configuration. 102 00:10:06,360 --> 00:10:11,360 Okay, there are two pointers and one buffer who are interesting to us. 103 00:10:11,560 --> 00:10:28,100 So what happens when you press a key, the keyboard interrupt service routine copies that key into the yellow buffer and updates the pointers accordingly. 104 00:10:28,100 --> 00:10:30,860 And same thing when you try to retrieve a key. 105 00:10:30,860 --> 00:10:38,100 So here we have the full process, I mean, from a keyboard to a process kind of thing. 106 00:10:38,300 --> 00:10:39,560 Okay, that's clear? 107 00:10:39,980 --> 00:10:40,900 Everybody? 108 00:10:41,420 --> 00:10:42,140 Awesome. 109 00:10:42,920 --> 00:10:55,180 Okay, so in details, if you look at the keyboard buffer, that yellow thing inside memory, every time you enter a key, the pointer to the last character is incremented. 110 00:10:55,180 --> 00:10:59,700 Okay, so this is the yellow arrow there. 111 00:10:59,940 --> 00:11:06,280 And when you retrieve a key, the red one, the pointer to the next character is updated. 112 00:11:06,300 --> 00:11:08,680 Okay, so it's always pointing to the next one. 113 00:11:09,080 --> 00:11:12,580 The big problem here, I guess you guys can already see it. 114 00:11:15,080 --> 00:11:21,280 Okay, is that this buffer is actually never flushed. 115 00:11:21,280 --> 00:11:30,060 So every time you enter a password at boot time, and the BIOS takes care of reading it, it remains in memory forever. 116 00:11:30,180 --> 00:11:30,820 Okay? 117 00:11:31,540 --> 00:11:32,520 Yeah. 118 00:11:34,800 --> 00:11:36,020 Thank you. 119 00:11:41,700 --> 00:11:48,220 So this has been there for like 25 years, and more than that actually. 120 00:11:48,660 --> 00:11:52,540 And we're going to see that pretty much everybody is vulnerable to that. 121 00:11:52,540 --> 00:12:07,640 So in an ideal world, what you would do when you called a bootloader kind of thing, you would sanitize the BIOS keyboard buffer, that yellow thing, after reading a password. 122 00:12:08,340 --> 00:12:12,960 Okay, let's see how it actually works in real life, and how it is implemented. 123 00:12:14,000 --> 00:12:26,300 So a good example to check how BIOS aware are people, is to look at the way the BIOS guys implemented the BIOS password inside the BIOS itself. 124 00:12:26,360 --> 00:12:26,880 Okay ? 125 00:12:27,420 --> 00:12:39,420 So to do that, I mean, every code you edit on the CD-ROM, there is a toggle on the CD-ROM, so I really encourage you to have a look at it, and give us feedback if you have questions out of it. 126 00:12:40,960 --> 00:12:55,880 So anyway, we wrote a small USB bootable OS, in 60-byte read mode, to dump the content of the BIOS keyboard buffer. 127 00:12:56,540 --> 00:13:06,500 So basically you boot, the BIOS asks you for a password, and then, for a small OS kind of thing, dumps the content of the memory. 128 00:13:06,500 --> 00:13:11,420 Okay, what we've been seeing is that most BIOS passwords are vulnerable to that. 129 00:13:11,940 --> 00:13:25,280 So let's imagine third-party developers, like a guy writing software encryption things, or any kind of bootloader asking for a password, they are most probably not aware of it. 130 00:13:25,280 --> 00:13:31,360 I mean, even if the BIOS developers make mistakes, don't expect a third-party to be much more aware of it. 131 00:13:33,140 --> 00:13:40,140 Okay, one interesting thing, let's imagine we have two passwords checking in a row. 132 00:13:42,930 --> 00:13:56,530 Could be like, for instance, you have a BIOS password, plus a GRUB or LILO password, or you could have a GRUB password, like asking an MD5 password, plus a disk encryption software in a row, okay? 133 00:13:56,770 --> 00:14:01,510 So in that case, what would the BIOS keyboard buffer look like? 134 00:14:04,880 --> 00:14:18,820 Okay, so actually, pass one would be the password for the first BIOS password, then you would have the enter key, then you would have the second password, and then you would have enter. 135 00:14:19,020 --> 00:14:27,060 So basically, if you have several passwords in a row, they are all concatenated inside the BIOS keyboard buffer. 136 00:14:27,060 --> 00:14:32,180 So from an exploitation point of view, this is really like the best possible thing ever. 137 00:14:35,350 --> 00:14:37,210 Okay, from now on, we're going to see... 138 00:14:37,210 --> 00:14:52,070 Okay, so just to summarize the scope, we've seen that in many cases, when we have preboot authentication passwords, the passwords remain in physical memory at a given location we know. 139 00:14:52,070 --> 00:14:54,530 Okay, we know that location in physical memory. 140 00:14:54,530 --> 00:15:03,470 The problem is, once the operating system is loaded, the kernel first switches in protected mode. 141 00:15:04,170 --> 00:15:10,350 So there, there is segmentation, paging and stuff, so you're not supposed to read physical memory anymore. 142 00:15:10,750 --> 00:15:22,910 So the whole deal of the next two chapters, Windows exploitation and Unix exploitation, is actually to manage to retrieve the password from that physical location we know in physical memory. 143 00:15:23,850 --> 00:15:26,050 Once the computer has booted. 144 00:15:26,070 --> 00:15:33,130 Okay, so we assume that the OS has been fully booted and we're given a shell. 145 00:15:33,690 --> 00:15:36,350 We're going to define the conditions later on. 146 00:15:36,350 --> 00:15:44,290 So the big change with a common approach to cold boot attacks, we don't need physical access. 147 00:15:45,670 --> 00:15:50,850 Okay, let's first discuss the Windows case. 148 00:15:50,850 --> 00:16:00,050 We will discuss a bit, so just summarize the challenges, like I just did actually. 149 00:16:00,190 --> 00:16:06,730 Then discuss possible attack scenario, and well, discuss the actual implementation we've done. 150 00:16:07,930 --> 00:16:15,530 So that's the physical address, 40.0x1.e, from protected mode. 151 00:16:15,650 --> 00:16:18,270 And we want to try to retrieve it. 152 00:16:18,270 --> 00:16:23,330 So possible things we could do, like how do you read physical memory? 153 00:16:23,910 --> 00:16:26,910 So one thing could be to get back to real mode. 154 00:16:26,910 --> 00:16:38,130 That way you would disable segmentation, disable paging, so you could very well read the stuff from the physical memory. 155 00:16:39,170 --> 00:16:40,520 That's one solution. 156 00:16:41,050 --> 00:16:45,690 You could think of switching to SMM, which is another CPU mode. 157 00:16:45,690 --> 00:16:48,730 So same thing, there is no segmentation, no paging. 158 00:16:48,730 --> 00:16:50,230 So that could be an option. 159 00:16:50,690 --> 00:16:53,230 Or you could try to get it from Kernel land. 160 00:16:54,010 --> 00:17:00,770 The big problem is that all those solutions require typically huge amount of privileges. 161 00:17:00,870 --> 00:17:04,390 So under Windows you need system privileges or kernel privileges. 162 00:17:04,770 --> 00:17:06,070 So let's not do that. 163 00:17:07,970 --> 00:17:11,630 We're going to use a Microsoft feature. 164 00:17:14,430 --> 00:17:18,170 Yeah, you can start laughing, but just wait to look at it. 165 00:17:18,170 --> 00:17:20,230 I mean, it's pretty awesome. 166 00:17:21,650 --> 00:17:25,130 Okay, we're going to use the MS-DOS emulation mode. 167 00:17:26,030 --> 00:17:35,350 Basically it has been there since Windows 95 to allow retro compatibility with MS-DOS. 168 00:17:35,350 --> 00:17:44,150 So it's built over the last CPU mode we've not seen so far, which is a virtual mode. 169 00:17:44,150 --> 00:17:54,790 It basically emulates an 8886 CPU, so a very old Intel CPU, with some restrictions and with some mistakes. 170 00:17:54,790 --> 00:18:03,930 Like , okay, this is fully documented, but the addressing from 16-bit to 32-bit triggers some problem in the stack and stuff. 171 00:18:03,930 --> 00:18:15,070 Anyway, the good thing about that is that it maps physical memory in the ranges which are interesting to us into user layout. 172 00:18:17,110 --> 00:18:19,630 So let's go for a demo. 173 00:18:30,880 --> 00:18:34,280 Okay, I launched a demo in the background and let's keep going. 174 00:18:38,080 --> 00:18:41,460 Now let's discuss the thing about UNIX. 175 00:18:41,460 --> 00:18:48,540 By UNIX we mean BSD, Saurus, whatever, which is running Intel-compatible CPUs. 176 00:18:48,720 --> 00:18:52,740 Otherwise, you don't have a BIOS in the first place, and it's not really interesting to us. 177 00:18:54,520 --> 00:19:07,240 So, unfortunately, we don't have such a good thing as the kernel mapping all the interesting BIOS data area thing inside user layout for you. 178 00:19:07,240 --> 00:19:12,860 So we will have to assume we have some privileges to retrieve the password. 179 00:19:14,040 --> 00:19:17,400 So, first of all, we could try to get it from user layout. 180 00:19:18,120 --> 00:19:28,500 When it comes to physical memory under UNIX, you have a special device which is called DevMem, which is actually a mapping of your physical memory. 181 00:19:28,500 --> 00:19:37,100 So if you use a simple tool, you can actually read the password in plain text into DevMem. 182 00:19:37,540 --> 00:19:39,540 This is really awesome also. 183 00:19:39,540 --> 00:19:41,600 It has been there for years. 184 00:19:41,600 --> 00:19:46,480 Everybody has been using password, and apparently it's the first time someone is disclosing it. 185 00:19:48,360 --> 00:19:53,940 Instead of using DevMem, you could use DevCardMem, which is a mapping of the kernel. 186 00:19:53,940 --> 00:20:00,620 For the technical guys here, I'm assuming 3GB, 1GB kernel split. 187 00:20:00,620 --> 00:20:02,980 Otherwise, the addresses won't be the same. 188 00:20:03,060 --> 00:20:04,500 But the principle is always the same. 189 00:20:04,500 --> 00:20:07,280 You can get it from KernelN also. 190 00:20:10,000 --> 00:20:15,140 DevCardCore, which basically contains the very same information in the form of a core file. 191 00:20:15,480 --> 00:20:18,380 So using the very same tool, you can also retrieve your password. 192 00:20:19,760 --> 00:20:24,440 Okay, so we have implemented a simple tool to automate pretty much the test for you. 193 00:20:24,580 --> 00:20:34,080 It's been testing under a wide range of Unix distributions, running on x86 CPUs. 194 00:20:35,440 --> 00:20:37,160 Okay, so same thing. 195 00:20:37,160 --> 00:20:38,500 You can see the stuff in red. 196 00:20:38,500 --> 00:20:41,260 It's your actual whatever password. 197 00:20:41,260 --> 00:20:44,720 Like it could be a BIOS password, book loader password, and stuff. 198 00:20:46,200 --> 00:20:48,180 Okay, let's get back to the demo. 199 00:20:49,660 --> 00:20:51,600 Okay, so this is Windows. 200 00:20:51,600 --> 00:20:53,240 I have a guest account. 201 00:20:53,520 --> 00:20:56,120 And I'm using a very simple COM file. 202 00:20:58,340 --> 00:21:02,820 The VOX is encrypted with, I mean it has full disk encryption with TrueCrypt. 203 00:21:03,140 --> 00:21:05,320 And you can see my password is total. 204 00:21:06,660 --> 00:21:08,220 You can applaud here. 205 00:21:11,100 --> 00:21:12,220 Thank you. 206 00:21:21,820 --> 00:21:30,260 Okay, so we can also think about getting the password under Unix from a kernel end. 207 00:21:30,700 --> 00:21:40,960 So actually what happens is that the BIOS data area is copied inside a special page inside the kernel, which is called the zero page. 208 00:21:40,960 --> 00:21:44,660 This is done in setup.c if you want to look at the kernel source. 209 00:21:44,660 --> 00:21:48,940 So it's really early stage of the kernel before switching to protected mode. 210 00:21:49,620 --> 00:21:54,900 So we're assuming the same kernel split I explained before. 211 00:21:54,960 --> 00:21:58,200 So does everybody know what is a kernel split in the first place? 212 00:21:58,740 --> 00:22:02,280 Okay, basically it means that you have a user land and kernel land. 213 00:22:02,280 --> 00:22:06,860 And the amount of memory allocated to both can differ. 214 00:22:07,100 --> 00:22:13,660 And you can actually on any kind of distribution specify at boot time which kind of split you want. 215 00:22:13,660 --> 00:22:21,200 So in case of the standard three gigabyte, one gigabyte split, the address where it is copied. 216 00:22:21,200 --> 00:22:26,140 So this is defined by setup.c where it is copied inside the zero page. 217 00:22:26,200 --> 00:22:28,900 This is the address written there. 218 00:22:30,920 --> 00:22:37,240 So let's verify the password is actually located there in memory. 219 00:22:37,240 --> 00:22:41,920 So to do that, we can use, for instance, kernel debugging. 220 00:22:41,920 --> 00:22:43,520 Okay, remote kernel debugging. 221 00:22:43,540 --> 00:22:50,740 Here I'm using a VMware machine and I'm debugging the kernel inside the VMware machine. 222 00:22:51,320 --> 00:22:58,280 And what we see if we print what is at the given address, everybody gets to see it. 223 00:22:58,280 --> 00:23:01,400 So the letters in red are actually my BIOS password. 224 00:23:03,860 --> 00:23:20,660 Okay, since you probably don't want to have to do kernel debugging every time you want to read a password, we have written a small kernel module which adds an entry in the slash file system. 225 00:23:20,800 --> 00:23:24,840 And just by doing a cat on it, you can retrieve any kind of password. 226 00:23:33,410 --> 00:23:34,610 Thank you. 227 00:23:36,190 --> 00:23:44,010 Okay, so like we mentioned before, this bug has been there since humans have been using BIOS. 228 00:23:44,850 --> 00:23:46,470 So since we have PCs. 229 00:23:47,430 --> 00:23:50,690 And the awesome stuff is everything is in plain text. 230 00:23:51,030 --> 00:23:55,210 So just open your eyes, there might be other kinds of bugs like that. 231 00:23:56,510 --> 00:23:59,930 Okay, I'll give you a Unix demo. 232 00:24:00,610 --> 00:24:02,870 Okay, this is a raw Ubuntu. 233 00:24:04,230 --> 00:24:07,330 It has a GRUB MD5 password. 234 00:24:08,070 --> 00:24:10,730 So I need to assume several privileges. 235 00:24:10,730 --> 00:24:13,790 So typically I have a root console. 236 00:24:19,040 --> 00:24:24,740 Okay, here are the kind of attacks you can do against it. 237 00:24:24,740 --> 00:24:28,920 So you could try to retrieve it from DevMem, OldMem, whatever. 238 00:24:28,920 --> 00:24:32,920 I mean, under Ubuntu, you have many links. 239 00:24:34,240 --> 00:24:38,500 Like, slash dev static dev core is actually a link to dev core and stuff like that. 240 00:24:38,500 --> 00:24:43,820 But still, you have many options to try to retrieve that stuff. 241 00:24:43,820 --> 00:24:49,720 Even if you are into a stripped-down demo, you will... stripped-down distribution. 242 00:24:50,080 --> 00:24:55,740 And any kind of Unix, not only Linux, you will at least find DevMem or something like that, right? 243 00:24:56,520 --> 00:24:59,080 So let's execute it. 244 00:25:01,230 --> 00:25:03,430 Okay, so guess what's my password? 245 00:25:06,400 --> 00:25:08,940 Okay, it's not actually DefCon1. 246 00:25:08,940 --> 00:25:10,260 That was a trick. 247 00:25:10,800 --> 00:25:17,700 Every time you have one character, which is the ASCII code, the next one inside the BIOS keyboard buffer is a scan code. 248 00:25:17,700 --> 00:25:19,780 So you have to ignore that one. 249 00:25:20,200 --> 00:25:23,720 It pretty much contains the same information, okay? 250 00:25:23,720 --> 00:25:29,340 But it's the convention used by the microcontrollers we've seen earlier. 251 00:25:29,460 --> 00:25:32,000 So here my password was indeed DefCon. 252 00:25:35,660 --> 00:25:49,000 Okay, so now that we think about it, we know that for many pre-boot authentication passwords, developers do not sanitize the memory after reading the password. 253 00:25:49,160 --> 00:25:50,300 Okay, good. 254 00:25:52,660 --> 00:26:00,820 One case which you might find when you try to break into a computer is that it would be nice to reboot the computer. 255 00:26:01,260 --> 00:26:06,740 So in some cases, it's not that difficult, but let's imagine you have a full disk encryption. 256 00:26:07,420 --> 00:26:09,060 You rooted the box already. 257 00:26:09,060 --> 00:26:13,060 You want to reboot it for some reason, like you want to flash the BIOS or something. 258 00:26:13,240 --> 00:26:24,180 For instance, to, I don't know, downgrade the BIOS EPROM, possibly to do SMM rootkit stuff, or you want to manipulate... 259 00:26:24,180 --> 00:26:32,280 I mean, if you have access to the machine before there is a kernel in memory, it's like ring minus one. 260 00:26:32,280 --> 00:26:34,000 You can't do anything, right? 261 00:26:34,280 --> 00:26:36,960 You broke the integrity very early. 262 00:26:37,700 --> 00:26:43,880 So let's assume we have a disk encryption kind of thing, and we want to reboot it anyway. 263 00:26:43,980 --> 00:26:56,360 If you just do a reboot, what's going to happen is that the computer will switch down, and then it will boot again until the moment that someone... 264 00:26:57,100 --> 00:27:02,040 I mean, the encryption software asks you for a password, right? 265 00:27:02,380 --> 00:27:10,260 And since you don't have access to the console, because we assume that you don't have physical access to the computer, well, pretty much you're fucked. 266 00:27:12,700 --> 00:27:19,620 So in the next section, we will try to find ways to reboot the computer anyway. 267 00:27:20,380 --> 00:27:25,680 So we assume you can write to the master boot record, and you can indeed reboot the computer. 268 00:27:25,680 --> 00:27:29,840 So typically, this will mean you have root kind of access. 269 00:27:29,900 --> 00:27:38,820 There are several cases that can be interesting, where you don't actually need root itself. 270 00:27:38,820 --> 00:27:44,900 For instance, if you're running Ubuntu, the default user would be good enough. 271 00:27:45,400 --> 00:27:51,100 If you have access to KMM, basically KMM group, you can read to DevMem, so that's good enough. 272 00:27:51,100 --> 00:27:55,740 But let's say, okay, for the sake of simplicity, let's say you have root access to the computer. 273 00:27:56,920 --> 00:27:59,000 So there are really two cases here. 274 00:27:59,220 --> 00:28:08,720 First one, the bootloader asks for a password, which is just there to bug you, but is not used to decrypt anything. 275 00:28:08,720 --> 00:28:11,980 This is typically the case of Lilo, Grub. 276 00:28:11,980 --> 00:28:22,120 There is no disk encryption stuff, so if you just nopped the password checking routine, you can bypass the authentication routine, right? 277 00:28:22,580 --> 00:28:27,100 The other case is when the password is actually used to decipher the disk. 278 00:28:27,100 --> 00:28:33,080 Then, if you just try to nop the password checking routine, well, nothing will happen. 279 00:28:33,080 --> 00:28:35,360 Like, you won't decrypt your drive, and that's it. 280 00:28:37,060 --> 00:28:52,680 Okay, so while the first case is really trivial, like we mentioned, if you have a Lilo or Grub password, or whatever, which does not use the password to decrypt anything on the drive, you can pretty much just patch the bootloader. 281 00:28:53,220 --> 00:29:03,180 This has been studied deeply in not the latest, but the previous FRAC issue. 282 00:29:03,180 --> 00:29:06,100 It's an article called Hacking Deeper in the System. 283 00:29:06,100 --> 00:29:09,000 It's pretty much a patch in Grub for fun and profit. 284 00:29:09,720 --> 00:29:16,100 Okay, so this is the example, I mean, a typical example of what could happen if you can write to the master boot record. 285 00:29:16,720 --> 00:29:25,780 Here, I had Lilo asking for a password, and I patched it, so it doesn't ask for a password anymore, and just reboots. 286 00:29:26,280 --> 00:29:28,660 If you look at Lilo, it's actually amazing. 287 00:29:28,660 --> 00:29:31,040 You can change the delays and stuff like that. 288 00:29:31,040 --> 00:29:32,800 Pretty fun. 289 00:29:33,740 --> 00:29:49,100 Okay, let's now go to the actual interesting case where you have a password check which will use a password to decrypt your hard drive. 290 00:29:56,880 --> 00:30:00,760 Okay, you might be thinking here, why is he talking about that anyway? 291 00:30:00,920 --> 00:30:05,680 So I'll show you that this is pretty linked to what we've been doing before. 292 00:30:05,680 --> 00:30:09,880 I will show you an actual attack scenario and a demo for it. 293 00:30:10,700 --> 00:30:12,260 Okay, here's a problem. 294 00:30:12,260 --> 00:30:28,100 We've seen that we can retrieve the password from memory because the guys who write bootloaders do not sanitize, typically, the BIOS keyboard buffer after reading the password. 295 00:30:28,380 --> 00:30:32,420 What if they don't initialize it before reading the password? 296 00:30:33,460 --> 00:30:36,600 So actually, what you could do... 297 00:30:36,600 --> 00:30:39,420 Okay, this is a world map we've been seeing before. 298 00:30:39,420 --> 00:30:48,040 Like you have the bootloader which uses BIOS interruptions to retrieve the content of the BIOS keyboard buffer. 299 00:30:49,360 --> 00:30:51,440 Okay, we don't need all of that. 300 00:30:51,580 --> 00:30:55,440 Okay, let's imagine I write... 301 00:30:55,440 --> 00:30:58,380 I replace the master boot record with mine. 302 00:30:58,460 --> 00:31:01,260 Okay, a rogue bootloader kind of thing. 303 00:31:01,260 --> 00:31:14,340 What it would do is actually talk directly using PIC programming to the two PICs inside the motherboard and the one inside the keyboard in order to... 304 00:31:14,340 --> 00:31:20,120 Okay, so this is done via EOPorts so you need root privileges to do that too. 305 00:31:20,740 --> 00:31:22,540 I mean, it's nonsense. 306 00:31:22,540 --> 00:31:32,540 Like , when you're a rogue bootloader you're running in real mode so you have access to anything anyway. 307 00:31:32,600 --> 00:31:36,840 But you can use EOPorts to reprogram those two PICs. 308 00:31:37,020 --> 00:31:43,080 So it's pretty much like emulating the fact of typing keys inside a keyboard. 309 00:31:43,380 --> 00:31:51,540 Okay, so you can fill in the BIOS keyboard buffer with the password you've discovered previously. 310 00:31:52,120 --> 00:32:06,280 Okay, and then remove the rogue bootloader replace it by the original bootloader which will do its task normally which is, it will ask for... 311 00:32:06,820 --> 00:32:17,860 it will ask using interruption 16 for user input and the BIOS interruption service routine will read the password you've entered previously. 312 00:32:18,040 --> 00:32:18,900 Okay? 313 00:32:19,840 --> 00:32:21,460 Normal stuff here. 314 00:32:22,920 --> 00:32:33,600 Okay, so in order to do that we need to write a rogue bootloader which is, first of all, backup the old master boot record. 315 00:32:37,880 --> 00:32:40,240 Okay, there are some conditions not very interesting. 316 00:32:40,240 --> 00:32:41,880 I'll check all the details later. 317 00:32:43,060 --> 00:32:46,020 Okay, so it basically backups the old master boot record. 318 00:32:46,020 --> 00:32:47,960 Okay, that's the installation process. 319 00:32:47,960 --> 00:32:55,800 This rogue bootloader will, using PIC programming enter a password inside the BIOS data area using PIC programming. 320 00:32:56,620 --> 00:33:04,660 And then it will copy back the old master boot record in place using, for instance, interruption 19. 321 00:33:04,660 --> 00:33:06,160 It's very valid. 322 00:33:06,380 --> 00:33:11,520 And transfer, control transfer to the original bootloader. 323 00:33:12,280 --> 00:33:20,640 Okay, I'll give you a demo here only it's a bit tricky to put in place so I'll cheat a bit, I'll show you a video. 324 00:33:31,860 --> 00:33:32,580 Hopefully... 325 00:33:32,580 --> 00:33:44,280 Okay, so in that case the computer is protected with two passwords. 326 00:33:44,280 --> 00:33:52,840 The first one is a grub password using md5 encryption and the computer is also... 327 00:33:52,840 --> 00:34:00,220 so we're under Linux we want to reboot that Windows machine which is also encrypted using TrueCrypt. 328 00:34:00,980 --> 00:34:03,780 So you can check the md5 password and stuff. 329 00:34:03,780 --> 00:34:05,140 There is one trick here. 330 00:34:05,140 --> 00:34:25,500 The name of the entry in grub is very long so I can actually not copy I cannot enter in grub the whole name of the grub entry because the size of the BIOS keyboard buffer is limited to 16. 331 00:34:25,500 --> 00:34:33,300 So what we do using character backslash x19 is to use the arrow key. 332 00:34:33,960 --> 00:35:07,080 First of all, the first character we use the escape character to escape the graphical interface entering the grub menu then we choose the actual entry we want to reboot using arrow keys we write the password for the first bootloader grub, which is owned then we press enter it's really the exact same stuff you would do if you were in front of the computer only we do that using a bootloader so we don't have to have access to the computer itself. 333 00:35:07,980 --> 00:35:23,120 Ok, so we wrote a small installer for that so you need to know the device and here is what happened it's going to be very fast Ok, this is it So, I don't know if you've seen Thank you 334 00:35:28,900 --> 00:35:37,380 So what happens is you can really reboot a computer even if it has multiple encryption and multiple password checking 335 00:35:41,050 --> 00:35:58,690 Ok, let's go to the I mean, I've been telling most of the people I've enabled and stuff so now I'm going to disclose the full list of people actually enabled First of all, I would like to thank the vendors for their attitude they've been very responsible and cooperative but TrueCrypt, 336 00:35:58,690 --> 00:36:26,210 like these guys told us the vulnerability only exists because you are misusing the software Thank you, that's very deep Ok, so the first kind of passwords we've been talking about are biased passwords so here is a list of vulnerable APROMs so you can see pretty much everybody is vulnerable ranging from, 337 00:36:26,210 --> 00:37:18,590 well, you read it Full disk encryption software with pre-boot authentication capabilities so BitLocker, which is the encryption software for Microsoft Vista on the version SP0 is vulnerable it has been fixed in SP1 TrueCrypt so even if those guys deny the truth I showed you before that you can also reboot it DiskCryptor and DriveCrypt and bootloader passwords so Grub and Lilo are also vulnerable for the sake of completeness I will also show you the list of non-vulnerable software we've seen so there are several biased passwords full disk encryption software. 338 00:37:18,750 --> 00:37:25,310 This list is obviously far from being exhaustive so I entitle you to, I mean, do your own experiments. 339 00:37:25,350 --> 00:37:28,210 Actually the exploit is the same everywhere. 340 00:37:28,350 --> 00:37:35,690 So there is one exploit for Unix which is going to work for any pre-boot authentication password if available. 341 00:37:35,890 --> 00:37:37,630 And one version for Windows. 342 00:37:37,630 --> 00:37:44,250 So you just check this, install a few software and check if they are vulnerable. 343 00:37:45,450 --> 00:37:50,070 If you do so, I would appreciate if you sent me a mail or something. 344 00:37:51,930 --> 00:37:56,190 Okay, so how do we mitigate those vulnerabilities? 345 00:37:56,930 --> 00:38:10,190 Okay, the most obvious, I mean, the most obvious advice I could give is like to sanitize the BIOS keyboard buffer before and after use, right? 346 00:38:11,950 --> 00:38:14,250 You can check on the website. 347 00:38:14,250 --> 00:38:17,990 We are trying to keep a list of patches to do that. 348 00:38:18,130 --> 00:38:25,710 Unfortunately when it comes, for instance , to BIOS EEPROMs, it's very difficult to patch it yourself . 349 00:38:25,710 --> 00:38:28,190 You have to wait for the vendor to issue fix. 350 00:38:29,030 --> 00:38:41,010 So you must probably looking for an intermediary solution which will not fix all the problems but, I mean, will fix most of them. 351 00:38:41,110 --> 00:38:48,970 So if you're using Linux, I can, I really entitle you to download the geosecurity patch from openworld.net. 352 00:38:49,450 --> 00:38:55,050 Brad has been very keen to release a new version today, including the patch we've written for it. 353 00:38:55,310 --> 00:38:59,610 So what it does basically is, yeah, 354 00:39:15,380 --> 00:39:16,440 absolutely not . 355 00:39:16,780 --> 00:39:17,860 No, no. 356 00:39:17,860 --> 00:39:19,900 What do you mean you have to actually? 357 00:39:31,220 --> 00:39:33,020 You're the true creep guy or something? 358 00:39:38,700 --> 00:39:39,700 Okay. 359 00:39:39,700 --> 00:39:47,420 See, what happens is, if the password can be entered by the keyboard, okay, just let me reply to you. 360 00:39:47,420 --> 00:40:06,260 If the password can be entered at the keyboard, okay, from the keyboard, there is no difference from the bootloader point of view if it's actually typed at boot time on the console or if it has been stored in the BIOS keyboard buffer by a previous rogue bootloader, 361 00:40:06,260 --> 00:40:06,680 okay? 362 00:40:07,060 --> 00:40:08,740 It's exactly the same thing. 363 00:40:08,740 --> 00:40:11,100 I mean, it's following the same process. 364 00:40:20,420 --> 00:40:21,880 It's... Okay. 365 00:40:25,680 --> 00:40:31,240 So see, I'm afraid I don't really understand your question, but we can... 366 00:40:39,040 --> 00:40:39,980 Okay. 367 00:40:40,000 --> 00:40:46,560 So what happens with, for instance, TPM ships, you can't actually mitigate, yeah, you're right. 368 00:40:46,560 --> 00:40:57,420 So you can retrieve the password, but you can't actually reboot the computer using the, I mean, rogue bootloader method. 369 00:40:57,420 --> 00:40:58,440 That was your point? 370 00:40:59,260 --> 00:41:00,740 So it's very true. 371 00:41:00,740 --> 00:41:03,320 No, I have no method to bypass TPM so far. 372 00:41:03,320 --> 00:41:05,480 I have not studied it deeply. 373 00:41:06,200 --> 00:41:08,740 There are really three vulnerabilities here. 374 00:41:08,740 --> 00:41:12,280 Like the first one is the ability to retrieve the password in plain text. 375 00:41:12,280 --> 00:41:16,120 The second one is the effect of rebooting, okay? 376 00:41:16,120 --> 00:41:23,860 And the third one is actually the kernel leakage inside user LAN from Microsoft, right? 377 00:41:23,860 --> 00:41:30,500 Which allows you to kind of retrieve the password with less privileges, okay? 378 00:41:30,500 --> 00:41:36,620 So I've discussed with the, I mean, guys responsible at Microsoft, they are working on a fix. 379 00:41:36,620 --> 00:41:39,580 This is very complicated to fix, okay? 380 00:41:40,240 --> 00:41:41,420 But you're right. 381 00:41:41,640 --> 00:41:47,220 My bypassing of TrueCrypt, of BitLocker, sorry, is not full. 382 00:41:47,220 --> 00:41:48,640 I could not reboot it. 383 00:41:50,440 --> 00:41:52,820 Okay, so just a few greetings. 384 00:41:52,860 --> 00:42:05,600 So first of all, I would like to thank my reviewers, the technical team which I work with, and the guys from EverybodyDies.com. 385 00:42:05,600 --> 00:42:13,380 It's actually a game, computer game, and they allowed me to use their screenshots of the game which is now called DEFCON inside my slides. 386 00:42:13,380 --> 00:42:15,240 This is why my slides look so good. 387 00:42:17,300 --> 00:42:21,040 Community guys, so plug the plug, plug security. 388 00:42:21,380 --> 00:42:25,060 Thank you for coming and waking up after the parties and stuff. 389 00:42:26,180 --> 00:42:32,160 All you for coming to the presentation, and indeed the DEFCON staff for the awesome event and parties. 390 00:42:32,360 --> 00:42:34,960 I think we can clap for that, yeah.