sábado, 22 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.

Related news


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

0 comentários:

Postar um comentário