Skip to content

Commit

Permalink
Merge pull request #406 from 0xTriboulet/3rd-party-support-DEV
Browse files Browse the repository at this point in the history
Update agent.go and handlers.go for 3rd party agent UI support
  • Loading branch information
S4ntiagoP authored Oct 10, 2023
2 parents 224ed10 + b741882 commit 0b0d276
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
15 changes: 14 additions & 1 deletion teamserver/pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,15 @@ func RegisterInfoToInstance(Header Header, RegisterInfo map[string]any) *Agent {
}
}

// Updated OS Version handling - 0xtriboulet
if val, ok := RegisterInfo["OS Version"]; ok {
agent.Info.OSVersion = val.(string)
// Assuming val is a string representing the OS version, split it by '.' to get the version parts, 0xtriboulet
versionParts := strings.Split(val.(string), ".")
OsVersion := make([]int, len(versionParts))
for i, part := range versionParts {
OsVersion[i], _ = strconv.Atoi(part)
}
agent.Info.OSVersion = getWindowsVersionString(OsVersion)
}

if val, ok := RegisterInfo["OS Build"]; ok {
Expand All @@ -288,6 +295,7 @@ func RegisterInfoToInstance(Header Header, RegisterInfo map[string]any) *Agent {
if val, ok := RegisterInfo["OS Arch"]; ok {
agent.Info.OSArch = val.(string)
}

if val, ok := RegisterInfo["SleepDelay"]; ok { // 0xtriboulet
switch v := val.(type) {
case float64:
Expand All @@ -304,8 +312,13 @@ func RegisterInfoToInstance(Header Header, RegisterInfo map[string]any) *Agent {
agent.Info.SleepDelay = 0
}
}


agent.Info.FirstCallIn = time.Now().Format("02/01/2006 15:04:05")

agent.Info.LastCallIn = time.Now().Format("02-01-2006 15:04:05")


agent.BackgroundCheck = false
agent.Active = true

Expand Down
7 changes: 6 additions & 1 deletion teamserver/pkg/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,12 @@ func handleServiceAgent(Teamserver agent.TeamServer, Header agent.Header, Extern
if Agent != nil {
AgentData = Agent.ToMap()
}


// Update Callback time - 0xtriboulet
if Teamserver.AgentExist(Header.AgentID) {
Agent.UpdateLastCallback(Teamserver)
}

Task = Teamserver.ServiceAgent(Header.MagicValue).SendResponse(AgentData, Header)
//logger.Debug("Response:\n", hex.Dump(Task))

Expand Down

0 comments on commit 0b0d276

Please sign in to comment.