public override bool SendMessageToProducer(string message) { bool bRet = true; try { DebugWriteLine($"Attempting to decrypt message of length {message.Length}..."); var deleteMe = MessageConsumer.cryptor.Decrypt(message); DebugWriteLine($"SUCCESS! Decrypted message is of length: {deleteMe.Length}"); DebugWriteLine($"Attempting to send message of length {deleteMe.Length} to {MessageProducer.HostName} using profile {MessageProducer.GetType().Name}..."); MessageProducer.Send("", MessageConsumer.cryptor.Decrypt(message)); DebugWriteLine($"SUCCESS! Sent message of length {deleteMe.Length} to {MessageProducer.HostName} using profile {MessageProducer.GetType().Name}!"); } catch (Exception ex) { DebugWriteLine($"ERROR! Could not send message of length {message.Length} to {MessageProducer.HostName} using profile {MessageProducer.GetType().Name}. \n\tReason: {ex.Message}\n\tStack Trace: {ex.StackTrace}"); bRet = false; } return(bRet); }
private static void Unlink(Job job, Agent implant) { LinkMessage linkMsg = JsonConvert.DeserializeObject <LinkMessage>(job.Task.parameters); string agentUUID = linkMsg.connection_info.agent_uuid; string message; if (agentUUID == null || agentUUID == "") { job.SetError($"Could not unlink from {linkMsg.connection_info.host} as no agent UUID could be parsed."); } else { // In the future, we need to change DelegateNodes to a list of delegate nodes, // which is then filtered down for unlinking and passing messages. Current model // will not support multiple P2P agents from one host to another. if (!implant.DelegateNodes.ContainsKey(agentUUID)) { job.SetError($"No such connection to {linkMsg.connection_info.host} (Agent {linkMsg.connection_info.agent_uuid} using {linkMsg.connection_info.c2_profile.name.ToUpper()}) exists."); return; } DelegateNode dg = implant.DelegateNodes[agentUUID]; switch (linkMsg.connection_info.c2_profile.name.ToLower()) { case "smbserver": SMBClientProfile hLinkedAgentProfile = (SMBClientProfile)dg.NodeRelay.MessageProducer; var unlinkMsg = new UnlinkMessage() { action = "unlink" }; message = JsonConvert.SerializeObject(unlinkMsg); hLinkedAgentProfile.Send("", message); implant.RemoveDelegateNode(agentUUID); job.SetComplete($"Successfully unlinked {linkMsg.connection_info.host} ({linkMsg.connection_info.c2_profile.name.ToUpper()})"); break; default: job.SetError($"Unknown peer-to-peer profile \"{linkMsg.connection_info.c2_profile.name}\""); break; } } }