Skip to content

Commit bfac664

Browse files
committed
initial pass for one-to-many pushc2 WIP
1 parent 19ebe8a commit bfac664

File tree

6 files changed

+237
-159
lines changed

6 files changed

+237
-159
lines changed

MythicReactUI/package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mythic-docker/src/grpc/initialize.go

+29
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type pushC2Server struct {
3535
services.UnimplementedPushC2Server
3636
sync.RWMutex
3737
clients map[int]*grpcPushC2ClientConnections
38+
clientsOneToMany map[string]*grpcPushC2ClientConnections
3839
connectionTimeout time.Duration
3940
channelSendTimeout time.Duration
4041
rabbitmqProcessPushC2AgentConnection chan PushC2ServerConnected
@@ -66,6 +67,7 @@ type grpcPushC2ClientConnections struct {
6667
var TranslationContainerServer translationContainerServer
6768
var PushC2Server pushC2Server
6869

70+
// translationContainerServer functions
6971
func (t *translationContainerServer) addNewGenerateKeysClient(translationContainerName string) (chan services.TrGenerateEncryptionKeysMessage, chan services.TrGenerateEncryptionKeysMessageResponse, error) {
7072
t.Lock()
7173
if _, ok := t.clients[translationContainerName]; !ok {
@@ -190,6 +192,7 @@ func (t *translationContainerServer) GetChannelTimeout() time.Duration {
190192
return t.channelSendTimeout
191193
}
192194

195+
// pushC2Server functions
193196
func (t *pushC2Server) GetRabbitMqProcessAgentMessageChannel() chan PushC2ServerConnected {
194197
return t.rabbitmqProcessPushC2AgentConnection
195198
}
@@ -207,6 +210,20 @@ func (t *pushC2Server) addNewPushC2Client(CallbackAgentID int, callbackUUID stri
207210
t.Unlock()
208211
return fromMythic, nil
209212
}
213+
func (t *pushC2Server) addNewPushC2OneToManyClient(c2ProfileName string) (chan services.PushC2MessageFromMythic, error) {
214+
t.Lock()
215+
if _, ok := t.clientsOneToMany[c2ProfileName]; !ok {
216+
t.clientsOneToMany[c2ProfileName] = &grpcPushC2ClientConnections{}
217+
t.clientsOneToMany[c2ProfileName].pushC2MessageFromMythic = make(chan services.PushC2MessageFromMythic, 100)
218+
}
219+
fromMythic := t.clientsOneToMany[c2ProfileName].pushC2MessageFromMythic
220+
t.clientsOneToMany[c2ProfileName].connected = true
221+
t.clientsOneToMany[c2ProfileName].callbackUUID = ""
222+
t.clientsOneToMany[c2ProfileName].base64Encoded = true
223+
t.clientsOneToMany[c2ProfileName].c2ProfileName = c2ProfileName
224+
t.Unlock()
225+
return fromMythic, nil
226+
}
210227
func (t *pushC2Server) GetPushC2ClientInfo(CallbackAgentID int) (chan services.PushC2MessageFromMythic, string, bool, string, error) {
211228
t.RLock()
212229
if _, ok := t.clients[CallbackAgentID]; ok {
@@ -233,6 +250,13 @@ func (t *pushC2Server) SetPushC2ChannelExited(CallbackAgentID int) {
233250
}
234251
t.RUnlock()
235252
}
253+
func (t *pushC2Server) SetPushC2OneToManyChannelExited(c2ProfileName string) {
254+
t.RLock()
255+
if _, ok := t.clientsOneToMany[c2ProfileName]; ok {
256+
t.clientsOneToMany[c2ProfileName].connected = false
257+
}
258+
t.RUnlock()
259+
}
236260
func (t *pushC2Server) CheckListening() (listening bool, latestError string) {
237261
return t.listening, t.latestError
238262
}
@@ -254,6 +278,11 @@ func (t *pushC2Server) GetConnectedClients() []int {
254278
clientIDs = append(clientIDs, clientID)
255279
}
256280
}
281+
for c2, _ := range t.clientsOneToMany {
282+
if t.clientsOneToMany[c2].connected {
283+
284+
}
285+
}
257286
return clientIDs
258287
}
259288
func (t *pushC2Server) GetTimeout() time.Duration {

0 commit comments

Comments
 (0)