#include <stdio.h>
#include <string.h>

void bad_func() {
	char v[500];
	memset(v + 0, 0x41, 500);				/* safe part of the buffer */
	memset(v + 500, 0x42, 4);				/* loaded into EBP */	
	memcpy(v + 504, "\xcf\x83\x04\x08", 4);	/* loaded into EIP */
	memset(v + 508, 0x43, 400);				/* example shellcode */
}

void test() {
	char a[256];
	char b[256] = "hello world\n";
	strcpy(a, b);
	strcpy(a, b);
}

int main() {


	test();
	test();
	
	
	char buf[256];
	char buf2[256];
	
	strcpy(buf, "hello world\n");
	
	__asm__ __volatile__(
		"rep movsb"
		: 
		:"c"(sizeof(buf)), "S"(buf), "D"(buf2)
	);
	
	
	bad_func();
	
	return 0;
}
