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
  •  | 
  •  

문제

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)

도움이 되었습니까?

해결책

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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top