Pesquisar este blog

domingo, 30 de agosto de 2020

Exploiting Golang Unsafe Pointers


There are situations when c interacts with golang for example in a library, and its possible to exploit a golang function writing raw memory using an unsafe.Pointer() parameter.

When golang receive a null terminated string on a *C.Char parameter, can be converted to golang s tring with  s2 := C.GoString(s1) we can do string operations with s2 safelly if the null byte is there.

When golang receives a pointer to a buffer on an unsafe.Pointer() and the length of the buffer on a C.int, if the length is not cheated can be converted to a []byte safelly with b := C.GoBytes(buf,sz)

Buuut what happens if golang receives a pointer to a buffer on an unsafe.Pointer() and is an OUT variable? the golang routine has to write on this pointer unsafelly for example we can create a golangs memcpy in the following way:



We convert to uintptr for indexing the pointer and then convert again to pointer casted to a byte pointer dereferenced and every byte is writed in this way.

If b is controlled, the memory can be written and the return pointer of main.main or whatever function can be modified.

https://play.golang.org/p/HppcVpLfuMf


The return addres can be pinpointed, for example 0x41 buffer 0x42 address:



We can reproduce it simulating the buffer from golang in this way:


we can dump the address of a function and redirect the execution to it:


https://play.golang.org/p/7htJHJp8gUJ

In this way it's possible to build a rop chain using golang runtime to unprotect a shellcode.

Related posts


  1. Hacking Tools Download
  2. Easy Hack Tools
  3. Pentest Tools For Mac
  4. Hack Tools Mac
  5. Hack Rom Tools
  6. Hacker Tools For Windows
  7. Underground Hacker Sites
  8. Hacking Tools For Kali Linux
  9. Pentest Tools Bluekeep
  10. Hacker Tools Free
  11. Hacking App
  12. Hacking Tools For Games
  13. Hacking Tools Windows 10
  14. Tools For Hacker
  15. Pentest Tools Subdomain
  16. Hack Tool Apk
  17. Growth Hacker Tools
  18. Pentest Tools Port Scanner
  19. Install Pentest Tools Ubuntu
  20. Best Pentesting Tools 2018
  21. Hacking Tools For Kali Linux
  22. Pentest Tools Github
  23. Pentest Tools Url Fuzzer
  24. Hacking Tools
  25. Hack And Tools
  26. Hacker
  27. Game Hacking
  28. Hacker Tools Windows
  29. Hackers Toolbox
  30. Game Hacking
  31. Game Hacking
  32. Hacking Tools Download
  33. Hacking Tools Name
  34. Hacker Search Tools
  35. Hack Apps
  36. Hacking Tools 2019
  37. Hacker Tools Linux
  38. New Hack Tools
  39. Hack Tools
  40. Hacker Tools For Ios
  41. Pentest Tools Port Scanner
  42. Hacking Tools For Mac
  43. Hacking Tools Pc
  44. Hack And Tools
  45. Hacking Tools Name
  46. Hack App
  47. Best Hacking Tools 2019
  48. Hacker Tools Software
  49. Hacking Tools For Windows Free Download
  50. Hack Tools
  51. Hacker Tools Software
  52. Hacking Tools For Kali Linux
  53. Hacker Tools For Windows
  54. Growth Hacker Tools
  55. Hacker Tools Windows
  56. Hacker Tools Apk Download
  57. Hack Tools Github
  58. Nsa Hacker Tools
  59. Hacking Tools
  60. Hack Website Online Tool
  61. Hacker Hardware Tools
  62. Pentest Tools Github
  63. Pentest Tools Url Fuzzer
  64. Hack Tool Apk
  65. Hacker Hardware Tools
  66. Hack Tools For Games
  67. Free Pentest Tools For Windows
  68. Hacker Tools
  69. Hack Tools For Windows
  70. Pentest Reporting Tools
  71. Hack Tools Pc
  72. Pentest Tools For Mac
  73. Blackhat Hacker Tools
  74. Pentest Reporting Tools
  75. Hacking Tools Software
  76. Pentest Tools Alternative
  77. Hack Rom Tools
  78. Hacker Security Tools
  79. Hack Apps
  80. Hack Tools For Windows
  81. Pentest Tools List
  82. How To Make Hacking Tools
  83. Pentest Tools Bluekeep
  84. Pentest Tools Website Vulnerability
  85. Hack Tools For Games
  86. Pentest Tools Online
  87. Hacker Tools Hardware
  88. Hacks And Tools
  89. Hacking Tools Mac
  90. Pentest Tools Subdomain
  91. Hack Tool Apk No Root
  92. Pentest Tools For Windows
  93. Hack Tools Online
  94. Pentest Tools Bluekeep
  95. Hack Tool Apk No Root
  96. Hacking Tools For Beginners
  97. Hacking Tools For Windows Free Download
  98. Nsa Hack Tools
  99. Hack Tools For Ubuntu
  100. Hack Tools For Windows
  101. Hacking Tools Mac
  102. Nsa Hack Tools
  103. Hack Apps
  104. Pentest Tools Nmap
  105. Hack Rom Tools
  106. Pentest Tools Alternative
  107. Hacker Tools Mac
  108. Pentest Tools Download
  109. Hack Tools Pc
  110. Hack App
  111. Hacker Tool Kit

Nenhum comentário: