Return to Snippet

Revision: 1714
at November 10, 2006 00:11 by whitetiger


Updated Code
#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\n", buffer1);
	printf("%p <-- buffer2\n", buffer2);
	printf("\n\n");

	// Stampa indirizzi...
	printf("Start code....\n");
	tmp=buffer1;
	while(tmp<buffer2+15)
	{
		printf("%p: %c (0x%x)\n", tmp, *tmp, *(unsigned int *)tmp);
		tmp++;
	}

	printf("\n");
	system(buffer2);
	return 0;
}

Revision: 1713
at November 9, 2006 23:54 by whitetiger


Initial Code
#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\n", buffer1);
	printf("%p <-- buffer2\n", buffer2);
	printf("\n\n");

	// Stampa indirizzi...
	printf("Start code....\n");
	tmp=buffer1;
	while(tmp<buffer2+15)
	{
		printf("%p: %c (0x%x)\n", tmp, *tmp, *(unsigned int *)tmp);
		tmp++;
	}

	printf("\n");
	system(buffer2);
	return 0;
}

Initial URL


Initial Description


Initial Title
C - Example Buffer OverFlow

Initial Tags
math, c

Initial Language
C++