Buffer Overflows Flashcards
What is the highest and lowest memory address used by Windows?
- lowest = 0x00000000
- highest = 0x7FFFFFFF
Define the Stack
- When a thread is running, it executes code from within the Program Image or from various DLLs (Dynamic Link Libraries)
- The thread requires short-term data areas for functions, local variables, and program control information….this short-term data area is the STACK
- To facilitate independent execution of multiple threads, each thread in a running application has its own STACK
Explain LIFO and the Stack
- Stack memory is “viewed” by the CPU as a Last-In First-Out structure
- Items put (“PUSHED”) onto the top of the Stack are removed (“POPPED”) first
- x86 architecture implements dedicated PUSH and POP assembly instructions in order to ADD or REMOVE data on the STACK
Explain Return Address
- When code within a Thread calls a Function, it must know which address to return to once the function completes
- This “RETURN ADDRESS” (along with the functions parameters and local variables) is stored on the Stack
- When a Function ends, the “RETURN ADDRESS” is taken from the Stack and used to restore the execution flow back to the main program or the “calling function”
CPU Registers
- To perform efficient code execution, the CPU maintains and uses a series of nine 32-bit registers
- Registers are small, extremely high-speed CPU storage locations where data can be efficiently read and manipulated.
What are the general purpose registers?
- EAX
- EBX
- ECX
- EDX
- ESI
- EDI
EAX
- Accumulator
- - Arithmetical and logical instructions
EBX
- Base
- - Base pointer for memory addresses
ECX
- Counter
- - Loop, shift, and rotation counter
EDX
- Data
- - I/O port addressing, multiplication, and division
ESI
- Source Index
- - Pointer addressing of data and source in string copy operations
EDI
- Destination Address
- - Pointer addressing of data and destination in string copy operations
ESP
- Stack Pointer
- - Keeps ‘track’ of the most recently referenced location on the Stack (top of the Stack) by storing a pointer to it
What does “pointer” mean?
- reference to an address (or location) in memory
- stores the target address
EBP
- Base Pointer
- stores a pointer to the top of the Stack when a function is called
- By accessing EBP, a function can easily reference information from its own Stack
EIP
- Instruction Pointer
- One of the most important registers because it points to the next code to be executed
- EIP directs the flow of a program
- ** The attacker’s primary target when exploiting any memory corruption vulnerability such as a buffer overflow ***
- ** Holy Grail for shellcoding ***