quinta-feira, 20 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. New Hack Tools
  2. Hacker Search Tools
  3. Hacker Tools Free
  4. Hack And Tools
  5. Hacking Tools And Software
  6. Hacker Tools For Windows
  7. Hack Tools For Ubuntu
  8. Hacking Tools For Beginners
  9. Hack Tools For Mac
  10. Hacker Tools
  11. Hacking Tools For Mac
  12. Pentest Tools Online
  13. Hack Tools Github
  14. Hacking Tools For Beginners
  15. Blackhat Hacker Tools
  16. Hack Tools Download
  17. Hacking Tools Software
  18. Hacker Techniques Tools And Incident Handling
  19. Hacking Tools Usb
  20. Pentest Tools For Mac
  21. Android Hack Tools Github
  22. Best Pentesting Tools 2018
  23. Hacker Security Tools
  24. Hack Tools
  25. Hack Tools For Pc
  26. Pentest Tools Linux
  27. Pentest Tools Kali Linux
  28. Pentest Tools Bluekeep
  29. Hacking Tools For Windows 7
  30. Hacker Tools For Mac
  31. Hacker Tool Kit
  32. Hacking Tools For Windows Free Download
  33. Hacker Tools For Ios
  34. Hacking Tools For Windows
  35. Pentest Tools Website
  36. Hacker Tools
  37. Hacker Tools
  38. Pentest Tools For Ubuntu
  39. Hacker Tools For Windows
  40. Pentest Tools Framework
  41. Hacker Tools For Mac
  42. Hack Tools Mac
  43. Hacking Tools For Kali Linux
  44. Hacker Tools For Mac
  45. Pentest Tools Review
  46. Hacking Tools For Games
  47. Hacking Tools Software
  48. Pentest Reporting Tools
  49. Computer Hacker
  50. Pentest Tools Free
  51. Hack Tools
  52. Hacking Tools For Beginners
  53. Physical Pentest Tools
  54. Hack Tools 2019
  55. Hack Tools
  56. Pentest Reporting Tools
  57. Tools 4 Hack
  58. How To Install Pentest Tools In Ubuntu
  59. Hacking Tools Github
  60. Hacker Tools Apk Download
  61. Hacker Tools Online
  62. Pentest Tools Website Vulnerability
  63. Blackhat Hacker Tools
  64. How To Make Hacking Tools
  65. Hacker Tools Hardware
  66. Hacking Tools Software
  67. Hack Tools For Mac
  68. Pentest Recon Tools
  69. Beginner Hacker Tools
  70. Hacking Tools 2019
  71. What Are Hacking Tools
  72. Hacker Search Tools
  73. Game Hacking
  74. Install Pentest Tools Ubuntu
  75. Physical Pentest Tools
  76. Hack And Tools
  77. Pentest Tools For Android
  78. Hack Tools
  79. Hackers Toolbox
  80. Tools For Hacker
  81. Hacker Tools Apk
  82. Pentest Tools Url Fuzzer
  83. Hacker Tools 2019
  84. Hacking Tools And Software
  85. Hack App
  86. Hacks And Tools
  87. Hack Tools For Pc
  88. Hack Tools
  89. Pentest Tools Bluekeep
  90. Hacking Tools Free Download
  91. World No 1 Hacker Software
  92. Pentest Tools Kali Linux
  93. Hacking Tools Software
  94. Pentest Tools Windows
  95. Hacker
  96. Hacking Tools Windows 10
  97. Pentest Tools For Android
  98. Hack Rom Tools
  99. Hacking Tools For Windows
  100. Hack And Tools
  101. Hacking Tools Download
  102. Underground Hacker Sites
  103. Pentest Automation Tools
  104. Hack Website Online Tool
  105. Physical Pentest Tools
  106. Hack Tools For Mac
  107. Pentest Tools Nmap

Nenhum comentário: