Friday, May 26, 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.




Continue reading

  1. Pentest Tools Windows
  2. Pentest Tools Website Vulnerability
  3. Nsa Hack Tools Download
  4. World No 1 Hacker Software
  5. Android Hack Tools Github
  6. Tools 4 Hack
  7. Pentest Tools For Ubuntu
  8. Blackhat Hacker Tools
  9. Hacker Tools Hardware
  10. Pentest Tools Website Vulnerability
  11. Pentest Reporting Tools
  12. Hacking Tools For Beginners
  13. Tools Used For Hacking
  14. Hack Tools
  15. Hacking Tools For Windows
  16. World No 1 Hacker Software
  17. Tools For Hacker
  18. Hacking Tools Github
  19. Pentest Tools Subdomain
  20. Hacking Tools Windows
  21. Hacking Tools Name
  22. Wifi Hacker Tools For Windows
  23. Pentest Automation Tools
  24. Hack Tools
  25. Free Pentest Tools For Windows
  26. Nsa Hacker Tools
  27. Hacking Tools Free Download
  28. Hack Tools
  29. Physical Pentest Tools
  30. Hacker Techniques Tools And Incident Handling
  31. Pentest Tools Kali Linux
  32. Hacking Tools Windows 10
  33. Hacking Tools Hardware
  34. Pentest Tools Download
  35. Hacking Tools Github
  36. Android Hack Tools Github
  37. World No 1 Hacker Software
  38. Pentest Tools Kali Linux
  39. Github Hacking Tools
  40. Pentest Tools List
  41. Pentest Tools Android
  42. Tools 4 Hack
  43. Hacker Tools Windows
  44. Hacking Tools Software
  45. Hack Tool Apk No Root
  46. Pentest Tools Port Scanner
  47. Hack Tools For Games
  48. Hacking Tools For Beginners
  49. Pentest Tools Subdomain
  50. Hackrf Tools
  51. Pentest Tools Url Fuzzer
  52. Hacking Tools And Software
  53. Pentest Tools
  54. Game Hacking
  55. Hacking Tools For Windows
  56. Hacking Tools For Windows 7
  57. Pentest Tools For Ubuntu
  58. Hacking Tools Mac
  59. Kik Hack Tools
  60. Hacker
  61. Hack Tools 2019
  62. Free Pentest Tools For Windows
  63. Hackers Toolbox

No comments:

Post a Comment