Buffers on the stack in x86 (assembly language)

I'm trying to get my head around buffers / buffer overflows in assembly language. I understand that if a buffer is created and the data being put into is larger than the buffer, it will overflow.

I can see that the instruction below will create space for a variable, but this would only be 4 bytes (32 bits) long.
sub esp, 4

Question 1: If I wanted to create a buffer 33 bits in length would the instruction simply be: sub esp, 8

Question 2:
If so, given the example of:
A: sub esp, 28 - large buffer all the way to ebp
B: sub esp, 32 - small buffer from ebp-32 to ebp-28

If more than 4 bytes were entered into B this would overflow into A. I understand that:
mov [ebp-32], ebx

would put a dword into ebp-32, but if I wanted to overflow into ebp-28 all the way to ebp I would need a 32*32=1024 bit/128byte string.

How could this be achieved / what would the instruction look like in assembly?

Thanks,
Frost

Replies

You are reading an archived discussion.

Related Posts

I was going through CE and I realized that I've hardly seen any posts on photography.👀 I am curious as to how many CEans are interested in photography? Needless to...
How many of us never played with Lego. Here is the chance. Go to https://www.buildwithchrome.com/ and start building your own architecture. Needless to say I am terrible. My first build
General Motors India seems to be all geared up for the Delhi Auto Expo in India which is going to be held between 7-11 February, 2014. Creating a buzz among...
Totally newbie question - What are the factors or features or categories that help us determine that a car is a SUV?
Catalyst is a techfest organized by the department of computer technology Rajiv Gandhi College of Engineering and Research Nagpur Each year the students strive to make the events more exciting...