[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: protection against buffer overflows

Here is a simple example with shellcode. It will give you a nice shell if
there's a /bin/sh on your system :
#include <stdio.h>
#include <string.h>

char shellcode[] =

char large_string[128];

int main(int ac, char *av[])
char buffer[96];
int i;
long *long_ptr = (long *) large_string;

for (i = 0; i < 32; i++)
    *(long_ptr + i) = (int) buffer;
for (i = 0; i < (int)
   strlen(shellcode); i++)
   large_string[i] = shellcode[i];
strcpy(buffer, large_string);
return 0;

The Alep1 article mentioned before here is an excellent reference.
If you understand French, have a look at http://www.cgsecurity.org/ , buffer
overflow section.


Reply to: