Is there any way to use buffer overflow and overwrite the stack, but to the LOWER MEMORY ADDRESSes?

StackOverflow https://stackoverflow.com/questions/18293991

  •  24-06-2022
  •  | 
  •  

Pergunta

I wanna know, is there any way to overwrite the stack by the use of buffer overflow vulnerability or other vuls so that it overwrites the lower memory addresses instead of the higher ones!? (Intel x86 arch)

Foi útil?

Solução

It depends on the buffer overflow under question.

char *buffer_start;
char *buffer_pos;
char *buffer_end;

void write_data(size_t offset, int c)
{
    if (buffer_pos + offset >= buffer_end)
        abort();
    buffer_pos += offset;
    *buffer_pos = c;
    buffer_pos++;
}

In the above scenario, one can write to lower addresses by specifying an offset that overflows. This in turn causes a buffer overflow to lower addresses.

As a reminder, to fix the buffer overflow you would write the check as follows:

if (offset >= buffer_end - buffer_pos)
    abort();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top