Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

BIOS Disassembly Ninjutsu Uncovered - Preface

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Preface

BIOS DISASSEMBLY NINJUTSU UNCOVERED THE BOOK


For many years, there has been a myth among computer enthusiasts and practitioners that
PC BIOS (Basic Input Output System) modification is a kind of black art and only a handful of
people can do it or only the motherboard vendor can carry out such a task. On the contrary, this
book will prove that with the right tools and approach, anyone can understand and modify the
BIOS to suit their needs without the existence of its source code. It can be achieved by using a
systematic approach to BIOS reverse engineering and modification. An advanced level of this
modification technique is injecting a custom code to the BIOS binary.
There are many reasons to carry out BIOS reverse engineering and modification, from the
fun of doing it to achieve higher clock speed in overclocking scenario, patching certain bug,
injecting a custom security code into the BIOS, up to commercial interest in the embedded x86
BIOS market. The emergence of embedded x86 platform as consumer electronic products such as
TV set-top boxes, telecom-related appliances and embedded x86 kiosks have raised the interest in
BIOS reverse engineering and modification. In the coming years, these techniques will become
even more important as the state of the art bus protocols have delegate a lot of their initialization
task to the firmware, i.e. the BIOS. Thus, by understanding the techniques, one can dig the
relevant firmware codes and understand the implementation of those protocols within the BIOS
binary.
The main purpose of the BIOS is to initialize the system into execution environment
suitable for the operating system. This task is getting more complex over the years, since x86
hardware evolves quite significantly. Its one of the most dynamic computing platform on earth.
Introduction of new chipsets happens once in 3 or at least 6 month. This event introduces a new
code base for the silicon support routine within the BIOS. Nevertheless, the overall architecture of
the BIOS is changing very slowly and the basic principle of the code inside the BIOS is preserved
over generations of its code. However, there has been a quite significant change in the BIOS scene
in the last few years, with the introduction of EFI (extensible Firmware Interface) by several major
hardware vendors and with the growth in OpenBIOS project. With these advances in BIOS
technology, its even getting more important to know systematically what lays within the BIOS.
In this book, the term BIOS has a much broader meaning than only motherboard BIOS,
which is familiar to most of the reader. It also means the expansion ROM. The latter term is the
official term used to refer to the firmware in the expansion cards within the PC, be it ISA, PCI or
PCI Express.
So, what can you expect after reading this book? Understanding the BIOS will open a
new frontier. You will be able to grasp how exactly the PC hardware works in its lowest level.
Understanding contemporary BIOS will reveal the implementation of the latest bus protocol
technology, i.e. HyperTransport and PCI-Express. In the software engineering front, you will be
able to appreciate the application of compression technology in the BIOS. The most important of
all, you will be able to carry out reverse engineering using advanced techniques and tools. You
will be able to use the powerful IDA Pro disassembler efficiently. Some reader with advanced
knowledge in hardware and software might even want to borrow some of the algorithm within
the BIOS for their own purposes. In short, you will be on the same level as other BIOS codediggers.
This book also presents a generic approach to PCI expansion ROM development using
the widely available GNU tools. There will be no more myth in the BIOS and everyone will be
able to learn from this state-of-the-art software technology for their own benefits.

THE AUDIENCE
This book is primarily oriented toward system programmers and computer security
experts. In addition, electronic engineers, pc technicians and computer enthusiasts can also benefit
a lot from this book. Furthermore, due to heavy explanation of applied computer architecture (x86

architecture) and compression algorithm, computer science students might also find it useful.
However, nothing prevents any people who is curious about BIOS technology to read this book
and get benefit from it.
Some prerequisite knowledge is needed to fully understand this book. It is not mandatory,
but it will be very difficult to grasp some of the concepts without it. The most important
knowledge is the understanding of x86 assembly language. Explanation of the disassembled code
resulting from the BIOS binary and also the sample BIOS patches are presented in x86 assembly
language. They are scattered throughout the book. Thus, its vital to know x86 assembly language,
even with very modest familiarity. Its also assumed that the reader have some familiarity with C
programming language. The chapter that dwell on expansion ROM development along with the
introductory chapter in BIOS related software development uses C language heavily for the
example code. C is also used heavily in the section that covers IDA Pro scripts and plugin
development. IDA Pro scripts have many similarities with C programming language. Familiarity
with Windows Application Programming Interface (Win32API) is not a requirement, but is very
useful to grasp the concept in the Optional section of chapter 3 that covers IDA Pro plugin
development.

