Sunday, January 21, 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 articles
  1. Pentest Tools For Ubuntu
  2. Hacker Tools Apk Download
  3. Pentest Tools Free
  4. Ethical Hacker Tools
  5. Best Pentesting Tools 2018
  6. Hacker Tools For Pc
  7. Hacker
  8. Kik Hack Tools
  9. Hacking Tools 2020
  10. Hacker Tools For Windows
  11. Hacking Tools Mac
  12. Android Hack Tools Github
  13. Pentest Tools Alternative
  14. Pentest Tools Alternative
  15. Pentest Tools Find Subdomains
  16. Hacking Tools Free Download
  17. Nsa Hacker Tools
  18. Hacker Tools Linux
  19. Hack Tool Apk No Root
  20. Hack Tools
  21. Pentest Recon Tools
  22. Hacker Tools Apk
  23. Hacker
  24. Hack Rom Tools
  25. Pentest Tools For Android
  26. Hack Tools Online
  27. Hacking Apps
  28. Hack Tools Github
  29. Tools Used For Hacking
  30. Pentest Tools Download
  31. Hacker Tools Linux
  32. Hacking Tools Usb
  33. Nsa Hack Tools Download
  34. Hacking Tools Windows 10
  35. Pentest Tools Framework
  36. Pentest Tools Linux
  37. Hacker Tools List
  38. Pentest Tools Online
  39. Hacker Tools Apk Download
  40. Best Pentesting Tools 2018
  41. Pentest Tools For Mac
  42. Hack Tools For Ubuntu
  43. Hacker Tools Mac
  44. Pentest Tools Framework
  45. Hacker Tools For Mac
  46. Hacker Tools Apk Download
  47. Android Hack Tools Github
  48. Hack Tools For Pc
  49. Growth Hacker Tools
  50. Pentest Tools Tcp Port Scanner
  51. Hacker Tools For Pc
  52. Pentest Tools Android
  53. Tools 4 Hack
  54. Hacking Tools Online
  55. Hacker Tools For Pc
  56. Hacker Tools For Windows
  57. Hacker Techniques Tools And Incident Handling
  58. Hack Tools 2019
  59. Hacker Tools 2020
  60. Hacker Tools For Mac
  61. Hackrf Tools
  62. Pentest Tools Bluekeep
  63. Underground Hacker Sites
  64. Hacker Tools Free
  65. Pentest Tools Free
  66. New Hacker Tools
  67. Hacker Tools
  68. What Are Hacking Tools
  69. Pentest Tools Framework
  70. Pentest Tools For Android
  71. Hacking Tools
  72. Pentest Tools Url Fuzzer
  73. Hacker Search Tools
  74. Nsa Hack Tools
  75. Pentest Tools Review
  76. Pentest Tools Nmap
  77. Computer Hacker
  78. Github Hacking Tools
  79. Hackrf Tools
  80. Hacker Techniques Tools And Incident Handling
  81. Nsa Hacker Tools
  82. Hacking Tools Download
  83. Hack Tool Apk
  84. Hacker Tools Free Download
  85. Best Pentesting Tools 2018
  86. Kik Hack Tools
  87. Hacker Tools For Windows
  88. Hacking App
  89. Hacker Hardware Tools
  90. Hacking Tools Download
  91. Pentest Tools Subdomain
  92. Pentest Tools Android
  93. Hacking Tools Usb
  94. Pentest Tools Linux
  95. Pentest Recon Tools
  96. Pentest Tools Website Vulnerability
  97. Best Pentesting Tools 2018
  98. Pentest Tools For Windows
  99. Nsa Hack Tools Download
  100. Hacker Tools Free Download
  101. Free Pentest Tools For Windows
  102. Hacking Tools 2019
  103. Hack Rom Tools
  104. Hacking Tools For Windows Free Download
  105. Hacker Tool Kit
  106. Hacking Tools Windows
  107. Computer Hacker
  108. Growth Hacker Tools
  109. Hacker Tools List
  110. Computer Hacker
  111. Hacking Tools For Windows
  112. Bluetooth Hacking Tools Kali
  113. Hacker Tools For Pc
  114. Pentest Tools Linux
  115. Pentest Tools For Windows
  116. Hacking Tools Online
  117. Pentest Tools
  118. Pentest Tools Kali Linux
  119. Pentest Tools For Windows
  120. Hacker Tools Free Download
  121. How To Hack

No comments:

Post a Comment