zzqq0103

Untitled

Feb 8th, 2025
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #define _GNU_SOURCE
  2.  
  3. #include <endian.h>
  4. #include <fcntl.h>
  5. #include <stdint.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <sys/stat.h>
  10. #include <sys/syscall.h>
  11. #include <sys/types.h>
  12. #include <unistd.h>
  13.  
  14. static long syz_open_dev(volatile long a0, volatile long a1, volatile long a2)
  15. {
  16. if (a0 == 0xc || a0 == 0xb) {
  17. char buf[128];
  18. sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1,
  19. (uint8_t)a2);
  20. return open(buf, O_RDWR, 0);
  21. } else {
  22. char buf[1024];
  23. char* hash;
  24. strncpy(buf, (char*)a0, sizeof(buf) - 1);
  25. buf[sizeof(buf) - 1] = 0;
  26. while ((hash = strchr(buf, '#'))) {
  27. *hash = '0' + (char)(a1 % 10);
  28. a1 /= 10;
  29. }
  30. return open(buf, a2, 0);
  31. }
  32. }
  33.  
  34. uint64_t r[1] = {0xffffffffffffffff};
  35.  
  36. int main(void)
  37. {
  38. syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul,
  39. /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
  40. /*offset=*/0ul);
  41. syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul,
  42. /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul,
  43. /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
  44. /*offset=*/0ul);
  45. syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul,
  46. /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
  47. /*offset=*/0ul);
  48. intptr_t res = 0;
  49. res = -1;
  50. res = syz_open_dev(/*dev=*/0xc, /*major=*/4, /*minor=*/1);
  51. if (res != -1)
  52. r[0] = res;
  53. *(uint16_t*)0x20000000 = 0x5d06;
  54. *(uint16_t*)0x20000002 = 0;
  55. *(uint16_t*)0x20000004 = 0;
  56. *(uint16_t*)0x20000006 = 0;
  57. syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x5414, /*arg=*/0x20000000ul);
  58. return 0;
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment