We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Direct Memory Attack the Kernel

00:00

Formal Metadata

Title
Direct Memory Attack the Kernel
Title of Series
Number of Parts
93
Author
License
CC Attribution 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Inexpensive universal DMA attacking is the new reality of today! In this talk I will explore and demonstrate how it is possible to take total control of operating system kernels by DMA code injection. Once control of the kernel has been gained I will execute code and dump gigabytes of memory in seconds. Full disk encryption will be defeated, authentication will be bypassed and shells will be spawned. This will all be made possible using a $100 piece of hardware together with the easy to use modular PCILeech toolkit - which will be published as open source after this talk. Bio: Ulf Frisk is a penetration tester working in the Swedish financial sector. Ulf focuses mainly on online banking security solutions, penetration testing and it-security audits during daytime and low-level coding during nighttime. Ulf has been working professionally with security since 2011 and has a dark past as a developer.
33
35
Memory managementComputer programmingSoftware testingMessage sequence chartComputerConvolutionDirection (geometry)ComputerWindowBitSoftware testingPhysical systemInformation securityConvolutionSoftwareTelebankingPurchasing2 (number)Demo (music)Read-only memoryCodeComputer programmingComputer fileProjective planeCore dumpInjektivitätComputer hardwareGastropod shellMereologyOrder (biology)Computer engineeringLevel (video gaming)Multiplication signLecture/Conference
Process capability indexWhiteboardSoftwareFirmwareMemory managementDevice driverOrder (biology)Slide rulePresentation of a groupDevice driverWhiteboardPhysical systemComputerCombinational logicRead-only memoryPlastikkarteComputer hardwareMedical imagingSoftware developerIndividualsoftware2 (number)Heat transferForm factor (electronics)Very-high-bit-rate digital subscriber lineBitFirmwareExpressionComputer animation
Computer hardwareSoftwareFirmwareDifferent (Kate Ryan album)ConvolutionTape drive2 (number)SoftwareComputer hardwareConvolutionHeat transferFirmware
Process capability indexBefehlsprozessorDifferent (Kate Ryan album)ExpressionRead-only memorySerial portThermal expansionPoint (geometry)TelecommunicationBounded variationMemory managementPCI ExpressThermal expansionSinc functionBus (computing)Network topologyVery-high-bit-rate digital subscriber lineTelecommunicationRight angleSerial portProcess capability indexPoint (geometry)Complex (psychology)Band matrixRoutingSoftwareView (database)Graphics processing unitAuthenticationSimilarity (geometry)BefehlsprozessorForm factor (electronics)Slide rulePlastikkarteBridging (networking)Bounded variationLaptopDirection (geometry)Standard deviationRead-only memoryCodeComputerRootConnected spaceCore dumpExpressionPCI ExpressFlow separationWriting
Address spaceCodeMemory managementProcess capability indexDirected setRead-only memoryMIDILarge eddy simulationRead-only memoryWeb pageMemory managementExecution unitCodeSeitentabelleOrder (biology)Address spaceCore dumpBefehlsprozessorVirtualizationCASE <Informatik>Read-only memoryDirection (geometry)Physicalism
Virtual realityCodeAddress spaceMemory managementProcess capability indexRead-only memoryRead-only memoryDirected setLimit (category theory)Memory managementExecution unitOperating systemAddress spaceTheoryBefehlsprozessorVirtualizationRead-only memoryCASE <Informatik>Firmware
FirmwareProcess capability indexPlastikkarteEmailMemory managementReading (process)GoogolProduct (business)Configuration spaceDefault (computer science)Product (business)40 (number)PlastikkarteEmailPower (physics)Structural loadLengthGame controllerBitTotal S.A.WhiteboardSoftwareClique-widthAddress spaceWordPCI Express
FirmwareProcess capability indexEmailMemory managementReading (process)WritingGoogolProduct (business)InformationComputer hardwareVery-high-bit-rate digital subscriber lineRead-only memoryHeat transferProduct (business)Asynchronous Transfer ModeDevice driver1 (number)WindowSign (mathematics)Public key certificateWritingReading (process)Computer programmingBitOrder (biology)ComputerComputer filePCI ExpressConfiguration spaceMultiplicationThread (computing)Point (geometry)
Patch (Unix)CodeMemory managementComputerRead-only memoryConvolutionModule (mathematics)SpywareAddress spaceProcess capability indexVirtual realityDataflowModule (mathematics)Patch (Unix)ConvolutionAddress spaceComputerPhysical systemCodeVirtualizationRead-only memorySpywareExploit (computer security)Data structureElectronic signaturePhysicalismJSON
Level (video gaming)ConvolutionFunction (mathematics)Web pageLevel (video gaming)Functional (mathematics)Network topologyLoop (music)Pointer (computer programming)Order (biology)Buffer solutionAddress spaceGame controllerState of matterComputer programmingMereologySheaf (mathematics)Read-only memoryConvolutionHookingSpacetimeContent (media)CodeNormal (geometry)DataflowWritingComputerModule (mathematics)Thread (computing)Data Encryption StandardMultiplication signReading (process)Device driverFerry CorstenSystem callProgram flowchart
Demo (music)Level (video gaming)ConvolutionAddress spaceRead-only memoryRead-only memoryAddress spacePhysicalismConvolutionRandomizationEquivalence relationDemo (music)CodeSymbol tableLevel (video gaming)WindowFunctional (mathematics)ZustandsgrößeMultiplication signPointer (computer programming)HookingSystem callFunktionspunktmethodeOrder (biology)JSON
Generic programmingConvolutionComputer fileRead-only memoryDemo (music)Read-only memoryOrder (biology)Demo (music)ConvolutionPhysical systemWindowVirtual memoryModule (mathematics)Game controllerAsynchronous Transfer ModeComputerComputer programmingRevision control1 (number)RootComputational physicsData storage deviceTraffic reportingPhysicalismSystem administratorRead-only memoryBitReading (process)ExpressionCore dumpComputer animation
Demo (music)Read-only memory2 (number)BitSource code
Generic programmingConvolutionComputer fileRead-only memoryDemo (music)SeitentabelleTable (information)Thread (computing)Asynchronous Transfer ModeConvolutionModule (mathematics)Physical systemWindowRead-only memorySeitentabelleData structureDevice driverWeb pageExpressionComputerBitVirtual memorySource code
Web pageBefehlsprozessorPoint (geometry)Partial differential equationSeitentabelleMereologyAddress spaceElectronic program guidePhysical systemSoftware developerSoftwareSeitentabelleWeb pageAddress spaceDirectory serviceTable (information)Order (biology)PhysicalismBitConvolutionPhysical systemExecution unitType theoryData structureLevel (video gaming)Line (geometry)BefehlsprozessorMemory managementVirtualizationMappingPointer (computer programming)
ConvolutionAddress spaceVirtual realityModule (mathematics)Electronic signatureWeb pageDevice driverTable (information)Formal grammarSeitentabelleMeta elementGame theoryVirtualizationAddress spaceSlide ruleWindowReading (process)RandomizationBitElectronic signatureBootingWritingWeb pageDevice driverConvolutionSeitentabelleDifferent (Kate Ryan album)Presentation of a groupDemo (music)Computer animation
SeitentabelleConvolutionCodeCore dumpModule (mathematics)Physical systemGastropod shellRead-only memoryComputerOrder (biology)SpeicheradresseModule (mathematics)Gastropod shellVirtual memoryCore dumpPasswordBitThread (computing)Game controllerUniform resource locatorLocal ringSeitentabellePulse (signal processing)Demo (music)Read-only memoryWindowPhysicalismComputer forensicsConvolutionComputer-assisted translationAddress spaceStructural loadComputer programmingCodeBuffer solutionPhysical systemSpywareCellular automatonDomain nameRobotDevice driverRevision controlLatent heatElectronic signatureReading (process)Read-only memorySource code
Physical systemTouchscreenWindowComputer fileAddress spaceDemo (music)ConvolutionModule (mathematics)BitSource code
Information securityMassComputerDefault (computer science)WindowInformation securityGodVirtualizationBootingEnterprise architectureSet (mathematics)Revision controlJSON
Process capability indexConvolutionPhysical systemRead-only memoryExt functorSign (mathematics)Order (biology)Slide ruleExtension (kinesiology)Uniform resource locatorOperating systemSystems integratorConvolutionDevice driverStructural loadRead-only memoryProjective planeWebsitePhysical system
Drum memoryProxy serverInclusion mapEmailConvolutionLevel (video gaming)Address spaceDemo (music)ComputerLevel (video gaming)EmailHookingFunctional (mathematics)Demo (music)Binary codeCodeBinary fileAddress spaceMultiplication signStatutePrinciple of maximum entropyRight angleConvolutionRead-only memoryJSON
Proxy serverDemo (music)Read-only memoryDemo (music)Order (biology)ComputerPlastikkarteData conversion2 (number)Power (physics)Right angleExpressionMereologySource code
BootingWebsitePasswordAsynchronous Transfer ModeRadical (chemistry)Data conversionBootingModule (mathematics)Data recoveryState of matterType theoryComputerGame controllerCellular automatonConvolutionSpeicheradresseBitRight angleAddress spaceSeries (mathematics)Non-volatile memoryComputer animation
Information securityVirtualizationComputer hardwareMemory managementMathematicsPasswordFirmwareAuthenticationTerm (mathematics)Set (mathematics)CodeGoodness of fitAuthenticationPasswordAsynchronous Transfer ModeInformation securityOrder (biology)Computer hardwareData recoveryOperating systemComputerVirtualizationWindowExpressionLevel (video gaming)BootingPlastikkarteJSON
MiniDiscEncryptionMathematical analysisStructural loadConvolutionDevice driverProcess capability indexModule (mathematics)CodeModul <Datentyp>Computer hardwarePhysical systemConvolutionDevice driverMereologyContext awarenessSoftwareComputer forensicsOperating systemMoment (mathematics)Mathematical analysisWindowCodeEncryptionModule (mathematics)Statistical hypothesis testingMalwareSampling (statistics)Read-only memoryMiniDiscBitKernel (computing)Physical lawGoodness of fit
Abstract state machinesCAN busComputerCellular automatonMaxima and minimaModul <Datentyp>TouchscreenElectronic signatureGame controllerRight angleComputer programmingConvolutionBefehlsprozessor
Memory managementVector potentialContext awarenessEncryptionMiniDiscDemo (music)Physical systemAcoustic shadowMultiplication signComputer fileEncryptionPasswordDefault (computer science)Source code
RootHash functionDefault (computer science)PasswordComputer filePhysical systemSource code
Vector potentialContext awarenessEncryptionOrder (biology)PhysicalismEncryptionAddress spaceSource codeComputer fileSoftware repositoryConvolutionInformation securityPhysical systemMiniDiscTape driveSurjective function
Source code
Transcript: English(auto-generated)
Alright, so let's get this show on the road. Please settle down, take a seat, and please give a warm welcome to a first time DefCon speaker, Ulf. So please. So thank you everyone for coming and listening to me. Today we are going to direct memory attack the kernel. My
name is Ulf Frisk and helping me with the demos today, I have, uh, Martin Bergqvist. Today we are going to totally own Linux, Windows, and OSX kernels by DMA code injection. We're going to dump memory at speeds in excess of 150 megabytes per second. We're
going to both pull and push files from the target system. We're going to execute code and spawn a system shell. After this talk, I will be open sourcing the software, making all this possible. And since we are talking about a hardware based attack, you also need a
hardware which is already available for purchase online for less than 100 dollars. But first a little bit about myself. My name is Ulf Frisk. I'm working as a penetration tester, primarily with online banking security. I'm employed in the, uh, financial sector in, uh,
Stockholm, Sweden. I have a master of science in, uh, computer science and engineering. And, uh, most recently I've been taking a special interest in low level Windows programming and DMA. And this has been a little bit like a learning by doing project for my part, learning more
about 64 bit assembly and operating system kernels. Actually in order to be able to do this talk, I have to put up this slide. I need to point out that, uh, this talk is given by me as an individual. My employer is not involved in any way whatsoever, what I'm doing here
today. But I'm here today to present PCI Leech. PCI Leech is the combination between the PLX technologies USB 3380 development board coupled with a custom firmware and a custom software. On the image here, you see this development board in the mini
PCI express form factor. To your left, you see the PCI express side. It's the side that goes into the target computer or if you wanted to call it the victim computer. The USB 3380 is able to send both DMA reads and writes into the target system main
memory. To your right, you see a USB 3 connector which allows us for connecting this board to a controlling computer and once connecting to a controlling computer, this controlling computer is able to transfer memory at very high speeds with USB 3 straight
into the memory of the target computer. What's very nice about this hardware is that it requires no drivers at all on the target computer. It just works. It's hardware only. And with this piece of hardware, I'm able to get well over 150 megabytes per second DMA
transfer speeds. Unfortunately, this chip is only capable of 32 bit addressing and that means that you're only able to access the lower 4 gigabytes of memory with this card. As we'll see later on, that's not really a problem in practice. Actually, actually the
USB 3380 has been presented here at Defcon before. It was presented 2 years ago as the NSA playset slot screamer device by Joe Fitzpatrick and Miles Crabill. So I want to really thank Joe for bringing this really nice piece of hardware into my attention. So thank you
very much Joe. If I compare PCILeech to slot screamer, it's obviously exactly the same hardware. It's the complete, it's a different firmware and a different software. This also means that if you already do have a slot screamer device, you should be able to re-flash it
and try this software on. It's er faster, the slot screamer was able to achieve around 3 megabytes per second, something like that. And the PCILeech device is able to achieve well over 150 megabytes per second DMA transfer speeds. The PCILeech is also able to
capable of er kernel implants, in fact it's relying heavily on kernel implants. But what makes all this possible is of course PCI Express. PCI Express is a high speed serial expansion bus, or it's not really a bus since it's point to point communication but
anyway, it's er packet based. And to the upper right you see a schematic of er PCI Express. You have the PCI Express root complex anchored within the CPU ship. From this root complex you have er several serial lanes that you can connect PCI Express endpoints to.
You can also connect like PCI Express switches and bridges. So you can say that PCI Express forms a small device network within a computer. Depending on how much bandwidth the device needs, it er can consume between 1 and 16 serial lanes, a graphics card that needs lots of bandwidth, typically consumes like 16 lanes. PCI Express is designed to be
hot pluggable and it comes in many form factors and variations. It comes as the standard form factor as you all know, the PCI Express, standard graphics card and similar things. It comes in the mini PCI Express form factor as you saw in the previous slide. It
comes as express card which goes into laptops and also thunderbolt encapsulates PCI Express. And what's nice about PCI Express from our point of view is that it's er DMA capable and that means that it's circumventing the CPU cores so the PCI Express endpoints can read
and write memory directly. But what is direct memory access? And how does it work? And you have the CPU core, it usually executes code in something called a virtual address
space and you have a memory management unit which is built into the CPU which uses page tables in order to translate these virtual addresses into physical addresses. And it actually translates pages and the page is er typically 4 kilobytes long, it can be larger as well but er most cases are 4 kilobytes long. Er PCI Express devices have
traditionally been able to access all physical memory straight out without any limitations whatsoever. But CPUs nowadays, they do have something called an IOMMU which works similar way to the memory management unit for the CPU and this allows for
virtualization of er device addresses as well. So in theory the operating system should be able to protect themselves fully against DMA attacks if the IOMMU is fully used. But as
we'll see later on that's not really the case. Actually this is the complete firmware of the PCILeech device. It's a whopping 46 bytes in total. The first 2 bytes is a header or actually the first byte is a header 5A 00 tells us that er just load configuration
data from the configuration er into the configuration registers at er power on. Next we have the length which is in little endium so 2A is er 42 bytes of configuration data. Then we
have the er USB controller register, we need to enable the USB 3 port on this board because it's disabled by default. First you have an address to the register with the 2310 here and then you have er a D word or 4 bytes or 32 bits which is er programmed into that
register at er power on. And this enables the USB 3 port. Then we set the PCI express vendor ID and product ID to a Broadcom SD card and er this is pretty much just a left over from the slot screamer software I started to toy around with. And then in
green here we enable the 4 DMA endpoints which are capable of high speed DMA transfers between USB 3 and PCI express. We set the first endpoint to a right endpoint which allows us to write memory from USB into main memory of the target computer at high speeds. Then
we set the following 3 endpoints to read endpoints. Reason why we set the 3 endpoints to read endpoints is that read is much more common than write and we can get a little bit more transfer speed out of this chip if we're doing multi-threaded access. And at last we
set the USB vendor ID and product ID to Google Glass. And the reason why I'm doing this is that er I wrote this program for Windows. Windows has a very nice user mode USB stack called Win USB. But er in order to activate it for a certain hardware you need
to sign a small configuration file with a driver signing certificate and er those ones are kinda expensive. So I didn't want to purchase one so it was much easier to find a device out there that actually uses this Win USB stuff already and lie about being that device.
But let's get into the kernels. Most computers today they do have more than 4 Gigs of memory. If you're able to get the kernel module into a system it should be able to access all memory and also be able to execute code. So what we can do is we can search for
kernel structures, code signatures, whatever in lower memory using DMA and er patch that code and hijack execution flow of the kernel code that way. And when we are doing this we need to keep in mind that the PC Express DMA works with physical addresses, kernel code
runs in er virtual address space. I divided exploitation into 3 stages. First we have the stage 1 which is pretty much just a hook. Then we have the stage 2 which is the er stager for the final stage 3 kernel module implant. We start by trying to locate the
kernel or a driver or whatever in the kernel space that we can target. Usually at the end of the er kernel itself or a driver there is some free space in the last page because
it's usually not completely filled out and that page is already executable so we put our stage 2 code in there which is around 500 bytes. Then we search for a function to hook and er yeah and once we find that function we overwrite it with a call into the stage
2 code which is already written into the kernel. And when a thread starts executing the hook function it immediately jumps to the stage 2 part code and er the very first thing the stage 2 code does it restores the stage 1 code to its original state. Then
we check if we are the first thread running here we might run in a multi-threaded environment and er if we are not the first thread running here we immediately jumps back to the now unhooked stage 1 function and resume the normal execution flow for that kernel thread. But if we are the first thread running here we locate the base of the kernel
and we need that in order to look up some er function pointers that we are going to need later on. For example we need those function pointers in order to allocate two pages of memory. The first page we use as a buffer that er the PCLEH main control
program running on the other computer can use DMA in this buffer in order to communicate with the kernel module that we are going to insert. The second page is the kernel module or the stage 2 tree code itself. Then we write a small stage 3 step into the
second page and er this is pretty much just a tight loop and then we create a new kernel thread in that loop. And at the very end in the stage 2 section we write the physical address of the buffer we allocated into the the code where the stage 2 part is
located and the PCLEH main control program is pulling this buffer all the time er with DMA and once it receives the physical address it writes the complete stage 3 contents into that address it received. Then the loop which is already executing the third kernel
thread there it senses that it er the complete stage 3 contents is written so it exits and er starts by setting up a DMA buffer which is around 4 to 16 megabytes big in lower memory and then it starts looping waiting for commands. The commands are pretty much
read memory, write memory, execute code or exit. Let's start by attacking Linux. The Linux kernel is er located in low physical memory. If kernel address space layer
randomisation is not enabled it's located at 16 megabytes in physical memory. If KASLR is enabled it slides at the 2 megabyte chunks. So once we find the kernel we search for a function or random function to hook. In my code I chose VFS read since it gets called
pretty often and it works fine. Then I search for a function called call SIMS lookup name. This is pretty much the equivalent of get proc address in Windows. It allows me to use a kernel symbol name er and send it to that function and it will look up the
function point function pointer for that or a symbol for that. Then we write the stage 2 code and write the stage 1 code then we wait for the stage 2 code to return with the physical address of stage 3. We write the complete stage 3 code and then it's demo time. In this demo I will show how we can use a generic kernel implant in order to both
pull and push files from and to a Linux system and we're also going to dump the memory. This is the demos, supposed to be like this. Sorry about that. Here you see a
Kali Linux computer and we will try to log on to that computer with the root account. That one was not working here, we'll show, we will reboot the computer
afterwards and do the demo after the Windows demo but we will start by dumping the memory on this computer anyway. So let's dump the memory. We'll use the Linux 64 bit
kernel module. We're going to dump the memory and store it in C temp here. So first we insert the kernel module into running kernel. Then we receive execution and then memory dumping is starting. Memory dumping works the following way, is that the kernel
module first asks the running kernel about the physical memory map. In computers physical memory is not one big chunk of memory. You have like memory map PC express devices in between there that if you read those ones you can crash the computer or
whatever. You also have unreadable memory such as system management mode that you can't read. So it first queries the computer about the memory map, reports this back to the PCLH main control program and once the main control program knows about the physical memory map it can ask the inserted kernel module to read certain memory
chunks. Dumping memory is usually pretty fast, it's uh should be well over 150 megabytes per second but in this demo I have to use a crappy USB hub so the speed is a little bit lower but it should still be well in excess of 100 megabytes per second as you
can see here. Thank you very much. And uh when we dump the memory let's try to run volatility on it as well. I'm running the Linux PS3 command here just to show you
that uh it's working here. At the very bottom you see the PCLH kernel thread for the inserted kernel module and if you scroll up here you see lots of kernel threads and
user mode processes here and the systemd at the very top here. So let's move back to Windows 10. In Windows 10 the kernel is located at the top of the physical memory which is uh kind of
boring for us since we can't access it directly and this is a problem for us if the computer do have more than around 3 and a half gigs of RAM and the reason for that is like memory map PC express devices and other things pushes the last uh bytes of the memory well
above 4 gigs. So this means that the kernel executable is not reachable directly and most drivers are also loaded below and above 4 gigs so they're not reachable but if you look at the uh memory structures below 4 gigs we see that uh the page table for the kernel
itself and important uh kernel drivers are actually loaded below 4 gigs in its entirely. So let's attack the page table. Paging on the 64 bit system works this way. First you have a virtual address or a linear address at the top in red here that you wish to
translate into physical address and this is what the memory management unit is doing. So it memory management unit starts by reading the physical address in a CPU register called CR3 in order to find the uh physical base address of a table called page mapping level 4. And
you take the top most bits from the virtual address to point out which entry in that table to use and uh in the PML4 entry you have the physical address of the page directory pointer table. And you take some more bits from the virtual address to point
out the entry in that table which contains the physical address of the page directory. Take some more bits from the virtual address which contains the entry in that table which uh is uh the physical base address of the page table itself. Take
some more bits in the page in the virtual address and you get the page table entry. It's the entry that we're going to target and corrupt in order to gain kernel execution. What's nice about this is that uh all 4 uh paging structures here are actually loaded
below 4 gigs so we can access them by using DMA. Kernel address space starts at the address you see here on this slide. Windows do have kernel address space layer randomization so that means that there is no fixed um virtual addresses between reboots. The
kernel is loaded at different places and drivers are loaded at different places as well so we can't use that. But if you take a page table entry and have a look at the uh lowest 3 bits and the highest bit which is the present bit and if it's a read or write page or
if it's a user or a supervisor slash kernel page or if it's an executable or non-executable page those 4 bits together form what I call a page signature. And if you take uh have a look at the driver or the kernel itself it actually you can call those collect that
collection of page signatures a driver signature. So what I'm doing I'm searching for the driver signature by walking the page table. Once I find the correct driver to target I locate the page and rewrite the uh physical address in the page table entry to a place
below 4 gigs which I can control over DMA. So let's continue on to the Windows 10 demo. In this demo I will use a page table rewrite in order to uh implant a kernel module. I'm going to execute code. I'm going to dump memory. I'm going to spawn a system shell and also
try to unlock the computer. So let's switch over to the demo. Here we have a Windows 10 computer. We will try to log on to that computer without using a password here. As you
can see we couldn't log on to that computer without using a password on the domain account. But what we can do is that we can insert the pcellh device here into the
computer. And once we've done that we can try to load a kernel module into running kernel by using a page table hijack. So in Windows 10 because we are looking for driver signatures we need to target a specific driver version. So let's do that and use the
page table hijack here. So we search for page table location. We hijack the page table. We wait for a kernel thread to start executing there. We receive execution and we load the kernel module at this memory address. And now we can try to remove the
passwords requirement to that computer. By the way it's fully bit locker so we can log on to it without using a password. In order to do this we need to uh specify that we are going to use the unlock implant. It works similar way to inception but uh this is all
done in kernel code because we are inserting this kernel module into the target system. And in order to insert it we also need to specify the memory address we just received here. So let's do that. And it says zero is success here. So it says zero here. So
quite easy to log on to this computer. Uh let's uh try to dump the memory of that computer as well. And we need to specify the kernel module address of the loaded kernel module here as well. Dumping dumping memory works in a similar way to
Linux. First we ask the uh kernel module that is already inserted to report back the physical memory map to the PCLH leech main control program running on uh my demo computer here. Then it uh asks the running kernel module to read certain memory
chunks that it knows it's already accessible and store them in the uh DMA buffer that was already allocated in lower memory. Memory dumping takes around uh a minute on an JIG system. And of course once you dump all memory you can run memory forensics tools on
it such as volatility. You should also be able to for example extract credentials with mimikatz or things like that. And this works on fully bit locker computers by the way.
So let's wait until the memory dump is complete here. And uh let's try to spawn a system shell. In order to spawn a system shell we can use the uh PDS CMD kernel implant.
And we also need to specify the memory address of the kernel module that is already inserted into the kernel. So let's try to run it. Spawn a system shell. And it's as easy as that. So let's check who we are. Thank you very much. And as you can see we are
system here. And once we're in a system of course we can do everything. We can disable bit locker, we can uh spy on other users files and uh do whatever stuff so. But
let's not do this here. So uh because this is a Windows demo there is one more thing missing here. So we need to specify the kernel module address here as well. We're
missing a blue screen here. I was missing that one. So let's run the uh PSBlue uh kernel implant here. Uh and uh as you can see. As you can see Windows don't like me.
Actually Windows 10 they do have some very nice anti DMA features built in. In the enterprise version. But they are not enabled by default. Windows 10 can be made rather
secure against DMA attacks if uh the virtualization based security features are enabled like credentials guard and device guard. It's quite easy often for users to mess around with settings in the UAFib. For example disable BTD or disable secure boot and
things like that and uh then uh this virtualization based security features will be disabled in Windows as well so. So we come to recommendations later on. But uh let's
look at OSX. OSX is just like Linux. It's located the kernel of OSX is located in uh low physical memory. It's location is dependent on the kernel ASLR slide. It's large in 2 megabyte chunks. OSX nowadays enforces uh kernel extension signing. System
integrated projection means that um users can't write to certain folders. And kernel extension signing means that you can't load unsigned drivers. Old Macs today pretty much have uh Thunderbolt but uh Thunderbolt is uh actually protected with uh BTD. OSX actually
uses this IOMMU in order to protect itself from DMA attacks. So that's kind of boring so what can we do in order to change that? So we can visit Apple's website.
Thank you Apple. And Apple on their website tells us in plain how to disable BTD. So yeah. It's as easy as that. In OSX we'll first uh by using DMA we will search for the uh
MACO kernel header. MACO is the binary format on binaries in Mac including the kernel. And then we search for like a random nice function to hook. I think guy hooked memcpy in this example. And then we write the stage 2 code into the memory of the target computer.
Then we write the stage 1 code. We wait for stage 2 code to return with the physical address of the stage 3 code. We write the stage 3 code and then it's demo time. In
DMA access. And then we're going to dump the memory and unlock the computer. So here you have a MAC actually. To write here you have a express card to uh Thunderbolt converter which you don't really need for this part. Uh all you need in order to disable
BTD is that you need to uh power on the MAC. We will do in a second. This was kind of slow here. I think the movie was very slow. Try to reopen it. Let's move on
here. We actually we boot into recovery mode by pressing command R. Uh when we are starting the computer. Then you enter recovery mode. There is no password into
recovery mode. And uh then you start the terminal and then you type uh nvram boot args dot equals 0 just as uh the MAC uh Apple tells you on their website. And VTD is now
fully disabled here. So once VTD is fully disabled we should be able to target the computer over Thunderbolt here. So let's do that. And here you have a MAC book air with that adapter connected to the right. And let's try to log on to that computer without
using a password at all. As you saw we couldn't log on to that computer which is kind
of boring. So let's insert the PCILeech uh control adapter in the converter here. So let's start by loading a kernel module into the running MAC OS kernel here. And it's as easy as that. We say that we're going to load the kernel module and that we're going to
target OSX here. And the kernel module is loaded at this address. And then we should be able to remove the password requirement on this MAC. So let's run the uh Apple 64 bit unlock implant here. And we need to specify the uh memory address of the
already inserted kernel module as well. And it says uh 0 is success here and we have a status 0 here so we should be able to log on here. So let's try to do that. And
we're in. Thank you very much. Thank you very much. Uh so what can we do about
this? In order to protect ourselves better. Of course we can purchase hardware without using any DMA ports whatsoever. It's the low tech variant. It works perfectly fine. If we do have Windows with auto booting bitlocker and things like that. Uh we should be able to
disable like express card ports in the uh computers. You can do this in uh the UAFE settings usually. But then you need to probably you need to change the bitlocker settings in order to trigger if uh this port is re-enabled at a later stage. Of course if
you don't want to have your MAC uh security disabled in recovery mode you can set a firmware password on the MAC in order to protect yourself. And also setting a BIOS password in the PC is a good idea. Of course pre-boot authentication is always nice to
have. And uh of course the long term solution here is for the operating system vendors actually to make full use of the IOMMU that is already in the hardware. And Windows 10
has some very nice virtualization based security features there going on. So Microsoft seems to do some very nice work as well. So what can we use PCLH for? Of course we can use it for awareness. It's part where I'm doing this talk. Uh you saw today that the full
disk encryption is not really invincible in any way. It's uh excellent for forensics and malware analysis. Uh sometimes you want to run malware samples on reliable hardware and you don't want to pollute that system with lots of diagnostic software or whatever so it could be nice to have a kernel implant in a hardware device. You can use it to load
unsigned drivers into the operating system kernels. It's a good pen testing tool. I do realize that law enforcement might use this tool as well. But uh please if you want to
take a look at this don't do any evil with this tool. PCLH targets uh 64 bit operating systems. It runs on 64 bit Windows 7 and 10 at the moment. It's able to read up to 4 gigs natively and if you're able to insert a kernel module it should be able to read all
memory of the target system that the kernel can uh read. And if a kernel module is inserted obviously you can execute code on the target system as well. I have kernel modules for Linux, Windows and OSX at the moment. It's uh written in C and assembly in
Visual Studio. It has a modular design. I tried to make it as modular as possible. You should be able to create your own signatures very easily. And uh also create your own kernel implants. Actually to the right here you see a very minimal kernel implant. Uh
it's in assembly and it reads some controlled registers on the of the CPU and prints them on screen on the computer running the PCLH main control program. Maybe we should. But we are missing one thing here. We should try the Linux demo again here. See if we're in a
better better luck this time. So as you saw we couldn't log on with uh the default
password. So let's pull a file from the Linux system. A nice file to pull is the shadow file. And it's as easy as just pulling a shadow file from a running Linux system which
uses the encrypt by the way. And then we can open the shadow file and have a look at it. And the root account here has a very long password hash. So of course you can
try to crack it but it's no fun doing that. So let's replace it instead with the default password hash of Tor. Uh so this is the default password hash of Tor. And so let's write the file back. And uh we're going to push it back to the Linux system. And we are
going to use the file push kernel implant here. And now it should be on the target system. So let's try to log on here. See if it works better this time. And as you can see
we're in. So when you leave here today, uh I want you to remember that uh inexpensive
universal DNA attacking is here. It's the new reality of today. Physical ad access is uh still very much an issue. You should be aware of potential even made attacks. For example if you bring your Mac onto security conferences. And uh please do remember that
full disk encryption is not invincible. After this talk I will be making the uh GitHub repo public at uh this address here. And please give me a couple of hours in order to
do that. But I will definitely do it uh today. And uh thank you very much to Joe for uh the slot streamer. And uh you've been a huge inspirational source for my work here. So thank you very much Joe. And also thank you to Inception for being a big
inspirational source for my work. And also thank you to the guys at PLX Technologies for creating this wonderful ship. So thank you. Thank you very much for today.