Wednesday, January 24, 2024

Linux Stack Protection By Default

Modern gcc compiler (v9.2.0) protects the stack by default and you will notice it because instead of SIGSEGV on stack overflow you will get a SIGABRT, but it also generates coredumps.




In this case the compiler adds the variable local_10. This variable helds a canary value that is checked at the end of the function.
The memset overflows the four bytes stack variable and modifies the canary value.



The 64bits canary 0x5429851ebaf95800 can't be predicted, but in specific situations is not re-generated and can be bruteforced or in other situations can be leaked from memory for example using a format string vulnerability or an arbitrary read wihout overflowing the stack.

If the canary doesn't match, the libc function __stack_chck_fail is called and terminates the prorgam with a SIGABORT which generates a coredump, in the case of archlinux managed by systemd and are stored on "/var/lib/systemd/coredump/"


❯❯❯ ./test 
*** stack smashing detected ***: terminated
fish: './test' terminated by signal SIGABRT (Abort)

❯❯❯ sudo lz4 -d core.test.1000.c611b7caa58a4fa3bcf403e6eac95bb0.1121.1574354610000000.lz4
[sudo] password for xxxx: 
Decoding file core.test.1000.c611b7caa58a4fa3bcf403e6eac95bb0.1121.1574354610000000 
core.test.1000.c611b : decoded 249856 bytes 

 ❯❯❯ sudo gdb /home/xxxx/test core.test.1000.c611b7caa58a4fa3bcf403e6eac95bb0.1121.1574354610000000 -q 


We specify the binary and the core file as a gdb parameters. We can see only one LWP (light weight process) or linux thread, so in this case is quicker to check. First of all lets see the back trace, because in this case the execution don't terminate in the segfaulted return.




We can see on frame 5 the address were it would had returned to main if it wouldn't aborted.



Happy Idea: we can use this stack canary aborts to detect stack overflows. In Debian with prevous versions it will be exploitable depending on the compilation flags used.
And note that the canary is located as the last variable in the stack so the previous variables can be overwritten without problems.




Related posts
  1. Hacker Tools Online
  2. Hacking Tools Windows 10
  3. Pentest Tools For Android
  4. Hack Tools
  5. Tools Used For Hacking
  6. Physical Pentest Tools
  7. Tools Used For Hacking
  8. Hacker Tools Apk Download
  9. Hacker
  10. Hacking Tools For Windows
  11. Nsa Hack Tools Download
  12. Hack Tools For Ubuntu
  13. Usb Pentest Tools
  14. Hack Tools For Ubuntu
  15. Pentest Tools Find Subdomains
  16. Usb Pentest Tools
  17. Best Hacking Tools 2020
  18. Pentest Tools For Android
  19. Best Hacking Tools 2019
  20. Android Hack Tools Github
  21. Hacking Tools Online
  22. Hacker Tools For Ios
  23. Hacking Tools For Games
  24. Hacker Tool Kit
  25. Hacking Tools Github
  26. Blackhat Hacker Tools
  27. Hack Apps
  28. Computer Hacker
  29. Nsa Hack Tools Download
  30. Nsa Hacker Tools
  31. Best Pentesting Tools 2018
  32. Hacking Tools Online
  33. Hack App
  34. Github Hacking Tools
  35. Hack Tools For Games
  36. Install Pentest Tools Ubuntu
  37. Pentest Tools Apk
  38. Hacking Tools Pc
  39. Blackhat Hacker Tools
  40. Kik Hack Tools
  41. Hack App
  42. Pentest Tools Website
  43. Pentest Tools Bluekeep
  44. Pentest Tools Open Source
  45. Hack Website Online Tool
  46. How To Install Pentest Tools In Ubuntu
  47. Hacking Tools Pc
  48. Hacking Tools Online
  49. Hacking Tools For Pc
  50. How To Install Pentest Tools In Ubuntu
  51. Hacker Techniques Tools And Incident Handling
  52. Pentest Tools Url Fuzzer
  53. Game Hacking
  54. Usb Pentest Tools
  55. What Are Hacking Tools
  56. Tools Used For Hacking
  57. Kik Hack Tools
  58. Kik Hack Tools
  59. Hacker Tools Hardware
  60. Pentest Tools Subdomain
  61. Hacker Tools Free
  62. Hacking Tools For Mac
  63. Hacker Tools Free
  64. Hacking Tools For Pc
  65. Hacking Tools Software
  66. Hacking Tools For Beginners
  67. Hacker Tools For Pc
  68. Pentest Tools Nmap
  69. Hacker Tools Hardware
  70. Hacker Tools List
  71. Pentest Tools For Android
  72. Hacking Tools Kit
  73. Pentest Recon Tools
  74. Beginner Hacker Tools
  75. Tools 4 Hack
  76. Hacking Tools Github
  77. Hacking Tools Github
  78. World No 1 Hacker Software
  79. Install Pentest Tools Ubuntu
  80. Hacking Tools For Windows
  81. Hack Tools For Ubuntu
  82. Android Hack Tools Github
  83. Easy Hack Tools
  84. Physical Pentest Tools
  85. World No 1 Hacker Software
  86. Wifi Hacker Tools For Windows
  87. Github Hacking Tools
  88. Hacking Tools Download
  89. Tools 4 Hack
  90. Hacker Tools Apk
  91. Pentest Recon Tools
  92. Install Pentest Tools Ubuntu

No comments:

Post a Comment