26 January, 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.




More information
  1. Hack Rom Tools
  2. Hack Website Online Tool
  3. Hackrf Tools
  4. Kik Hack Tools
  5. New Hack Tools
  6. Hack Tool Apk
  7. Physical Pentest Tools
  8. Hacker Tools Apk
  9. Hacking Tools Windows 10
  10. Hacking Tools 2019
  11. Hacks And Tools
  12. Computer Hacker
  13. Pentest Tools Free
  14. Pentest Tools Nmap
  15. Hack Tools
  16. Game Hacking
  17. Termux Hacking Tools 2019
  18. Best Pentesting Tools 2018
  19. Nsa Hack Tools Download
  20. Hack Tools
  21. Hacking Tools For Games
  22. Hacker Techniques Tools And Incident Handling
  23. Pentest Tools Subdomain
  24. Nsa Hacker Tools
  25. Top Pentest Tools
  26. Hacking Tools Software
  27. Game Hacking
  28. Ethical Hacker Tools
  29. Hacker Hardware Tools
  30. Hacker Techniques Tools And Incident Handling
  31. New Hacker Tools
  32. Hack Tools Mac
  33. Hacking Tools Kit
  34. Hacks And Tools
  35. Hack Tools For Pc
  36. Pentest Tools Windows
  37. Tools For Hacker
  38. Hack Tools Mac
  39. Growth Hacker Tools
  40. Hacking Tools Kit
  41. Pentest Tools For Ubuntu
  42. Hacking Tools For Windows Free Download
  43. Hacker Tools For Pc
  44. Hacker Tools Apk
  45. Pentest Tools Website
  46. Hack Tools For Games
  47. Hacker Search Tools
  48. Pentest Tools Android
  49. Hacking Tools And Software
  50. Hack Tools Mac
  51. How To Hack
  52. Hacking Tools For Kali Linux
  53. Hacking Tools For Pc
  54. Hack Tools Mac
  55. Hack Tools For Games
  56. Hacking Tools Free Download
  57. Hacker Tools Free Download
  58. Wifi Hacker Tools For Windows
  59. Pentest Tools Github
  60. Pentest Tools Apk
  61. Computer Hacker
  62. What Is Hacking Tools
  63. Pentest Tools Port Scanner
  64. Hack Apps
  65. Nsa Hacker Tools
  66. Nsa Hack Tools Download
  67. Hack Tools For Games
  68. Hacking Tools Windows 10
  69. Hak5 Tools
  70. How To Install Pentest Tools In Ubuntu
  71. Hack Tools Download
  72. Easy Hack Tools
  73. Best Pentesting Tools 2018
  74. Physical Pentest Tools
  75. Hack Tools For Ubuntu
  76. Pentest Tools List
  77. Hak5 Tools
  78. Pentest Tools Download
  79. Pentest Tools For Ubuntu
  80. Pentest Tools
  81. Best Pentesting Tools 2018
  82. Hack Tools
  83. Black Hat Hacker Tools
  84. Nsa Hacker Tools
  85. How To Make Hacking Tools
  86. Hack Tool Apk No Root
  87. World No 1 Hacker Software
  88. Hacker Tools List
  89. Hack Tools Download
  90. Hack Tools For Pc
  91. Hacker Tools For Windows
  92. New Hacker Tools
  93. Hacking Tools For Kali Linux
  94. Pentest Tools Review
  95. Hack Website Online Tool
  96. Pentest Tools Github
  97. Hacking Tools For Kali Linux
  98. Pentest Tools Tcp Port Scanner
  99. Hacker Tools
  100. Beginner Hacker Tools
  101. Hacking App
  102. Usb Pentest Tools
  103. Hacking Tools Windows

No comments: