@@ -195,12 +195,53 @@ Target Host: %s`,
195
195
newTagMap ["c2_profile" ].(string ) == oldTagMap ["c2_profile" ].(string ) &&
196
196
(newTagMap ["host_url" ].(string ) == "" ||
197
197
newTagMap ["host_url" ].(string ) == oldTagMap ["host_url" ].(string )) {
198
+ c2HostFileResponse , err := rabbitmq .RabbitMQConnection .SendC2RPCHostFile (rabbitmq.C2HostFileMessage {
199
+ Name : newTagMap ["c2_profile" ].(string ),
200
+ FileUUID : newTagMap ["agent_file_id" ].(string ),
201
+ HostURL : newTagMap ["host_url" ].(string ),
202
+ Remove : remove ,
203
+ })
204
+ if err != nil {
205
+ logging .LogError (err , "failed to send message to container to stop hosting it" )
206
+ go rabbitmq .SendAllOperationsMessage (fmt .Sprintf (
207
+ "%s failed to stop hosting file:\n %s" , newTagMap ["c2_profile" ].(string ),
208
+ err .Error ()), operationID , "" , database .MESSAGE_LEVEL_WARNING )
209
+ continue
210
+ }
211
+ if ! c2HostFileResponse .Success {
212
+ logging .LogError (err , "c2 profile failed to stop hosting file" )
213
+ go rabbitmq .SendAllOperationsMessage (fmt .Sprintf (
214
+ "%s failed to stop hosting file:\n %s" , newTagMap ["c2_profile" ].(string ),
215
+ c2HostFileResponse .Error ), operationID , "" , database .MESSAGE_LEVEL_WARNING )
216
+ continue
217
+ }
198
218
delete (updateTagData , key )
199
219
}
200
220
}
201
221
}
202
222
} else {
203
223
for key , val := range tagData {
224
+ newTagMap := val .(map [string ]interface {})
225
+ c2HostFileResponse , err := rabbitmq .RabbitMQConnection .SendC2RPCHostFile (rabbitmq.C2HostFileMessage {
226
+ Name : newTagMap ["c2_profile" ].(string ),
227
+ FileUUID : newTagMap ["agent_file_id" ].(string ),
228
+ HostURL : newTagMap ["host_url" ].(string ),
229
+ Remove : remove ,
230
+ })
231
+ if err != nil {
232
+ logging .LogError (err , "failed to send host file message to c2 profile" )
233
+ go rabbitmq .SendAllOperationsMessage (fmt .Sprintf (
234
+ "%s failed to start hosting file:\n %s" , newTagMap ["c2_profile" ].(string ),
235
+ err .Error ()), operationID , "" , database .MESSAGE_LEVEL_WARNING )
236
+ continue
237
+ }
238
+ if ! c2HostFileResponse .Success {
239
+ logging .LogError (err , "c2 profile failed to start hosting file" )
240
+ go rabbitmq .SendAllOperationsMessage (fmt .Sprintf (
241
+ "%s failed to start hosting file:\n %s" , newTagMap ["c2_profile" ].(string ),
242
+ c2HostFileResponse .Error ), operationID , "" , database .MESSAGE_LEVEL_WARNING )
243
+ continue
244
+ }
204
245
updateTagData [key ] = val
205
246
}
206
247
}
0 commit comments