quinta-feira, 20 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.

More info


  1. Hacking App
  2. Hackrf Tools
  3. Hacker Tools Mac
  4. Android Hack Tools Github
  5. Hacking Tools For Games
  6. Best Pentesting Tools 2018
  7. Hack Tool Apk
  8. Pentest Tools Github
  9. Hacker Tools For Pc
  10. Pentest Tools Nmap
  11. Pentest Tools Download
  12. Pentest Tools Nmap
  13. Hack Tools For Windows
  14. Hacker Tools Windows
  15. Hack And Tools
  16. Hackrf Tools
  17. Nsa Hack Tools
  18. Hacking Tools Hardware
  19. Hak5 Tools
  20. Hacker Security Tools
  21. Hacking Tools Download
  22. Hacking Tools And Software
  23. World No 1 Hacker Software
  24. How To Hack
  25. How To Hack
  26. Hacker Tools For Windows
  27. Hacking Tools Github
  28. Hacker Tools Windows
  29. Hacking Tools For Kali Linux
  30. Kik Hack Tools
  31. Hack Tools Github
  32. Wifi Hacker Tools For Windows
  33. Hacker Tools For Windows
  34. Pentest Tools Online
  35. Hacking Tools 2020
  36. Hacking Tools 2019
  37. Hacking Tools Usb
  38. Hackers Toolbox
  39. Hack Tools For Windows
  40. How To Install Pentest Tools In Ubuntu
  41. Hacking Tools Windows
  42. Hacking Tools For Windows
  43. Tools Used For Hacking
  44. Pentest Tools Open Source
  45. Hacking Tools Hardware
  46. Hacking App
  47. Hack Tools Mac
  48. Tools For Hacker
  49. Hacker Tools For Pc
  50. Hacker Tools Free
  51. Bluetooth Hacking Tools Kali
  52. Pentest Tools Review
  53. Pentest Tools Github
  54. Hacker Tools For Pc
  55. Hacker Tools Free
  56. Hacking Tools For Windows 7
  57. Hackrf Tools
  58. Hacker Tools Free Download
  59. Pentest Tools Android
  60. Hack Tools Online
  61. Kik Hack Tools
  62. Hacking Tools Usb
  63. Best Hacking Tools 2020
  64. Hacker Tools Hardware
  65. Ethical Hacker Tools
  66. Nsa Hack Tools
  67. Hack App
  68. Hacking Tools For Kali Linux
  69. Nsa Hack Tools Download
  70. Game Hacking
  71. Hacker Tools Online
  72. Hack Tools Online
  73. Tools Used For Hacking
  74. Pentest Tools Alternative
  75. Hacker Tools Free
  76. Hacker Tools Github
  77. Hacking App
  78. Hacking Tools For Windows 7
  79. Termux Hacking Tools 2019
  80. Nsa Hack Tools Download
  81. Nsa Hack Tools Download
  82. Hacker Tools List
  83. Hackrf Tools
  84. Android Hack Tools Github
  85. What Are Hacking Tools
  86. Pentest Tools For Android
  87. Underground Hacker Sites
  88. Pentest Tools For Ubuntu
  89. Hack Tools For Games
  90. Hacking Apps
  91. Hackrf Tools
  92. Best Hacking Tools 2020
  93. Hacking Tools For Mac
  94. Hacker
  95. Nsa Hacker Tools
  96. Hack Tool Apk No Root
  97. Beginner Hacker Tools
  98. Hacker Tools Mac
  99. Hacking Tools Software
  100. Hacking Tools For Games
  101. Tools 4 Hack
  102. Black Hat Hacker Tools
  103. Pentest Tools Website
  104. Pentest Tools Find Subdomains
  105. Hacker Tools Apk
  106. Hacker Tools Free Download
  107. Pentest Tools Android
  108. Hacker Tools Free Download
  109. Hackers Toolbox
  110. Hacking Tools And Software
  111. Pentest Tools Free
  112. Computer Hacker
  113. Hacking Tools Windows
  114. Pentest Tools For Mac
  115. Bluetooth Hacking Tools Kali
  116. Pentest Tools Free
  117. Blackhat Hacker Tools
  118. Pentest Tools Kali Linux
  119. Hacking Tools Mac
  120. Top Pentest Tools
  121. Hacking Tools For Beginners
  122. Computer Hacker
  123. Hacker Tools For Pc
  124. Hacker Tools Free
  125. Pentest Tools Apk
  126. Pentest Tools Android
  127. Android Hack Tools Github
  128. Hackrf Tools
  129. Hack Tools For Windows

Nenhum comentário: