Friday, August 28, 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. Hack Tools For Games
  2. Beginner Hacker Tools
  3. Hacker Security Tools
  4. Hacking Tools Pc
  5. Hacker Security Tools
  6. Hack Tools For Ubuntu
  7. Pentest Tools Bluekeep
  8. Hacker Hardware Tools
  9. Hack Tools 2019
  10. Hacker Tools For Ios
  11. Hacker Tools Free Download
  12. Hacking Tools
  13. Pentest Tools Framework
  14. Hacking Tools For Games
  15. Pentest Tools Subdomain
  16. Hacker Tools Apk
  17. Hack Tools For Mac
  18. Tools Used For Hacking
  19. Pentest Tools Apk
  20. Best Hacking Tools 2020
  21. Hack Tools Download
  22. Pentest Tools Open Source
  23. Pentest Tools Apk
  24. Pentest Tools For Ubuntu
  25. Hacker Security Tools
  26. Hack Apps
  27. Hacker Tools For Mac
  28. Pentest Tools Find Subdomains
  29. Pentest Tools Url Fuzzer
  30. Blackhat Hacker Tools
  31. Hacker Tools 2020
  32. Hack Tools For Games
  33. Beginner Hacker Tools
  34. Android Hack Tools Github
  35. Pentest Tools Android
  36. Pentest Tools Website
  37. Hacking Tools Free Download
  38. Tools 4 Hack
  39. Hacking Tools Kit
  40. Hack Tools Pc
  41. Hack Tools For Ubuntu
  42. Hacking Tools For Windows
  43. Pentest Tools Online
  44. Black Hat Hacker Tools
  45. Hack Tools
  46. Hacking Tools Free Download
  47. Hacker Tools Apk Download
  48. Hacker Security Tools
  49. Pentest Tools Tcp Port Scanner
  50. Hacker
  51. Hacking Tools Github
  52. Hacker
  53. Hacking Tools And Software
  54. Hacking App
  55. Hacking Tools For Pc
  56. Hacking Apps
  57. New Hack Tools
  58. Hacker Tools Mac
  59. Hacking Apps
  60. Nsa Hack Tools
  61. Hacker Search Tools
  62. Best Pentesting Tools 2018
  63. Pentest Tools Nmap
  64. Free Pentest Tools For Windows
  65. Hack Tool Apk No Root
  66. Pentest Tools Review
  67. Hacking Tools Mac
  68. Top Pentest Tools
  69. Hacking Tools For Windows Free Download
  70. Pentest Tools
  71. Pentest Tools Url Fuzzer
  72. Hacker Tools Free
  73. Hacks And Tools
  74. Hack Tools
  75. Game Hacking
  76. Hack Tools Online
  77. How To Hack
  78. Hacking Tools Kit
  79. Pentest Tools Apk
  80. Hacker Techniques Tools And Incident Handling
  81. Top Pentest Tools
  82. Hacking Tools Windows
  83. Hacker Tools Windows

No comments:

Post a Comment