zzqq0103

Untitled

Mar 12th, 2024
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.40 KB | None | 0 0
  1. #define _GNU_SOURCE
  2.  
  3. #include <endian.h>
  4. #include <stdint.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <sys/syscall.h>
  9. #include <sys/types.h>
  10. #include <unistd.h>
  11.  
  12. uint64_t r[1] = {0xffffffffffffffff};
  13.  
  14. int main(void)
  15. {
  16.   syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul,
  17.           /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
  18.           /*offset=*/0ul);
  19.   syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul,
  20.           /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul,
  21.           /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
  22.           /*offset=*/0ul);
  23.   syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul,
  24.           /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
  25.           /*offset=*/0ul);
  26.   intptr_t res = 0;
  27.   memcpy((void*)0x20000380, "/dev/kvm\000", 9);
  28.   res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x20000380ul,
  29.                 /*flags=*/0ul, /*mode=*/0ul);
  30.   {
  31.     int i;
  32.     for (i = 0; i < 64; i++) {
  33.       syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x20000380ul,
  34.               /*flags=*/0ul, /*mode=*/0ul);
  35.     }
  36.   }
  37.   if (res != -1)
  38.     r[0] = res;
  39.   syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0xae01, /*type=*/0ul);
  40.   {
  41.     int i;
  42.     for (i = 0; i < 32; i++) {
  43.       syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0xae01, /*type=*/0ul);
  44.     }
  45.   }
  46.   return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment