The Stack The stack is a very important structure to understand when developing a debugger. The stack stores information about how a function is called, the parameters it takes, and how it should return after it is finished executing. The stack is a First In, Last Out (FILO) structure, where arguments are pushed onto the stack for a function call and popped off the stack when the function is finished. The ESP register is used to track the very top of the stack frame, and the EBP register is used to track the bottom of the stack frame. The stack grows from high memory addresses to low memory addresses. Let's use our previously covered function my_socks() as a simplified example of how the stack works. Function Call in C int my_socks(color_one, color_two, color_three); Function Call in x86 Assembly push color_three push color_two push color_one call my_socks To see what the stack frame would look like, refer to Figure 2-1. Image from book Figure 2-1: Stack frame for the my_socks...
I've picked up the book Gray Hat Python by Justin Seitz and although it's not exactly an introductory book, I think even python or security noob can find some some pretty cool stuff that would make it worth the price. I've decided to use this blog as a note book for a quick reference later in the next more advanced chapters if I need to. Much of the stuff included in these notes below, I learned before in Assembly language class years ago, but I haven't played with assembly in a while, and I wish I had taken easily accessible notes to jog my memory. The following is just basic CPU architecture taken from chapter 2: In the x86 instruction set, a CPU uses eight general-purpose registers: EAX, EDX, ECX, ESI, EDI, EBP, ESP, and EBX. The registers are small pieces of storage designed for for quick access by CPU. The eight general-purpose registers have specific roles and are designed to enable to CPU to efficiently process instructions. The EAX register: This register is...