示例#1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                SocksServer = new ReverseProxyServer();
                SocksServer.OnConnectionEstablished += socksServer_onConnectionEstablished;
                SocksServer.OnUpdateConnection += socksServer_onUpdateConnection;
                SocksServer.StartServer(_clients, "0.0.0.0", (int)nudServerPort.Value);
                btnStart.Enabled = false;
                btnStop.Enabled = true;

                _refreshTimer = new Timer();
                _refreshTimer.Tick += RefreshTimer_Tick;
                _refreshTimer.Interval = 100;
                _refreshTimer.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    string.Format(
                        "An unexpected error occurred: {0}\n\nPlease report this as fast as possible here:\\https://github.com/MaxXor/xRAT/issues",
                        ex.Message), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnStop_Click(sender, null);
            }
        }
示例#2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                ushort port = GetPortSafe();

                if (port == 0)
                {
                    MessageBox.Show("Please enter a valid port > 0.", "Please enter a valid port", MessageBoxButtons.OK,
                        MessageBoxIcon.Warning);
                    return;
                }

                SocksServer = new ReverseProxyServer();
                SocksServer.OnConnectionEstablished += socksServer_onConnectionEstablished;
                SocksServer.OnUpdateConnection += socksServer_onUpdateConnection;
                SocksServer.StartServer(_clients, "0.0.0.0", port);
                ToggleButtons(true);

                _refreshTimer = new Timer();
                _refreshTimer.Tick += RefreshTimer_Tick;
                _refreshTimer.Interval = 100;
                _refreshTimer.Start();
            }
            catch (SocketException ex)
            {
                if (ex.ErrorCode == 10048)
                {
                    MessageBox.Show("The port is already in use.", "Listen Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(
                        string.Format(
                            "An unexpected socket error occurred: {0}\n\nError Code: {1}\n\nPlease report this as fast as possible here:\n{2}/issues",
                            ex.Message, ex.ErrorCode, Settings.RepositoryURL), "Unexpected Listen Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                btnStop_Click(sender, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    string.Format(
                        "An unexpected error occurred: {0}\n\nPlease report this as fast as possible here:\n{1}/issues",
                        ex.Message, Settings.RepositoryURL), "Unexpected Listen Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnStop_Click(sender, null);
            }
        }
示例#3
0
        public ReverseProxyClient(Client client, Socket socket, ReverseProxyServer server)
        {
            this.Handle           = socket;
            this.Client           = client;
            this._handshakeStream = new MemoryStream();
            this._buffer          = new byte[BUFFER_SIZE];
            this.IsConnected      = true;
            this.TargetServer     = "";
            this.Type             = ProxyType.Unknown;
            this.Server           = server;

            try
            {
                socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, socket_Receive, null);
            }
            catch
            {
                Disconnect();
            }
        }
示例#4
0
        public ReverseProxyClient(Client client, Socket socket, ReverseProxyServer server)
        {
            this.Handle = socket;
            this.Client = client;
            this._handshakeStream = new MemoryStream();
            this._buffer = new byte[BUFFER_SIZE];
            this.IsConnected = true;
            this.TargetServer = "";
            this.Type = ProxyType.Unknown;
            this.Server = server;

            try
            {
                socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, socket_Receive, null);
            }
            catch
            {
                Disconnect();
            }
        }