예제 #1
0
        ///<summary>
        ///Start the connection.
        ///</summary>
        public void Start()
        {
            if (Method != "4" && Method != "5" && Method != "connect")
            {
                System.Console.WriteLine($"Warning: Supported protocols are 4 (SOCKS v.4), 5 (SOCKS v.5) and connect (HTTPS proxy). If the protocol is not specified, SOCKS version 5 is used. Got: {Method}.");
            }
            string NCatProxyType;
            string PrCommand;
            string ClArgs;

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                NCatProxyType = "";
                switch (Method)
                {
                case "4":
                    NCatProxyType = "socks4";
                    break;

                case "5":
                    NCatProxyType = "socks5";
                    break;

                case "connect":
                    NCatProxyType = "http";
                    break;
                }
                PrCommand = $"./nc.exe";
                ClArgs    = $" -X {Method} -x {ProxyServerName}:{ProxyPort} {HostName} {Port}";
            }
            else
            {
                PrCommand = $"nc";
                ClArgs    = $" -X {Method} -x {ProxyServerName}:{ProxyPort} {HostName} {Port}";
            }
            if (Unbuffer == null)
            {
                SS = new ShellSocket(PrCommand, ClArgs, Unbuffer, Unbuffer_Args);
            }
            else
            {
                SS = new ShellSocket(PrCommand, ClArgs);
            }
            if (AutoConfigure)
            {
                SS.AutoConfigure = true;
                SS.PackageName   = "NC";
            }
            if (VERBOSE)
            {
                SetColour(5, 0);
                System.Console.Error.WriteLine(PrCommand + " " + ClArgs);
                ResetColour();
            }
            SS.Start();
            S = SS.GetStream();
        }
예제 #2
0
        ///<summary>
        ///Start the connection.
        ///</summary>
        public void Start()
        {
            string psk_hex   = BitConverter.ToString(PSK).Replace("-", String.Empty);
            string PrCommand = "";

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                if (!ShellSocket.CheckExecutableExistence("openssl.exe"))
                {
                    PrCommand = $"./openssl.exe";
                }
            }
            else
            {
                PrCommand = $"openssl";
            }
            string ClArguments = $"s_client -dtls -connect {HostName}:{Port} -psk {psk_hex} -quiet";

            if (Unbuffer == null)
            {
                SS = new ShellSocket(PrCommand, ClArguments, Unbuffer, Unbuffer_Args);
            }
            else
            {
                SS = new ShellSocket(PrCommand, ClArguments);
            }
            if (VERBOSE)
            {
                SetColour(5, 0);
                System.Console.Error.WriteLine(PrCommand + " " + ClArguments);
                ResetColour();
            }
            if (AutoConfigure)
            {
                SS.AutoConfigure = true;
                SS.PackageName   = "OpenSSL";
            }
            SS.Start();
        }