Nytro Posted May 5, 2011 Report Posted May 5, 2011 Kernel-mode Payloads on Windowsbugcheck, chris@bugcheck.orgskape, mmiller@hick.orgThis paper discusses the theoretical and practical implementations of kernel-mode payloads on Windows. At the time of this writing, kernel-mode research is generally regarded as the realm of a few, but it is hoped that documents such as this one will encourage a thoughtful progression of the subject matter. To that point, this paper will describe some of the general techniques and algorithms that may be useful when implementing kernel-mode payloads. Furthermore, the anatomy of a kernel-mode payload will be broken down into four distinct units, known as payload components, and explained in detail. In the end, the reader should walk away with a concrete understanding of the way in which kernel-mode payloads operate on Windows. Contents1 Foreword 22 Introduction 33 General Techniques 53.1 Finding Ntoskrnl.exe Base Address . . . . . . . . . . . . . . . . . 53.1.1 IDT Scandown . . . . . . . . . . . . . . . . . . . . . . . . 63.1.2 KPRCB IdleThread Scandown . . . . . . . . . . . . . . . 73.1.3 SYSENTER EIP MSR Scandown . . . . . . . . . . . . . . 73.1.4 Known Portable Base Scandown . . . . . . . . . . . . . . 83.2 Resolving Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Payload Components 114.1 Migration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124.1.1 Direct IRQL Adjustment . . . . . . . . . . . . . . . . . . 134.1.2 System Call MSR/IDT Hooking . . . . . . . . . . . . . . 144.1.3 Thread Notify Routine . . . . . . . . . . . . . . . . . . . . 164.1.4 Hooking Object Type Initializer Procedures . . . . . . . . 204.1.5 Hooking KfRaiseIrql . . . . . . . . . . . . . . . . . . . . . 204.2 Stagers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.2.1 System Call Return Address Overwrite . . . . . . . . . . 214.2.2 Thread APC . . . . . . . . . . . . . . . . . . . . . . . . . 224.2.3 User-mode Function Pointer Hook . . . . . . . . . . . . . 234.2.4 SharedUserData SystemCall Hook . . . . . . . . . . . . . 234.3 Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.3.1 Thread Spinning . . . . . . . . . . . . . . . . . . . . . . . 284.3.2 Throwing an Exception . . . . . . . . . . . . . . . . . . . 294.3.3 Thread Restart . . . . . . . . . . . . . . . . . . . . . . . . 294.3.4 Lock Release . . . . . . . . . . . . . . . . . . . . . . . . . 314.4 Stages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 Conclusion 32Download:http://www.uninformed.org/?v=3&a=4&t=pdfOnline:http://www.uninformed.org/?v=3&a=4 Quote