Monday, August 24, 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.




Read more

  1. Pentest Tools Review
  2. Hacker Tools Windows
  3. Pentest Tools Alternative
  4. Free Pentest Tools For Windows
  5. Physical Pentest Tools
  6. Hacker Tools 2020
  7. Computer Hacker
  8. Pentest Tools Windows
  9. Hacker Tools Free
  10. Hacking Tools For Windows Free Download
  11. Hacker Tools Apk
  12. Free Pentest Tools For Windows
  13. Hacking Tools Pc
  14. Hacker Hardware Tools
  15. Hack Tool Apk
  16. Termux Hacking Tools 2019
  17. Hack Website Online Tool
  18. Hacking App
  19. Pentest Tools Review
  20. Pentest Tools Free
  21. Ethical Hacker Tools
  22. Hacker Tools Software
  23. Pentest Tools Bluekeep
  24. Hacker Tools Apk
  25. Hacker Tools Apk Download
  26. How To Hack
  27. Pentest Automation Tools
  28. Hacking Tools Windows 10
  29. Pentest Tools Online
  30. Hackrf Tools
  31. Hacking Tools Software
  32. Hacker Tools Free
  33. Hacking Tools For Games
  34. Pentest Tools Url Fuzzer
  35. Hackers Toolbox
  36. Hacking Tools For Kali Linux
  37. Hack App
  38. Hacking Tools For Kali Linux
  39. Hacker Tools Apk
  40. Tools For Hacker
  41. Bluetooth Hacking Tools Kali
  42. Hacking Tools Windows
  43. Hack Tools Github
  44. Hack Tools For Ubuntu
  45. Wifi Hacker Tools For Windows
  46. Black Hat Hacker Tools
  47. Nsa Hack Tools Download
  48. Easy Hack Tools
  49. Hacking Tools 2019
  50. Hack Tools For Mac
  51. Hack Tools Online
  52. New Hacker Tools
  53. How To Make Hacking Tools
  54. Hacking Tools Mac
  55. What Is Hacking Tools
  56. Hack Tools Online
  57. Hacking Tools Software
  58. Pentest Tools Windows

No comments: