Monday, May 29, 2023

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 Tools Pc
  2. How To Install Pentest Tools In Ubuntu
  3. Computer Hacker
  4. Wifi Hacker Tools For Windows
  5. Pentest Tools For Ubuntu
  6. Hacking Tools Pc
  7. Hacker
  8. Hack Tools For Mac
  9. Hacking Tools For Kali Linux
  10. Hacker Tools For Ios
  11. Hacking Tools For Windows 7
  12. Pentest Tools Open Source
  13. Pentest Tools Port Scanner
  14. Hacking Tools And Software
  15. Pentest Tools Alternative
  16. Hacker Tools 2020
  17. Hacker Tools For Pc
  18. What Is Hacking Tools
  19. Hacking Tools Github
  20. Pentest Tools For Mac
  21. What Are Hacking Tools
  22. Pentest Tools Port Scanner
  23. Hacking Tools
  24. Hack Tools
  25. Hacker Tools
  26. Hacker Security Tools
  27. Hacking Tools Windows
  28. Hacker Tools For Mac
  29. Hack Tools Online
  30. Pentest Tools Open Source
  31. Top Pentest Tools
  32. Hacking Tools Online
  33. Pentest Tools Windows
  34. Hacking Tools Software
  35. Hacker Tools Free Download
  36. Pentest Tools Alternative
  37. Hacker Tools Software
  38. Pentest Tools Linux
  39. Best Pentesting Tools 2018
  40. Blackhat Hacker Tools
  41. Pentest Recon Tools
  42. Hacker Tools Github
  43. Hacking Tools For Kali Linux
  44. Pentest Tools Framework
  45. Hacking Tools And Software
  46. Pentest Tools
  47. Hack App
  48. Install Pentest Tools Ubuntu
  49. Pentest Tools Free
  50. Pentest Reporting Tools
  51. Computer Hacker
  52. Hacker Tools
  53. Pentest Tools Tcp Port Scanner
  54. Free Pentest Tools For Windows
  55. Hacking Tools For Mac
  56. Hack Tools
  57. Pentest Reporting Tools
  58. Pentest Tools Nmap
  59. Hacker Tools Windows
  60. Hack Tools Online
  61. Hacker Tools For Mac
  62. Pentest Recon Tools
  63. Pentest Tools Review
  64. Hacking Tools Kit
  65. Hackers Toolbox
  66. Hacker Tools List
  67. Hacking App
  68. Pentest Tools List
  69. Nsa Hack Tools
  70. Tools Used For Hacking

No comments:

Post a Comment