THE ORGANIZATION
The first part of the book lays the foundation knowledge to do BIOS reverse engineering and
Expansion ROM development. In this part, the reader is introduced with:
a. Various bus protocols in use nowadays within the x86 platform, i.e. PCI, HyperTransport and
PCI-Express. The focus is toward the relationship between BIOS code execution and the
implementation of protocols.
b. Reverse engineering tools and techniques needed to carry out the tasks in later chapter, mostly
introduction to IDA Pro disassembler along with its advanced techniques.
c. Crash course on advanced compiler tricks needed to develop firmware. The emphasis is in
using GNU C compiler to develop a firmware framework.
The second part of this book reveals the details of motherboard BIOS reverse engineering and
modification. This includes indepth coverage of BIOS file structure, algorithms used within the
BIOS, explanation of various BIOS specific tools from its corresponding vendor and explanation
of tricks to perform BIOS modification.
The third part of the book deals with the development of PCI expansion ROM. In this part,
PCI Expansion ROM structure is explained thoroughly. Then, a systematic PCI expansion ROM
development with GNU tools is presented.
The fourth part of the book deals heavily with the security concerns within the BIOS. This
part is biased toward possible implementation of rootkits within the BIOS and possible
exploitation scenario that might be used by an attacker by exploiting the BIOS flaw. Computer
security experts will find a lot of important information in this part. This part is the central theme
in this book. Its presented to improve the awareness against malicious code that can be injected
into BIOS.
The fifth part of the book deals with the application of BIOS technology outside of its
traditional space, i.e. the PC. In this chapter, the reader is presented with various application of the
BIOS technology in the emerging embedded x86 platform. In the end of this part, further
application of the technology presented in this book is explained briefly. Some explanation
regarding the OpenBIOS and Extensible Firmware Interface (EFI) is also presented.

SOFTWARE TOOLS COMPATIBILITY


This book mainly deals with reverse engineering tools running in windows operating system.
However, in chapters that deal with PCI Expansion ROM development, an x86 Linux installation

is needed. This is due to the inherent problems that occurred with the windows port of the GNU
tools when trying to generate a flat binary file from ELF file format.

Proposed Table of Contents


Preface
Table of contents

i
iv

Part I The Basics


Chapter 1

Introducing PC BIOS Technology


1.1. Motherboard BIOS
1.2. Expansion ROM
1.3. Other PC Firmware
1.4. Bus Protocols and Chipset Technology
1.4.1. System-Wide Addressing
1.4.2. PCI Bus Protocol
1.4.3. Propietary Inter-Chipset Protocol Technology
1.4.4. PCI-Express Bus Protocol
1.4.5. HyperTransport Bus Protocol

1
1
7
9
9
9
11
15
17
18

Chapter 2

Preliminary Reverse Code Engineering


2.1. Binary Scanning
2.2. Introducing IDA Pro
2.3. IDA Pro Scripting and Key Bindings
2.4. IDA Pro Plug-in Development (Optional)

19
19
22
28
37

Chapter 3

Preliminary BIOS-Related Software Development


3.1. BIOS-Related Software Development with Pure Assembler
3.2. BIOS-Related Software Development with GCC

48
48
53

Part II Motherboard BIOS Reverse Engineering


Chapter 4

Getting Acquainted with the System


4.1. Hardware Peculiarities
4.2. BIOS Binary Structure
4.3. Software Peculiarities
4.4. BIOS Disassembling with IDA Pro

61
61
74
77
81

Chapter 5

BIOS Reverse Engineering


5.1. Award BIOS
5.1.1. Award BIOS File Structure
5.1.2. Award BIOS Tools
5.1.3. Award Bootblock BIOS Reverse Engineering
5.1.4. Award System BIOS Reverse Engineering
5.2. AMI BIOS
5.2.1. AMI BIOS File Structure
5.2.2. AMI BIOS Tools
5.2.3. AMI Bootblock BIOS Reverse Engineering
5.2.4. AMI System BIOS Reverse Engineering

83
83
83
85
86
99
113
113
115
116
129

Chapter 6

BIOS Modification
6.1. Tools of the Trade
6.2. Code Injection
6.3. Other Modifications

173
173
174
184

Part III Expansion ROM

You might also like