Exemplo n.º 1
0
        private void KillSessionItem_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in Sessions.SelectedRows)
            {
                var session = (Session)row.DataBoundItem;
                int targetsid;

                if (!int.TryParse(session.Sid, System.Globalization.NumberStyles.HexNumber, null, out targetsid))
                {
                    continue;
                }

                if (targetsid == _sid)
                {
                    MessageBox.Show(Strings.ADMINFORM_KILL_OWN_SESSION, string.Empty, MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
                else
                {
                    IMinimalResponse response = _tunnel.KillSession(new KillSessionRequest(targetsid, _sid));
                    if (!response.Success)
                    {
                        HandleResponse(response);
                    }
                }
            }

            RefreshSessions();
        }
Exemplo n.º 2
0
 private static void HandleResponse(IMinimalResponse response)
 {
     if (!response.Success)
     {
         MessageBox.Show(response.Message, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 3
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Termine une connexion
        /// </summary>
        /// <param name="sender">l'appelant</param>
        /// <param name="e">les parametres</param>
        /// -----------------------------------------------------------------------------
        private void KillConnectionItem_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in Connections.SelectedRows)
            {
                var connection = (Connection)row.DataBoundItem;
                int targetsid;
                int targetcid;

                if (int.TryParse(_currentsession.Sid, System.Globalization.NumberStyles.HexNumber, null, out targetsid) &&
                    int.TryParse(connection.Cid, System.Globalization.NumberStyles.HexNumber, null, out targetcid))
                {
                    IMinimalResponse response = _tunnel.KillConnection(new KillConnectionRequest(targetsid, _sid, targetcid));
                    if (!response.Success)
                    {
                        HandleResponse(response);
                    }
                }
            }
            RefreshSessions();
        }
Exemplo n.º 4
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Traite une réponse du serveur
 /// </summary>
 /// <param name="response">la réponse</param>
 /// -----------------------------------------------------------------------------
 private void HandleResponse(IMinimalResponse response)
 {
     if (!response.Success)
         MessageBox.Show(response.Message, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
 }
Exemplo n.º 5
0
        public void StartClient()
        {
            Log(string.Format(Strings.CLIENT_TITLE, GetType().Assembly.GetName().Version.ToString(3)), ESeverity.INFO);
            Log(FrameworkVersion(), ESeverity.INFO);

            Protocol.ConfigureClient();
            ConfigureProxy(Protocol);

            IMinimalResponse response = null;
            bool             retry;

            do
            {
                retry = false;
                try
                {
                    Tunnel   = Protocol.GetTunnel();
                    response = Tunnel.Version();
                }
                catch (WebException ex)
                {
                    var webResponse = ex.Response as HttpWebResponse;
                    if (webResponse != null && Protocol is IProxyCompatible)
                    {
                        var proxyProtocol = (IProxyCompatible)Protocol;
                        if (webResponse.StatusCode != HttpStatusCode.ProxyAuthenticationRequired)
                        {
                            continue;
                        }

                        retry = true;
                        InputProxyCredentials(proxyProtocol, ref retry);
                    }
                    else
                    {
                        throw;
                    }
                }
            } while (retry);

            if (response != null && Tunnel != null)
            {
                if (response.Message.IndexOf(GetType().Assembly.GetName().Version.ToString(3), StringComparison.Ordinal) < 0)
                {
                    Log(Strings.VERSION_MISMATCH, ESeverity.WARN);
                }

                Log(response.Message, ESeverity.INFO);
                if (!response.Success)
                {
                    return;
                }

                var loginResponse = Tunnel.Login(new LoginRequest(ClientConfig.ServiceUserName, ClientConfig.ServicePassword));
                if (loginResponse.Success)
                {
                    _sid = loginResponse.Sid;
                    Log(loginResponse.Message, ESeverity.INFO);

                    if (Args == null || Args.Length == 0)
                    {
                        InitializeForwards(Tunnel, _sid.Value);
                        InitializeSocks(Tunnel, _sid.Value);
                    }
                }
                else
                {
                    throw new Exception(loginResponse.Message);
                }
            }
            else
            {
                throw new Exception(Strings.CONNECTION_FAILED);
            }
        }
Exemplo n.º 6
0
 private void HandleError(IMinimalResponse response)
 {
     HandleError(response.Message, true);
 }
Exemplo n.º 7
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Démarrage du client
        /// </summary>
        /// -----------------------------------------------------------------------------
        public void StartClient()
        {
            Log(string.Format(Strings.CLIENT_TITLE, GetType().Assembly.GetName().Version.ToString(3)), ESeverity.INFO);
            Log(FrameworkVersion(), ESeverity.INFO);

            Protocol.ConfigureClient();
            ConfigureProxy(Protocol);

            IMinimalResponse response = null;
            bool             retry;

            // Communication avec le tunnel. Détection éventuelle d'une authentification incorrecte proxy
            do
            {
                retry = false;
                try
                {
                    Tunnel   = Protocol.GetTunnel();
                    response = Tunnel.Version();
                }
                catch (WebException ex)
                {
                    if ((ex.Response) is HttpWebResponse && (Protocol is IProxyCompatible))
                    {
                        var proxyProtocol = (IProxyCompatible)Protocol;
                        var httpres       = (HttpWebResponse)ex.Response;
                        if (httpres.StatusCode == HttpStatusCode.ProxyAuthenticationRequired)
                        {
                            retry = true;
                            InputProxyCredentials(proxyProtocol, ref retry);
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            } while (retry);

            // Démarrage effectif du client, récuperation du session-id
            if ((response != null) && (Tunnel != null))
            {
                if (response.Message.IndexOf(GetType().Assembly.GetName().Version.ToString(3), StringComparison.Ordinal) < 0)
                {
                    Log(Strings.VERSION_MISMATCH, ESeverity.WARN);
                }
                Log(response.Message, ESeverity.INFO);
                if (response.Success)
                {
                    LoginResponse loginResponse = Tunnel.Login(new LoginRequest(ClientConfig.ServiceUserName, ClientConfig.ServicePassword));
                    if (loginResponse.Success)
                    {
                        _sid = loginResponse.Sid;
                        Log(loginResponse.Message, ESeverity.INFO);

                        // Pas d'initialisation socks/forward en mode 'commandes'
                        if (Args == null || Args.Length == 0)
                        {
                            // Mise En place des forwards
                            InitializeForwards(Tunnel, _sid.Value);
                            // Puis du serveur Socks
                            InitializeSocks(Tunnel, _sid.Value);
                        }
                    }
                    else
                    {
                        throw new Exception(loginResponse.Message);
                    }
                }
            }
            else
            {
                throw new Exception(Strings.CONNECTION_FAILED);
            }
        }