Aug 23, 2020

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 info


  1. Hacking Tools Online
  2. Hackers Toolbox
  3. Hak5 Tools
  4. Hacker Tools For Ios
  5. Hacker Tools
  6. Pentest Tools Port Scanner
  7. Pentest Tools Github
  8. Pentest Tools Linux
  9. Kik Hack Tools
  10. New Hack Tools
  11. Growth Hacker Tools
  12. Hack Tools
  13. Tools Used For Hacking
  14. Hacking Tools For Windows
  15. Black Hat Hacker Tools
  16. Hacker Tools Windows
  17. Hacking Tools Windows 10
  18. Hacker Security Tools
  19. Hacker Tool Kit
  20. Hack Website Online Tool
  21. Hack Apps
  22. Hack Tools For Mac
  23. Hack Rom Tools
  24. Hacking Tools Online
  25. Best Pentesting Tools 2018
  26. Pentest Tools Android
  27. Hacking Tools Online
  28. Beginner Hacker Tools
  29. Pentest Tools For Android
  30. Hacking Tools Github
  31. Hackrf Tools
  32. Pentest Tools Tcp Port Scanner
  33. Hacker Tool Kit
  34. Pentest Tools For Mac
  35. Hacking Tools Free Download
  36. Android Hack Tools Github
  37. Hack Tools For Ubuntu
  38. Hacking Tools For Games
  39. Hacker Hardware Tools
  40. Pentest Tools Linux
  41. Best Hacking Tools 2020
  42. Pentest Tools Linux
  43. Hacker Tools Online
  44. Hacking Tools 2019
  45. Pentest Tools Tcp Port Scanner
  46. Beginner Hacker Tools
  47. New Hacker Tools
  48. Pentest Tools Nmap
  49. Pentest Box Tools Download
  50. Hacking Tools Windows
  51. Hacker
  52. Hacker Techniques Tools And Incident Handling
  53. Hacking Tools Name
  54. Hacker Tools For Ios
  55. Pentest Tools Url Fuzzer
  56. Pentest Tools Alternative
  57. Hacking Tools 2019
  58. Hacking Tools Online
  59. Hack Tools For Ubuntu
  60. Hacker Tool Kit
  61. Pentest Tools Framework
  62. Underground Hacker Sites
  63. Hack Tools For Windows
  64. Pentest Tools Apk
  65. Hacking Tools Software
  66. Pentest Tools Free
  67. Hacker Tools Windows
  68. Install Pentest Tools Ubuntu
  69. Hacking Tools Download
  70. Pentest Tools Online
  71. Hacker Security Tools
  72. Hack Tools Online
  73. Hacking Tools Online
  74. Hack Tool Apk No Root
  75. Hacking Apps
  76. Beginner Hacker Tools
  77. Pentest Tools Apk
  78. Pentest Tools Review
  79. Android Hack Tools Github
  80. Hacker Tools
  81. Hacker Tools Github
  82. Hacking Tools For Mac
  83. Pentest Tools For Android
  84. Hacker Tools Hardware
  85. Hacker Tools For Ios
  86. Nsa Hack Tools
  87. Hacking Tools For Kali Linux
  88. Hack App
  89. Beginner Hacker Tools
  90. Ethical Hacker Tools
  91. Pentest Reporting Tools
  92. Hacking Tools 2020
  93. Pentest Automation Tools
  94. Hacking Tools For Kali Linux
  95. Hacking Tools Mac
  96. Hacking Tools And Software
  97. Hacking Tools Usb
  98. Hacker Tools For Mac

No comments:

Post a Comment