Rootkits and Bootkits with a Record of Discovering Advanced Malware.” — Rodrigo Rubira Branco Rootkits
Total Page:16
File Type:pdf, Size:1020Kb
“Follow in the footsteps of professionals Bootkits and Rootkits with a record of discovering advanced malware.” Rootkits — Rodrigo Rubira Branco Rootkits and Bootkits will teach you how How to better understand the delivery stage to understand and counter sophisticated, of threats against BIOS and UEFI firmware advanced threats buried deep in a machine’s in order to create detection capabilities boot process or UEFI firmware. How to use virtualization tools like VMware and Bootkits With the aid of numerous case studies and Workstation to reverse engineer bootkits professional research from three of the world’s and the Intel Chipsec tool to dig into forensic leading security experts, you’ll trace malware analysis development over time from rootkits like TDL3 Reversing Modern Malware and to present-day UEFI implants and examine Cybercrime syndicates and malicious actors how they infect a system, persist through will continue to write ever more persistent reboot, and evade security software. As you and covert attacks, but the game is not lost. Next Generation Threats inspect and dissect real malware, you’ll learn: Explore the cutting edge of malware analysis with Rootkits and Bootkits. How Windows boots—including 32-bit, 64-bit, and UEFI mode—and where to find About the Authors vulnerabilities and Malware Modern Reversing Alex Matrosov is an Offensive Security The details of boot process security Threats Generation Next mechanisms like Secure Boot, including Research Lead at NVIDIA with over 20 years of an overview of Virtual Secure Mode (VSM) experience in reverse engineering, advanced and Device Guard malware analysis, firmware security, and exploitation techniques. Eugene Rodionov, Reverse engineering and forensic techniques PhD, is a Security Researcher at Intel working for analyzing real malware, including in BIOS security for Client Platforms. Sergey bootkits like Rovnix/Carberp, Gapz, TDL4, Bratus is a Research Associate Professor in the and the infamous rootkits TDL3 and Festi Computer Science Department at Dartmouth College. He has previously worked at BBN How to perform static and dynamic Technologies on natural language processing analysis using emulation and tools like research. Bochs and IDA Pro “I LIE FLAT.” This book uses a durable binding that won’t snap shut. Matrosov, THE FINEST IN GEEK ENTERTAINMENT™ www.nostarch.com Rodionov, Price: $49.95 ($65.95 CDN) and Bratus Shelve In: COMPUTErs/SECUriTY Alex Matrosov, Eugene Rodionov, and Sergey Bratus FSC FPO Foreword by Rodrigo Rubira Branco ROOTKITS AND BOOTKITS ROOTKITS AND BOOTKITS Reversing Modern Malware and Next Generation Threats by Alex Matrosov, Eugene Rodionov, and Sergey Bratus San Francisco ROOTKITS AND BOOTKITS. Copyright © 2019 by Alex Matrosov, Eugene Rodionov, and Sergey Bratus. All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owners and the publisher. ISBN-10: 1-59327-716-4 ISBN-13: 978-1-59327-716-1 Publisher: William Pollock Production Editor: Laurel Chun Cover Illustration: Garry Booth Interior Design: Octopod Studios Developmental Editors: Liz Chadwick, William Pollock, and Frances Saux Technical Reviewer: Rodrigo Rubira Branco Copyeditor: Rachel Monaghan Compositors: Kassie Andreadis and Britt Bogan Proofreader: Paula L. Fleming Indexer: Erica Orloff For information on distribution, translations, or bulk sales, please contact No Starch Press, Inc. directly: No Starch Press, Inc. 245 8th Street, San Francisco, CA 94103 phone: 1.415.863.9900; [email protected] www.nostarch.com Library of Congress Control Number: 2018949204 No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been taken in the preparation of this work, neither the authors nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it. To our families and to those who made this book possible About the Authors Alex Matrosov is a leading offensive security researcher at NVIDIA. He has more than two decades of experience with reverse engineer- ing, advanced malware analysis, firmware security, and exploitation techniques. Before joining NVIDIA, Alex served as Principal Security Researcher at Intel Security Center of Excellence (SeCoE), spent more than six years in the Intel Advanced Threat Research team, and was Senior Security Researcher at ESET. Alex has authored and co-authored numerous research papers and is a frequent speaker at security confer- ences, including REcon, ZeroNights, Black Hat, DEFCON, and others. Alex received an award from Hex-Rays for his open source plug-in HexRaysCodeXplorer, supported since 2013 by the team at REhint. Eugene Rodionov, PhD, is a Security Researcher at Intel working in BIOS security for Client Platforms. Before that, Rodionov ran internal research projects and performed in-depth analysis of complex threats at ESET. His fields of interest include firmware security, kernel-mode programming, anti-rootkit technologies, and reverse engineering. Rodionov has spoken at security conferences, such as Black Hat, REcon, ZeroNights, and CARO, and has co-authored numerous research papers. Sergey Bratus is a Research Associate Professor in the Computer Science Department at Dartmouth College. He has previously worked at BBN Technologies on Natural Language Processing research. Bratus is inter- ested in all aspects of Unix security, in particular Linux kernel security, and detection and reverse engineering of Linux malware. About the Technical Reviewer Rodrigo Rubira Branco (BSDaemon) works as Chief Security Researcher at Intel Corporation where he leads the STORM (Strategic Offensive Research and Mitigations) team. Rodrigo released dozens of vulnerabilities in many important technologies and published innovative research in exploitation, reverse engineering, and malware analysis. He is a member of the RISE Security Group and is one of the organizers of the Hackers to Hackers Conference (H2HC), the oldest security research conference in Latin America. BRIEF CONTENTS Foreword by Rodrigo Rubira Branco..................................... xix Acknowledgments ................................................. xxiii Abbreviations .................................................... xxv Introduction ...................................................... xxix PART I: ROOTKITS Chapter 1: What’s in a Rootkit: The TDL3 Case Study ......................... 3 Chapter 2: Festi Rootkit: The Most Advanced Spam and DDoS Bot................ 13 Chapter 3: Observing Rootkit Infections .................................. 35 PART II: BOOTKITS Chapter 4: Evolution of the Bootkit ...................................... 49 Chapter 5: Operating System Boot Process Essentials ......................... 57 Chapter 6: Boot Process Security . 69 Chapter 7: Bootkit Infection Techniques .................................. 83 Chapter 8: Static Analysis of a Bootkit Using IDA Pro ......................... 95 Chapter 9: Bootkit Dynamic Analysis: Emulation and Virtualization .............. 115 Chapter 10: An Evolution of MBR and VBR Infection Techniques: Olmasco ......... 133 Chapter 11: IPL Bootkits: Rovnix and Carberp ............................. 147 Chapter 12: Gapz: Advanced VBR Infection .............................. 177 Chapter 13: The Rise of MBR Ransomware ............................... 207 Chapter 14: UEFI Boot vs. the MBR/VBR Boot Process ....................... 233 Chapter 15: Contemporary UEFI Bootkits ................................ 255 Chapter 16: UEFI Firmware Vulnerabilities ............................... 285 PART III: DEFENSE AND FORENSIC TECHNIQUES Chapter 17: How UEFI Secure Boot Works ............................... 319 Chapter 18: Approaches to Analyzing Hidden Filesystems .................... 351 Chapter 19: BIOS/UEFI Forensics: Firmware Acquisition and Analysis Approaches ... 363 Index ......................................................... 391 x Brief Contents CONTENTS IN DETAIL FOREWORD by Rodrigo Rubira Branco xix ACKNOWLEDGMENTS xxiii ABBREVIATIONS xxv INTRODUCTION xxix Why Read This Book? .............................................. xxx What’s in the Book? ................................................ xxx Part 1: Rootkits ............................................ xxxi Part 2: Bootkits ............................................ xxxi Part 3: Defense and Forensic Techniques ......................... xxxiii How to Read This Book............................................. xxxiii PART I: ROOTKITS 1 WHAt’s in A ROOTKIT: THE TDL3 CASE STUDY 3 History of TDL3 Distribution in the Wild.................................... 4 Infection Routine ................................................... 5 Controlling the Flow of Data ........................................... 7 Bring Your Own Linker ....................................... 7 How