Jumat, 28 Agustus 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 word


  1. Hacking Tools Download
  2. Physical Pentest Tools
  3. Pentest Tools Find Subdomains
  4. Hacking Tools Hardware
  5. Hacker Tool Kit
  6. Hack Rom Tools
  7. Hacking Tools For Beginners
  8. Pentest Tools Port Scanner
  9. Pentest Tools Kali Linux
  10. Github Hacking Tools
  11. Pentest Tools Linux
  12. Hacker Tools 2019
  13. Pentest Tools Download
  14. Kik Hack Tools
  15. Kik Hack Tools
  16. Hacking Tools Hardware
  17. Nsa Hack Tools
  18. Hacker Tool Kit
  19. Install Pentest Tools Ubuntu
  20. Hacker Tool Kit
  21. Hacker Tools Software
  22. Hacking Tools Free Download
  23. Pentest Tools Online
  24. Pentest Tools Find Subdomains
  25. Pentest Tools Github
  26. Growth Hacker Tools
  27. Hacker Tools Online
  28. Pentest Tools For Android
  29. Growth Hacker Tools
  30. Pentest Tools Nmap
  31. Hacking Tools Windows
  32. Hacking App
  33. Wifi Hacker Tools For Windows
  34. Hacking Tools Free Download
  35. Hacking Tools And Software
  36. Hacker Tools Mac
  37. Pentest Tools Subdomain
  38. Ethical Hacker Tools
  39. Nsa Hacker Tools
  40. Github Hacking Tools
  41. Hacking Tools Windows
  42. Hacking Tools For Pc
  43. Pentest Tools Open Source
  44. Hacking Tools For Beginners
  45. Hack Tools For Games
  46. Blackhat Hacker Tools
  47. Pentest Tools Apk
  48. Game Hacking
  49. Pentest Tools Review
  50. Hacker Tools For Ios
  51. Pentest Tools Online
  52. Install Pentest Tools Ubuntu
  53. Ethical Hacker Tools
  54. Best Hacking Tools 2019
  55. Hacking Tools
  56. Tools Used For Hacking
  57. Hack Tools Online
  58. Pentest Tools List
  59. Hack Tools For Mac
  60. Hacker Tools Free Download
  61. Hacker Tools 2020
  62. Top Pentest Tools
  63. Hack Tools For Pc
  64. Hacker Tools List
  65. Best Pentesting Tools 2018
  66. Pentest Tools For Android
  67. New Hacker Tools
  68. How To Hack
  69. Hacking Tools Windows 10
  70. Black Hat Hacker Tools
  71. Hacking Tools For Pc
  72. Hack Tools Github
  73. Pentest Reporting Tools
  74. Hack Rom Tools
  75. Android Hack Tools Github
  76. Kik Hack Tools
  77. Pentest Tools Port Scanner
  78. Hacking Tools Free Download
  79. Hacking Tools For Beginners
  80. Hacking Tools Windows
  81. Hacking Tools
  82. Hacking Tools Online
  83. Hacker Tools Linux
  84. Pentest Tools Linux
  85. Best Hacking Tools 2019
  86. Hacking Apps
  87. Hacker Tools Mac
  88. Blackhat Hacker Tools
  89. Hacker Tools For Pc
  90. Hacking Tools Windows
  91. Hacking Tools Windows 10
  92. Best Hacking Tools 2019
  93. Hacking Tools Hardware
  94. Hacking Tools For Mac
  95. Hack Tools For Ubuntu
  96. Pentest Tools Download
  97. Hack Rom Tools
  98. Hacker Tools Github
  99. Hacking Tools Mac
  100. Hack Tools Github
  101. Hacking Tools 2019

Tidak ada komentar:

Posting Komentar