Populating AgentDetails and sending it, instead of just the script.

This commit is contained in:
James Wells 2021-11-08 18:06:41 -08:00
parent abba1972d1
commit 27045c94d6
Signed by: jwells
GPG key ID: 73196D10B8E65666
2 changed files with 9 additions and 6 deletions

View file

@ -36,12 +36,14 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) {
log.Printf("[ERROR] No such file or directory: %s", config.File) log.Printf("[ERROR] No such file or directory: %s", config.File)
os.Exit(4) os.Exit(4)
} }
agent.Shasum = fmt.Sprintf("%x", sha.Sum256(agent.ScriptCode)) log.Printf("[DEBUG] Agent file contents: \n----- -----\n%s\n----- -----\n", agent.ScriptCode)
agent.Status = "loaded"
log.Printf("[INFO] SHA256 of Agent file: %s", agent.Shasum)
log.Printf("[DEBUG] Agent file contents: \n%s\n", agent.ScriptCode)
} }
agent.Client = config.UUID
agent.Shasum = fmt.Sprintf("%x", sha.Sum256(agent.ScriptCode))
log.Printf("[INFO] SHA256 of Agent file: %s", agent.Shasum)
agent.Status = "loaded"
agent.Hints = getTagsFromHints(agent) agent.Hints = getTagsFromHints(agent)
agent.Answer = nil
for key := range config.Routers { for key := range config.Routers {
/* /*
@ -54,7 +56,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) {
connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[key].RouterAddr, rport) connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[key].RouterAddr, rport)
wg.Add(1) wg.Add(1)
go sendAgent(wg, config.UUID, connectString, agent.ScriptCode) go sendAgent(wg, config.UUID, connectString, agent)
} }
} }
@ -75,7 +77,7 @@ func getTagsFromHints(agent gstructs.AgentDetails) []string {
return tags return tags
} }
func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent []byte) { func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent gstructs.AgentDetails) {
defer wg.Done() defer wg.Done()
var mu sync.Mutex var mu sync.Mutex

View file

@ -129,4 +129,5 @@ type AgentDetails struct {
Status string `hcl:"status"` Status string `hcl:"status"`
ScriptCode []byte ScriptCode []byte
Hints []string Hints []string
Answer []byte
} }