[00:01.090 --> 00:04.690] Wow. Hello everybody. Thank you for coming. [00:06.150 --> 00:08.570] Just a little survey before we start. [00:09.290 --> 00:16.090] Does everybody have any experience with writing viruses kind of thing for master boot records? [00:16.090 --> 00:17.910] Please raise your hand. [00:19.710 --> 00:22.210] Okay, so officer, those two guys. [00:24.630 --> 00:28.270] Okay, more seriously, if you have absolutely no idea what is a BIOS [00:28.270 --> 00:34.090] or what is a boot loader, maybe you should take an app or something for the next 50 minutes. [00:35.710 --> 00:39.630] Okay, basically we're going to talk about pre-boot authentication passwords. [00:40.150 --> 00:41.670] Okay, everybody see? Okay. [00:42.030 --> 00:48.350] Pre-boot authentication. So let's start with the initial introduction kind of thing. [00:49.150 --> 00:52.350] So I'm a French guy. I live in India. [00:52.350 --> 00:55.790] I work for a company named IVS Security. [00:56.310 --> 00:59.590] I mean, IVS Technology Solutions Private Limited. [01:00.990 --> 01:05.390] I would like to pass a private message kind of thing also [01:05.390 --> 01:12.450] to the girl who leaked my tattoo yesterday night at the immunity party. [01:13.110 --> 01:17.170] So we have not been introduced formally, [01:17.170 --> 01:21.690] but my room number is 524 at the Sahara Hotel, [01:21.690 --> 01:23.550] so you're most welcome anytime. [01:26.320 --> 01:30.260] Okay, so basically we're going to talk about one new class of vulnerabilities. [01:30.260 --> 01:34.260] It's not something affecting only one piece of software, [01:34.260 --> 01:38.980] but multiple pre-boot authentication implementations. [01:38.980 --> 01:42.480] We'll define later what is exactly a pre-boot authentication password. [01:42.840 --> 01:45.880] We focus on password-based authentication only. [01:46.520 --> 01:51.400] The thing that's a bit remarkable, like if you've been to Blackout or something this year, [01:51.400 --> 01:55.600] there was a talk called boot attacks. [01:56.040 --> 01:58.840] Here, we don't need at all physical access to the computer. [02:00.920 --> 02:03.200] Okay, so we'll start with a few definitions, [02:03.200 --> 02:06.000] like defining exactly what is the scope of the talk, [02:06.000 --> 02:08.800] and what is a pre-boot authentication password. [02:09.580 --> 02:13.520] Then we'll switch to Windows, and then to unique exploitation, [02:13.520 --> 02:18.700] and then we will see a few further enhancements to the technology we've been developing. [02:20.220 --> 02:27.600] Okay, so just as a reminder, I'm pretty sure all of you know the boot seconds kind of stuff, [02:27.600 --> 02:34.020] but I've read so many mistakes that just to fix the IDs, I spent some time on that. [02:34.240 --> 02:37.900] Then we will define the different types of passwords we're going to be attacking, [02:38.800 --> 02:45.720] and have a closer look at the bias functions to read user keyboard, user input basically. [02:46.860 --> 02:48.400] Okay, here we go. [02:48.880 --> 02:52.560] So when you start a computer, the CPU starts in read mode. [02:53.880 --> 03:01.640] There is pretty nothing which is known, like there is no disk, there is no RAM, [03:01.640 --> 03:03.400] there is no nothing at the very beginning. [03:03.680 --> 03:11.440] So while memory, I mean, control is transferred to the bias by performing a long jump kind of thing, [03:11.440 --> 03:19.560] which is basically translated via hardware, since there is no RAM, to the bias entry point. [03:20.180 --> 03:27.360] So the bias itself is in charge of several things, like setting up the power, initializing the clock. [03:29.520 --> 03:33.300] Okay, it then discovers your RAM, so we can start doing things. [03:34.080 --> 03:37.160] Your hard drive with the master boot record. [03:39.200 --> 03:45.720] Okay, one thing really important, it starts at address zero, the interrupt vector table. [03:45.980 --> 03:50.800] So from now on, we can basically issue interruptions, which was not the case before. [03:51.480 --> 03:56.860] So using interruption 19, the master boot record is mapped in RAM. [03:57.020 --> 03:58.840] Okay, it's basically the boot loader. [03:58.840 --> 04:03.120] It was in charge of loading later on the kernel. [04:03.120 --> 04:10.000] So if we think about it, like let's do our kind of collecting, kind of brainstorming. [04:10.180 --> 04:12.420] Let's say we want to code a boot loader. [04:12.620 --> 04:16.980] Basically, which is the API which is available to you? [04:16.980 --> 04:19.080] There is no kernel in memory, no nothing. [04:19.240 --> 04:20.580] So what can you use? [04:21.740 --> 04:22.680] No one? [04:23.300 --> 04:27.660] Okay, so all the API which is available is indeed the bias. [04:27.660 --> 04:33.680] The bias provides you input-output interface, okay? [04:33.700 --> 04:39.720] And you could use also physical ERQs, like writing directly to disk and stuff like that. [04:41.000 --> 04:45.180] So this is very important for the rest of the speech, right? [04:45.180 --> 04:47.260] We'll focus on bias stuff for a reason. [04:47.260 --> 04:51.800] Because basically, when you want to write a boot loader, it's the only API which is available. [04:52.760 --> 04:57.440] Okay, let's see a bit the different kind of passwords you can have when you boot a computer. [04:57.440 --> 05:04.280] By pre-boot, we mean anything that can ask for a password before there is actually a kernel in memory, right? [05:04.360 --> 05:07.480] So they could be of several kinds. [05:07.920 --> 05:13.680] Like bias passwords, you know those blue screens that pop up when you first start your computer. [05:14.060 --> 05:15.680] So those are one kind. [05:16.060 --> 05:19.080] Boot loader passwords, basically those are the most common. [05:19.080 --> 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. [05:26.440 --> 05:30.280] So it could be like Vista Boot Loader, Grub, Lilo. [05:30.440 --> 05:32.960] We'll see some other examples later on. [05:33.380 --> 05:36.640] And it could be also early stage passwords. [05:37.180 --> 05:47.040] Typically, when the kernel first starts in real mode, before switching in private mode, it could ask you for a password. [05:47.040 --> 05:50.340] So we'll see that later on also. [05:51.620 --> 05:56.420] Okay, let's have a closer look at the BIOS functions. [05:56.420 --> 05:58.740] They are used to read user input. [05:59.920 --> 06:10.520] Okay, there is basically one interruption for the BIOS, which is interruption 16, which has two function relevance to us. [06:10.640 --> 06:19.940] The first one, getsKeyStroke, is mostly used to check and retrieve one keystroke at a time. [06:19.940 --> 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. [06:33.080 --> 06:34.260] Zero flag, sorry. [06:34.300 --> 06:43.540] So this is typically used to first check if a keystroke has been entered, and then retrieve it. [06:43.540 --> 06:47.480] For instance, in Lilo, this is done like that. [06:47.480 --> 06:51.780] So you can see there are, I mean, there's two functions implemented, right? [06:51.880 --> 06:59.400] The first one is using function, I mean, sub-function 01, and the second one is actually retrieving the key. [07:01.300 --> 07:03.820] Okay, give me two second. [07:08.960 --> 07:23.540] 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, [07:23.540 --> 07:31.440] because nowadays, I mean, most OSCs will prevent you to do that, they are running in private mode, okay? [07:31.440 --> 07:39.100] So they have segmentation and stuff, and obviously you cannot trigger BIOS interrupts. [07:39.900 --> 07:51.440] 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, [07:51.440 --> 08:01.800] so you enter as a parameter into AX either 0 or 01, and you later on call interruption 16, [08:01.800 --> 08:08.140] and in return, okay, you opt to retrieve an ASCII scan code, okay, for a key that was pressed. [08:08.940 --> 08:17.660] Okay, you must probably know that, or in fear, that somewhere on the field, there is a keyboard. Fine. [08:17.660 --> 08:23.380] The real question is, how is it all tied together? Like, what's in the middle? [08:27.660 --> 08:34.340] Okay, so let's detail a bit how this is all working from the keyboard to the process. [08:34.440 --> 08:37.700] Because this is really the whole core of my presentation. [08:38.500 --> 08:42.260] So basically, inside the keyboard, you have the first PIC. [08:42.420 --> 08:45.960] So if you know PIC programming, you can actually program your keyboard. [08:45.960 --> 08:50.500] I mean, the data sheets are available on Intel website. [08:50.980 --> 08:54.860] So this one is the first one. [08:59.220 --> 09:07.160] Okay, that chip is responsible for triggering an event every time you press or you release a key. [09:07.260 --> 09:11.520] There is a second one, which is embedded inside your motherboard. [09:11.520 --> 09:19.300] So the first PIC sends to the other one an event every time you press or release. [09:19.320 --> 09:21.300] This is actually not good enough. [09:21.300 --> 09:25.920] Like, if you press for quite a time, you would like the key to be repeated. [09:25.920 --> 09:30.760] And if you just press and release, you would like it to be counted as only one key. [09:30.760 --> 09:43.340] So this is the role of the second PIC, which actually unifies the scan codes and sends them to interruption 09, [09:43.340 --> 09:50.160] which is also called DRQ01, which is responsible for handling the keyboard in the level. [09:50.680 --> 09:54.120] Okay, the interesting thing is really the next thing. [09:54.380 --> 10:00.040] Inside the RAM, there is a data structure called the BIOS data area. [10:00.040 --> 10:05.920] It contains many fields of your BIOS configuration. [10:06.360 --> 10:11.360] Okay, there are two pointers and one buffer who are interesting to us. [10:11.560 --> 10:24.500] So what happens when you press a key, the keyboard interrupt service routine copies that key into the yellow buffer [10:24.500 --> 10:28.100] and updates the pointers accordingly. [10:28.100 --> 10:30.860] And same thing when you try to retrieve a key. [10:30.860 --> 10:38.100] So here we have the full process, I mean, from a keyboard to a process kind of thing. [10:38.300 --> 10:42.140] Okay, that's clear? Everybody? Awesome. [10:42.920 --> 10:49.100] Okay, so in details, if you look at the keyboard buffer, that yellow thing inside memory, [10:49.860 --> 10:55.180] every time you enter a key, the pointer to the last character is incremented. [10:55.180 --> 10:59.700] Okay, so this is the yellow arrow there. [10:59.940 --> 11:06.280] And when you retrieve a key, the red one, the pointer to the next character is updated. [11:06.300 --> 11:08.680] Okay, so it's always pointing to the next one. [11:09.080 --> 11:12.580] The big problem here, I guess you guys can already see it. [11:15.080 --> 11:21.280] Okay, is that this buffer is actually never flushed. [11:21.280 --> 11:28.100] So every time you enter a password at boot time, and the BIOS takes care of reading it, [11:28.100 --> 11:32.520] it remains in memory forever. Okay? Yeah. [11:34.800 --> 11:36.020] Thank you. [11:41.700 --> 11:48.220] So this has been there for like 25 years, and more than that actually. [11:48.660 --> 11:52.540] And we're going to see that pretty much everybody is vulnerable to that. [11:52.540 --> 11:58.960] So in an ideal world, what you would do when you called a bootloader kind of thing, [11:58.960 --> 12:07.640] you would sanitize the BIOS keyboard buffer, that yellow thing, after reading a password. [12:08.340 --> 12:12.960] Okay, let's see how it actually works in real life, and how it is implemented. [12:14.000 --> 12:20.680] So a good example to check how BIOS aware are people, [12:20.680 --> 12:26.300] is to look at the way the BIOS guys implemented the BIOS password inside the BIOS itself. [12:26.360 --> 12:26.880] Okay? [12:27.420 --> 12:32.580] So to do that, I mean, every code you edit on the CD-ROM, there is a toggle on the CD-ROM, [12:32.580 --> 12:39.420] so I really encourage you to have a look at it, and give us feedback if you have questions out of it. [12:40.960 --> 12:50.700] So anyway, we wrote a small USB bootable OS, in 60-byte read mode, [12:50.700 --> 12:55.880] to dump the content of the BIOS keyboard buffer. [12:56.540 --> 13:00.420] So basically you boot, the BIOS asks you for a password, [13:01.080 --> 13:06.500] and then, for a small OS kind of thing, dumps the content of the memory. [13:06.500 --> 13:11.420] Okay, what we've been seeing is that most BIOS passwords are vulnerable to that. [13:11.940 --> 13:20.080] So let's imagine third-party developers, like a guy writing software encryption things, [13:20.080 --> 13:25.280] or any kind of bootloader asking for a password, they are most probably not aware of it. [13:25.280 --> 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. [13:33.140 --> 13:40.140] Okay, one interesting thing, let's imagine we have two passwords checking in a row. [13:42.930 --> 13:48.910] Could be like, for instance, you have a BIOS password, plus a GRUB or LILO password, [13:48.910 --> 13:56.530] or you could have a GRUB password, like asking an MD5 password, plus a disk encryption software in a row, okay? [13:56.770 --> 14:01.510] So in that case, what would the BIOS keyboard buffer look like? [14:04.880 --> 14:13.380] Okay, so actually, pass one would be the password for the first BIOS password, [14:13.380 --> 14:18.820] then you would have the enter key, then you would have the second password, and then you would have enter. [14:19.020 --> 14:27.060] So basically, if you have several passwords in a row, they are all concatenated inside the BIOS keyboard buffer. [14:27.060 --> 14:32.180] So from an exploitation point of view, this is really like the best possible thing ever. [14:35.350 --> 14:37.210] Okay, from now on, we're going to see... [14:37.210 --> 14:47.770] Okay, so just to summarize the scope, we've seen that in many cases, when we have preboot authentication passwords, [14:47.770 --> 14:52.070] the passwords remain in physical memory at a given location we know. [14:52.070 --> 14:54.530] Okay, we know that location in physical memory. [14:54.530 --> 15:03.470] The problem is, once the operating system is loaded, the kernel first switches in protected mode. [15:04.170 --> 15:10.350] So there, there is segmentation, paging and stuff, so you're not supposed to read physical memory anymore. [15:10.750 --> 15:16.210] So the whole deal of the next two chapters, Windows exploitation and Unix exploitation, [15:16.210 --> 15:22.910] is actually to manage to retrieve the password from that physical location we know in physical memory. [15:23.850 --> 15:26.050] Once the computer has booted. [15:26.070 --> 15:33.130] Okay, so we assume that the OS has been fully booted and we're given a shell. [15:33.690 --> 15:36.350] We're going to define the conditions later on. [15:36.350 --> 15:44.290] So the big change with a common approach to cold boot attacks, we don't need physical access. [15:45.670 --> 15:50.850] Okay, let's first discuss the Windows case. [15:50.850 --> 16:00.050] We will discuss a bit, so just summarize the challenges, like I just did actually. [16:00.190 --> 16:06.730] Then discuss possible attack scenario, and well, discuss the actual implementation we've done. [16:07.930 --> 16:15.530] So that's the physical address, 40.0x1.e, from protected mode. [16:15.650 --> 16:18.270] And we want to try to retrieve it. [16:18.270 --> 16:23.330] So possible things we could do, like how do you read physical memory? [16:23.910 --> 16:26.910] So one thing could be to get back to real mode. [16:26.910 --> 16:38.130] That way you would disable segmentation, disable paging, so you could very well read the stuff from the physical memory. [16:39.170 --> 16:40.520] That's one solution. [16:41.050 --> 16:45.690] You could think of switching to SMM, which is another CPU mode. [16:45.690 --> 16:48.730] So same thing, there is no segmentation, no paging. [16:48.730 --> 16:50.230] So that could be an option. [16:50.690 --> 16:53.230] Or you could try to get it from Kernel land. [16:54.010 --> 17:00.770] The big problem is that all those solutions require typically huge amount of privileges. [17:00.870 --> 17:04.390] So under Windows you need system privileges or kernel privileges. [17:04.770 --> 17:06.070] So let's not do that. [17:07.970 --> 17:11.630] We're going to use a Microsoft feature. [17:14.430 --> 17:18.170] Yeah, you can start laughing, but just wait to look at it. [17:18.170 --> 17:20.230] I mean, it's pretty awesome. [17:21.650 --> 17:25.130] Okay, we're going to use the MS-DOS emulation mode. [17:26.030 --> 17:35.350] Basically it has been there since Windows 95 to allow retro compatibility with MS-DOS. [17:35.350 --> 17:44.150] So it's built over the last CPU mode we've not seen so far, which is a virtual mode. [17:44.150 --> 17:54.790] It basically emulates an 8886 CPU, so a very old Intel CPU, with some restrictions and with some mistakes. [17:54.790 --> 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. [18:03.930 --> 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. [18:17.110 --> 18:19.630] So let's go for a demo. [18:30.880 --> 18:34.280] Okay, I launched a demo in the background and let's keep going. [18:38.080 --> 18:41.460] Now let's discuss the thing about UNIX. [18:41.460 --> 18:48.540] By UNIX we mean BSD, Saurus, whatever, which is running Intel-compatible CPUs. [18:48.720 --> 18:52.740] Otherwise, you don't have a BIOS in the first place, and it's not really interesting to us. [18:54.520 --> 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. [19:07.240 --> 19:12.860] So we will have to assume we have some privileges to retrieve the password. [19:14.040 --> 19:17.400] So, first of all, we could try to get it from user layout. [19:18.120 --> 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. [19:28.500 --> 19:37.100] So if you use a simple tool, you can actually read the password in plain text into DevMem. [19:37.540 --> 19:41.600] This is really awesome also. It has been there for years. [19:41.600 --> 19:46.480] Everybody has been using password, and apparently it's the first time someone is disclosing it. [19:48.360 --> 19:53.940] Instead of using DevMem, you could use DevCardMem, which is a mapping of the kernel. [19:53.940 --> 20:02.980] For the technical guys here, I'm assuming 3GB, 1GB kernel split. Otherwise, the addresses won't be the same. [20:03.060 --> 20:07.280] But the principle is always the same. You can get it from KernelN also. [20:10.000 --> 20:15.140] DevCardCore, which basically contains the very same information in the form of a core file. [20:15.480 --> 20:18.380] So using the very same tool, you can also retrieve your password. [20:19.760 --> 20:24.440] Okay, so we have implemented a simple tool to automate pretty much the test for you. [20:24.580 --> 20:34.080] It's been testing under a wide range of Unix distributions, running on x86 CPUs. [20:35.440 --> 20:41.260] Okay, so same thing. You can see the stuff in red. It's your actual whatever password. [20:41.260 --> 20:44.720] Like it could be a BIOS password, book loader password, and stuff. [20:46.200 --> 20:48.180] Okay, let's get back to the demo. [20:49.660 --> 20:56.120] Okay, so this is Windows. I have a guest account. And I'm using a very simple COM file. [20:58.340 --> 21:02.820] The VOX is encrypted with, I mean it has full disk encryption with TrueCrypt. [21:03.140 --> 21:08.220] And you can see my password is total. You can applaud here. [21:11.100 --> 21:12.220] Thank you. [21:21.820 --> 21:30.260] Okay, so we can also think about getting the password under Unix from a kernel end. [21:30.700 --> 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. [21:40.960 --> 21:44.660] This is done in setup.c if you want to look at the kernel source. [21:44.660 --> 21:48.940] So it's really early stage of the kernel before switching to protected mode. [21:49.620 --> 21:54.900] So we're assuming the same kernel split I explained before. [21:54.960 --> 21:58.200] So does everybody know what is a kernel split in the first place? [21:58.740 --> 22:02.280] Okay, basically it means that you have a user land and kernel land. [22:02.280 --> 22:06.860] And the amount of memory allocated to both can differ. [22:07.100 --> 22:13.660] And you can actually on any kind of distribution specify at boot time which kind of split you want. [22:13.660 --> 22:21.200] So in case of the standard three gigabyte, one gigabyte split, the address where it is copied. [22:21.200 --> 22:26.140] So this is defined by setup.c where it is copied inside the zero page. [22:26.200 --> 22:28.900] This is the address written there. [22:30.920 --> 22:37.240] So let's verify the password is actually located there in memory. [22:37.240 --> 22:41.920] So to do that, we can use, for instance, kernel debugging. [22:41.920 --> 22:43.520] Okay, remote kernel debugging. [22:43.540 --> 22:50.740] Here I'm using a VMware machine and I'm debugging the kernel inside the VMware machine. [22:51.320 --> 22:58.280] And what we see if we print what is at the given address, everybody gets to see it. [22:58.280 --> 23:01.400] So the letters in red are actually my BIOS password. [23:03.860 --> 23:11.840] Okay, since you probably don't want to have to do kernel debugging every time you want to read a password, [23:11.840 --> 23:20.660] we have written a small kernel module which adds an entry in the slash file system. [23:20.800 --> 23:24.840] And just by doing a cat on it, you can retrieve any kind of password. [23:33.410 --> 23:34.610] Thank you. [23:36.190 --> 23:44.010] Okay, so like we mentioned before, this bug has been there since humans have been using BIOS. [23:44.850 --> 23:46.470] So since we have PCs. [23:47.430 --> 23:50.690] And the awesome stuff is everything is in plain text. [23:51.030 --> 23:55.210] So just open your eyes, there might be other kinds of bugs like that. [23:56.510 --> 23:59.930] Okay, I'll give you a Unix demo. [24:00.610 --> 24:02.870] Okay, this is a raw Ubuntu. [24:04.230 --> 24:07.330] It has a GRUB MD5 password. [24:08.070 --> 24:10.730] So I need to assume several privileges. [24:10.730 --> 24:13.790] So typically I have a root console. [24:19.040 --> 24:24.740] Okay, here are the kind of attacks you can do against it. [24:24.740 --> 24:28.920] So you could try to retrieve it from DevMem, OldMem, whatever. [24:28.920 --> 24:32.920] I mean, under Ubuntu, you have many links. [24:34.240 --> 24:38.500] Like, slash dev static dev core is actually a link to dev core and stuff like that. [24:38.500 --> 24:43.820] But still, you have many options to try to retrieve that stuff. [24:43.820 --> 24:49.720] Even if you are into a stripped-down demo, you will... stripped-down distribution. [24:50.080 --> 24:55.740] And any kind of Unix, not only Linux, you will at least find DevMem or something like that, right? [24:56.520 --> 24:59.080] So let's execute it. [25:01.230 --> 25:03.430] Okay, so guess what's my password? [25:06.400 --> 25:08.940] Okay, it's not actually DefCon1. [25:08.940 --> 25:10.260] That was a trick. [25:10.800 --> 25:14.100] Every time you have one character, which is the ASCII code, [25:14.100 --> 25:17.700] the next one inside the BIOS keyboard buffer is a scan code. [25:17.700 --> 25:19.780] So you have to ignore that one. [25:20.200 --> 25:23.720] It pretty much contains the same information, okay? [25:23.720 --> 25:29.340] But it's the convention used by the microcontrollers we've seen earlier. [25:29.460 --> 25:32.000] So here my password was indeed DefCon. [25:35.660 --> 25:38.740] Okay, so now that we think about it, [25:38.740 --> 25:44.560] we know that for many pre-boot authentication passwords, [25:45.180 --> 25:49.000] developers do not sanitize the memory after reading the password. [25:49.160 --> 25:50.300] Okay, good. [25:52.660 --> 25:56.860] One case which you might find when you try to break into a computer [25:58.180 --> 26:00.820] is that it would be nice to reboot the computer. [26:01.260 --> 26:03.500] So in some cases, it's not that difficult, [26:03.500 --> 26:06.740] but let's imagine you have a full disk encryption. [26:07.420 --> 26:09.060] You rooted the box already. [26:09.060 --> 26:13.060] You want to reboot it for some reason, like you want to flash the BIOS or something. [26:13.240 --> 26:17.900] For instance, to, I don't know, downgrade the BIOS EPROM, [26:17.900 --> 26:21.240] possibly to do SMM rootkit stuff, [26:21.240 --> 26:24.180] or you want to manipulate... [26:24.180 --> 26:29.900] I mean, if you have access to the machine before there is a kernel in memory, [26:30.540 --> 26:32.280] it's like ring minus one. [26:32.280 --> 26:34.000] You can't do anything, right? [26:34.280 --> 26:36.960] You broke the integrity very early. [26:37.700 --> 26:41.900] So let's assume we have a disk encryption kind of thing, [26:41.900 --> 26:43.880] and we want to reboot it anyway. [26:43.980 --> 26:46.360] If you just do a reboot, what's going to happen [26:46.360 --> 26:52.360] is that the computer will switch down, [26:52.360 --> 26:54.740] and then it will boot again [26:54.740 --> 26:56.360] until the moment that someone... [26:57.100 --> 27:02.040] I mean, the encryption software asks you for a password, right? [27:02.380 --> 27:04.240] And since you don't have access to the console, [27:04.240 --> 27:07.680] because we assume that you don't have physical access to the computer, [27:07.680 --> 27:10.260] well, pretty much you're fucked. [27:12.700 --> 27:15.180] So in the next section, [27:15.180 --> 27:19.620] we will try to find ways to reboot the computer anyway. [27:20.380 --> 27:23.640] So we assume you can write to the master boot record, [27:23.640 --> 27:25.680] and you can indeed reboot the computer. [27:25.680 --> 27:29.840] So typically, this will mean you have root kind of access. [27:29.900 --> 27:36.240] There are several cases that can be interesting, [27:36.240 --> 27:38.820] where you don't actually need root itself. [27:38.820 --> 27:42.880] For instance, if you're running Ubuntu, [27:42.880 --> 27:44.900] the default user would be good enough. [27:45.400 --> 27:48.480] If you have access to KMM, basically KMM group, [27:48.480 --> 27:51.100] you can read to DevMem, so that's good enough. [27:51.100 --> 27:53.620] But let's say, okay, for the sake of simplicity, [27:53.620 --> 27:55.740] let's say you have root access to the computer. [27:56.920 --> 27:59.000] So there are really two cases here. [27:59.220 --> 28:03.660] First one, the bootloader asks for a password, [28:03.660 --> 28:06.440] which is just there to bug you, [28:06.440 --> 28:08.720] but is not used to decrypt anything. [28:08.720 --> 28:11.980] This is typically the case of Lilo, Grub. [28:11.980 --> 28:13.920] There is no disk encryption stuff, [28:13.920 --> 28:18.780] so if you just nopped the password checking routine, [28:18.780 --> 28:22.120] you can bypass the authentication routine, right? [28:22.580 --> 28:24.720] The other case is when the password [28:24.720 --> 28:27.100] is actually used to decipher the disk. [28:27.100 --> 28:31.160] Then, if you just try to nop the password checking routine, [28:31.160 --> 28:33.080] well, nothing will happen. [28:33.080 --> 28:35.360] Like, you won't decrypt your drive, and that's it. [28:37.060 --> 28:39.780] Okay, so while the first case is really trivial, [28:39.780 --> 28:42.100] like we mentioned, if you have a Lilo or Grub password, [28:42.100 --> 28:45.080] or whatever, which does not use the password [28:45.080 --> 28:49.480] to decrypt anything on the drive, [28:49.480 --> 28:52.680] you can pretty much just patch the bootloader. [28:53.220 --> 28:59.780] This has been studied deeply in not the latest, [28:59.780 --> 29:03.180] but the previous FRAC issue. [29:03.180 --> 29:06.100] It's an article called Hacking Deeper in the System. [29:06.100 --> 29:09.000] It's pretty much a patch in Grub for fun and profit. [29:09.720 --> 29:12.140] Okay, so this is the example, [29:12.140 --> 29:14.000] I mean, a typical example of what could happen [29:14.000 --> 29:16.100] if you can write to the master boot record. [29:16.720 --> 29:20.360] Here, I had Lilo asking for a password, [29:20.360 --> 29:22.380] and I patched it, [29:22.700 --> 29:24.680] so it doesn't ask for a password anymore, [29:24.680 --> 29:25.780] and just reboots. [29:26.280 --> 29:28.660] If you look at Lilo, it's actually amazing. [29:28.660 --> 29:31.040] You can change the delays and stuff like that. [29:31.040 --> 29:32.800] Pretty fun. [29:33.740 --> 29:39.060] Okay, let's now go to the actual interesting case [29:39.060 --> 29:45.160] where you have a password check [29:45.160 --> 29:49.100] which will use a password to decrypt your hard drive. [29:56.880 --> 29:58.560] Okay, you might be thinking here, [29:58.820 --> 30:00.760] why is he talking about that anyway? [30:00.920 --> 30:03.300] So I'll show you that this is pretty linked [30:03.300 --> 30:05.680] to what we've been doing before. [30:05.680 --> 30:08.040] I will show you an actual attack scenario [30:08.040 --> 30:09.880] and a demo for it. [30:10.700 --> 30:12.260] Okay, here's a problem. [30:12.260 --> 30:16.080] We've seen that we can retrieve the password from memory [30:16.080 --> 30:21.860] because the guys who write bootloaders [30:21.860 --> 30:25.960] do not sanitize, typically, the BIOS keyboard buffer [30:25.960 --> 30:28.100] after reading the password. [30:28.380 --> 30:30.280] What if they don't initialize it [30:30.280 --> 30:32.420] before reading the password? [30:33.460 --> 30:36.600] So actually, what you could do... [30:36.600 --> 30:39.420] Okay, this is a world map we've been seeing before. [30:39.420 --> 30:40.400] Like you have the bootloader [30:42.380 --> 30:44.760] which uses BIOS interruptions [30:44.760 --> 30:48.040] to retrieve the content of the BIOS keyboard buffer. [30:49.360 --> 30:51.440] Okay, we don't need all of that. [30:51.580 --> 30:55.440] Okay, let's imagine I write... [30:55.440 --> 30:58.380] I replace the master boot record with mine. [30:58.460 --> 31:01.260] Okay, a rogue bootloader kind of thing. [31:01.260 --> 31:05.360] What it would do is actually talk directly [31:06.540 --> 31:07.820] using PIC programming [31:08.480 --> 31:11.020] to the two PICs inside the motherboard [31:11.020 --> 31:12.680] and the one inside the keyboard [31:13.260 --> 31:14.340] in order to... [31:14.340 --> 31:16.580] Okay, so this is done via EOPorts [31:16.580 --> 31:20.120] so you need root privileges to do that too. [31:20.740 --> 31:22.540] I mean, it's nonsense. [31:22.540 --> 31:27.560] Like, when you're a rogue bootloader [31:29.100 --> 31:30.480] you're running in real mode [31:30.480 --> 31:32.540] so you have access to anything anyway. [31:32.600 --> 31:36.840] But you can use EOPorts to reprogram those two PICs. [31:37.020 --> 31:38.360] So it's pretty much like [31:39.100 --> 31:43.080] emulating the fact of typing keys inside a keyboard. [31:43.380 --> 31:47.040] Okay, so you can fill in the BIOS keyboard buffer [31:47.040 --> 31:51.540] with the password you've discovered previously. [31:52.120 --> 31:57.180] Okay, and then remove the rogue bootloader [31:57.180 --> 31:59.820] replace it by the original bootloader [31:59.820 --> 32:02.360] which will do its task normally [32:02.360 --> 32:06.280] which is, it will ask for... [32:06.820 --> 32:10.740] it will ask using interruption 16 for user input [32:10.740 --> 32:13.860] and the BIOS interruption service routine [32:13.860 --> 32:17.860] will read the password you've entered previously. [32:18.040 --> 32:18.900] Okay? [32:19.840 --> 32:21.460] Normal stuff here. [32:22.920 --> 32:25.440] Okay, so in order to do that [32:26.040 --> 32:29.640] we need to write a rogue bootloader [32:29.640 --> 32:33.600] which is, first of all, backup the old master boot record. [32:37.880 --> 32:40.240] Okay, there are some conditions not very interesting. [32:40.240 --> 32:41.880] I'll check all the details later. [32:43.060 --> 32:46.020] Okay, so it basically backups the old master boot record. [32:46.020 --> 32:47.960] Okay, that's the installation process. [32:47.960 --> 32:50.320] This rogue bootloader will, using PIC programming [32:50.320 --> 32:54.220] enter a password inside the BIOS data area [32:54.220 --> 32:55.800] using PIC programming. [32:56.620 --> 32:58.300] And then it will copy back [32:58.300 --> 33:02.400] the old master boot record in place [33:02.400 --> 33:04.660] using, for instance, interruption 19. [33:04.660 --> 33:06.160] It's very valid. [33:06.380 --> 33:11.520] And transfer, control transfer to the original bootloader. [33:12.280 --> 33:14.940] Okay, I'll give you a demo here [33:14.940 --> 33:17.560] only it's a bit tricky to put in place [33:17.560 --> 33:20.640] so I'll cheat a bit, I'll show you a video. [33:31.860 --> 33:32.580] Hopefully... [33:32.580 --> 33:38.040] Okay, so in that case [33:38.040 --> 33:44.280] the computer is protected with two passwords. [33:44.280 --> 33:48.680] The first one is a grub password [33:48.680 --> 33:50.420] using md5 encryption [33:50.420 --> 33:52.840] and the computer is also... [33:52.840 --> 33:53.960] so we're under Linux [33:53.960 --> 33:55.980] we want to reboot that Windows machine [33:55.980 --> 34:00.220] which is also encrypted using TrueCrypt. [34:00.980 --> 34:03.780] So you can check the md5 password and stuff. [34:03.780 --> 34:05.140] There is one trick here. [34:05.140 --> 34:11.020] The name of the entry in grub is very long [34:11.020 --> 34:13.340] so I can actually not copy [34:14.100 --> 34:16.480] I cannot enter in grub [34:16.480 --> 34:21.300] the whole name of the grub entry [34:21.300 --> 34:25.500] because the size of the BIOS keyboard buffer is limited to 16. [34:25.500 --> 34:31.240] So what we do using character backslash x19 [34:31.240 --> 34:33.300] is to use the arrow key. [34:33.960 --> 34:35.600] First of all, the first character [34:35.600 --> 34:37.160] we use the escape character [34:37.160 --> 34:39.740] to escape the graphical interface [34:39.740 --> 34:40.860] entering the grub menu [34:41.370 --> 34:43.220] then we choose the actual entry [34:43.220 --> 34:45.600] we want to reboot using arrow keys [34:45.600 --> 34:49.460] we write the password for the first bootloader [34:49.460 --> 34:51.140] grub, which is owned [34:51.860 --> 34:53.160] then we press enter [34:53.160 --> 34:55.540] it's really the exact same stuff [34:55.540 --> 34:57.440] you would do if you were in front of the computer [34:57.440 --> 35:03.280] only we do that using a bootloader [35:03.940 --> 35:07.080] so we don't have to have access to the computer itself. [35:07.980 --> 35:13.120] Ok, so we wrote a small installer for that [35:13.120 --> 35:14.760] so you need to know the device [35:14.760 --> 35:15.800] and here is what happened [35:15.800 --> 35:17.180] it's going to be very fast [35:18.040 --> 35:19.320] Ok, this is it [35:20.060 --> 35:22.160] So, I don't know if you've seen [35:22.160 --> 35:23.120] Thank you [35:28.900 --> 35:30.020] So what happens is [35:30.020 --> 35:31.180] you can really reboot [35:32.420 --> 35:32.780] a computer [35:32.780 --> 35:34.680] even if it has multiple encryption [35:34.680 --> 35:37.380] and multiple password checking [35:41.050 --> 35:42.410] Ok, let's go to the [35:42.990 --> 35:44.670] I mean, I've been telling [35:44.670 --> 35:45.910] most of the people [35:45.910 --> 35:46.930] I've enabled and stuff [35:46.930 --> 35:48.030] so now I'm going to disclose [35:48.030 --> 35:49.750] the full list of people actually enabled [35:50.870 --> 35:52.830] First of all, I would like to thank the vendors [35:52.830 --> 35:53.950] for their attitude [35:53.950 --> 35:55.290] they've been very responsible [35:55.290 --> 35:56.490] and cooperative [35:57.250 --> 35:59.970] but TrueCrypt, like these guys told us [36:00.670 --> 36:02.470] the vulnerability only exists [36:02.470 --> 36:04.710] because you are misusing the software [36:06.230 --> 36:07.890] Thank you, that's very deep [36:10.310 --> 36:11.330] Ok, so [36:11.330 --> 36:13.210] the first kind of passwords [36:13.210 --> 36:14.190] we've been talking about [36:14.190 --> 36:15.070] are biased passwords [36:15.070 --> 36:17.670] so here is a list of [36:17.670 --> 36:20.910] vulnerable APROMs [36:20.910 --> 36:22.870] so you can see pretty much [36:22.870 --> 36:24.610] everybody is vulnerable [36:24.610 --> 36:27.530] ranging from, well, you read it [36:28.690 --> 36:30.610] Full disk encryption software [36:30.610 --> 36:32.350] with pre-boot authentication [36:32.790 --> 36:33.210] capabilities [36:34.590 --> 36:37.150] so BitLocker, which is the [36:37.150 --> 36:38.750] encryption [36:38.750 --> 36:40.330] software [36:40.910 --> 36:42.710] for Microsoft Vista [36:42.710 --> 36:44.710] on the version [36:44.710 --> 36:46.510] SP0 is vulnerable [36:46.510 --> 36:48.650] it has been fixed in SP1 [36:49.670 --> 36:50.290] TrueCrypt [36:50.290 --> 36:52.590] so even if those guys deny the truth [36:52.590 --> 36:54.710] I showed you before [36:54.710 --> 36:56.290] that you can also reboot it [36:57.430 --> 36:58.390] DiskCryptor and [36:58.390 --> 36:59.470] DriveCrypt [37:00.810 --> 37:02.230] and bootloader passwords [37:02.230 --> 37:04.670] so Grub and Lilo [37:04.670 --> 37:05.470] are also vulnerable [37:06.730 --> 37:08.570] for the sake of completeness [37:08.570 --> 37:10.590] I will also show you the list [37:10.590 --> 37:12.250] of non-vulnerable software we've seen [37:12.250 --> 37:14.470] so there are several [37:14.470 --> 37:15.710] biased passwords [37:16.430 --> 37:20.130] full disk encryption software. This list is obviously far from [37:20.130 --> 37:24.210] being exhaustive so I entitle you to, I mean, do your own [37:24.210 --> 37:28.210] experiments. Actually the exploit is the same everywhere. [37:28.350 --> 37:31.590] So there is one exploit for Unix which is going to work for [37:31.590 --> 37:36.450] any pre-boot authentication password if available. And one [37:36.450 --> 37:41.050] version for Windows. So you just check this, install a few [37:41.050 --> 37:46.930] software and check if they are vulnerable. If you do so, I [37:46.930 --> 37:53.550] would appreciate if you sent me a mail or something. Okay, so [37:53.550 --> 37:57.510] how do we mitigate those vulnerabilities? Okay, the most [37:57.510 --> 38:05.150] obvious, I mean, the most obvious advice I could give is [38:05.150 --> 38:08.730] like to sanitize the BIOS keyboard buffer before and after [38:08.730 --> 38:15.830] use, right? You can check on the website. We are trying to keep a [38:15.830 --> 38:19.850] list of patches to do that. Unfortunately when it comes, for [38:19.850 --> 38:25.530] instance, to BIOS EEPROMs, it's very difficult to patch it [38:25.530 --> 38:31.510] yourself. You have to wait for the vendor to issue fix. So you [38:31.510 --> 38:34.430] must probably looking for an intermediary solution which will [38:34.430 --> 38:41.210] not fix all the problems but, I mean, will fix most of them. So [38:41.210 --> 38:45.890] if you're using Linux, I can, I really entitle you to download [38:45.890 --> 38:50.210] the geosecurity patch from openworld.net. Brad has been very [38:50.210 --> 38:53.970] keen to release a new version today, including the patch we've [38:53.970 --> 39:15.920] written for it. So what it does basically is, yeah, absolutely [39:15.920 --> 39:31.580] not. No, no. What do you mean you have to actually? You're the [39:31.580 --> 39:42.100] true creep guy or something? Okay. See, what happens is, if [39:42.100 --> 39:46.300] the password can be entered by the keyboard, okay, just let me [39:46.300 --> 39:50.660] reply to you. If the password can be entered at the keyboard, [39:50.660 --> 39:53.560] okay, from the keyboard, there is no difference from the [39:53.560 --> 39:58.140] bootloader point of view if it's actually typed at boot time on [39:58.140 --> 40:02.380] the console or if it has been stored in the BIOS keyboard [40:02.380 --> 40:07.940] buffer by a previous rogue bootloader, okay? It's exactly [40:07.940 --> 40:11.100] the same thing. I mean, it's following the same process. [40:20.420 --> 40:28.000] It's... Okay. So see, I'm afraid I don't really understand your [40:28.000 --> 40:43.020] question, but we can... Okay. So what happens with, for instance, [40:43.020 --> 40:46.660] TPM ships, you can't actually mitigate, yeah, you're right. So [40:46.660 --> 40:52.180] you can retrieve the password, but you can't actually reboot [40:52.180 --> 40:57.560] the computer using the, I mean, rogue bootloader method. That [40:57.560 --> 41:01.860] was your point? So it's very true. No, I have no method to [41:01.860 --> 41:06.740] bypass TPM so far. I have not studied it deeply. There are [41:06.740 --> 41:09.860] really three vulnerabilities here. Like the first one is the [41:09.860 --> 41:13.300] ability to retrieve the password in plain text. The second one is [41:13.300 --> 41:18.340] the effect of rebooting, okay? And the third one is actually the [41:19.340 --> 41:24.200] kernel leakage inside user LAN from Microsoft, right? Which [41:24.200 --> 41:28.880] allows you to kind of retrieve the password with less [41:28.880 --> 41:34.100] privileges, okay? So I've discussed with the, I mean, guys [41:34.100 --> 41:37.000] responsible at Microsoft, they are working on a fix. This is [41:37.000 --> 41:42.980] very complicated to fix, okay? But you're right. My bypassing [41:42.980 --> 41:47.680] of TrueCrypt, of BitLocker, sorry, is not full. I could not [41:47.680 --> 41:54.080] reboot it. Okay, so just a few greetings. So first of all, I [41:54.080 --> 41:59.360] would like to thank my reviewers, the technical team [41:59.360 --> 42:05.780] which I work with, and the guys from EverybodyDies.com. It's [42:05.780 --> 42:09.060] actually a game, computer game, and they allowed me to use [42:09.060 --> 42:11.620] their screenshots of the game which is now called DEFCON [42:12.150 --> 42:17.800] inside my slides. This is why my slides look so good. Community [42:17.800 --> 42:22.140] guys, so plug the plug, plug security. Thank you for coming [42:22.790 --> 42:27.000] and waking up after the parties and stuff. All you for coming to [42:27.000 --> 42:30.860] the presentation, and indeed the DEFCON staff for the awesome [42:30.860 --> 42:34.960] event and parties. I think we can clap for that, yeah.