MCPcopy
hub / github.com/Ne0nd0g/merlin / agentToAgentInfo

Method agentToAgentInfo

pkg/services/rpc/agentService.go:44–104  ·  view source on GitHub ↗

* RPC METHODS TO INTERACT WITH THE AGENT SERVICE */ agentToAgentInfo converts a server-side Agent structure into a protobuf AgentInfo structure

(a agents.Agent)

Source from the content-addressed store, hash-verified

42
43// agentToAgentInfo converts a server-side Agent structure into a protobuf AgentInfo structure
44func (s *Server) agentToAgentInfo(a agents.Agent) *pb.AgentInfo {
45 build := &pb.Build{
46 Build: a.Build().Build,
47 Version: a.Build().Version,
48 }
49
50 host := &pb.Host{
51 Architecture: a.Host().Architecture,
52 Platform: a.Host().Platform,
53 Name: a.Host().Name,
54 IPs: a.Host().IPs,
55 }
56
57 comms := &pb.Comms{
58 Failed: int32(a.Comms().Failed),
59 JA3: a.Comms().JA3,
60 KillDate: a.Comms().Kill,
61 Padding: int32(a.Comms().Padding),
62 Protocol: a.Comms().Proto,
63 Retry: int32(a.Comms().Retry),
64 Skew: a.Comms().Skew,
65 Wait: a.Comms().Wait,
66 }
67
68 process := &pb.Process{
69 ID: int32(a.Process().ID),
70 IntegrityLevel: int32(a.Process().Integrity),
71 Name: a.Process().Name,
72 Username: a.Process().UserName,
73 UserGUID: a.Process().UserGUID,
74 Domain: a.Process().Domain,
75 }
76 var links []string
77 for _, link := range a.Links() {
78 links = append(links, link.String())
79 }
80
81 status, err := s.agentService.Status(a.ID())
82 if err != nil {
83 slog.Error(err.Error())
84 }
85
86 // Create the AgentInfo structure
87 agentInfo := &pb.AgentInfo{
88 ID: a.ID().String(),
89 Alive: a.Alive(),
90 Authenticated: a.Authenticated(),
91 Build: build,
92 Host: host,
93 Comms: comms,
94 Process: process,
95 InitialCheckin: a.Initial().Format(time.RFC3339),
96 LastCheckin: a.StatusCheckin().Format(time.RFC3339),
97 Listener: a.Listener().String(),
98 Links: links,
99 Note: a.Note(),
100 Status: status,
101 Groups: s.agentService.Groups(),

Callers 1

GetAgentMethod · 0.95

Calls 15

BuildMethod · 0.80
HostMethod · 0.80
CommsMethod · 0.80
ProcessMethod · 0.80
ErrorMethod · 0.80
AliveMethod · 0.80
InitialMethod · 0.80
StatusCheckinMethod · 0.80
StringMethod · 0.65
StatusMethod · 0.65
IDMethod · 0.65
ListenerMethod · 0.65

Tested by

no test coverage detected