Saturday, August 22, 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. Pentest Reporting Tools
  2. Hacking Tools Online
  3. Wifi Hacker Tools For Windows
  4. What Is Hacking Tools
  5. Hack Website Online Tool
  6. Hacker Tools For Pc
  7. Hacking Tools For Kali Linux
  8. Hack Tools For Ubuntu
  9. Hacker Security Tools
  10. Best Hacking Tools 2019
  11. Beginner Hacker Tools
  12. What Are Hacking Tools
  13. World No 1 Hacker Software
  14. Best Hacking Tools 2019
  15. Wifi Hacker Tools For Windows
  16. Pentest Tools Download
  17. Pentest Tools Github
  18. How To Install Pentest Tools In Ubuntu
  19. Hack Tools Github
  20. Hacking Tools Kit
  21. Hacker Hardware Tools
  22. How To Make Hacking Tools
  23. Pentest Box Tools Download
  24. Pentest Tools Url Fuzzer
  25. Hacker Tools Software
  26. Pentest Tools Android
  27. Hacking Tools For Windows 7
  28. Pentest Tools Find Subdomains
  29. Hacking Tools Usb
  30. Hack Tools
  31. Hacking Tools Mac
  32. Pentest Tools Kali Linux
  33. Hacker Security Tools
  34. Best Hacking Tools 2020
  35. Pentest Tools Framework
  36. Hacker Tools Free Download
  37. Hacking Tools And Software
  38. Hacker Tools Hardware
  39. Pentest Tools Alternative
  40. Hak5 Tools
  41. Hacking Tools For Mac
  42. Hacking Apps
  43. Pentest Tools Online
  44. Pentest Tools Apk
  45. Free Pentest Tools For Windows
  46. Hack Tool Apk No Root
  47. Hacker Tools
  48. Hacking Tools Github
  49. How To Hack
  50. Hacker Tools Free
  51. Hacking Tools Kit
  52. Hacker Techniques Tools And Incident Handling
  53. Hack Tools For Ubuntu
  54. Pentest Tools Port Scanner
  55. Hacker Tools For Mac
  56. Hacker Tools Hardware
  57. Hacker Tools Apk
  58. How To Make Hacking Tools
  59. Hack Tools For Games
  60. Hack Tool Apk No Root
  61. Tools For Hacker
  62. Hack Tools Mac
  63. Hacker Tools Apk
  64. Hacking Tools Hardware
  65. Pentest Tools Port Scanner
  66. Game Hacking
  67. Hacking Tools Free Download
  68. Hacker Tools Software
  69. Hacker
  70. Hacking Tools
  71. Game Hacking
  72. Easy Hack Tools
  73. Hacking Tools Hardware
  74. Hacking Tools Hardware
  75. Hacker Tools Online
  76. Pentest Tools For Ubuntu
  77. Growth Hacker Tools
  78. Hacker
  79. Pentest Recon Tools
  80. Hacking Tools Github
  81. Blackhat Hacker Tools
  82. Hacker Tools 2019
  83. Hacking Tools Usb
  84. Hacker Tools For Mac
  85. Hacks And Tools
  86. Pentest Tools Website Vulnerability
  87. Pentest Tools Nmap
  88. Tools For Hacker
  89. Hacker Tools Online
  90. Pentest Tools Alternative
  91. Ethical Hacker Tools
  92. Hack Tools For Mac
  93. Hacker Tools Github
  94. How To Install Pentest Tools In Ubuntu
  95. Underground Hacker Sites
  96. Hacker Hardware Tools
  97. Hacking Tools For Games

No comments:

Post a Comment