#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char *buffer1 = (char *)calloc(5, sizeof(char));
char *buffer2 = (char *)calloc(15, sizeof(char));
char *tmp;
strcpy(buffer2, "ls -a --color");
strcpy(buffer1, argv[1]);
// Indirizzi di memoria...
printf("%p <-- buffer1
", buffer1);
printf("%p <-- buffer2
", buffer2);
printf("
");
// Stampa indirizzi...
printf("Start code....
");
tmp=buffer1;
while(tmp<buffer2+15)
{
printf("%p: %c (0x%x)
", tmp, *tmp, *(unsigned int *)tmp);
tmp++;
}
printf("
");
system(buffer2);
return 0;
}
C – Example Buffer OverFlow
Leave a Reply
You must be logged in to post a comment.