Exemplo n.º 1
0
 static LoginStatus f_OnAuthentication(object sender, SocksAuthenticationEventArgs e)
 {
     if (e.User.Username == "Thr" && e.User.Password == "yoloswag")
     {
         return(LoginStatus.Correct);
     }
     return(LoginStatus.Denied);
 }
Exemplo n.º 2
0
 LoginStatus client_OnClientAuthenticating(object sender, SocksAuthenticationEventArgs e)
 {
     if (this.Authenticate)
     {
         return(OnAuthentication(sender, e));
     }
     else
     {
         return(LoginStatus.Correct);
     }
 }
Exemplo n.º 3
0
 private void OnClientAuthenticating(object sender, SocksAuthenticationEventArgs e)
 {
     if (!Authentication)
     {
         e.Status = LoginStatus.Correct;
     }
     else
     {
         OnAuthentication(sender, e);
     }
 }
Exemplo n.º 4
0
        public void Begin(int packetSize, int timeout)
        {
            Client.OnClientDisconnected += ClientOnClientDisconnected;
            var authtypes = Socks5.RequestAuth(this);

            if (authtypes.Count <= 0)
            {
                Client.Send(new byte[] { 0x00, 0xFF });
                Client.Disconnect();
                return;
            }

            if (Authentication && OnClientAuthenticating != null)
            {
                var user = Socks5.RequestLogin(this);
                if (user == null)
                {
                    Client.Disconnect();
                    return;
                }
                var authEventArgs = new SocksAuthenticationEventArgs(user);
                Events.Raise(OnClientAuthenticating, this, authEventArgs);
                var status = authEventArgs.Status;

                Client.Send(new [] { (byte)HeaderTypes.Socks5, (byte)status });
                if (status == LoginStatus.Denied)
                {
                    Client.Disconnect();
                    return;
                }

                if (status == LoginStatus.Correct)
                {
                    Authenticated = true;
                }
            }
            else
            {
                Authenticated = true;
                Client.Send(new[] { (byte)HeaderTypes.Socks5, (byte)HeaderTypes.Zero });
            }
            var requestTunnel = Socks5.RequestTunnel(this);

            if (requestTunnel == null)
            {
                Client.Disconnect();
                return;
            }

            var tunnel = new SocksTunnel(this, requestTunnel, packetSize);

            tunnel.Open();
        }