Ben Kurtz: Writing Golang Malware
In this talk, Ben Kurtz highlights why Golang based malware is on the rise and why the language itself is so useful for this specific purpose. We are given a wonderful introduction into the world of Golang malware. According to Ben, Golang is magical due to its extensiveness/completeness, versatility, unparalleled third party library support, and the cross-compiler. In his opinion Golang is the fastest way to get things done.
Golang (or GO) is not interpreted and statically compiled. Now when some popular Golang payloads appeared a lot of endpoint detection and response companies (EDRs) tried to push signatures for this. To no surprise this resulted instead in flagging Golang runtime which is used by all Golang programs. This means it also hit rather crucial tools like Docker and Terraform. As a result the signatures had to be pulled again rather quickly. This highlights how signatures for Go can be rather troublesome to accurately implement due to the static compilation. This makes it an interesting option for malware authors.
Additionally there a lot of interesting libraries out there. One great example he gives us is Binject which is a forked stdlib parser, and supports accessing, adding, and changing signatures as well as plenty of other cool stuff. Or ccpgo which supports calls to application binary interfaces (ABI), adds Apple M1 support etc.
In terms of exploitation tools/repos there are plenty out there, some good examples were:
- Binjection, with which we can insert shellcode into binaries
- Backdoorfactory, a man-in-the-middle (Mitm) tool that can infect downloaded binaries with shellcode
- Bettercap, which intercepts web downloads and replaces them with shellcode (download-autopwn)
- Limelighter, to sign EXE/DLL files with real certificates or create a brand new one.
- Relic, which can sign basically everything (RPM, DEB, JAR, XAP, APK, DMG, etc.)
- GoWMIExec, for remote Windows management Instrumentation calls from Go to run shell commands.
- Go-smb2, for full Server Message Block (SMB) support.
- Gophish, a phishing toolkit
- Gobuster, brute force tool for URIs, vhosts, etc.
- madns, DNS server for XML external entity (XXE) exploitation and the like
- Modlishka, for a reverse proxy and 2FA bypass
As Ben quickly hinted at earlier, there are also a variety of options to evade Endpoint Detection & Response (EDR) and Network Intrusion Detection Systems (NIDS). According to him some of the most popular tools for this are:
- Garble, a Golang obfuscator which can strip out Go metadata, replace string literals with labdas to avoid sigs, etc.
- Ratnet, which is aimed at NIDS evasion with a custom protocol, pluggable transport methods (UDP, TLS, HTTPS, DNS, AWS S3), end-to-end encryption, offline and mesh functionality, etc. This is an amazing tool I highly recommend checking it out.
- Chashell, to reverse shell over DNS
- Chisel, for a TCP/UDP tunnel over HTTP
- Gost, a HTTP/Socks5 tunnel
- Holeysocks, for reverse socks via SSH
- Pandorasbox, another tool to evade EDR, provides encrypted in-memory VFS (virtual file system) functionality.
- Universal Loader, gives use reflective DLL loading so we never have to touch the disk and can do stuff from memory.
- Go-donut, a payload creation framework to convert an exe, dll, (etc.) assembly to an encrypted and injectable shellcode. It also serves as an assembly loader for remote and local loads of payloads into processes, as well as many other functionalities.
- ScareCrow, another popular payload creation framework that works with limelighter, provides AES encryption, disables Event Tracing for Windows (ETW) and so on .
- BananaPhone, an improved Golang version of Hell's Gate, which allows for direct system calls.
- Gopherheaven, a Golang version of Heaven's Gate, which allows to call 64-bit code from 32-bit, evading EDRs.
Now that we know more about the different exploitation and evasion tools, Ben gives us some insight on Post-exploitation tools:
- Go-mimikatz, contains a combination of go-donut and BananaPhone. It loads Mimikatz, a tool for viewing and saving authentication credentials (such as Kerberos tickets) into the RAM turns it then into a Donut payload, and injects itself with BanaPhone system calls.
- Taskmaster, a windows task scheduler library to gain persistence.
- Gscript, embedds a JS based runtime logic for persistence. It can also disable AVs, EDRs, firewalls, and do all kinds of fun stuff.
- GosecretsdumpGosecretsdump, extemely fast at dumping hashes from NTDS.dit files
- goLazagne, extracts browser, email, and admin tool passwords
- rclone, to extract data from cloud storage
- sudophisher, replaces ASKPASS to log the sudo password
This is one of the best and most interesting talks I have come across that talks about this topic. Big thanks to Ben Kurtz for sharing his awesome presentation and extensive knowledge. I highly recommend to check out his full talk below. It really sparked my interest for Go, and my picture of the language and its capabilities has completely changed.