sábado, 27 de janeiro de 2024

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. Hacking Tools Name
  2. Hacker Tools For Windows
  3. Hacking Tools For Mac
  4. Pentest Tools Kali Linux
  5. World No 1 Hacker Software
  6. Hacker Tools For Ios
  7. Hack Tools For Pc
  8. Pentest Tools Kali Linux
  9. Hacker Techniques Tools And Incident Handling
  10. Hacking Tools For Kali Linux
  11. Pentest Tools Android
  12. Nsa Hack Tools Download
  13. Pentest Tools Nmap
  14. What Is Hacking Tools
  15. Free Pentest Tools For Windows
  16. Pentest Tools Kali Linux
  17. Hack Tools 2019
  18. Ethical Hacker Tools
  19. Hacker Security Tools
  20. New Hack Tools
  21. Hack Tools For Pc
  22. Pentest Box Tools Download
  23. What Are Hacking Tools
  24. Tools 4 Hack
  25. Hacking Tools 2020
  26. Pentest Automation Tools
  27. Hacking Apps
  28. Best Hacking Tools 2019
  29. Hacks And Tools
  30. Hacker Tools Windows
  31. New Hack Tools
  32. Free Pentest Tools For Windows
  33. Hacking App
  34. Hacker Tools 2019
  35. Pentest Automation Tools
  36. Hacker Tools For Pc
  37. Hackrf Tools
  38. Hack Tools Online
  39. Pentest Recon Tools
  40. Best Hacking Tools 2020
  41. What Is Hacking Tools
  42. Hacking Apps
  43. Hak5 Tools
  44. Hacker Tools Software
  45. Game Hacking
  46. Hacking Tools Pc
  47. Growth Hacker Tools
  48. Hack And Tools
  49. Tools For Hacker
  50. Hack App
  51. Pentest Tools Review
  52. Hacking Tools
  53. Tools 4 Hack
  54. Hack Tools Download
  55. Hacker Tools 2019
  56. Hacking Tools Pc
  57. Pentest Tools Port Scanner
  58. Game Hacking
  59. Wifi Hacker Tools For Windows
  60. Best Hacking Tools 2020
  61. Nsa Hacker Tools
  62. How To Hack
  63. Install Pentest Tools Ubuntu
  64. Hack Tools For Games
  65. Pentest Recon Tools
  66. Hack Tools
  67. How To Hack
  68. Pentest Box Tools Download
  69. Hacker Tools For Mac
  70. Easy Hack Tools
  71. Hacking Tools For Windows 7
  72. Hack Tools
  73. Hacking Tools For Kali Linux
  74. Hacker Tools For Windows
  75. Hacking Tools Github
  76. Pentest Tools Bluekeep
  77. Pentest Tools Framework
  78. Nsa Hack Tools Download
  79. Pentest Tools Port Scanner
  80. Hacking Tools 2019
  81. Nsa Hacker Tools
  82. Hack Tools
  83. Hack Tools Pc
  84. Pentest Tools Online
  85. Pentest Tools Framework
  86. Hacking Tools For Beginners
  87. Pentest Reporting Tools
  88. Tools For Hacker
  89. Pentest Tools For Ubuntu
  90. Pentest Tools Framework
  91. Hacking Tools 2020
  92. Best Pentesting Tools 2018
  93. Hack Tools
  94. How To Install Pentest Tools In Ubuntu
  95. Best Pentesting Tools 2018
  96. Pentest Tools Kali Linux
  97. Pentest Tools Url Fuzzer

Nenhum comentário:

Postar um comentário