Пример #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>
 ///Get the Stream formed by the process.
 ///Should be Start()ed first.
 ///</summary>
 public Stream GetStream()
 {
     return(SS.GetStream());
 }