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.
Read more
- Install Pentest Tools Ubuntu
- Hack Tools Download
- Physical Pentest Tools
- Physical Pentest Tools
- Pentest Tools Android
- Hacker Tools Linux
- How To Make Hacking Tools
- Hack Tools Github
- Hacker Tools Free Download
- Pentest Tools Alternative
- Hacking Tools Name
- Hack Tools Mac
- Hacking Tools Hardware
- Hacker Security Tools
- Hack Tool Apk No Root
- Hacker Tools Software
- Best Hacking Tools 2020
- Pentest Tools Tcp Port Scanner
- New Hacker Tools
- Hacker Security Tools
- Pentest Tools Online
- Hacking Tools For Pc
- Pentest Tools Url Fuzzer
- Pentest Tools Website Vulnerability
- Pentest Reporting Tools
- Hack Tools For Pc
- What Are Hacking Tools
- Game Hacking
- Pentest Tools Free
- Hacker Tools Windows
- Nsa Hack Tools Download
- Hack Tools
- Black Hat Hacker Tools
- Hacking Tools Free Download
- Hack Tools For Games
- Hacking Tools For Windows Free Download
- Pentest Tools Tcp Port Scanner
- Hack Tools 2019
- Hackers Toolbox
- Nsa Hack Tools Download
- Hacking Tools Windows 10
- Underground Hacker Sites
- Hacker Hardware Tools
- Pentest Tools Find Subdomains
- Hacker Tools Windows
- Hacker Tools For Ios
- Bluetooth Hacking Tools Kali
- Hacker Tools For Pc
- Hacking Tools 2020
- Hacking Tools 2020
- Github Hacking Tools
- How To Install Pentest Tools In Ubuntu
- Hacking Apps
- Hacks And Tools
- Hacking Tools For Windows
- World No 1 Hacker Software
- Hacker Tools Linux
- Hacks And Tools
- Pentest Tools Url Fuzzer
- Github Hacking Tools
- Hacker Tools 2020
- Nsa Hacker Tools
- Install Pentest Tools Ubuntu
- Hack Tool Apk
- Pentest Tools
- Pentest Tools Github
- Github Hacking Tools
- Hacking Tools For Windows
- Hacking Tools For Kali Linux
- Hacking Tools Github
- Game Hacking
- Pentest Tools Tcp Port Scanner
- Hacking Tools Download
- Pentest Tools Android
- Tools Used For Hacking
- Pentest Tools Online
- Hack Apps
- Hacking App
- Hacking Tools 2020
- Black Hat Hacker Tools
- Hacking Apps
- Pentest Tools Framework
- Tools Used For Hacking
- Hacker Tools
- Hacking App
- Best Hacking Tools 2020
- Pentest Tools Subdomain