2023年6月5日月曜日

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.

More info
  1. New Hack Tools
  2. Pentest Tools Website
  3. Pentest Tools Github
  4. Hack Apps
  5. Tools Used For Hacking
  6. New Hack Tools
  7. Tools 4 Hack
  8. Hacking Tools Online
  9. Hacker Tools
  10. Hacking Tools Github
  11. Hack Tools Mac
  12. Pentest Tools For Ubuntu
  13. Pentest Tools Windows
  14. Hack Tools Download
  15. Top Pentest Tools
  16. Hack Tools For Pc
  17. Hacking Tools For Mac
  18. What Is Hacking Tools
  19. Hacker Hardware Tools
  20. Beginner Hacker Tools
  21. Hacker Hardware Tools
  22. Pentest Tools Find Subdomains
  23. Hack Tools
  24. Hackers Toolbox
  25. Hacker Tool Kit
  26. Github Hacking Tools
  27. Hacker Hardware Tools
  28. Hacking Tools For Windows Free Download
  29. Hacking Tools For Pc
  30. Hack Tools Mac
  31. Hacking Tools Download
  32. Hacking Tools Free Download
  33. Hacker Tools Apk Download
  34. How To Make Hacking Tools
  35. Hacking Tools For Beginners
  36. Hacking Tools For Games
  37. Hacker Tools Windows
  38. Ethical Hacker Tools
  39. Kik Hack Tools
  40. Best Hacking Tools 2020
  41. Pentest Tools Find Subdomains
  42. Hack Tool Apk
  43. Pentest Tools Apk
  44. Pentest Tools Android
  45. Hacking Tools And Software
  46. Hacker Tools Apk
  47. Hacking Tools Github
  48. Hacker Tools
  49. Pentest Tools Open Source
  50. Hacking Tools For Windows 7
  51. Black Hat Hacker Tools
  52. Free Pentest Tools For Windows
  53. Pentest Tools Apk
  54. Hacking Tools For Kali Linux
  55. Beginner Hacker Tools
  56. Hacker Tools For Ios
  57. How To Make Hacking Tools
  58. Hacking Tools 2019
  59. Hack Website Online Tool
  60. Android Hack Tools Github
  61. What Are Hacking Tools
  62. Hacker Tools Mac
  63. Hacker Tools For Mac
  64. Hacking Tools 2019
  65. Hacker Tools 2019
  66. Usb Pentest Tools
  67. Hacker Tools For Pc
  68. Pentest Tools Apk
  69. Hacker Techniques Tools And Incident Handling
  70. Best Hacking Tools 2019
  71. Hacking Tools Pc
  72. Pentest Tools Subdomain
  73. Beginner Hacker Tools
  74. Top Pentest Tools
  75. Hack Tools 2019
  76. Hack Tools
  77. Hack Tool Apk
  78. Hacking Tools Hardware
  79. Hacker Tools Online
  80. Hacker Tools Free
  81. Hacking Tools Mac
  82. Top Pentest Tools
  83. Pentest Automation Tools
  84. Hacker Tools For Ios
  85. Wifi Hacker Tools For Windows
  86. Pentest Box Tools Download
  87. Pentest Tools
  88. Best Hacking Tools 2020
  89. How To Make Hacking Tools
  90. Hacker Hardware Tools
  91. Pentest Tools Linux
  92. Pentest Automation Tools
  93. Hacker Tools Apk Download
  94. Hack Apps
  95. Hacking Tools For Beginners
  96. Pentest Tools Apk
  97. Pentest Tools Url Fuzzer
  98. Hack Tools For Windows
  99. Pentest Tools Port Scanner
  100. Hacker Tools Hardware
  101. Hacker Tool Kit
  102. Hacker Tools Online
  103. Hack Tools Github
  104. Hacking Tools Usb
  105. Best Hacking Tools 2020
  106. Hacker Tools Online
  107. Beginner Hacker Tools
  108. Hacker Techniques Tools And Incident Handling
  109. Pentest Tools For Ubuntu
  110. Best Pentesting Tools 2018
  111. Hacker Tools Free
  112. Pentest Tools Kali Linux
  113. Pentest Tools Alternative
  114. Pentest Tools Alternative
  115. Hacker Search Tools
  116. Hack Tools Online
  117. Hack And Tools
  118. Pentest Tools Url Fuzzer
  119. Hack Tools For Pc
  120. Hacker Search Tools
  121. Usb Pentest Tools
  122. Growth Hacker Tools
  123. Hacker Tools 2019
  124. Hack Tool Apk
  125. Game Hacking
  126. Hacker Tools Apk Download
  127. Pentest Tools Subdomain
  128. Computer Hacker
  129. Hacking Tools
  130. What Is Hacking Tools
  131. Hacking Tools For Games
  132. Termux Hacking Tools 2019
  133. Hack App
  134. Hak5 Tools
  135. Hacking Tools Download
  136. Hacker Tools Online
  137. Pentest Tools Alternative
  138. Hackers Toolbox
  139. Pentest Tools For Mac
  140. Tools For Hacker
  141. Hacking Tools And Software
  142. Hack App
  143. Hacking Tools Kit
  144. Hacker Tools Software
  145. Hacker Tools Free
  146. Pentest Tools Apk
  147. Hack Tools
  148. New Hack Tools
  149. What Is Hacking Tools
  150. Hack Tools For Pc
  151. Hack And Tools
  152. Kik Hack Tools
  153. Hacking Tools Pc
  154. Pentest Box Tools Download
  155. Wifi Hacker Tools For Windows
  156. What Is Hacking Tools
  157. Github Hacking Tools
  158. Hacking Tools Hardware
  159. Pentest Reporting Tools
  160. Pentest Automation Tools
  161. Hack Tools Mac
  162. Pentest Tools Windows
  163. Hacker Tools List
  164. Pentest Tools Url Fuzzer
  165. Hack App
  166. Hack Tools
  167. Hacker Tools Hardware
  168. Hacker Tools Apk Download
  169. Hacking Tools Free Download
  170. Hacker Tools Free Download
  171. Pentest Tools Framework
  172. Hacker Tools Github
  173. Pentest Automation Tools
  174. Beginner Hacker Tools
  175. Hacking Tools Download

0 件のコメント: