public static Cipher CreateCipher(SSHProtocol protocol, CipherAlgorithm algorithm, byte[] key) { if (protocol == SSHProtocol.SSH1) { switch (algorithm) { case CipherAlgorithm.TripleDES: return(new SSH1.TripleDESCipher1(key)); case CipherAlgorithm.Blowfish: return(new SSH1.BlowfishCipher1(key)); default: throw new SSHException("unknown algorithm " + algorithm); } } else { switch (algorithm) { case CipherAlgorithm.TripleDES: return(new SSH2.TripleDESCipher2(key)); case CipherAlgorithm.Blowfish: return(new SSH2.BlowfishCipher2(key)); default: throw new SSHException("unknown algorithm " + algorithm); } } }
public static Cipher CreateCipher(SSHProtocol protocol, CipherAlgorithm algorithm, byte[] key, byte[] iv) { if (protocol == SSHProtocol.SSH1) { //ignoring iv return CreateCipher(protocol, algorithm, key); } else { switch (algorithm) { case CipherAlgorithm.TripleDES: return new SSH2.TripleDESCipher2(key, iv); case CipherAlgorithm.Blowfish: return new SSH2.BlowfishCipher2(key, iv); case CipherAlgorithm.AES128: case CipherAlgorithm.AES192: case CipherAlgorithm.AES256: case CipherAlgorithm.AES128CTR: case CipherAlgorithm.AES192CTR: case CipherAlgorithm.AES256CTR: //return new RijindaelManagedCipher(key, iv, algorithm); return new SSH2.RijindaelCipher2(key, iv, algorithm); default: throw new SSHException("unknown algorithm " + algorithm); } } }
public static Cipher CreateCipher(SSHProtocol protocol, CipherAlgorithm algorithm, byte[] key, byte[] iv) { if (protocol == SSHProtocol.SSH1) //ignoring iv { return(CreateCipher(protocol, algorithm, key)); } else { switch (algorithm) { case CipherAlgorithm.TripleDES: return(new SSH2.TripleDESCipher2(key, iv)); case CipherAlgorithm.Blowfish: return(new SSH2.BlowfishCipher2(key, iv)); case CipherAlgorithm.AES128: case CipherAlgorithm.AES192: case CipherAlgorithm.AES256: case CipherAlgorithm.AES128CTR: case CipherAlgorithm.AES192CTR: case CipherAlgorithm.AES256CTR: return(new SSH2.RijindaelCipher2(key, iv, algorithm)); default: throw new SSHException("unknown algorithm " + algorithm); } } }
public SSHLoginParameter() { _method = SSHProtocol.SSH2; _authType = AuthenticationType.Password; _passwordOrPassphrase = ""; _identityFile = ""; _letUserInputPassword = true; this.Port = 22; }
/// <summary> /// Get version string of the Granados. /// </summary> /// <param name="p">SSH protocol type</param> /// <returns>a version string</returns> public static string ClientVersionString(SSHProtocol p) { Assembly assy = Assembly.GetAssembly(typeof(SSHUtil)); Version ver = assy.GetName().Version; string s = String.Format("{0}-{1}.{2}", (p == SSHProtocol.SSH1) ? "SSH-1.5-Granados" : "SSH-2.0-Granados", ver.Major, ver.Minor); return(s); }
private void ThrowVersionMismatchException(string version, SSHProtocol client) { StringBuilder bld = new StringBuilder(); bld.Append("The protocol version of the server ["); bld.Append(version); bld.Append("] is not compatible with "); bld.Append(client.ToString()); ThrowSSHException(bld.ToString()); }
/// <summary> /// Login with root privileges /// </summary> /// <param name="sshProtocol"><see cref=" SSHProtocol"/></param> private static void LoginAsRoot(SSHProtocol sshProtocol) { sshProtocol.Send("su -"); string resultString = sshProtocol.Send("\n"); if (resultString.Contains("Password", StringComparison.CurrentCultureIgnoreCase)) { sshProtocol.Send(PASSWORD); sshProtocol.Send("\n"); } }
public SSHLoginParameter(SSHLoginParameter src) : base(src) { _method = src._method; _authType = src._authType; _account = src._account; _identityFile = src._identityFile; _passwordOrPassphrase = src._passwordOrPassphrase; _letUserInputPassword = src._letUserInputPassword; _agentForward = src._agentForward; }
public SSHConnectionParameter() { _authtype = AuthenticationType.Password; _terminalname = "vt100"; _width = 80; _height = 25; _protocol = SSHProtocol.SSH2; _cipherAlgorithms = new CipherAlgorithm[] { CipherAlgorithm.AES256CTR, CipherAlgorithm.AES256, CipherAlgorithm.AES192CTR, CipherAlgorithm.AES192, CipherAlgorithm.AES128CTR, CipherAlgorithm.AES128, CipherAlgorithm.Blowfish, CipherAlgorithm.TripleDES }; _hostkeyAlgorithms = new PublicKeyAlgorithm[] { PublicKeyAlgorithm.DSA, PublicKeyAlgorithm.RSA }; _windowsize = 0x1000; _maxpacketsize = 0x10000; _checkMACError = true; _tracer = null; }
public static Cipher CreateCipher(SSHProtocol protocol, CipherAlgorithm algorithm, byte[] key) { if (protocol == SSHProtocol.SSH1) { throw new SSHException("SSH1 is not supported"); } else { switch (algorithm) { case CipherAlgorithm.TripleDES: return new SSH2.TripleDESCipher2(key); case CipherAlgorithm.Blowfish: return new SSH2.BlowfishCipher2(key); default: throw new SSHException("unknown algorithm " + algorithm); } } }
/// <summary> /// Constructor /// </summary> /// <param name="hostName">Host name</param> /// <param name="portNumber">port number</param> /// <param name="protocol">SSH protocol version</param> /// <param name="authType">authentication type</param> /// <param name="userName">user name for login</param> /// <param name="password">password for login. pass empty string for the keyboard interactive mode.</param> public SSHConnectionParameter(string hostName, int portNumber, SSHProtocol protocol, AuthenticationType authType, string userName, string password) { HostName = hostName; PortNumber = portNumber; Protocol = protocol; PreferableCipherAlgorithms = new CipherAlgorithm[] { CipherAlgorithm.AES256CTR, CipherAlgorithm.AES256, CipherAlgorithm.AES192CTR, CipherAlgorithm.AES192, CipherAlgorithm.AES128CTR, CipherAlgorithm.AES128, CipherAlgorithm.Blowfish, CipherAlgorithm.TripleDES }; PreferableHostKeyAlgorithms = new PublicKeyAlgorithm[] { PublicKeyAlgorithm.DSA, PublicKeyAlgorithm.RSA }; AuthenticationType = authType; UserName = userName; Password = password; TerminalName = "vt100"; WindowSize = 0x1000; MaxPacketSize = 0x10000; CheckMACError = true; }
public SSHConnectionParameter() { _random = new Random(); _authtype = AuthenticationType.Password; _terminalname = "vt100"; _width = 80; _height = 25; _protocol = SSHProtocol.SSH2; _cipherAlgorithms = new CipherAlgorithm[] { CipherAlgorithm.AES128, CipherAlgorithm.Blowfish, CipherAlgorithm.TripleDES }; _hostkeyAlgorithms = new PublicKeyAlgorithm[] { PublicKeyAlgorithm.DSA, PublicKeyAlgorithm.RSA }; _windowsize = 0x1000; _maxpacketsize = 0x10000; _checkMACError = true; _ssh1VersionEOL = "\n"; }
/// <summary> /// Constructor /// </summary> /// <param name="hostName">Host name</param> /// <param name="portNumber">port number</param> /// <param name="protocol">SSH protocol version</param> /// <param name="authType">authentication type</param> /// <param name="userName">user name for login</param> /// <param name="password">password for login. pass empty string for the keyboard interactive mode.</param> public SSHConnectionParameter(string hostName, int portNumber, SSHProtocol protocol, AuthenticationType authType, string userName, string password) { HostName = hostName; PortNumber = portNumber; Protocol = protocol; PreferableCipherAlgorithms = new CipherAlgorithm[] { CipherAlgorithm.AES256CTR, CipherAlgorithm.AES256, CipherAlgorithm.AES192CTR, CipherAlgorithm.AES192, CipherAlgorithm.AES128CTR, CipherAlgorithm.AES128, CipherAlgorithm.Blowfish, CipherAlgorithm.TripleDES }; PreferableHostKeyAlgorithms = new PublicKeyAlgorithm[] { PublicKeyAlgorithm.DSA, PublicKeyAlgorithm.RSA }; AuthenticationType = authType; UserName = userName; Password = password; TerminalName = "vt100"; WindowSize = 0x1000; MaxPacketSize = 0x10000; CheckMACError = true; VerifySSHHostKey = p => true; }
/// <summary> /// Execute command on Linux server /// </summary> /// <param name="address">Linux server IP Address</param> /// <param name="command">Command to be executed</param> public static string ExecuteCommand(IPAddress address, string command) { TraceFactory.Logger.Debug("Executing command: {0}".FormatWith(command)); SSHProtocol sshProtocol = new SSHProtocol(USER_NAME, PASSWORD, address); if (sshProtocol.Connect()) { // Login as root before executing commands LoginAsRoot(sshProtocol); sshProtocol.Send(command); return(sshProtocol.Send("\n")); } else { return(string.Empty); } }
public SSHConnectionParameter() { AuthenticationType = AuthenticationType.Password; TerminalName = "vt100"; TerminalWidth = 80; TerminalHeight = 25; _protocol = SSHProtocol.SSH2; PreferableCipherAlgorithms = new[] { CipherAlgorithm.AES256CTR, CipherAlgorithm.AES256, CipherAlgorithm.AES192CTR, CipherAlgorithm.AES192, CipherAlgorithm.AES128CTR, CipherAlgorithm.AES128, CipherAlgorithm.Blowfish, CipherAlgorithm.TripleDES }; PreferableHostKeyAlgorithms = new[] {PublicKeyAlgorithm.DSA, PublicKeyAlgorithm.RSA}; WindowSize = 0x1000; MaxPacketSize = 0x10000; CheckMACError = true; EventTracer = null; }
private void SSHSuccess(SSHProtocol sshprotocol) { ProtocolServiceTestPlugin.Instance.Reset(); ISSHLoginParameter ssh = _protocolService.CreateDefaultSSHParameter(); ssh.Method = sshprotocol; ssh.Account = UnitTestUtil.GetUnitTestConfig("protocols.ssh_account"); ssh.PasswordOrPassphrase = UnitTestUtil.GetUnitTestConfig("protocols.ssh_password"); ITCPParameter tcp = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter)); tcp.Destination = GetSSHConnectableHost(); Assert.AreEqual(22, tcp.Port); ResultCallback client = new ResultCallback(); IInterruptable t = _protocolService.AsyncSSHConnect(client, ssh); client.AssertSuccess(); ProtocolServiceTestPlugin.Instance.AssertSuccess(); }
private ITerminalConnection CreateSSHConnection(SSHProtocol sshprotocol) { ISSHLoginParameter ssh = _protocolService.CreateDefaultSSHParameter(); ssh.Method = sshprotocol; ssh.Account = UnitTestUtil.GetUnitTestConfig("protocols.ssh_account"); ssh.PasswordOrPassphrase = UnitTestUtil.GetUnitTestConfig("protocols.ssh_password"); ITCPParameter tcp = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter)); tcp.Destination = UnitTestUtil.GetUnitTestConfig("protocols.ssh_connectable"); Debug.Assert(tcp.Port == 22); ISynchronizedConnector sc = _protocolService.CreateFormBasedSynchronozedConnector(null); IInterruptable t = _protocolService.AsyncSSHConnect(sc.InterruptableConnectorClient, ssh); ITerminalConnection con = sc.WaitConnection(t, 5000); Debug.Assert(con.Destination == ssh); _rawsocket = ((InterruptableConnector)t).RawSocket; _testReceiver = new TestReceiver(); con.Socket.RepeatAsyncRead(_testReceiver); return(con); }
/// <summary> /// Verify server version /// </summary> /// <param name="protocol">expected protocol version</param> /// <exception cref="SSHException">server version doesn't match</exception> public void Verify(SSHProtocol protocol) { if (_serverVersion == null) { throw new SSHException(Strings.GetString("NotSSHServer")); } string[] sv = _serverVersion.Split('-'); if (sv.Length >= 3 && sv[0] == "SSH") { string protocolVersion = sv[1]; string[] pv = protocolVersion.Split('.'); if (pv.Length >= 2) { if (protocol == SSHProtocol.SSH1) { if (pv[0] == "1") { return; // OK } } else if (protocol == SSHProtocol.SSH2) { if (pv[0] == "2" || (pv[0] == "1" && pv[1] == "99")) { return; // OK } } throw new SSHException( String.Format(Strings.GetString("IncompatibleProtocolVersion"), _serverVersion, protocol.ToString())); } } throw new SSHException( String.Format(Strings.GetString("InvalidServerVersionFormat"), _serverVersion)); }
public static Cipher CreateCipher(SSHProtocol protocol, CipherAlgorithm algorithm, byte[] key, byte[] iv) { if(protocol==SSHProtocol.SSH1) { return CreateCipher(protocol, algorithm, key); } else { switch(algorithm) { case CipherAlgorithm.TripleDES: return new TripleDESCipher2(key, iv); case CipherAlgorithm.Blowfish: return new BlowfishCipher2(key, iv); case CipherAlgorithm.AES128: return new RijindaelCipher2(key, iv); default: throw new SSHException("unknown algorithm " + algorithm); } } }
private void SSHBadPassword(SSHProtocol sshprotocol) { ProtocolServiceTestPlugin.Instance.Reset(); ISSHLoginParameter ssh = _protocolService.CreateDefaultSSHParameter(); ssh.Method = sshprotocol; ssh.Account = UnitTestUtil.GetUnitTestConfig("protocols.ssh_account"); ssh.PasswordOrPassphrase = UnitTestUtil.GetUnitTestConfig("protocols.ssh_wrongpassword"); ITCPParameter tcp = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter)); tcp.Destination = GetSSHConnectableHost(); Assert.AreEqual(22, tcp.Port); ResultCallback client = new ResultCallback(); IInterruptable t = _protocolService.AsyncSSHConnect(client, ssh); client.AssertFail(); ProtocolServiceTestPlugin.Instance.AssertFail(); Socket s = ((InterruptableConnector)t).RawSocket; Assert.IsFalse(s.Connected); }
private ITerminalConnection CreateSSHConnection(SSHProtocol sshprotocol) { ISSHLoginParameter ssh = _protocolService.CreateDefaultSSHParameter(); ssh.Method = sshprotocol; ssh.Account = UnitTestUtil.GetUnitTestConfig("protocols.ssh_account"); ssh.PasswordOrPassphrase = UnitTestUtil.GetUnitTestConfig("protocols.ssh_password"); ITCPParameter tcp = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter)); tcp.Destination = UnitTestUtil.GetUnitTestConfig("protocols.ssh_connectable"); Debug.Assert(tcp.Port==22); ISynchronizedConnector sc = _protocolService.CreateFormBasedSynchronozedConnector(null); IInterruptable t = _protocolService.AsyncSSHConnect(sc.InterruptableConnectorClient, ssh); ITerminalConnection con = sc.WaitConnection(t, 5000); Debug.Assert(con.Destination==ssh); _rawsocket = ((InterruptableConnector)t).RawSocket; _testReceiver = new TestReceiver(); con.Socket.RepeatAsyncRead(_testReceiver); return con; }
/// <summary> /// Get version string of the Granados. /// </summary> /// <param name="p">SSH protocol type</param> /// <returns>a version string</returns> public static string ClientVersionString(SSHProtocol p) { Assembly assy = Assembly.GetAssembly(typeof(SSHUtil)); Version ver = assy.GetName().Version; string s = String.Format("{0}-{1}.{2}", (p == SSHProtocol.SSH1) ? "SSH-1.5-Granados" : "SSH-2.0-Granados", ver.Major, ver.Minor); return s; }
public static string ClientVersionString(SSHProtocol p) { return(p == SSHProtocol.SSH1? "SSH-1.5-Granados-1.0" : "SSH-2.0-Granados-1.0"); }
public static string ClientVersionString(SSHProtocol p) { return p == SSHProtocol.SSH1 ? "SSH-1.5-Granados-2.0" : "SSH-2.0-Granados-2.0"; }
public ChameleonForm() { InitializeComponent(); m_templateMenuItems = new List <ToolStripMenuItem>(); m_compiler = new Compiler(); this.m_editors = new Chameleon.GUI.EditorContainer(); this.splitEditorTerminal.Panel1.Controls.Add(this.m_editors); this.m_editors.Dock = System.Windows.Forms.DockStyle.Fill; this.m_editors.Location = new System.Drawing.Point(0, 0); this.m_editors.Name = "m_editors"; this.m_editors.Size = new System.Drawing.Size(660, 261); this.m_editors.TabIndex = 4; this.m_editors.EditorStatusChanged += new EventHandler(OnEditorStatusChanged); addThrowExceptionMenuItem(); FormFontFixer.Fix(this); Options options = App.GlobalSettings; // Scintilla provides these already, so we don't need to actually set the keys menuEditUndo.ShortcutKeyDisplayString = "Ctrl+Z"; menuEditRedo.ShortcutKeyDisplayString = "Ctrl+Y"; menuEditCopy.ShortcutKeyDisplayString = "Ctrl+C"; menuEditCut.ShortcutKeyDisplayString = "Ctrl+X"; menuEditPaste.ShortcutKeyDisplayString = "Ctrl+V"; toolTextPassword.TextBox.UseSystemPasswordChar = true; m_networking = ChameleonNetworking.Instance; toolStatusConnected.Text = "Disconnected"; toolHostDisconnect.Enabled = false; SSHBuffer buffer = new SSHBuffer(); m_sshProtocol = new SSHProtocol(buffer); m_sshProtocol.OnDisconnect += new Action(SetDisconnectedUI); m_terminal = new SwingTerminal(buffer); m_terminal.Dock = DockStyle.Fill; m_terminal.ForeColor = Color.White; m_terminal.BackColor = Color.Black; m_terminal.Parent = m_tabTerminal; m_terminal.Enabled = false; m_terminal.Resize += (sender, e) => { m_terminal.ResizeBuffer(); if (m_networking.IsConnected) { int width = m_terminal.VDUBuffer.Columns; int height = m_terminal.VDUBuffer.Rows; m_sshProtocol._pf.ResizeTerminal(width, height, width, height); } }; RemoteFileDialog rfd = Singleton <RemoteFileDialog> .Instance; rfd.Networking = ChameleonNetworking.Instance; cmw = Singleton <CtagsManagerWrapper> .Instance; string indexerPath = Path.GetDirectoryName(Application.ExecutablePath); string tagsDBPath = Path.Combine(Options.DataFolder, "ChameleonTags.db"); cmw.CodeLiteParserInit(indexerPath, tagsDBPath); parserInitialized = true; ShowPermittedUI(); toolTextHost.Text = App.UserSettings.LastHostname; toolTextUser.Text = App.UserSettings.LastUsername; m_clickedSnippet = false; m_zoom = ZoomLevel.Normal; m_compiler.CompilerEvent += new EventHandler <CompilerEventArgs>(OnCompilerEvent); ImageList compilerErrorIcons = new ImageList(); compilerErrorIcons.ColorDepth = ColorDepth.Depth32Bit; Icon warning = Shell32.IconFromFile("user32.dll", IconSize.Small, 1); Icon error = Shell32.IconFromFile("user32.dll", IconSize.Small, 3); compilerErrorIcons.ImageSize = new Size(16, 16); compilerErrorIcons.Images.Add(warning); compilerErrorIcons.Images.Add(error); m_lvCompilerErrors.SmallImageList = compilerErrorIcons; UpdateCompileButton(); UpdateZoomMenu(); LoadSnippetImages(); AddSnippetGroups(); Application.Idle += new EventHandler(OnApplicationIdle); }
public static Cipher CreateCipher(SSHProtocol protocol, CipherAlgorithm algorithm, byte[] key) { if(protocol==SSHProtocol.SSH1) { switch(algorithm) { case CipherAlgorithm.TripleDES: return new TripleDESCipher1(key); case CipherAlgorithm.Blowfish: return new BlowfishCipher1(key); default: //throw new Exception("unknown algorithm " + algorithm); throw new Exception("unknown algorithm " + algorithm); } } else { switch(algorithm) { case CipherAlgorithm.TripleDES: return new TripleDESCipher2(key); case CipherAlgorithm.Blowfish: return new BlowfishCipher2(key); default: //throw new Exception("unknown algorithm " + algorithm); throw new Exception("unknown algorithm " + algorithm); } } }