Saturday, June 3, 2023

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

No comments:

Post a Comment