public HttpOverSocksProxy(IPEndPoint http_listen, IPEndPoint socks_proxy, ProxyTypes socks_proxy_type, int buffer_size = 1024 *4) { this.EndPoint_Source_Http = http_listen; this.EndPoint_Destination_Socks = socks_proxy; this.SocksProxyType = socks_proxy_type; this.Buffer_Size = buffer_size; }
public void WhenNonGenericInstanceClass(Type type, ProxyTypes proxyType, string name) { var pt = moduleBuilder.DefineProxyType(type.GetTypeInfo(), proxyType).CreateType(); Assert.NotNull(pt); Assert.Equal(name, pt.FullName); }
public MyTcp1225(string ip, int port, ProxyTypes pt = ProxyTypes.None, string daili = "", string localip = "") { ipendPoint_0 = new IPEndPoint(IPAddress.Parse(ip), port); clientSocket = new ProxySocket(ipendPoint_0.AddressFamily, SocketType.Stream, ProtocolType.Tcp); clientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, new LingerOption(true, 0)); IPAddress address; if (!string.IsNullOrWhiteSpace(localip) && IPAddress.TryParse(localip, out address)) { IPEndPoint localEP = new IPEndPoint(address, 0); clientSocket.Bind(localEP); } if (!string.IsNullOrWhiteSpace(daili) && daili.Trim().Length > 0) { string[] array = daili.Split('|'); if (pt == ProxyTypes.Https) { array = daili.Split(':'); } clientSocket.ProxyEndPoint = new IPEndPoint(IPAddress.Parse(array[0]), Convert.ToInt32(array[1])); if (array.Length > 2) { clientSocket.ProxyUser = array[2]; clientSocket.ProxyPass = array[3]; } } clientSocket.ProxyType = pt; list_0 = new List <byte>(); }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">Connection port.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> /// <exception cref="ArgumentException"><paramref name="host"/> is invalid, or <paramref name="username"/> is null or contains whitespace characters.</exception> /// /// <exception cref="ArgumentOutOfRangeException"><paramref name="port"/> is not within <see cref="IPEndPoint.MinPort"/> and <see cref="IPEndPoint.MaxPort"/>.</exception> /// /// <exception cref="ArgumentException"><paramref name="username"/> is null or empty.</exception> protected ConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : this() { if (!host.IsValidHost()) throw new ArgumentException("host"); if (!string.IsNullOrEmpty(proxyHost) && !proxyHost.IsValidHost()) throw new ArgumentException("proxyHost"); if (!port.IsValidPort()) throw new ArgumentOutOfRangeException("port"); if (!proxyPort.IsValidPort()) throw new ArgumentOutOfRangeException("proxyPort"); if (username.IsNullOrWhiteSpace()) throw new ArgumentException("username"); this.Host = host; this.Port = port; this.Username = username; this.ProxyType = proxyType; this.ProxyHost = proxyHost; this.ProxyPort = proxyPort; this.ProxyUsername = proxyUsername; this.ProxyPassword = proxyPassword; }
internal bool TryCreateImplementation(ProxyTypes proxyType, Type needPeoxyType, ServiceDescriptor descriptor, Func <ServiceDescriptor, Type, ServiceDescriptor> createServiceDescriptor, out ServiceDescriptor proxyServiceDescriptor) { var implementationType = proxyGenerator.Create(needPeoxyType, proxyType); proxyServiceDescriptor = implementationType == null ? null : createServiceDescriptor(descriptor, implementationType); return(proxyServiceDescriptor != null); }
public static void Menu() { Console.Clear(); WriteConsole.AsciiText("ProxyStar", true, true, ConsoleColor.Cyan); WriteConsole.ColorText($"Welcome to ProxyStar V1.0.0!\n\nRead {ProxyQueue.Count.ToString()} Proxies from proxies.txt\n", ConsoleColor.Cyan); WriteConsole.ColorText("Menu:\n\n1) Check HTTP(s) proxies\n2) Check SOCKS4 proxies\n3) Check SOCKS5 proxies\n\nInput: ", ConsoleColor.Cyan); var UserInput = Console.ReadKey(); if (UserInput.Key == ConsoleKey.D1) { type = ProxyTypes.Http; } else if (UserInput.Key == ConsoleKey.D2) { type = ProxyTypes.Socks4; } else if (UserInput.Key == ConsoleKey.D3) { type = ProxyTypes.Socks5; } else { Menu(); } Console.Clear(); WriteConsole.ColorText($"Loaded: {ProxyQueue.Count.ToString()} Proxies from proxies.txt\n", ConsoleColor.Cyan); Console.WriteLine("Threads: "); threads = Convert.ToInt32(Console.ReadLine()); CheckProxy(); }
public void PasswordConnectionInfoConstructorTest10() { string host = string.Empty; // TODO: Initialize to an appropriate value string username = string.Empty; // TODO: Initialize to an appropriate value string password = string.Empty; // TODO: Initialize to an appropriate value ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value string proxyHost = string.Empty; // TODO: Initialize to an appropriate value int proxyPort = 0; // TODO: Initialize to an appropriate value PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password, proxyType, proxyHost, proxyPort); Assert.Inconclusive("TODO: Implement code to verify target"); }
[Ignore] // placeholder for actual test public void KeyboardInteractiveConnectionInfoConstructorTest3() { string host = string.Empty; // TODO: Initialize to an appropriate value string username = string.Empty; // TODO: Initialize to an appropriate value ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value string proxyHost = string.Empty; // TODO: Initialize to an appropriate value int proxyPort = 0; // TODO: Initialize to an appropriate value KeyboardInteractiveConnectionInfo target = new KeyboardInteractiveConnectionInfo(host, username, proxyType, proxyHost, proxyPort); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void KeyboardInteractiveConnectionInfoConstructorTest2() { string host = string.Empty; // TODO: Initialize to an appropriate value string username = string.Empty; // TODO: Initialize to an appropriate value ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value string proxyHost = string.Empty; // TODO: Initialize to an appropriate value int proxyPort = 0; // TODO: Initialize to an appropriate value string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value KeyboardInteractiveConnectionInfo target = new KeyboardInteractiveConnectionInfo(host, username, proxyType, proxyHost, proxyPort, proxyUsername); Assert.Inconclusive("TODO: Implement code to verify target"); }
void btnTestProxy_Click(object sender, System.EventArgs e) { if (txtProxyIpAddress.Text.Trim() == "") { MsgBox.Warning("Sorry,the IP address can't be empty"); return; } if (this.txtProxyUserName.Text.Trim() == "") { MsgBox.Warning("Sorry,the user name can't be empty"); return; } if (this.txtProxyPortNumber.Text.Trim() == "") { MsgBox.Warning("Sorry,the port number can't be empty"); return; } using (var cursor = new WaitCursor()) { using (ProxySocket socket = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(txtIpAddress.Text), Convert.ToInt32(txtPortNumber.Text)); IPEndPoint proxyEndPoint = new IPEndPoint(IPAddress.Parse(this.txtProxyIpAddress.Text), Convert.ToInt32(this.txtProxyPortNumber.Text)); ProxyTypes proxyType = (ProxyTypes)Enum.Parse(typeof(ProxyTypes), ddlProxyType.SelectedItem.ToString()); TcpConnectionParams Params = new TcpConnectionParams(endPoint, proxyEndPoint, proxyType, txtProxyUserName.Text, txtProxyPassword.Text); socket.ProxyEndPoint = Params.ProxyEndPoint; socket.ProxyType = Params.ProxyType; socket.ProxyUser = Params.ProxyUser; socket.ProxyPass = Params.ProxyPassword; try { socket.Connect(Params.EndPoint); MsgBox.Warning("Test successful"); } catch { MsgBox.Warning("Sorry,test failed,please try again"); } finally { try { socket.Shutdown(SocketShutdown.Both); socket.Close(); } catch { } } } } }
[Ignore] // placeholder for actual test public void PasswordConnectionInfoConstructorTest12() { string host = string.Empty; // TODO: Initialize to an appropriate value int port = 0; // TODO: Initialize to an appropriate value string username = string.Empty; // TODO: Initialize to an appropriate value string password = string.Empty; // TODO: Initialize to an appropriate value ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value string proxyHost = string.Empty; // TODO: Initialize to an appropriate value int proxyPort = 0; // TODO: Initialize to an appropriate value PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password, proxyType, proxyHost, proxyPort); Assert.Inconclusive("TODO: Implement code to verify target"); }
[Ignore] // placeholder for actual test public void PrivateKeyConnectionInfoConstructorTest3() { string host = string.Empty; // TODO: Initialize to an appropriate value string username = string.Empty; // TODO: Initialize to an appropriate value ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value string proxyHost = string.Empty; // TODO: Initialize to an appropriate value int proxyPort = 0; // TODO: Initialize to an appropriate value PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, proxyType, proxyHost, proxyPort, keyFiles); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void ConnectionInfoConstructorTest() { string host = string.Empty; // TODO: Initialize to an appropriate value int port = 0; // TODO: Initialize to an appropriate value string username = string.Empty; // TODO: Initialize to an appropriate value ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value string proxyHost = string.Empty; // TODO: Initialize to an appropriate value int proxyPort = 0; // TODO: Initialize to an appropriate value string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value AuthenticationMethod[] authenticationMethods = null; // TODO: Initialize to an appropriate value ConnectionInfo target = new ConnectionInfo(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, authenticationMethods); Assert.Inconclusive("TODO: Implement code to verify target"); }
public Type Create(Type serviceType, ProxyTypes proxyType) { switch (proxyType) { case ProxyTypes.Inherit: return(inherit.Create(serviceType, interceptorCreator, moduleBuilder)); case ProxyTypes.Facade: return(facade.Create(serviceType, interceptorCreator, moduleBuilder)); default: return(null); } }
public TcpConnectionParams(IPEndPoint endPoint , IPEndPoint proxyEndPoint , ProxyTypes proxyType , string proxyUser , string proxyPassword) : this(endPoint , SR.EOF , SR.HeartPacket , SR.HeartInterval , SR.BufferSize , proxyEndPoint , proxyType , proxyUser , proxyPassword) { }
public MyTcp(string ip, int port, bool isservice = false, string daili = "", ProxyTypes pt = ProxyTypes.None) { try { bool_0 = isservice; proxySocket_0 = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); if (daili.Trim().Length > 0) { string[] array = daili.Split('|'); if (pt == ProxyTypes.Https) { array = daili.Split(':'); } proxySocket_0.ProxyEndPoint = new IPEndPoint(IPAddress.Parse(array[0]), Convert.ToInt32(array[1])); if (array.Length > 2) { proxySocket_0.ProxyUser = array[2]; proxySocket_0.ProxyPass = array[3]; } } proxySocket_0.ProxyType = pt; arc4_0 = null; arc4_1 = null; IPAddress address = IPAddress.Parse(ip); ipendPoint_0 = new IPEndPoint(address, port); timer_3 = new System.Timers.Timer(20.0); timer_3.Elapsed += timer_3_Elapsed; timer_3.AutoReset = true; timer_0 = new System.Timers.Timer(20.0); timer_0.Elapsed += timer_0_Elapsed; timer_0.AutoReset = true; timer_1 = new System.Timers.Timer(15000.0); timer_1.Elapsed += timer_1_Elapsed; timer_1.AutoReset = true; timer_2 = new System.Timers.Timer(63000.0); timer_2.Elapsed += timer_2_Elapsed; timer_2.AutoReset = true; concurrentQueue_0 = new ConcurrentQueue <byte[]>(); } catch (Exception ex) { throw new Exception("ctcp:" + ex.Message); } }
public TcpConnectionParams(IPEndPoint endPoint , byte[] packetSeparateFlag , byte[] heartPacket , int heartTicket , int bufferSize , IPEndPoint proxyEndPoint , ProxyTypes proxyType , string proxyUser , string proxyPassword) : base(endPoint, packetSeparateFlag, heartPacket, heartTicket, bufferSize) { if (proxyEndPoint != null && proxyType != ProxyTypes.None) { ProxyEndPoint = proxyEndPoint; ProxyType = proxyType; ProxyUser = proxyUser; ProxyPassword = proxyPassword; } }
public OldTcp(string ip, int port, string daili = "", ProxyTypes pt = ProxyTypes.None, string localip = "") { try { client = new TcpClient(); proxySocket_0 = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); proxySocket_0.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, new LingerOption(true, 0)); IPAddress address; if (!string.IsNullOrWhiteSpace(localip) && IPAddress.TryParse(localip, out address)) { IPEndPoint localEP = new IPEndPoint(address, 0); proxySocket_0.Bind(localEP); } if (daili.Trim().Length > 0) { string[] array = daili.Split('|'); if (pt == ProxyTypes.Https) { array = daili.Split(':'); } proxySocket_0.ProxyEndPoint = new IPEndPoint(IPAddress.Parse(array[0]), Convert.ToInt32(array[1])); if (array.Length > 2) { proxySocket_0.ProxyUser = array[2]; proxySocket_0.ProxyPass = array[3]; } } proxySocket_0.ProxyType = pt; client.ReceiveTimeout = 3000; arc4_0 = null; arc4_1 = null; IPAddress address2 = IPAddress.Parse(ip); ipendPoint_0 = new IPEndPoint(address2, port); } catch (Exception ex) { throw new Exception("ctcp:" + ex.Message); } }
public Type CreateProxyType(Type serviceType, ProxyTypes proxyType = ProxyTypes.Inherit) { if (!generators.TryGetValue(proxyType, out var generator)) { return(null); } lock (_lock) { var name = generator.GetProxyTypeName(serviceType); if (!definedTypes.TryGetValue(name, out Type type)) { type = generator.CreateProxyType(new ProxyGeneratorContext() { ProxyTypeName = name, ServiceType = serviceType, ModuleBuilder = moduleBuilder }); definedTypes[name] = type; } return(type); } }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">Connection port.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> /// <exception cref="ArgumentException"><paramref name="host"/> is invalid, or <paramref name="username"/> is null or contains whitespace characters.</exception> /// /// <exception cref="ArgumentOutOfRangeException"><paramref name="port"/> is not within <see cref="IPEndPoint.MinPort"/> and <see cref="IPEndPoint.MaxPort"/>.</exception> /// /// <exception cref="ArgumentException"><paramref name="username"/> is null or empty.</exception> protected ConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : this() { if (!host.IsValidHost()) { throw new ArgumentException("host"); } if (!string.IsNullOrEmpty(proxyHost) && !proxyHost.IsValidHost()) { throw new ArgumentException("proxyHost"); } if (!port.IsValidPort()) { throw new ArgumentOutOfRangeException("port"); } if (!proxyPort.IsValidPort()) { throw new ArgumentOutOfRangeException("proxyPort"); } if (username.IsNullOrWhiteSpace()) { throw new ArgumentException("username"); } this.Host = host; this.Port = port; this.Username = username; this.ProxyType = proxyType; this.ProxyHost = proxyHost; this.ProxyPort = proxyPort; this.ProxyUsername = proxyUsername; this.ProxyPassword = proxyPassword; }
/// <summary> /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername) : this(host, 22, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty) { }
// эти 2 конструктора просто повторяют конструкторы родительского класса public MyProxy(string addressAndPort, ProxyTypes type) : base(addressAndPort, type) { ErrorsCount = StartErrors; }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">The port.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> public PasswordConnectionInfo(string host, int port, string username, byte[] password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, new PasswordAuthenticationMethod(username, password)) { foreach (var authenticationMethod in AuthenticationMethods) { var pwdAuthentication = authenticationMethod as PasswordAuthenticationMethod; if (pwdAuthentication != null) { pwdAuthentication.PasswordExpired += AuthenticationMethod_PasswordExpired; } } }
// TODO: DOCS Add exception documentation for this class. /// <summary> /// Initializes a new instance of the <see cref="ConnectionInfo" /> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">Connection port.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> /// <param name="authenticationMethods">The authentication methods.</param> /// <exception cref="ArgumentNullException"><paramref name="host"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException"><paramref name="username" /> is null, a zero-length string or contains only whitespace characters.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="port" /> is not within <see cref="F:System.Net.IPEndPoint.MinPort" /> and <see cref="F:System.Net.IPEndPoint.MaxPort" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="proxyType"/> is not <see cref="ProxyTypes.None"/> and <paramref name="proxyHost" /> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="proxyType"/> is not <see cref="ProxyTypes.None"/> and <paramref name="proxyPort" /> is not within <see cref="F:System.Net.IPEndPoint.MinPort" /> and <see cref="F:System.Net.IPEndPoint.MaxPort" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="authenticationMethods"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">No <paramref name="authenticationMethods"/> specified.</exception> public ConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, params AuthenticationMethod[] authenticationMethods) { if (host == null) { throw new ArgumentNullException("host"); } port.ValidatePort("port"); if (username == null) { throw new ArgumentNullException("username"); } if (username.All(char.IsWhiteSpace)) { throw new ArgumentException("Cannot be empty or contain only whitespace.", "username"); } if (proxyType != ProxyTypes.None) { if (proxyHost == null) { throw new ArgumentNullException("proxyHost"); } proxyPort.ValidatePort("proxyPort"); } if (authenticationMethods == null) { throw new ArgumentNullException("authenticationMethods"); } if (!authenticationMethods.Any()) { throw new ArgumentException("At least one authentication method should be specified.", "authenticationMethods"); } // Set default connection values this.Timeout = TimeSpan.FromSeconds(30); this.RetryAttempts = 10; this.MaxSessions = 10; this.Encoding = Encoding.UTF8; this.KeyExchangeAlgorithms = new Dictionary <string, Type> { { "diffie-hellman-group-exchange-sha256", typeof(KeyExchangeDiffieHellmanGroupExchangeSha256) }, { "diffie-hellman-group-exchange-sha1", typeof(KeyExchangeDiffieHellmanGroupExchangeSha1) }, { "diffie-hellman-group14-sha1", typeof(KeyExchangeDiffieHellmanGroup14Sha1) }, { "diffie-hellman-group1-sha1", typeof(KeyExchangeDiffieHellmanGroup1Sha1) }, //{"ecdh-sha2-nistp256", typeof(KeyExchangeEllipticCurveDiffieHellman)}, //{"ecdh-sha2-nistp256", typeof(...)}, //{"ecdh-sha2-nistp384", typeof(...)}, //{"ecdh-sha2-nistp521", typeof(...)}, //"gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==" - WinSSHD //"gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==" - WinSSHD }; this.Encryptions = new Dictionary <string, CipherInfo> { { "aes256-ctr", new CipherInfo(256, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null)) }, { "3des-cbc", new CipherInfo(192, (key, iv) => new TripleDesCipher(key, new CbcCipherMode(iv), null)) }, { "aes128-cbc", new CipherInfo(128, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), null)) }, { "aes192-cbc", new CipherInfo(192, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), null)) }, { "aes256-cbc", new CipherInfo(256, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), null)) }, { "blowfish-cbc", new CipherInfo(128, (key, iv) => new BlowfishCipher(key, new CbcCipherMode(iv), null)) }, { "twofish-cbc", new CipherInfo(256, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null)) }, { "twofish192-cbc", new CipherInfo(192, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null)) }, { "twofish128-cbc", new CipherInfo(128, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null)) }, { "twofish256-cbc", new CipherInfo(256, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null)) }, ////{"serpent256-cbc", typeof(CipherSerpent256CBC)}, ////{"serpent192-cbc", typeof(...)}, ////{"serpent128-cbc", typeof(...)}, { "arcfour", new CipherInfo(128, (key, iv) => new Arc4Cipher(key, false)) }, { "arcfour128", new CipherInfo(128, (key, iv) => new Arc4Cipher(key, true)) }, { "arcfour256", new CipherInfo(256, (key, iv) => new Arc4Cipher(key, true)) }, ////{"idea-cbc", typeof(...)}, { "cast128-cbc", new CipherInfo(128, (key, iv) => new CastCipher(key, new CbcCipherMode(iv), null)) }, ////{"*****@*****.**", typeof(...)}, { "aes128-ctr", new CipherInfo(128, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null)) }, { "aes192-ctr", new CipherInfo(192, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null)) }, }; this.HmacAlgorithms = new Dictionary <string, HashInfo> { { "hmac-md5", new HashInfo(16 * 8, key => new HMac <MD5Hash>(key)) }, { "hmac-sha1", new HashInfo(20 * 8, key => new HMac <SHA1Hash>(key)) }, { "hmac-sha2-256", new HashInfo(32 * 8, key => new HMac <SHA256Hash>(key)) }, { "hmac-sha2-256-96", new HashInfo(32 * 8, key => new HMac <SHA256Hash>(key, 96)) }, //{"hmac-sha2-512", new HashInfo(64 * 8, key => new HMac<SHA512Hash>(key))}, //{"hmac-sha2-512-96", new HashInfo(64 * 8, key => new HMac<SHA512Hash>(key, 96))}, //{"*****@*****.**", typeof(HMacSha1)}, { "hmac-ripemd160", new HashInfo(160, key => new HMac <RIPEMD160Hash>(key)) }, { "*****@*****.**", new HashInfo(160, key => new HMac <RIPEMD160Hash>(key)) }, { "hmac-md5-96", new HashInfo(16 * 8, key => new HMac <MD5Hash>(key, 96)) }, { "hmac-sha1-96", new HashInfo(20 * 8, key => new HMac <SHA1Hash>(key, 96)) }, //{"none", typeof(...)}, }; this.HostKeyAlgorithms = new Dictionary <string, Func <byte[], KeyHostAlgorithm> > { { "ssh-rsa", data => new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data) }, { "ssh-dss", data => new KeyHostAlgorithm("ssh-dss", new DsaKey(), data) }, //{"ecdsa-sha2-nistp256 "} //{"x509v3-sign-rsa", () => { ... }, //{"x509v3-sign-dss", () => { ... }, //{"spki-sign-rsa", () => { ... }, //{"spki-sign-dss", () => { ... }, //{"pgp-sign-rsa", () => { ... }, //{"pgp-sign-dss", () => { ... }, }; this.CompressionAlgorithms = new Dictionary <string, Type> { //{"*****@*****.**", typeof(ZlibOpenSsh)}, //{"zlib", typeof(Zlib)}, { "none", null }, }; this.ChannelRequests = new Dictionary <string, RequestInfo> { { EnvironmentVariableRequestInfo.NAME, new EnvironmentVariableRequestInfo() }, { ExecRequestInfo.NAME, new ExecRequestInfo() }, { ExitSignalRequestInfo.NAME, new ExitSignalRequestInfo() }, { ExitStatusRequestInfo.NAME, new ExitStatusRequestInfo() }, { PseudoTerminalRequestInfo.NAME, new PseudoTerminalRequestInfo() }, { ShellRequestInfo.NAME, new ShellRequestInfo() }, { SignalRequestInfo.NAME, new SignalRequestInfo() }, { SubsystemRequestInfo.NAME, new SubsystemRequestInfo() }, { WindowChangeRequestInfo.NAME, new WindowChangeRequestInfo() }, { X11ForwardingRequestInfo.NAME, new X11ForwardingRequestInfo() }, { XonXoffRequestInfo.NAME, new XonXoffRequestInfo() }, { EndOfWriteRequestInfo.NAME, new EndOfWriteRequestInfo() }, { KeepAliveRequestInfo.NAME, new KeepAliveRequestInfo() }, }; this.Host = host; this.Port = port; this.Username = username; this.ProxyType = proxyType; this.ProxyHost = proxyHost; this.ProxyPort = proxyPort; this.ProxyUsername = proxyUsername; this.ProxyPassword = proxyPassword; this.AuthenticationMethods = authenticationMethods; }
/// <summary> /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">Connection port.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> public KeyboardInteractiveConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, new KeyboardInteractiveAuthenticationMethod(username)) { foreach (var authenticationMethod in this.AuthenticationMethods.OfType<KeyboardInteractiveAuthenticationMethod>()) { authenticationMethod.AuthenticationPrompt += AuthenticationMethod_AuthenticationPrompt; } }
/// <summary> /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername) : this(host, ConnectionInfo.DEFAULT_PORT, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty) { }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> public PasswordConnectionInfo(string host, string username, string password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : this(host, ConnectionInfo.DEFAULT_PORT, username, Encoding.UTF8.GetBytes(password), proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) { }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">Connection port.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> /// <param name="authenticationMethods">The authentication methods.</param> /// <exception cref="ArgumentException"><paramref name="host"/> is invalid, or <paramref name="username"/> is null or contains whitespace characters.</exception> /// /// <exception cref="ArgumentOutOfRangeException"><paramref name="port"/> is not within <see cref="IPEndPoint.MinPort"/> and <see cref="IPEndPoint.MaxPort"/>.</exception> /// /// <exception cref="ArgumentException"><paramref name="username"/> is null or empty.</exception> public ConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, params AuthenticationMethod[] authenticationMethods) { if (!host.IsValidHost()) { throw new ArgumentException("host"); } if (!string.IsNullOrEmpty(proxyHost) && !proxyHost.IsValidHost()) { throw new ArgumentException("proxyHost"); } if (!port.IsValidPort()) { throw new ArgumentOutOfRangeException("port"); } if (!proxyPort.IsValidPort()) { throw new ArgumentOutOfRangeException("proxyPort"); } if (username.IsNullOrWhiteSpace()) { throw new ArgumentException("username"); } // Set default connection values this.Timeout = TimeSpan.FromSeconds(30); this.RetryAttempts = 10; this.MaxSessions = 100; this.KeyExchangeAlgorithms = new Dictionary <string, Type>() { { "diffie-hellman-group-exchange-sha256", typeof(KeyExchangeDiffieHellmanGroupExchangeSha256) }, { "diffie-hellman-group-exchange-sha1", typeof(KeyExchangeDiffieHellmanGroupExchangeSha1) }, { "diffie-hellman-group14-sha1", typeof(KeyExchangeDiffieHellmanGroup14Sha1) }, { "diffie-hellman-group1-sha1", typeof(KeyExchangeDiffieHellmanGroup1Sha1) }, }; this.Encryptions = new Dictionary <string, CipherInfo>() { //{"aes256-ctr", new CipherInfo(256, (key, iv)=>{ return new AesCipher(key, new CtrCipherMode(iv), null); }) }, { "3des-cbc", new CipherInfo(192, (key, iv) => { return(new TripleDesCipher(key, new CbcCipherMode(iv), null)); }) }, //{"aes128-cbc", new CipherInfo(128, (key, iv)=>{ return new AesCipher(key, new CbcCipherMode(iv), null); }) }, //{"aes192-cbc", new CipherInfo(192, (key, iv)=>{ return new AesCipher(key, new CbcCipherMode(iv), null); }) }, //{"aes256-cbc", new CipherInfo(256, (key, iv)=>{ return new AesCipher(key, new CbcCipherMode(iv), null); }) }, //{"blowfish-cbc", new CipherInfo(128, (key, iv)=>{ return new BlowfishCipher(key, new CbcCipherMode(iv), null); }) }, //{"cast128-cbc", new CipherInfo(128, (key, iv)=>{ return new CastCipher(key, new CbcCipherMode(iv), null); }) }, //{"aes128-ctr", new CipherInfo(128, (key, iv)=>{ return new AesCipher(key, new CtrCipherMode(iv), null); }) }, //{"aes192-ctr", new CipherInfo(192, (key, iv)=>{ return new AesCipher(key, new CtrCipherMode(iv), null); }) }, }; this.HmacAlgorithms = new Dictionary <string, Func <byte[], HashAlgorithm> >() { { "hmac-md5", (key) => { return(new HMac <MD5Hash>(key.Take(16).ToArray())); } }, //{"hmac-sha1", (key) => { return new HMac<SHA1Hash>(key.Take(20).ToArray());}}, //{"*****@*****.**", typeof(HMacSha1)}, //{"hmac-ripemd160", typeof(HMacSha1)}, //{"*****@*****.**", typeof(HMacSha1)}, //{"hmac-md5-96", typeof(...)}, //{"hmac-sha1-96", typeof(...)}, //{"none", typeof(...)}, }; this.HostKeyAlgorithms = new Dictionary <string, Func <byte[], KeyHostAlgorithm> >() { { "ssh-rsa", (data) => { return(new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data)); } }, //{"ssh-dss", (data) => { return new KeyHostAlgorithm("ssh-dss", new DsaKey(), data); }}, //{"x509v3-sign-rsa", () => { ... }, //{"x509v3-sign-dss", () => { ... }, //{"spki-sign-rsa", () => { ... }, //{"spki-sign-dss", () => { ... }, //{"pgp-sign-rsa", () => { ... }, //{"pgp-sign-dss", () => { ... }, }; this.CompressionAlgorithms = new Dictionary <string, Type>() { { "none", null }, //{"zlib", typeof(Zlib)}, //{"*****@*****.**", typeof(ZlibOpenSsh)}, }; this.ChannelRequests = new Dictionary <string, RequestInfo>() { { EnvironmentVariableRequestInfo.NAME, new EnvironmentVariableRequestInfo() }, { ExecRequestInfo.NAME, new ExecRequestInfo() }, { ExitSignalRequestInfo.NAME, new ExitSignalRequestInfo() }, { ExitStatusRequestInfo.NAME, new ExitStatusRequestInfo() }, { PseudoTerminalRequestInfo.NAME, new PseudoTerminalRequestInfo() }, { ShellRequestInfo.NAME, new ShellRequestInfo() }, { SignalRequestInfo.NAME, new SignalRequestInfo() }, { SubsystemRequestInfo.NAME, new SubsystemRequestInfo() }, { WindowChangeRequestInfo.NAME, new WindowChangeRequestInfo() }, // {X11ForwardingRequestInfo.NAME, new X11ForwardingRequestInfo()}, { XonXoffRequestInfo.NAME, new XonXoffRequestInfo() }, { EndOfWriteRequestInfo.NAME, new EndOfWriteRequestInfo() }, { KeepAliveRequestInfo.NAME, new KeepAliveRequestInfo() }, }; this.Host = host; this.Port = port; this.Username = username; this.ProxyType = proxyType; this.ProxyHost = proxyHost; this.ProxyPort = proxyPort; this.ProxyUsername = proxyUsername; this.ProxyPassword = proxyPassword; this.AuthenticationMethods = authenticationMethods; }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">The port.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> public PasswordConnectionInfo(string host, int port, string username, byte[] password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, new PasswordAuthenticationMethod(username, password)) { foreach (var authenticationMethod in AuthenticationMethods.OfType<PasswordAuthenticationMethod>()) { authenticationMethod.PasswordExpired += AuthenticationMethod_PasswordExpired; } }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> public PasswordConnectionInfo(string host, string username, string password, ProxyTypes proxyType, string proxyHost, int proxyPort) : this(host, DefaultPort, username, Encoding.UTF8.GetBytes(password), proxyType, proxyHost, proxyPort, string.Empty, string.Empty) { }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> public PasswordConnectionInfo(string host, string username, byte[] password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : this(host, DefaultPort, username, password, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) { }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">The port.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> public PasswordConnectionInfo(string host, int port, string username, byte[] password, ProxyTypes proxyType, string proxyHost, int proxyPort) : this(host, port, username, password, proxyType, proxyHost, proxyPort, string.Empty, string.Empty) { }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">The port.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> /// <param name="keyFiles">The key files.</param> public AgentConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, IAgentProtocol protocol) : base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, new AgentAuthenticationMethod(username,protocol)) { this.Protocol = protocol; }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> public PasswordConnectionInfo(string host, string username, string password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername) : this(host, 22, username, password, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty) { }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> /// <param name="keyFiles">The key files.</param> public PrivateKeyConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, params PrivateKeyFile[] keyFiles) : this(host, 22, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, keyFiles) { }
public MyProxy(string address, int port, ProxyTypes type, string login = null, string password = null) : base(address, port, type, login, password) { ErrorsCount = StartErrors; }
/// <summary> /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> public NoneConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort) : this(host, 22, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty) { }
/// <summary> /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">Connection port.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> public KeyboardInteractiveConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) { this._requestMessage = new RequestMessageKeyboardInteractive(ServiceName.Connection, username); }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="keyFiles">The key files.</param> public PrivateKeyConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, params PrivateKeyFile[] keyFiles) : this(host, DefaultPort, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty, keyFiles) { }
/// <summary> /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">Connection port.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> public KeyboardInteractiveConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort) : this(host, port, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty) { }
[Ignore] // placeholder for actual test public void PrivateKeyConnectionInfoConstructorTest5() { string host = string.Empty; // TODO: Initialize to an appropriate value int port = 0; // TODO: Initialize to an appropriate value string username = string.Empty; // TODO: Initialize to an appropriate value ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value string proxyHost = string.Empty; // TODO: Initialize to an appropriate value int proxyPort = 0; // TODO: Initialize to an appropriate value PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, port, username, proxyType, proxyHost, proxyPort, keyFiles); Assert.Inconclusive("TODO: Implement code to verify target"); }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> public PasswordConnectionInfo(string host, string username, string password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : this(host, DefaultPort, username, Encoding.UTF8.GetBytes(password), proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) { }
/// <summary> /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">Connection port.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> public NoneConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) { }
/// <summary> /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort) : this(host, ConnectionInfo.DEFAULT_PORT, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty) { }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">The port.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> public PasswordConnectionInfo(string host, int port, string username, byte[] password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername) : this(host, port, username, password, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty) { }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">The port.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> public PasswordConnectionInfo(string host, int port, string username, byte[] password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, new PasswordAuthenticationMethod(username, password)) { foreach (var authenticationMethod in this.AuthenticationMethods.OfType <PasswordAuthenticationMethod>()) { authenticationMethod.PasswordExpired += AuthenticationMethod_PasswordExpired; } }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionInfo" /> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">Connection port.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> /// <param name="authenticationMethods">The authentication methods.</param> /// <exception cref="ArgumentNullException"><paramref name="host"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException"><paramref name="username" /> is null, a zero-length string or contains only whitespace characters.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="port" /> is not within <see cref="F:System.Net.IPEndPoint.MinPort" /> and <see cref="F:System.Net.IPEndPoint.MaxPort" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="proxyType"/> is not <see cref="ProxyTypes.None"/> and <paramref name="proxyHost" /> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="proxyType"/> is not <see cref="ProxyTypes.None"/> and <paramref name="proxyPort" /> is not within <see cref="F:System.Net.IPEndPoint.MinPort" /> and <see cref="F:System.Net.IPEndPoint.MaxPort" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="authenticationMethods"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">No <paramref name="authenticationMethods"/> specified.</exception> public ConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, params AuthenticationMethod[] authenticationMethods) { if (host == null) throw new ArgumentNullException("host"); port.ValidatePort("port"); if (username == null) throw new ArgumentNullException("username"); if (username.All(char.IsWhiteSpace)) throw new ArgumentException("Cannot be empty or contain only whitespace.", "username"); if (proxyType != ProxyTypes.None) { if (proxyHost == null) throw new ArgumentNullException("proxyHost"); proxyPort.ValidatePort("proxyPort"); } if (authenticationMethods == null) throw new ArgumentNullException("authenticationMethods"); if (authenticationMethods.Length == 0) throw new ArgumentException("At least one authentication method should be specified.", "authenticationMethods"); // Set default connection values Timeout = TimeSpan.FromSeconds(30); RetryAttempts = 10; MaxSessions = 10; Encoding = Encoding.UTF8; KeyExchangeAlgorithms = new Dictionary<string, Type> { {"diffie-hellman-group-exchange-sha256", typeof (KeyExchangeDiffieHellmanGroupExchangeSha256)}, {"diffie-hellman-group-exchange-sha1", typeof (KeyExchangeDiffieHellmanGroupExchangeSha1)}, {"diffie-hellman-group14-sha1", typeof (KeyExchangeDiffieHellmanGroup14Sha1)}, {"diffie-hellman-group1-sha1", typeof (KeyExchangeDiffieHellmanGroup1Sha1)}, //{"ecdh-sha2-nistp256", typeof(KeyExchangeEllipticCurveDiffieHellman)}, //{"ecdh-sha2-nistp256", typeof(...)}, //{"ecdh-sha2-nistp384", typeof(...)}, //{"ecdh-sha2-nistp521", typeof(...)}, //"gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==" - WinSSHD //"gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==" - WinSSHD }; Encryptions = new Dictionary<string, CipherInfo> { {"aes256-ctr", new CipherInfo(256, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null))}, {"3des-cbc", new CipherInfo(192, (key, iv) => new TripleDesCipher(key, new CbcCipherMode(iv), null))}, {"aes128-cbc", new CipherInfo(128, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), null))}, {"aes192-cbc", new CipherInfo(192, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), null))}, {"aes256-cbc", new CipherInfo(256, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), null))}, {"blowfish-cbc", new CipherInfo(128, (key, iv) => new BlowfishCipher(key, new CbcCipherMode(iv), null))}, {"twofish-cbc", new CipherInfo(256, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null))}, {"twofish192-cbc", new CipherInfo(192, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null))}, {"twofish128-cbc", new CipherInfo(128, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null))}, {"twofish256-cbc", new CipherInfo(256, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null))}, ////{"serpent256-cbc", typeof(CipherSerpent256CBC)}, ////{"serpent192-cbc", typeof(...)}, ////{"serpent128-cbc", typeof(...)}, {"arcfour", new CipherInfo(128, (key, iv) => new Arc4Cipher(key, false))}, {"arcfour128", new CipherInfo(128, (key, iv) => new Arc4Cipher(key, true))}, {"arcfour256", new CipherInfo(256, (key, iv) => new Arc4Cipher(key, true))}, ////{"idea-cbc", typeof(...)}, {"cast128-cbc", new CipherInfo(128, (key, iv) => new CastCipher(key, new CbcCipherMode(iv), null))}, ////{"*****@*****.**", typeof(...)}, {"aes128-ctr", new CipherInfo(128, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null))}, {"aes192-ctr", new CipherInfo(192, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null))}, }; HmacAlgorithms = new Dictionary<string, HashInfo> { {"hmac-md5", new HashInfo(16*8, HashAlgorithmFactory.CreateHMACMD5)}, {"hmac-md5-96", new HashInfo(16*8, key => HashAlgorithmFactory.CreateHMACMD5(key, 96))}, {"hmac-sha1", new HashInfo(20*8, HashAlgorithmFactory.CreateHMACSHA1)}, {"hmac-sha1-96", new HashInfo(20*8, key => HashAlgorithmFactory.CreateHMACSHA1(key, 96))}, {"hmac-sha2-256", new HashInfo(32*8, HashAlgorithmFactory.CreateHMACSHA256)}, {"hmac-sha2-256-96", new HashInfo(32*8, key => HashAlgorithmFactory.CreateHMACSHA256(key, 96))}, {"hmac-sha2-512", new HashInfo(64 * 8, HashAlgorithmFactory.CreateHMACSHA512)}, {"hmac-sha2-512-96", new HashInfo(64 * 8, key => HashAlgorithmFactory.CreateHMACSHA512(key, 96))}, //{"*****@*****.**", typeof(HMacSha1)}, {"hmac-ripemd160", new HashInfo(160, HashAlgorithmFactory.CreateHMACRIPEMD160)}, {"*****@*****.**", new HashInfo(160, HashAlgorithmFactory.CreateHMACRIPEMD160)}, //{"none", typeof(...)}, }; HostKeyAlgorithms = new Dictionary<string, Func<byte[], KeyHostAlgorithm>> { {"ssh-rsa", data => new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data)}, {"ssh-dss", data => new KeyHostAlgorithm("ssh-dss", new DsaKey(), data)}, //{"ecdsa-sha2-nistp256 "} //{"x509v3-sign-rsa", () => { ... }, //{"x509v3-sign-dss", () => { ... }, //{"spki-sign-rsa", () => { ... }, //{"spki-sign-dss", () => { ... }, //{"pgp-sign-rsa", () => { ... }, //{"pgp-sign-dss", () => { ... }, }; CompressionAlgorithms = new Dictionary<string, Type> { //{"*****@*****.**", typeof(ZlibOpenSsh)}, //{"zlib", typeof(Zlib)}, {"none", null}, }; ChannelRequests = new Dictionary<string, RequestInfo> { {EnvironmentVariableRequestInfo.Name, new EnvironmentVariableRequestInfo()}, {ExecRequestInfo.Name, new ExecRequestInfo()}, {ExitSignalRequestInfo.Name, new ExitSignalRequestInfo()}, {ExitStatusRequestInfo.Name, new ExitStatusRequestInfo()}, {PseudoTerminalRequestInfo.Name, new PseudoTerminalRequestInfo()}, {ShellRequestInfo.Name, new ShellRequestInfo()}, {SignalRequestInfo.Name, new SignalRequestInfo()}, {SubsystemRequestInfo.Name, new SubsystemRequestInfo()}, {WindowChangeRequestInfo.Name, new WindowChangeRequestInfo()}, {X11ForwardingRequestInfo.Name, new X11ForwardingRequestInfo()}, {XonXoffRequestInfo.Name, new XonXoffRequestInfo()}, {EndOfWriteRequestInfo.Name, new EndOfWriteRequestInfo()}, {KeepAliveRequestInfo.Name, new KeepAliveRequestInfo()}, }; Host = host; Port = port; Username = username; ProxyType = proxyType; ProxyHost = proxyHost; ProxyPort = proxyPort; ProxyUsername = proxyUsername; ProxyPassword = proxyPassword; AuthenticationMethods = authenticationMethods; }
/// <summary> /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : this(host, DefaultPort, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) { }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">The port.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> public PasswordConnectionInfo(string host, int port, string username, string password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) { if (password == null) throw new ArgumentNullException("password"); this._password = password; this._requestMessage = new RequestMessagePassword(ServiceName.Connection, this.Username, password); }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="keyFiles">The key files.</param> public AgentConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, IAgentProtocol protocol) : this(host, 22, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty, protocol) { }
// TODO: DOCS Add exception documentation for this class. /// <summary> /// Initializes a new instance of the <see cref="ConnectionInfo" /> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">Connection port.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> /// <param name="authenticationMethods">The authentication methods.</param> /// <exception cref="System.ArgumentException">host</exception> /// <exception cref="System.ArgumentOutOfRangeException">proxyPort</exception> /// <exception cref="ArgumentException"><paramref name="host" /> is invalid, or <paramref name="username" /> is null or contains whitespace characters.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="port" /> is not within <see cref="F:System.Net.IPEndPoint.MinPort" /> and <see cref="F:System.Net.IPEndPoint.MaxPort" />.</exception> /// <exception cref="ArgumentException"><paramref name="host" /> is invalid, or <paramref name="username" /> is null or contains whitespace characters.</exception> public ConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, params AuthenticationMethod[] authenticationMethods) { if (!host.IsValidHost()) throw new ArgumentException("host"); if (proxyType != ProxyTypes.None) { if (string.IsNullOrEmpty(proxyHost) && !proxyHost.IsValidHost()) throw new ArgumentException("proxyHost"); if (!proxyPort.IsValidPort()) throw new ArgumentOutOfRangeException("proxyPort"); } if (!port.IsValidPort()) throw new ArgumentOutOfRangeException("port"); if (username.IsNullOrWhiteSpace()) throw new ArgumentException("username"); if (authenticationMethods == null || authenticationMethods.Length < 1) throw new ArgumentException("authenticationMethods"); // Set default connection values this.Timeout = TimeSpan.FromSeconds(30); this.RetryAttempts = 10; this.MaxSessions = 10; this.Encoding = Encoding.UTF8; this.KeyExchangeAlgorithms = new Dictionary<string, Type>() { {"diffie-hellman-group-exchange-sha256", typeof(KeyExchangeDiffieHellmanGroupExchangeSha256)}, {"diffie-hellman-group-exchange-sha1", typeof(KeyExchangeDiffieHellmanGroupExchangeSha1)}, {"diffie-hellman-group14-sha1", typeof(KeyExchangeDiffieHellmanGroup14Sha1)}, {"diffie-hellman-group1-sha1", typeof(KeyExchangeDiffieHellmanGroup1Sha1)}, //{"ecdh-sha2-nistp256", typeof(KeyExchangeEllipticCurveDiffieHellman)}, //{"ecdh-sha2-nistp256", typeof(...)}, //{"ecdh-sha2-nistp384", typeof(...)}, //{"ecdh-sha2-nistp521", typeof(...)}, //"gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==" - WinSSHD //"gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==" - WinSSHD }; this.Encryptions = new Dictionary<string, CipherInfo>() { {"aes256-ctr", new CipherInfo(256, (key, iv)=>{ return new AesCipher(key, new CtrCipherMode(iv), null); }) }, {"3des-cbc", new CipherInfo(192, (key, iv)=>{ return new TripleDesCipher(key, new CbcCipherMode(iv), null); }) }, {"aes128-cbc", new CipherInfo(128, (key, iv)=>{ return new AesCipher(key, new CbcCipherMode(iv), null); }) }, {"aes192-cbc", new CipherInfo(192, (key, iv)=>{ return new AesCipher(key, new CbcCipherMode(iv), null); }) }, {"aes256-cbc", new CipherInfo(256, (key, iv)=>{ return new AesCipher(key, new CbcCipherMode(iv), null); }) }, {"blowfish-cbc", new CipherInfo(128, (key, iv)=>{ return new BlowfishCipher(key, new CbcCipherMode(iv), null); }) }, {"twofish-cbc", new CipherInfo(256, (key, iv)=>{ return new TwofishCipher(key, new CbcCipherMode(iv), null); }) }, {"twofish192-cbc", new CipherInfo(192, (key, iv)=>{ return new TwofishCipher(key, new CbcCipherMode(iv), null); }) }, {"twofish128-cbc", new CipherInfo(128, (key, iv)=>{ return new TwofishCipher(key, new CbcCipherMode(iv), null); }) }, {"twofish256-cbc", new CipherInfo(256, (key, iv)=>{ return new TwofishCipher(key, new CbcCipherMode(iv), null); }) }, ////{"serpent256-cbc", typeof(CipherSerpent256CBC)}, ////{"serpent192-cbc", typeof(...)}, ////{"serpent128-cbc", typeof(...)}, {"arcfour", new CipherInfo(128, (key, iv)=>{ return new Arc4Cipher(key, false); }) }, {"arcfour128", new CipherInfo(128, (key, iv)=>{ return new Arc4Cipher(key, true); }) }, {"arcfour256", new CipherInfo(256, (key, iv)=>{ return new Arc4Cipher(key, true); }) }, ////{"idea-cbc", typeof(...)}, {"cast128-cbc", new CipherInfo(128, (key, iv)=>{ return new CastCipher(key, new CbcCipherMode(iv), null); }) }, ////{"*****@*****.**", typeof(...)}, {"aes128-ctr", new CipherInfo(128, (key, iv)=>{ return new AesCipher(key, new CtrCipherMode(iv), null); }) }, {"aes192-ctr", new CipherInfo(192, (key, iv)=>{ return new AesCipher(key, new CtrCipherMode(iv), null); }) }, }; this.HmacAlgorithms = new Dictionary<string, HashInfo>() { {"hmac-md5", new HashInfo(16 * 8, (key)=>{ return new HMac<MD5Hash>(key); }) }, {"hmac-sha1", new HashInfo(20 * 8, (key)=>{ return new HMac<SHA1Hash>(key); }) }, {"hmac-sha2-256", new HashInfo(32 * 8, (key)=>{ return new HMac<SHA256Hash>(key); }) }, {"hmac-sha2-256-96", new HashInfo(32 * 8, (key)=>{ return new HMac<SHA256Hash>(key, 96); }) }, //{"hmac-sha2-512", new HashInfo(64 * 8, (key)=>{ return new HMac<SHA512Hash>(key); }) }, //{"hmac-sha2-512-96", new HashInfo(64 * 8, (key)=>{ return new HMac<SHA512Hash>(key, 96); }) }, //{"*****@*****.**", typeof(HMacSha1)}, {"hmac-ripemd160", new HashInfo(160, (key)=>{ return new HMac<RIPEMD160Hash>(key); }) }, {"*****@*****.**", new HashInfo(160, (key)=>{ return new HMac<RIPEMD160Hash>(key); }) }, {"hmac-md5-96", new HashInfo(16 * 8, (key)=>{ return new HMac<MD5Hash>(key, 96); }) }, {"hmac-sha1-96", new HashInfo(20 * 8, (key)=>{ return new HMac<SHA1Hash>(key, 96); }) }, //{"none", typeof(...)}, }; this.HostKeyAlgorithms = new Dictionary<string, Func<byte[], KeyHostAlgorithm>>() { {"ssh-rsa", (data) => { return new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data); }}, {"ssh-dss", (data) => { return new KeyHostAlgorithm("ssh-dss", new DsaKey(), data); }}, //{"ecdsa-sha2-nistp256 "} //{"x509v3-sign-rsa", () => { ... }, //{"x509v3-sign-dss", () => { ... }, //{"spki-sign-rsa", () => { ... }, //{"spki-sign-dss", () => { ... }, //{"pgp-sign-rsa", () => { ... }, //{"pgp-sign-dss", () => { ... }, }; this.CompressionAlgorithms = new Dictionary<string, Type>() { //{"*****@*****.**", typeof(ZlibOpenSsh)}, //{"zlib", typeof(Zlib)}, {"none", null}, }; this.ChannelRequests = new Dictionary<string, RequestInfo>() { {EnvironmentVariableRequestInfo.NAME, new EnvironmentVariableRequestInfo()}, {ExecRequestInfo.NAME, new ExecRequestInfo()}, {ExitSignalRequestInfo.NAME, new ExitSignalRequestInfo()}, {ExitStatusRequestInfo.NAME, new ExitStatusRequestInfo()}, {PseudoTerminalRequestInfo.NAME, new PseudoTerminalRequestInfo()}, {ShellRequestInfo.NAME, new ShellRequestInfo()}, {SignalRequestInfo.NAME, new SignalRequestInfo()}, {SubsystemRequestInfo.NAME, new SubsystemRequestInfo()}, {WindowChangeRequestInfo.NAME, new WindowChangeRequestInfo()}, {X11ForwardingRequestInfo.NAME, new X11ForwardingRequestInfo()}, {XonXoffRequestInfo.NAME, new XonXoffRequestInfo()}, {EndOfWriteRequestInfo.NAME, new EndOfWriteRequestInfo()}, {KeepAliveRequestInfo.NAME, new KeepAliveRequestInfo()}, }; this.Host = host; this.Port = port; this.Username = username; this.ProxyType = proxyType; this.ProxyHost = proxyHost; this.ProxyPort = proxyPort; this.ProxyUsername = proxyUsername; this.ProxyPassword = proxyPassword; this.AuthenticationMethods = authenticationMethods; }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="keyFiles">The key files.</param> public PrivateKeyConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, params PrivateKeyFile[] keyFiles) : this(host, ConnectionInfo.DEFAULT_PORT, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty, keyFiles) { }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> public PasswordConnectionInfo(string host, string username, byte[] password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : this(host, ConnectionInfo.DEFAULT_PORT, username, password, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) { }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="keyFiles">The key files.</param> public PrivateKeyConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, params PrivateKeyFile[] keyFiles) : this(host, DefaultPort, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty, keyFiles) { }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> public PasswordConnectionInfo(string host, string username, string password, ProxyTypes proxyType, string proxyHost, int proxyPort) : this(host, ConnectionInfo.DEFAULT_PORT, username, Encoding.UTF8.GetBytes(password), proxyType, proxyHost, proxyPort, string.Empty, string.Empty) { }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="username">Connection username.</param> /// <param name="password">Connection password.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> public PasswordConnectionInfo(string host, string username, byte[] password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername) : this(host, ConnectionInfo.DEFAULT_PORT, username, password, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty) { }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionInfo" /> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">Connection port.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> /// <param name="authenticationMethods">The authentication methods.</param> /// <exception cref="ArgumentNullException"><paramref name="host"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException"><paramref name="username" /> is <c>null</c>, a zero-length string or contains only whitespace characters.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="port" /> is not within <see cref="F:System.Net.IPEndPoint.MinPort" /> and <see cref="F:System.Net.IPEndPoint.MaxPort" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="proxyType"/> is not <see cref="ProxyTypes.None"/> and <paramref name="proxyHost" /> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="proxyType"/> is not <see cref="ProxyTypes.None"/> and <paramref name="proxyPort" /> is not within <see cref="F:System.Net.IPEndPoint.MinPort" /> and <see cref="F:System.Net.IPEndPoint.MaxPort" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="authenticationMethods"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">No <paramref name="authenticationMethods"/> specified.</exception> public ConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, params AuthenticationMethod[] authenticationMethods) { if (host == null) { throw new ArgumentNullException("host"); } port.ValidatePort("port"); if (username == null) { throw new ArgumentNullException("username"); } if (username.All(char.IsWhiteSpace)) { throw new ArgumentException("Cannot be empty or contain only whitespace.", "username"); } if (proxyType != ProxyTypes.None) { if (proxyHost == null) { throw new ArgumentNullException("proxyHost"); } proxyPort.ValidatePort("proxyPort"); } if (authenticationMethods == null) { throw new ArgumentNullException("authenticationMethods"); } if (authenticationMethods.Length == 0) { throw new ArgumentException("At least one authentication method should be specified.", "authenticationMethods"); } // Set default connection values Timeout = DefaultTimeout; ChannelCloseTimeout = DefaultChannelCloseTimeout; RetryAttempts = 10; MaxSessions = 10; Encoding = Encoding.UTF8; KeyExchangeAlgorithms = new Dictionary <string, Type> { { "curve25519-sha256", typeof(KeyExchangeECCurve25519) }, { "*****@*****.**", typeof(KeyExchangeECCurve25519) }, { "ecdh-sha2-nistp256", typeof(KeyExchangeECDH256) }, { "ecdh-sha2-nistp384", typeof(KeyExchangeECDH384) }, { "ecdh-sha2-nistp521", typeof(KeyExchangeECDH521) }, { "diffie-hellman-group-exchange-sha256", typeof(KeyExchangeDiffieHellmanGroupExchangeSha256) }, { "diffie-hellman-group-exchange-sha1", typeof(KeyExchangeDiffieHellmanGroupExchangeSha1) }, { "diffie-hellman-group16-sha512", typeof(KeyExchangeDiffieHellmanGroup16Sha512) }, { "diffie-hellman-group14-sha256", typeof(KeyExchangeDiffieHellmanGroup14Sha256) }, { "diffie-hellman-group14-sha1", typeof(KeyExchangeDiffieHellmanGroup14Sha1) }, { "diffie-hellman-group1-sha1", typeof(KeyExchangeDiffieHellmanGroup1Sha1) }, }; Encryptions = new Dictionary <string, CipherInfo> { { "aes256-ctr", new CipherInfo(256, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null)) }, { "3des-cbc", new CipherInfo(192, (key, iv) => new TripleDesCipher(key, new CbcCipherMode(iv), null)) }, { "aes128-cbc", new CipherInfo(128, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), null)) }, { "aes192-cbc", new CipherInfo(192, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), null)) }, { "aes256-cbc", new CipherInfo(256, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), null)) }, { "blowfish-cbc", new CipherInfo(128, (key, iv) => new BlowfishCipher(key, new CbcCipherMode(iv), null)) }, { "twofish-cbc", new CipherInfo(256, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null)) }, { "twofish192-cbc", new CipherInfo(192, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null)) }, { "twofish128-cbc", new CipherInfo(128, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null)) }, { "twofish256-cbc", new CipherInfo(256, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null)) }, ////{"serpent256-cbc", typeof(CipherSerpent256CBC)}, ////{"serpent192-cbc", typeof(...)}, ////{"serpent128-cbc", typeof(...)}, { "arcfour", new CipherInfo(128, (key, iv) => new Arc4Cipher(key, false)) }, { "arcfour128", new CipherInfo(128, (key, iv) => new Arc4Cipher(key, true)) }, { "arcfour256", new CipherInfo(256, (key, iv) => new Arc4Cipher(key, true)) }, ////{"idea-cbc", typeof(...)}, { "cast128-cbc", new CipherInfo(128, (key, iv) => new CastCipher(key, new CbcCipherMode(iv), null)) }, ////{"*****@*****.**", typeof(...)}, { "aes128-ctr", new CipherInfo(128, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null)) }, { "aes192-ctr", new CipherInfo(192, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null)) }, }; HmacAlgorithms = new Dictionary <string, HashInfo> { { "hmac-sha1", new HashInfo(20 * 8, CryptoAbstraction.CreateHMACSHA1) }, { "hmac-sha1-96", new HashInfo(20 * 8, key => CryptoAbstraction.CreateHMACSHA1(key, 96)) }, { "hmac-sha2-256", new HashInfo(32 * 8, CryptoAbstraction.CreateHMACSHA256) }, { "hmac-sha2-256-96", new HashInfo(32 * 8, key => CryptoAbstraction.CreateHMACSHA256(key, 96)) }, { "hmac-sha2-512", new HashInfo(64 * 8, CryptoAbstraction.CreateHMACSHA512) }, { "hmac-sha2-512-96", new HashInfo(64 * 8, key => CryptoAbstraction.CreateHMACSHA512(key, 96)) }, //{"*****@*****.**", typeof(HMacSha1)}, { "hmac-ripemd160", new HashInfo(160, CryptoAbstraction.CreateHMACRIPEMD160) }, { "*****@*****.**", new HashInfo(160, CryptoAbstraction.CreateHMACRIPEMD160) }, //{"none", typeof(...)}, }; HostKeyAlgorithms = new Dictionary <string, Func <byte[], KeyHostAlgorithm> > { { "ssh-ed25519", data => new KeyHostAlgorithm("ssh-ed25519", new ED25519Key(), data) }, #if FEATURE_ECDSA { "ecdsa-sha2-nistp256", data => new KeyHostAlgorithm("ecdsa-sha2-nistp256", new EcdsaKey(), data) }, { "ecdsa-sha2-nistp384", data => new KeyHostAlgorithm("ecdsa-sha2-nistp384", new EcdsaKey(), data) }, { "ecdsa-sha2-nistp521", data => new KeyHostAlgorithm("ecdsa-sha2-nistp521", new EcdsaKey(), data) }, #endif { "ssh-rsa", data => new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data) }, { "ssh-dss", data => new KeyHostAlgorithm("ssh-dss", new DsaKey(), data) }, //{"x509v3-sign-rsa", () => { ... }, //{"x509v3-sign-dss", () => { ... }, //{"spki-sign-rsa", () => { ... }, //{"spki-sign-dss", () => { ... }, //{"pgp-sign-rsa", () => { ... }, //{"pgp-sign-dss", () => { ... }, }; CompressionAlgorithms = new Dictionary <string, Type> { //{"*****@*****.**", typeof(ZlibOpenSsh)}, //{"zlib", typeof(Zlib)}, { "none", null }, }; ChannelRequests = new Dictionary <string, RequestInfo> { { EnvironmentVariableRequestInfo.Name, new EnvironmentVariableRequestInfo() }, { ExecRequestInfo.Name, new ExecRequestInfo() }, { ExitSignalRequestInfo.Name, new ExitSignalRequestInfo() }, { ExitStatusRequestInfo.Name, new ExitStatusRequestInfo() }, { PseudoTerminalRequestInfo.Name, new PseudoTerminalRequestInfo() }, { ShellRequestInfo.Name, new ShellRequestInfo() }, { SignalRequestInfo.Name, new SignalRequestInfo() }, { SubsystemRequestInfo.Name, new SubsystemRequestInfo() }, { WindowChangeRequestInfo.Name, new WindowChangeRequestInfo() }, { X11ForwardingRequestInfo.Name, new X11ForwardingRequestInfo() }, { XonXoffRequestInfo.Name, new XonXoffRequestInfo() }, { EndOfWriteRequestInfo.Name, new EndOfWriteRequestInfo() }, { KeepAliveRequestInfo.Name, new KeepAliveRequestInfo() }, }; Host = host; Port = port; Username = username; ProxyType = proxyType; ProxyHost = proxyHost; ProxyPort = proxyPort; ProxyUsername = proxyUsername; ProxyPassword = proxyPassword; AuthenticationMethods = authenticationMethods; }
/// <summary> /// Initializes a new instance of the <see cref="PasswordConnectionInfo"/> class. /// </summary> /// <param name="host">Connection host.</param> /// <param name="port">The port.</param> /// <param name="username">Connection username.</param> /// <param name="proxyType">Type of the proxy.</param> /// <param name="proxyHost">The proxy host.</param> /// <param name="proxyPort">The proxy port.</param> /// <param name="proxyUsername">The proxy username.</param> /// <param name="proxyPassword">The proxy password.</param> /// <param name="keyFiles">The key files.</param> public PrivateKeyConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, params PrivateKeyFile[] keyFiles) : base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, new PrivateKeyAuthenticationMethod(username, keyFiles)) { this.KeyFiles = new Collection<PrivateKeyFile>(keyFiles); }