Mrs. King - School Year 2010-2011

Wednesday, January 17, 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 word
  1. Hacking Tools Mac
  2. Hacker Tools For Mac
  3. Termux Hacking Tools 2019
  4. Hacking Tools For Windows
  5. Hak5 Tools
  6. Hacker Tools Software
  7. Pentest Tools Framework
  8. How To Hack
  9. Best Pentesting Tools 2018
  10. Best Pentesting Tools 2018
  11. What Is Hacking Tools
  12. Hacker Tools Mac
  13. Usb Pentest Tools
  14. Computer Hacker
  15. Hacking Tools For Windows Free Download
  16. Hacker Tool Kit
  17. Hacking Tools Kit
  18. Pentest Recon Tools
  19. Hacking Tools Pc
  20. Hacking Tools Windows
  21. What Is Hacking Tools
  22. Hack Tools For Mac
  23. Hacking Tools For Windows 7
  24. Hacks And Tools
  25. Pentest Recon Tools
  26. Pentest Tools Kali Linux
  27. Hacker Tools 2020
  28. Pentest Tools List
  29. Hack And Tools
  30. Hack Tools
  31. Hacking Tools Hardware
  32. Hack App
  33. Hacker Tools Free Download
  34. Hacker Tools For Windows
  35. What Are Hacking Tools
  36. Pentest Tools Alternative
  37. Nsa Hack Tools Download
  38. Hacker Tools Apk
  39. Hacking Tools Windows 10
  40. Install Pentest Tools Ubuntu
  41. Pentest Tools Tcp Port Scanner
  42. Hacker Tools For Windows
  43. Pentest Tools Bluekeep
  44. Pentest Tools For Windows
  45. Hacker Tool Kit
  46. Hacker Tools
  47. Hacking Tools And Software
  48. Bluetooth Hacking Tools Kali
  49. Pentest Tools Url Fuzzer
  50. Hack Tools Pc
  51. Hack Tool Apk No Root
  52. Beginner Hacker Tools
  53. Hacking Tools Name
  54. Pentest Tools Kali Linux
  55. Hacking Tools Software
  56. Pentest Tools Find Subdomains
  57. Hack Tools For Ubuntu
  58. Pentest Tools Framework
  59. Hacker Tools Github
  60. Hacking Tools For Kali Linux
  61. Hack Tools
  62. Pentest Tools Alternative
  63. Hack Rom Tools
  64. Termux Hacking Tools 2019
  65. Hacking App
  66. Pentest Reporting Tools
  67. Hacker Tool Kit
  68. World No 1 Hacker Software
  69. Hackrf Tools
  70. Pentest Tools Port Scanner
  71. Usb Pentest Tools
  72. Hacker Tools Apk Download
  73. Hacking Tools Windows 10
  74. Pentest Tools Review
  75. Best Hacking Tools 2020
  76. Nsa Hack Tools Download
  77. Pentest Tools Bluekeep
  78. How To Install Pentest Tools In Ubuntu
  79. Pentest Tools Free

Blog Archive