Nytro Posted March 4, 2013 Report Posted March 4, 2013 BIOS Disassembly Ninjutsu UncoveredPreface ________________________ 1The Audience ___________________________ 2The Organization 3Software Tools Compatibility 4Typographical Conventions 4PART I: THE BASICS __________________________________________________ 5Chapter 1: PC BIOS Technology ______________ 7Preview ____________________________ 71.1. Motherboard 8105 _____________________ ,81.2. Expansion ROM 121.3. Other Firmware within the PC 131.4. Bus Protocols Fundamentals 141.4 .1. System -Wide Addressing 141.4.2. PC! Bus Protocol 161.4.3. Proprietary Intcrchipset Protocol Technology 23VI Contents •1.4.4. PCI Express Bus Protocoll _________________ 251.4.5. HyperTransport Bus Protocol _______________ 27Chapter 2: Preliminary Reverse Code Engineering _________ 29Preview -----____________________ 292.1. Binary Scanning _____ ________________ 302.2. Introducing IDA Pro 312.3. IDA Pro Scripting and Key Bindings 382.4. IDA Pro Plugin (Optional) 47Chapter 3: BIOS-Related Software Development Preliminary _____ 61Preview _________________________ 613.1. BIOS-Related Software Development with Pure Assembler _______ 623.2. BIOS-Related Software Development with ecc 67PART II: MOTHERBOARD BIOS REVERSE ENGINEERING _______ 77Chapter 4: Gelling Acquainted with the System _________ 79Preview --_______________________ 794.1. Hardware Peculiarities ___________________ 804.1.1. System Address Mapping and BIOS Chip Addressing' ________ 804.1.2. Obscure Hardware Ports 964.1.3. Relocatablc Hardware Ports ________________ 994.1.4. Expansion ROM Handling;.. _______________ 101Contents VII$4.2. BIOS Binary Structure ____________________ 1014.3. Software Peculiarities 1024.3.1. call Instruction Peculiarity 1024.3.2. retn Instruction Peculiarity 1034.3.3. Cache-as-RAM 1084.4. BIO$ Disassembling with IDA Pro 112Chapter 5: Implementation of Motherboard BIOS ________ 115Preview _________________________ 1155.1. Award BIOS ______________________ 1165.1.1. Award BIOS File Structure 1165. 1.2. Award Boot-Block Reverse Engineering _____________ 1215.1.2.1. Boot-Block Helper Routine 1225.1.2.2. Chipset Early Initialization Routine 1235.1.2.3. Super 1/0 Chip Initialization Routine 1245.1.2.4. Jump to CMOS Values and Memory Initialization 1245.1.2.5. BBSS Search and Early Memory Test Routines 1255.1.2.6. Boot Block Is Copied and Executed in RAM 1265.1.2.7. System BIOS Decompression and its Entry Point 1285.1.3. Award System BIOS Reverse Engineering 1425.1.3.1. Entry Point from the "Boot Block in RAM" 1425.1.3.2. POST Jump Table Execution 1425.l.3.3. Decompression Block Relocation and awardext.rom Decompression _1435.1.3.4. Extension Components Decompression ___________ 1465.1.3.5. Exotic Intersegment Procedure Call 149VIII Contents•5.2. AMI 8105 __ 1605.2.1. AMI BIOS File Structure 1615.2.2. AMI BIOS Tools 1625.2.3. AMI Boot-Block Reverse Engineering __ 1635.2.3.1. Boot-Block Jump Table 1635.2.3.2. Decompression Block Relocation __ 1655.2.3.3. Decompression Engine Initialization 1685,2,3.4. BIOS Binary Relocation into RAM 1705.2.3.5. POST Preparation 1775.2.4. AMI System BIOS Reverse Engineering 182Chapter 6: BIOS Modification __ 187Preview __ 1876.1. Tools of the Tmde __ 1886,2. Code Injection __ 1936.2.1. Locating the POST Jump Table 1956.2.2. Finding a Dummy Procedure in the POST Jump Table 1976.2.3. Assembling the Injected Code 1976.2.4. Extracting the Genuine System BIOS 2006.2.5. Looking for Padding Bytes 2016.2.6. Injecting the Code 2026.2.7. Modifying the POST Jump Table 2026.2.8. Rebuilding the BIOS Binary 2046.2.9. Flashing the Modified BIOS Binary 2046.3. Other Modifications 205Contents IX•PART III: EXPANSION ROM 209Chapter 7: PCI Expansion ROM Software Development 211Preview 2117.1. PnP BIOS and Expansion ROM Architecture 2127.1.1. PnP BIOS Architecture 2127.1.2. "Abusing" PnP BIOS for Expansion ROM Development 2127.1.3. POST and PCI Expansion ROM Initialization 2137.1.4. PCI Expansion XROMBAR 2137.1.5. PCI Expansion ROM 2147.1.5.1. PCI Expansion ROM Contents 2157.1.5.2. PC-Compatible Expansion ROMs 2187.1.6. PCI PnP Expansion ROM Structure 2217.2. PCI Expansion ROM Peculiarities 2227.3. Implementation Sample 2247.3.1. Hardware Testbed 2247.3.2. Software Development Tool 2257.3.3. Expansion ROM Source Code 2257.3.3.1. Core PCI PnP Expansion ROM Source Code 2267.3.3.2. PCI PnP Expansion ROM Checksum Utility Source Code 2277.3.4. Building the Sample 2277.3.5. Testing the Sample 2297.3.6. Potential Bug and Its Workaround 230X Contents$Chapter 8: PCI Expansion ROM Reverse Engineering _______ 233Preview -------____________________ 2338.1. Binary Architecture' ____________________ 2348.2. Disassembling the Main Code __________________ 2368.2.1. Disassembling Realtek 8139 Expansion ROM __________ 2368.2.2. Disassembling Gigabyte GV -NX76T2S6D-RHGeForce 7600 GT Expansion ROM ______________ 2418.2.3. A Note on Expansion ROM Code-Injection Possibility _______ 244PART IV: BIOS NINIUTSU ________________ 245Chapter 9: Accessing BIOS within the Operating System ______ 247Preview ___________________________ 2479.1. General Access Method ____________________ 2489.2. Accessing Motherboard BIOS Contents in Linux ___________ 2499.2.1. Introduction to j1ash_n_burn 2S 19.2.2. Internals ofj1ash_n_burn 2559.3. Accessing Motherboard BIOS Contents in Windows 2619.3.1. Kernel -Mode Device Driver of bios_probe' ____________ 2639.3.2. User-Mode Application of bios_probe 2789.3.2.1. The Main Application 2789.3.2 .2. The PCI Library 2929.4. Accessing PCl Expansion ROM Contents in Linux __________ 297Contents XI$9.5. Accessing PCI Expansion ROM Contents in Windows 3019.5.1. The RTL8139 Address-Mapping Method 3019.5.2. The Atme] AT29C512 Access Method 3059.5.3. Implementing the Methods in Source Code 3059.5.4. Testing the Software 316Chapter 10: Low-Level Remote Server Management 321Preview 32110.1. DMI 'nd 5MBIOS 32210.2. Remote Server Management Code Implementation 334Chapter 11: BIOS Security Measures 341Preview 34111.1. Password Protection 34211.1.1. Invalidating the CMOS Checksum 34311.1.2. Reading the BIOS Password from BDA 34811.1.3 The Downsides - An Attacker's Point of View 35711.2. BIOS Component Integrity Checks 35711.2.1. Award BIOS Component Integrity Checks 35811.2.2. AMI BIOS Component Integrity Checks 36111.3. Remote Server Management Security Measures 36311.4. Hardware-Based Security Measures 364XII Contents •Chapter 12: BIOS Rootkit Engineering _____________ 375Preview ___________________________ 37512.1. Looking Back through BIOS Exploitation History __________ 37612.2. Hijacking the System BIOS 39112.2.1. Hijacking Award BIOS 4.51PG Interrupt Handlers 39512.2.2. Hijacking Award BIOS 6.00PG Interrupt Handlers ________ 40S12.2.3. Extending the Technique to a BIOS from Other Vendors ______ 41312.3. PCI Expansion ROM Rootkit Development Scenario _________ 41412.3.1. PCI Expansion ROM Detour Patching ____________ 41612.3.2. Multi-lmage PC! Expansion ROM 41812.3.3. PCI Expansion ROM Peculiarity in Network Cards 420Chapter 13: BIOS Defense Techniques _____________ 421Preview ___________________________ 42113.1. Prevention Methods _______________ _____ 42213.1.1. Hardware-Based Security Measures _ _____________ 42213.1.2. Virtual Machine Defense 42613.1.2. WBEM Security in Relation to the BIOS RooLkit 42713.1.3. Defense against PCI Expansion ROM Rootkit Attacks 42913.1.4. Miscellaneous BIOS-Related Defense Methods 43013.2. Recognizing Compromised Systems, _______________ 44013.2.1. Recognizing a Compromised Motherboard BIOS 44013.2.2. Recognizing a Compromised PCI Expansion ROM 44213.3. Healing Compromised Systems 443Contents XIIIPART V: OTHER APPLICATIONS OF 8105 TECHOLOGY 445Chapter 14: Embedded x86 8105 Technology 447Preview44714.1. Embedded x86 BIOS Architecture 44814.2. Embedded x86 BIOS Implementation Samples 45114.2.1. TV Set-Top Box 45114.2.2. Network Appliance 46614.2.3. Kiosk 47114.3. Embedded x86 BIOS Exploitation 473Chapter 15: What's Next? 475Preview 47515.1. Future of BIOS Technology 47615.1.1. Unified Extensible Firmware Interface 47615.1.2. BIOS Vendors Road Map 48115.2. Ubiquitous Computing and Development in BIOS 48615.3. Future of BIOS-Related Security Threats 487The CD-ROM Description 489Index 491Download:http://www.handgrep.se/repository/ebooks/Security/Reversing/BIOS-Disassembly-Ninjutsu-Uncovered.pdf Quote