sábado, 20 de enero de 2024

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 information

  1. Hacking Tools 2019
  2. Underground Hacker Sites
  3. Tools For Hacker
  4. Hacker Tools Mac
  5. Physical Pentest Tools
  6. Hacking Tools Free Download
  7. Hacker Tools Hardware
  8. Hacker Security Tools
  9. Tools For Hacker
  10. Wifi Hacker Tools For Windows
  11. Hacking Tools Github
  12. Pentest Tools Alternative
  13. Hacking Tools For Pc
  14. Black Hat Hacker Tools
  15. Hak5 Tools
  16. World No 1 Hacker Software
  17. Hack Tools 2019
  18. Hack Tools Github
  19. Usb Pentest Tools
  20. Pentest Tools Open Source
  21. Pentest Tools Review
  22. Hacking Tools For Kali Linux
  23. Pentest Tools Subdomain
  24. Hacking Tools 2020
  25. Pentest Tools Website
  26. What Is Hacking Tools
  27. Hack Tools
  28. Hacking Tools Name
  29. Hacking Tools For Mac
  30. Hack Website Online Tool
  31. Nsa Hack Tools
  32. Hacking Tools Usb
  33. Hackrf Tools
  34. Pentest Tools For Mac
  35. How To Make Hacking Tools
  36. Hacking Tools For Kali Linux
  37. Hacker Tools
  38. Hacking Tools 2019
  39. Hack And Tools
  40. Ethical Hacker Tools
  41. Hacking Tools Github
  42. Hacking Tools Kit
  43. Hacking Tools For Windows 7
  44. Growth Hacker Tools
  45. Hacker Tools For Mac
  46. Blackhat Hacker Tools
  47. Pentest Tools Download
  48. Hacker Tools For Windows
  49. Pentest Tools Website
  50. Pentest Tools For Ubuntu
  51. Termux Hacking Tools 2019
  52. Hacker Tool Kit
  53. Hacking Tools For Pc
  54. Hack Tools For Windows
  55. Easy Hack Tools
  56. Hacks And Tools
  57. Hacking Tools For Games
  58. Hacking Tools For Kali Linux
  59. Hack Tools
  60. Pentest Tools Free
  61. Pentest Tools Online
  62. Tools Used For Hacking
  63. Hacker Tools 2019
  64. Pentest Tools For Ubuntu
  65. Hak5 Tools
  66. Hak5 Tools
  67. Android Hack Tools Github
  68. Underground Hacker Sites
  69. Hacking Apps
  70. Pentest Tools For Mac
  71. Pentest Tools Linux
  72. Pentest Tools Bluekeep
  73. Pentest Tools For Windows
  74. Black Hat Hacker Tools
  75. Pentest Automation Tools
  76. Hacking Tools Download
  77. Pentest Tools Website Vulnerability
  78. Pentest Tools Url Fuzzer
  79. Hacking Tools Kit
  80. Wifi Hacker Tools For Windows
  81. What Are Hacking Tools
  82. Hacker Tools For Mac
  83. Hacking Tools Hardware
  84. Hacking Tools Name
  85. Hacking Tools Hardware
  86. Underground Hacker Sites
  87. Hack Tools For Games
  88. Hacking Tools Pc
  89. Pentest Tools Nmap
  90. Hack Tools Download
  91. Pentest Box Tools Download
  92. Growth Hacker Tools
  93. Hack Apps
  94. New Hacker Tools
  95. Hacking Tools Pc
  96. What Are Hacking Tools
  97. Beginner Hacker Tools
  98. Hacking Tools Kit
  99. Pentest Tools For Windows
  100. Pentest Tools For Windows
  101. Hacker Tools Free Download
  102. Pentest Recon Tools
  103. Pentest Tools Online
  104. Pentest Tools Framework
  105. Hack Tools
  106. Hacker Hardware Tools
  107. Pentest Tools Apk
  108. Hacking Tools For Windows 7
  109. Hack Tools For Games
  110. Hacking Tools Kit

No hay comentarios: