sábado, 22 de agosto de 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 articles
  1. Hacking Tools Github
  2. Hacking Tools Github
  3. Blackhat Hacker Tools
  4. Pentest Tools Alternative
  5. Hack Tools
  6. Hacking Tools For Windows 7
  7. How To Install Pentest Tools In Ubuntu
  8. Hacking Tools Mac
  9. Pentest Box Tools Download
  10. Hacker Tools Mac
  11. Hack Tools For Games
  12. Hacking Tools For Mac
  13. Hack Tools Online
  14. Hack Tools Download
  15. What Are Hacking Tools
  16. Computer Hacker
  17. Hacker Tools Software
  18. Pentest Tools For Ubuntu
  19. Hack Tools 2019
  20. Pentest Tools List
  21. Pentest Tools Tcp Port Scanner
  22. Hacker Tools Mac
  23. Hacking Tools Name
  24. Termux Hacking Tools 2019
  25. Blackhat Hacker Tools
  26. Pentest Tools Url Fuzzer
  27. Tools Used For Hacking
  28. Black Hat Hacker Tools
  29. Hacking Tools Pc
  30. Hack Tools Pc
  31. Pentest Tools List
  32. Hack Tools Download
  33. Pentest Tools Free
  34. Pentest Tools For Windows
  35. Pentest Tools
  36. Hacker Tools 2020
  37. Hacker Tool Kit
  38. Pentest Tools Windows
  39. Hak5 Tools
  40. Pentest Tools Url Fuzzer
  41. Blackhat Hacker Tools
  42. Hacks And Tools
  43. Hacker Tools Linux
  44. Top Pentest Tools
  45. Hacker Tools 2020
  46. Pentest Tools Framework
  47. Hack Tool Apk
  48. How To Install Pentest Tools In Ubuntu
  49. Hacking Tools For Kali Linux
  50. Pentest Tools Windows
  51. Hacking Tools And Software
  52. Hacking Tools
  53. Hacker Tools Free
  54. New Hacker Tools
  55. Hacking Tools For Windows Free Download
  56. Pentest Recon Tools
  57. Hacker Security Tools
  58. Hacker Tools For Windows
  59. Hack Tools For Games
  60. New Hack Tools
  61. Pentest Recon Tools
  62. Hacker Search Tools
  63. Kik Hack Tools
  64. Hacking Tools For Kali Linux
  65. Hacking Tools Online
  66. Usb Pentest Tools
  67. Pentest Tools Review
  68. Pentest Tools List
  69. Hacker
  70. Pentest Tools Website Vulnerability
  71. Pentest Tools Website Vulnerability
  72. Pentest Tools Github
  73. Hack Rom Tools
  74. Hacking Tools Online
  75. Hacker Tools 2020
  76. Hacking App
  77. What Is Hacking Tools
  78. Hack Tools For Games
  79. Top Pentest Tools
  80. Hack Tools For Mac
  81. Pentest Tools
  82. Hack Tools For Pc
  83. Pentest Automation Tools
  84. Pentest Automation Tools
  85. Hacker Tools For Pc
  86. Hacker Tools For Ios
  87. Hack Website Online Tool
  88. Hack Tools
  89. Hacker Tools Free

No hay comentarios:

Publicar un comentario