π
π
π
π
Intruder
Twitter
Searchβ¦
About Shantanu Khandelwal
Reporting
Excel Sheet to Word Report by PowerShell
Ghostwriter - Add report type
Red Team
HTTPS C2 Done Right NGINX
Domain Front
GoLang
Red Team: How to embed Golang tools in C#
Red Team: Using SharpChisel to exfil internal network
Converting your GO bins to Shellcode and Using them in C#
ShellCode Injection
PowerShell
Database
Dealing with the Errors
Setting Up OPENVAS in KALI 2020.3
Phishing
Connecting GoPhish with Office365
SharpLoginPrompt - Success and a Curious Case
Gophish MODs
Long Live DMARC - Email Spoof issues
Talks I Like
Talks Worth Checking Out
Powered By
GitBook
Converting your GO bins to Shellcode and Using them in C#
How to convert binaries compiled in golang to shellcode
With release of Go1.15 a new "buildmode" flag has been released.
-buildmode=pie
Lets do a simple demo of converting a go binary to shellcode and injecting it to other processes
Building Go Binary
I am going to build a simple golang program which launches calc
calc.go
1
package
main
2
β
3
import
(
4
"fmt"
5
"os/exec"
6
)
7
β
8
func
main
(){
9
c
:=
exec
.
Command
(
"calc.exe"
)
10
β
11
if
err
:=
c
.
Run
();
err
!=
nil
{
12
fmt
.
Println
(
"Error: "
,
err
)
13
}
14
}
Copied!
Now lets build the program. I am using Windows 10 amd64 machine. You may need to specify other parameters if you are cross compiling
1
go build -buildmode
=
pie -o calc.exe calc.go
Copied!
The command will generate a static binary
calc.exe.
Converting Binary to Shellcode
Here we will use TheWover's
Donut
to convert the calc.exe to shellcode. The command is quite simple
1
donut.exe calc.exe -o calc.bin
Copied!
Using DonutTest
β
DonutTest
is a subproject of Donut repo. DonutTest provides a test harness to test your generated Shellcode.
To use our calc.bin inside donut test we need to convert it into base64
1
[Convert]::ToBase64String([IO.File]::ReadAllBytes("./calc.bin")) | clip
Copied!
Now paste the shellcode in DonutTest and compile. Your program should run as expected and you should see a calc pop
1
DonutTest.exe <pid>
Copied!
Credits:
β
https://twitter.com/rkervell
β
Previous
Red Team: Using SharpChisel to exfil internal network
Next - Red Team
ShellCode Injection
Last modified
1yr ago
Copy link
Contents
Building Go Binary
Converting Binary to Shellcode
Using DonutTest
Credits: