├── SSH ├── icon.ico ├── icon.png ├── packages.config ├── App.config ├── Properties │ ├── Settings.settings │ └── Settings.Designer.cs ├── ISshConnection.cs ├── App.xaml ├── NativeMethods.cs └── RelayCommand.cs ├── libsshnet ├── app.rc ├── app.ico ├── resource.h ├── Stdafx.cpp ├── Stdafx.h ├── include │ └── libssh │ │ ├── CMakeLists.txt │ │ ├── knownhosts.h │ │ ├── crc32.h │ │ ├── threads.h │ │ ├── options.h │ │ ├── bignum.h │ │ ├── string.h │ │ ├── ecdh.h │ │ └── ge25519.h ├── AssemblyInfo.cpp └── ReadMe.txt ├── Ssh.Net ├── Renci.SshNet.snk └── Renci.SshNet │ ├── Properties │ ├── CommonAssemblyInfo.cs │ └── AssemblyInfo.cs │ ├── Messages │ ├── Transport │ │ ├── IKeyExchangedAllowed.cs │ │ ├── NewKeysMessage.cs │ │ ├── UnimplementedMessage.cs │ │ ├── KeyExchangeDhGroupExchangeInit.cs │ │ ├── KeyExchangeDhInitMessage.cs │ │ ├── KeyExchangeDhGroupExchangeGroup.cs │ │ ├── ServiceAcceptMessage.cs │ │ ├── IgnoreMessage.cs │ │ ├── DebugMessage.cs │ │ ├── KeyExchangeDhGroupExchangeReply.cs │ │ ├── KeyExchangeDhReplyMessage.cs │ │ └── KeyExchangeEcdhInitMessage.cs │ ├── ServiceName.cs │ ├── Connection │ │ ├── GlobalRequestName.cs │ │ ├── RequestFailureMessage.cs │ │ ├── ChannelOpen │ │ │ ├── SessionChannelOpenInfo.cs │ │ │ └── ChannelOpenInfo.cs │ │ ├── ChannelOpenFailureReasons.cs │ │ ├── ChannelEofMessage.cs │ │ ├── ChannelCloseMessage.cs │ │ ├── ChannelSuccessMessage.cs │ │ ├── ChannelFailureMessage.cs │ │ ├── ChannelRequest │ │ │ ├── ShellRequestInfo.cs │ │ │ ├── EndOfWriteRequestInfo.cs │ │ │ ├── KeepAliveRequestInfo.cs │ │ │ └── RequestInfo.cs │ │ ├── ChannelMessage.cs │ │ └── RequestSuccessMessage.cs │ ├── Authentication │ │ ├── SuccessMessage.cs │ │ ├── RequestMessageNone.cs │ │ ├── BannerMessage.cs │ │ ├── PasswordChangeRequiredMessage.cs │ │ ├── PublicKeyMessage.cs │ │ └── InformationResponseMessage.cs │ └── MessageAttribute.cs │ ├── Security │ ├── Cryptography │ │ ├── AsymmetricCipher.cs │ │ ├── Ciphers │ │ │ ├── CipherPadding.cs │ │ │ └── Paddings │ │ │ │ ├── PKCS5Padding.cs │ │ │ │ └── PKCS7Padding.cs │ │ ├── StreamCipher.cs │ │ └── DigitalSignature.cs │ ├── Algorithm.cs │ ├── KeyExchangeDiffieHellmanGroupExchangeSha1.cs │ ├── KeyExchangeDiffieHellmanGroupExchangeSha256.cs │ ├── KeyExchangeDiffieHellmanGroup1Sha1.cs │ └── HostAlgorithm.cs │ ├── IForwardedPort.cs │ ├── PasswordConnectionInfo.NET40.cs │ ├── KeyboardInteractiveConnectionInfo.NET40.cs │ ├── Shell.NET40.cs │ ├── Compression │ ├── CompressionMode.cs │ ├── Zlib.cs │ └── ZlibOpenSsh.cs │ ├── ForwardedPortDynamic.NET40.cs │ ├── ProxyTypes.cs │ ├── SftpClient.NET40.cs │ ├── PasswordAuthenticationMethod.NET40.cs │ ├── KeyboardInteractiveAuthenticationMethod.NET40.cs │ ├── ShellStream.NET40.cs │ ├── SshCommand.NET40.cs │ ├── AuthenticationResult.cs │ ├── Channels │ ├── ChannelDirectTcpip.NET40.cs │ ├── ChannelTypes.cs │ ├── ChannelForwardedTcpip.NET40.cs │ └── IChannelForwardedTcpip.cs │ ├── ForwardedPortLocal.NET40.cs │ ├── ForwardedPortRemote.NET40.cs │ ├── Sftp │ ├── Responses │ │ ├── ExtendedReplies │ │ │ ├── ExtendedReplyInfo.cs │ │ │ └── StatVfsReplyInfo.cs │ │ ├── SftpExtendedReplyResponse.cs │ │ ├── SftpAttrsResponse.cs │ │ ├── SftpHandleResponse.cs │ │ ├── SftpResponse.cs │ │ ├── SftpDataResponse.cs │ │ ├── SftpVersionResponse.cs │ │ ├── StatVfsResponse.cs │ │ ├── SftpStatusResponse.cs │ │ └── SftpNameResponse.cs │ ├── SftpDataMessage.cs │ ├── Requests │ │ ├── SftpInitRequest.cs │ │ ├── SftpExtendedRequest.cs │ │ ├── SftpCloseRequest.cs │ │ ├── StatVfsRequest.cs │ │ ├── ExtendedRequests │ │ │ ├── FStatVfsRequest.cs │ │ │ ├── HardLinkRequest.cs │ │ │ ├── StatVfsRequest.cs │ │ │ └── PosixRenameRequest.cs │ │ ├── SftpFStatRequest.cs │ │ ├── SftpReadDirRequest.cs │ │ ├── PosixRenameRequest.cs │ │ ├── SftpRmDirRequest.cs │ │ ├── SftpRemoveRequest.cs │ │ ├── SftpStatRequest.cs │ │ ├── SftpLStatRequest.cs │ │ ├── SftpOpenDirRequest.cs │ │ ├── SftpReadLinkRequest.cs │ │ ├── SftpFSetStatRequest.cs │ │ ├── SftpRealPathRequest.cs │ │ ├── SftpRenameRequest.cs │ │ ├── SftpSetStatRequest.cs │ │ ├── SftpWriteRequest.cs │ │ ├── SftpUnblockRequest.cs │ │ ├── SftpSymLinkRequest.cs │ │ ├── SftpReadRequest.cs │ │ ├── SftpBlockRequest.cs │ │ └── SftpMkDirRequest.cs │ ├── Flags.cs │ ├── SftpListDirectoryAsyncResult.cs │ └── SftpSynchronizeDirectoriesAsyncResult.cs │ ├── ExpectAsyncResult.cs │ ├── Common │ ├── AuthenticationEventArgs.cs │ ├── ChannelEventArgs.cs │ ├── ExceptionEventArgs.cs │ ├── ChannelRequestEventArgs.cs │ ├── ObjectIdentifier.cs │ ├── AuthenticationPasswordChangeEventArgs.cs │ ├── ProxyException.NET40.cs │ ├── SshException.cs │ ├── ScpException.NET40.cs │ ├── ShellDataEventArgs.cs │ ├── AuthenticationBannerEventArgs.cs │ ├── ScpException.cs │ ├── ProxyException.cs │ ├── SshOperationTimeoutException.NET40.cs │ ├── SshException.NET40.cs │ ├── NetConfServerException.cs │ ├── SftpPathNotFoundException.cs │ ├── SshAuthenticationException.cs │ ├── ScpUploadEventArgs.cs │ ├── SshConnectionException.NET40.cs │ ├── SshOperationTimeoutException.cs │ ├── SshAuthenticationException.NET40.cs │ ├── SftpPathNotFoundException.NET40.cs │ ├── SftpPermissionDeniedException.cs │ ├── ScpDownloadEventArgs.cs │ ├── NetConfServerException.NET40.cs │ ├── SftpPermissionDeniedException.NET40.cs │ ├── Extensions.NET40.cs │ ├── SshPassPhraseNullOrEmptyException.NET40.cs │ ├── SshPassPhraseNullOrEmptyException.cs │ ├── ChannelOpenFailedEventArgs.cs │ ├── PortForwardEventArgs.cs │ ├── ChannelOpenConfirmedEventArgs.cs │ ├── Extensions.NET.cs │ ├── AuthenticationPromptEventArgs.cs │ └── ChannelDataEventArgs.cs │ ├── IServiceFactory.NET.cs │ ├── Netconf │ └── INetConfSession.cs │ ├── ServiceFactory.NET.cs │ ├── MessageEventArgs.cs │ ├── IAuthenticationMethod.cs │ ├── CipherInfo.cs │ ├── HashInfo.cs │ ├── ForwardedPortRemote.NET.cs │ └── Session.NET40.cs ├── Terminal ├── Properties │ ├── Settings.settings │ └── Settings.Designer.cs ├── TerminalRun.cs ├── IStreamNotifier.cs └── ITerminalHandler.cs ├── TerminalControl ├── Properties │ ├── Settings.settings │ └── Settings.Designer.cs ├── NativeMethods.cs ├── Themes │ └── Generic.xaml ├── RelayCommand.cs └── DebugColors.cs ├── LICENSE ├── TerminalControlTests ├── DequeTests.cs └── Properties │ └── AssemblyInfo.cs └── TerminalTest ├── Properties └── AssemblyInfo.cs └── TerminalLineTests.cs /SSH/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/npcook/terminal/HEAD/SSH/icon.ico -------------------------------------------------------------------------------- /SSH/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/npcook/terminal/HEAD/SSH/icon.png -------------------------------------------------------------------------------- /libsshnet/app.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/npcook/terminal/HEAD/libsshnet/app.rc -------------------------------------------------------------------------------- /libsshnet/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/npcook/terminal/HEAD/libsshnet/app.ico -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/npcook/terminal/HEAD/Ssh.Net/Renci.SshNet.snk -------------------------------------------------------------------------------- /libsshnet/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by app.rc 4 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Properties/CommonAssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/npcook/terminal/HEAD/Ssh.Net/Renci.SshNet/Properties/CommonAssemblyInfo.cs -------------------------------------------------------------------------------- /SSH/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SSH/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /libsshnet/Stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // libsshnet.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /SSH/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Terminal/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /SSH/ISshConnection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace npcook.Ssh 8 | { 9 | interface ISshConnection 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /TerminalControl/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /libsshnet/Stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, 3 | // but are changed infrequently 4 | 5 | #pragma once 6 | 7 | #include "libsshnet.h" 8 | 9 | #include 10 | -------------------------------------------------------------------------------- /SSH/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Transport/IKeyExchangedAllowed.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Transport 2 | { 3 | /// 4 | /// Indicates that message that implement this interface is allowed during key exchange phase 5 | /// 6 | public interface IKeyExchangedAllowed 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /TerminalControl/NativeMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace npcook.Terminal.Controls 9 | { 10 | static class NativeMethods 11 | { 12 | [DllImport("user32.dll")] 13 | public static extern uint GetCaretBlinkTime(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Security/Cryptography/AsymmetricCipher.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Security.Cryptography 2 | { 3 | /// 4 | /// Base class for asymmetric cipher implementations. 5 | /// 6 | public abstract class AsymmetricCipher : Cipher 7 | { 8 | public override byte MinimumSize 9 | { 10 | get { return 0; } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Security/Algorithm.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Security 2 | { 3 | /// 4 | /// Represents the abstract base class from which all implementations of algorithms must inherit. 5 | /// 6 | public abstract class Algorithm 7 | { 8 | /// 9 | /// Gets algorithm name. 10 | /// 11 | public abstract string Name { get; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/IForwardedPort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet 4 | { 5 | /// 6 | /// Supports port forwarding functionality. 7 | /// 8 | public interface IForwardedPort 9 | { 10 | /// 11 | /// The event occurs as the forwarded port is being stopped. 12 | /// 13 | event EventHandler Closing; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/ServiceName.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages 2 | { 3 | /// 4 | /// Specifies list of supported services 5 | /// 6 | public enum ServiceName 7 | { 8 | /// 9 | /// ssh-userauth 10 | /// 11 | UserAuthentication, 12 | 13 | /// 14 | /// ssh-connection 15 | /// 16 | Connection 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/PasswordConnectionInfo.NET40.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using System; 3 | 4 | namespace Renci.SshNet 5 | { 6 | /// 7 | /// Provides connection information when password authentication method is used 8 | /// 9 | public partial class PasswordConnectionInfo 10 | { 11 | partial void ExecuteThread(Action action) 12 | { 13 | Task.Factory.StartNew(action); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/GlobalRequestName.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Connection 2 | { 3 | /// 4 | /// Specifies supported request names. 5 | /// 6 | public enum GlobalRequestName 7 | { 8 | /// 9 | /// tcpip-forward 10 | /// 11 | TcpIpForward, 12 | /// 13 | /// cancel-tcpip-forward 14 | /// 15 | CancelTcpIpForward, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/KeyboardInteractiveConnectionInfo.NET40.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using System; 3 | 4 | namespace Renci.SshNet 5 | { 6 | /// 7 | /// Provides connection information when keyboard interactive authentication method is used 8 | /// 9 | public partial class KeyboardInteractiveConnectionInfo 10 | { 11 | partial void ExecuteThread(Action action) 12 | { 13 | Task.Factory.StartNew(action); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Terminal/TerminalRun.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace npcook.Terminal 8 | { 9 | public class TerminalRun 10 | { 11 | public string Text 12 | { get; set; } 13 | 14 | public TerminalFont Font 15 | { get; set; } 16 | 17 | public TerminalRun() 18 | { } 19 | 20 | public TerminalRun(string text, TerminalFont font) 21 | { 22 | Text = text; 23 | Font = font; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Shell.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Renci.SshNet 5 | { 6 | /// 7 | /// Represents instance of the SSH shell object 8 | /// 9 | public partial class Shell 10 | { 11 | /// is null. 12 | partial void ExecuteThread(Action action) 13 | { 14 | ThreadPool.QueueUserWorkItem(o => action()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Compression/CompressionMode.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Compression 2 | { 3 | /// 4 | /// Specifies compression modes 5 | /// 6 | public enum CompressionMode 7 | { 8 | /// 9 | /// Specifies that content should be compressed. 10 | /// 11 | Compress = 0, 12 | 13 | /// 14 | /// Specifies that content should be decompressed. 15 | /// 16 | Decompress = 1, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/ForwardedPortDynamic.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Renci.SshNet 5 | { 6 | public partial class ForwardedPortDynamic 7 | { 8 | /// 9 | /// Executes the specified action in a separate thread. 10 | /// 11 | /// The action to execute. 12 | partial void ExecuteThread(Action action) 13 | { 14 | ThreadPool.QueueUserWorkItem(o => action()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/ProxyTypes.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet 2 | { 3 | /// 4 | /// Specifies the type of proxy client will use to connect to server. 5 | /// 6 | public enum ProxyTypes 7 | { 8 | /// No proxy server. 9 | None, 10 | /// A SOCKS4 proxy server. 11 | Socks4, 12 | /// A SOCKS5 proxy server. 13 | Socks5, 14 | /// A HTTP proxy server. 15 | Http, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/SftpClient.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Renci.SshNet 5 | { 6 | /// 7 | /// 8 | /// 9 | public partial class SftpClient 10 | { 11 | /// 12 | /// Executes the specified action in a separate thread. 13 | /// 14 | /// The action to execute. 15 | partial void ExecuteThread(Action action) 16 | { 17 | ThreadPool.QueueUserWorkItem(o => action()); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/PasswordAuthenticationMethod.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Renci.SshNet 5 | { 6 | public partial class PasswordAuthenticationMethod : AuthenticationMethod 7 | { 8 | /// 9 | /// Executes the specified action in a separate thread. 10 | /// 11 | /// The action to execute. 12 | partial void ExecuteThread(Action action) 13 | { 14 | ThreadPool.QueueUserWorkItem(o => action()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/KeyboardInteractiveAuthenticationMethod.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Renci.SshNet 5 | { 6 | public partial class KeyboardInteractiveAuthenticationMethod : AuthenticationMethod 7 | { 8 | /// 9 | /// Executes the specified action in a separate thread. 10 | /// 11 | /// The action to execute. 12 | partial void ExecuteThread(Action action) 13 | { 14 | ThreadPool.QueueUserWorkItem(o => action()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroupExchangeSha1.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Security 2 | { 3 | /// 4 | /// Represents "diffie-hellman-group-exchange-sha1" algorithm implementation. 5 | /// 6 | public class KeyExchangeDiffieHellmanGroupExchangeSha1 : KeyExchangeDiffieHellmanGroupExchangeShaBase 7 | { 8 | /// 9 | /// Gets algorithm name. 10 | /// 11 | public override string Name 12 | { 13 | get { return "diffie-hellman-group-exchange-sha1"; } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Terminal/IStreamNotifier.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace npcook.Terminal 9 | { 10 | public class DataAvailableEventArgs : EventArgs 11 | { 12 | public int ChunkSize 13 | { get; } 14 | 15 | public DataAvailableEventArgs(int chunkSize) 16 | { 17 | ChunkSize = chunkSize; 18 | } 19 | } 20 | 21 | public interface IStreamNotifier 22 | { 23 | Stream Stream 24 | { get; } 25 | 26 | event EventHandler DataAvailable; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/ShellStream.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Renci.SshNet 5 | { 6 | /// 7 | /// Represents instance of the SSH shell object 8 | /// 9 | public partial class ShellStream 10 | { 11 | /// 12 | /// Executes the specified action in a separate thread. 13 | /// 14 | /// The action to execute. 15 | partial void ExecuteThread(Action action) 16 | { 17 | ThreadPool.QueueUserWorkItem(o => action()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/SshCommand.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Renci.SshNet 5 | { 6 | /// 7 | /// Represents SSH command that can be executed. 8 | /// 9 | public partial class SshCommand 10 | { 11 | /// 12 | /// Executes the specified action in a separate thread. 13 | /// 14 | /// The action to execute. 15 | partial void ExecuteThread(Action action) 16 | { 17 | ThreadPool.QueueUserWorkItem(o => action()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Terminal/ITerminalHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace npcook.Terminal 10 | { 11 | public class TitleChangeEventArgs : EventArgs 12 | { 13 | public string Title 14 | { get; } 15 | 16 | public TitleChangeEventArgs(string title) 17 | { 18 | Title = title; 19 | } 20 | } 21 | 22 | public interface ITerminalHandler 23 | { 24 | TerminalBase Terminal 25 | { get; } 26 | 27 | TerminalFont DefaultFont 28 | { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/AuthenticationResult.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet 2 | { 3 | /// 4 | /// Represents possible authentication methods results 5 | /// 6 | public enum AuthenticationResult 7 | { 8 | /// 9 | /// Authentication was successful. 10 | /// 11 | Success, 12 | /// 13 | /// Authentication completed with partial success. 14 | /// 15 | PartialSuccess, 16 | /// 17 | /// Authentication failed. 18 | /// 19 | Failure 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Channels/ChannelDirectTcpip.NET40.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Sockets; 2 | 3 | namespace Renci.SshNet.Channels 4 | { 5 | /// 6 | /// Implements "direct-tcpip" SSH channel. 7 | /// 8 | internal partial class ChannelDirectTcpip 9 | { 10 | partial void InternalSocketReceive(byte[] buffer, ref int read) 11 | { 12 | read = this._socket.Receive(buffer); 13 | } 14 | 15 | partial void InternalSocketSend(byte[] data) 16 | { 17 | this._socket.Send(data, 0, data.Length, SocketFlags.None); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/ForwardedPortLocal.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Renci.SshNet 5 | { 6 | /// 7 | /// Provides functionality for local port forwarding 8 | /// 9 | public partial class ForwardedPortLocal 10 | { 11 | /// 12 | /// Executes the specified action in a separate thread. 13 | /// 14 | /// The action to execute. 15 | partial void ExecuteThread(Action action) 16 | { 17 | ThreadPool.QueueUserWorkItem(o => action()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/ForwardedPortRemote.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Renci.SshNet 5 | { 6 | /// 7 | /// Provides functionality for remote port forwarding 8 | /// 9 | public partial class ForwardedPortRemote 10 | { 11 | /// 12 | /// Executes the specified action in a separate thread. 13 | /// 14 | /// The action to execute. 15 | partial void ExecuteThread(Action action) 16 | { 17 | ThreadPool.QueueUserWorkItem(o => action()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Security/Cryptography/Ciphers/CipherPadding.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Security.Cryptography.Ciphers 2 | { 3 | /// 4 | /// Base class for cipher padding implementations 5 | /// 6 | public abstract class CipherPadding 7 | { 8 | /// 9 | /// Pads specified input to match block size. 10 | /// 11 | /// Size of the block. 12 | /// The input. 13 | /// Padded data array. 14 | public abstract byte[] Pad(int blockSize, byte[] input); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Responses/ExtendedReplies/ExtendedReplyInfo.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Common; 2 | using System; 3 | 4 | namespace Renci.SshNet.Sftp.Responses 5 | { 6 | internal abstract class ExtendedReplyInfo : SshData 7 | { 8 | protected override void LoadData() 9 | { 10 | // Read Message Type 11 | var messageType = this.ReadByte(); 12 | 13 | // Read Response ID 14 | var responseId = this.ReadUInt32(); 15 | } 16 | 17 | protected override void SaveData() 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Responses/SftpExtendedReplyResponse.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Common; 2 | 3 | namespace Renci.SshNet.Sftp.Responses 4 | { 5 | internal class SftpExtendedReplyResponse : SftpResponse 6 | { 7 | public override SftpMessageTypes SftpMessageType 8 | { 9 | get { return SftpMessageTypes.ExtendedReply; } 10 | } 11 | 12 | public SftpExtendedReplyResponse(uint protocolVersion) 13 | : base(protocolVersion) 14 | { 15 | } 16 | 17 | public T GetReply() where T : SshData, new() 18 | { 19 | return this.OfType(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/SftpDataMessage.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Messages.Connection; 2 | 3 | namespace Renci.SshNet.Sftp 4 | { 5 | internal class SftpDataMessage : ChannelDataMessage 6 | { 7 | public SftpDataMessage(uint localChannelNumber, SftpMessage sftpMessage) 8 | { 9 | this.LocalChannelNumber = localChannelNumber; 10 | 11 | var messageData = sftpMessage.GetBytes(); 12 | 13 | var data = new byte[4 + messageData.Length]; 14 | 15 | ((uint)messageData.Length).GetBytes().CopyTo(data, 0); 16 | messageData.CopyTo(data, 4); 17 | this.Data = data; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Channels/ChannelTypes.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace Renci.SshNet.Channels 3 | { 4 | /// 5 | /// Lists channel types as defined by the protocol. 6 | /// 7 | internal enum ChannelTypes 8 | { 9 | /// 10 | /// session 11 | /// 12 | Session, 13 | /// 14 | /// x11 15 | /// 16 | X11, 17 | /// 18 | /// forwarded-tcpip 19 | /// 20 | ForwardedTcpip, 21 | /// 22 | /// direct-tcpip 23 | /// 24 | DirectTcpip, 25 | 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /SSH/NativeMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace npcook.Ssh 9 | { 10 | internal static class NativeMethods 11 | { 12 | [StructLayout(LayoutKind.Sequential)] 13 | public struct RECT 14 | { 15 | public int left; 16 | public int top; 17 | public int right; 18 | public int bottom; 19 | } 20 | 21 | [DllImport("user32.dll")] 22 | public static extern bool GetClientRect(IntPtr hwnd, out RECT rect); 23 | 24 | [DllImport("user32.dll")] 25 | public static extern bool GetWindowRect(IntPtr hwnd, out RECT rect); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Security/Cryptography/StreamCipher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Security.Cryptography 4 | { 5 | /// 6 | /// Base class of stream cipher algorithms. 7 | /// 8 | public abstract class StreamCipher : SymmetricCipher 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | /// The key. 14 | /// is null. 15 | protected StreamCipher(byte[] key) 16 | : base(key) 17 | { 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Responses/SftpAttrsResponse.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Sftp.Responses 2 | { 3 | internal class SftpAttrsResponse : SftpResponse 4 | { 5 | public override SftpMessageTypes SftpMessageType 6 | { 7 | get { return SftpMessageTypes.Attrs; } 8 | } 9 | 10 | public SftpFileAttributes Attributes { get; private set; } 11 | 12 | public SftpAttrsResponse(uint protocolVersion) 13 | : base(protocolVersion) 14 | { 15 | } 16 | 17 | protected override void LoadData() 18 | { 19 | base.LoadData(); 20 | this.Attributes = this.ReadAttributes(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Responses/SftpHandleResponse.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Sftp.Responses 2 | { 3 | internal class SftpHandleResponse : SftpResponse 4 | { 5 | public override SftpMessageTypes SftpMessageType 6 | { 7 | get { return SftpMessageTypes.Handle; } 8 | } 9 | 10 | public byte[] Handle { get; private set; } 11 | 12 | public SftpHandleResponse(uint protocolVersion) 13 | : base(protocolVersion) 14 | { 15 | } 16 | 17 | protected override void LoadData() 18 | { 19 | base.LoadData(); 20 | 21 | this.Handle = this.ReadBinaryString(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /libsshnet/include/libssh/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(libssh-headers C) 2 | 3 | set(libssh_HDRS 4 | callbacks.h 5 | libssh.h 6 | ssh2.h 7 | legacy.h 8 | libsshpp.hpp 9 | ) 10 | 11 | if (WITH_SFTP) 12 | set(libssh_HDRS 13 | ${libssh_HDRS} 14 | sftp.h 15 | ) 16 | endif (WITH_SFTP) 17 | 18 | if (WITH_SSH1) 19 | set(libssh_HDRS 20 | ${libssh_HDRS} 21 | ssh1.h 22 | ) 23 | endif (WITH_SSH1) 24 | 25 | if (WITH_SERVER) 26 | set(libssh_HDRS 27 | ${libssh_HDRS} 28 | server.h 29 | ) 30 | endif (WITH_SERVER) 31 | 32 | install( 33 | FILES 34 | ${libssh_HDRS} 35 | DESTINATION 36 | ${INCLUDE_INSTALL_DIR}/${APPLICATION_NAME} 37 | COMPONENT 38 | headers 39 | ) 40 | 41 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Transport/NewKeysMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Transport 2 | { 3 | /// 4 | /// Represents SSH_MSG_KEXINIT message. 5 | /// 6 | [Message("SSH_MSG_NEWKEYS", 21)] 7 | public class NewKeysMessage : Message, IKeyExchangedAllowed 8 | { 9 | /// 10 | /// Called when type specific data need to be loaded. 11 | /// 12 | protected override void LoadData() 13 | { 14 | } 15 | 16 | /// 17 | /// Called when type specific data need to be saved. 18 | /// 19 | protected override void SaveData() 20 | { 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Transport/UnimplementedMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Transport 2 | { 3 | /// 4 | /// Represents SSH_MSG_UNIMPLEMENTED message. 5 | /// 6 | [Message("SSH_MSG_UNIMPLEMENTED", 3)] 7 | public class UnimplementedMessage : Message 8 | { 9 | /// 10 | /// Called when type specific data need to be loaded. 11 | /// 12 | protected override void LoadData() 13 | { 14 | } 15 | 16 | /// 17 | /// Called when type specific data need to be saved. 18 | /// 19 | protected override void SaveData() 20 | { 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Authentication/SuccessMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Authentication 2 | { 3 | /// 4 | /// Represents SSH_MSG_USERAUTH_SUCCESS message. 5 | /// 6 | [Message("SSH_MSG_USERAUTH_SUCCESS", 52)] 7 | public class SuccessMessage : Message 8 | { 9 | /// 10 | /// Called when type specific data need to be loaded. 11 | /// 12 | protected override void LoadData() 13 | { 14 | } 15 | 16 | /// 17 | /// Called when type specific data need to be saved. 18 | /// 19 | protected override void SaveData() 20 | { 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/RequestFailureMessage.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace Renci.SshNet.Messages.Connection 3 | { 4 | /// 5 | /// Represents SSH_MSG_REQUEST_FAILURE message. 6 | /// 7 | [Message("SSH_MSG_REQUEST_FAILURE", 82)] 8 | public class RequestFailureMessage : Message 9 | { 10 | /// 11 | /// Called when type specific data need to be loaded. 12 | /// 13 | protected override void LoadData() 14 | { 15 | } 16 | 17 | /// 18 | /// Called when type specific data need to be saved. 19 | /// 20 | protected override void SaveData() 21 | { 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Compression/Zlib.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Compression 2 | { 3 | /// 4 | /// Represents "zlib" compression implementation 5 | /// 6 | internal class Zlib : Compressor 7 | { 8 | /// 9 | /// Gets algorithm name. 10 | /// 11 | public override string Name 12 | { 13 | get { return "zlib"; } 14 | } 15 | 16 | /// 17 | /// Initializes the algorithm 18 | /// 19 | /// The session. 20 | public override void Init(Session session) 21 | { 22 | base.Init(session); 23 | this.IsActive = true; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/ExpectAsyncResult.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Common; 2 | using System; 3 | 4 | namespace Renci.SshNet 5 | { 6 | /// 7 | /// Provides additional information for asynchronous command execution 8 | /// 9 | public class ExpectAsyncResult : AsyncResult 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The async callback. 15 | /// The state. 16 | internal ExpectAsyncResult(AsyncCallback asyncCallback, Object state) 17 | : base(asyncCallback, state) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/ChannelOpen/SessionChannelOpenInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Connection 2 | { 3 | /// 4 | /// Used to open "session" channel type 5 | /// 6 | internal class SessionChannelOpenInfo : ChannelOpenInfo 7 | { 8 | /// 9 | /// Specifies channel open type 10 | /// 11 | public const string NAME = "session"; 12 | 13 | /// 14 | /// Gets the type of the channel to open. 15 | /// 16 | /// 17 | /// The type of the channel to open. 18 | /// 19 | public override string ChannelType 20 | { 21 | get { return NAME; } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/AuthenticationEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// Base class for authentication events. 7 | /// 8 | public abstract class AuthenticationEventArgs : EventArgs 9 | { 10 | /// 11 | /// Gets the username. 12 | /// 13 | public string Username { get; private set; } 14 | 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The username. 19 | public AuthenticationEventArgs(string username) 20 | { 21 | this.Username = username; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ChannelEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// Base class for all channel related events. 7 | /// 8 | public class ChannelEventArgs : EventArgs 9 | { 10 | /// 11 | /// Gets the channel number. 12 | /// 13 | public uint ChannelNumber { get; private set; } 14 | 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The channel number. 19 | public ChannelEventArgs(uint channelNumber) 20 | { 21 | this.ChannelNumber = channelNumber; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/IServiceFactory.NET.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.NetConf; 3 | 4 | namespace Renci.SshNet 5 | { 6 | internal partial interface IServiceFactory 7 | { 8 | /// 9 | /// Creates a new in a given 10 | /// and with the specified operation timeout. 11 | /// 12 | /// The to create the in. 13 | /// The operation timeout. 14 | /// 15 | /// An . 16 | /// 17 | INetConfSession CreateNetConfSession(ISession session, TimeSpan operationTimeout); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Netconf/INetConfSession.cs: -------------------------------------------------------------------------------- 1 | using System.Xml; 2 | 3 | namespace Renci.SshNet.NetConf 4 | { 5 | internal interface INetConfSession : ISubsystemSession 6 | { 7 | /// 8 | /// Gets the NetConf server capabilities. 9 | /// 10 | /// 11 | /// The NetConf server capabilities. 12 | /// 13 | XmlDocument ServerCapabilities { get; } 14 | 15 | /// 16 | /// Gets the NetConf client capabilities. 17 | /// 18 | /// 19 | /// The NetConf client capabilities. 20 | /// 21 | XmlDocument ClientCapabilities { get; } 22 | 23 | XmlDocument SendReceiveRpc(XmlDocument rpc, bool automaticMessageIdHandling); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Responses/SftpResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Sftp.Responses 4 | { 5 | internal abstract class SftpResponse : SftpMessage 6 | { 7 | public uint ResponseId { get; private set; } 8 | 9 | public uint ProtocolVersion { get; private set; } 10 | 11 | public SftpResponse(uint protocolVersion) 12 | { 13 | this.ProtocolVersion = protocolVersion; 14 | } 15 | 16 | protected override void LoadData() 17 | { 18 | base.LoadData(); 19 | 20 | this.ResponseId = this.ReadUInt32(); 21 | } 22 | 23 | protected override void SaveData() 24 | { 25 | throw new InvalidOperationException("Response cannot be saved."); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpInitRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Sftp.Requests 2 | { 3 | internal class SftpInitRequest : SftpMessage 4 | { 5 | public override SftpMessageTypes SftpMessageType 6 | { 7 | get { return SftpMessageTypes.Init; } 8 | } 9 | 10 | public uint Version { get; private set; } 11 | 12 | public SftpInitRequest(uint version) 13 | { 14 | this.Version = version; 15 | } 16 | 17 | protected override void LoadData() 18 | { 19 | base.LoadData(); 20 | this.Version = this.ReadUInt32(); 21 | } 22 | 23 | protected override void SaveData() 24 | { 25 | base.SaveData(); 26 | this.Write(this.Version); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/ChannelOpenFailureReasons.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Connection 2 | { 3 | /// 4 | /// List channel open failure reasons defined by the protocol. 5 | /// 6 | internal enum ChannelOpenFailureReasons : uint 7 | { 8 | /// 9 | /// SSH_OPEN_ADMINISTRATIVELY_PROHIBITED 10 | /// 11 | AdministativelyProhibited = 1, 12 | /// 13 | /// SSH_OPEN_CONNECT_FAILED 14 | /// 15 | ConnectFailed = 2, 16 | /// 17 | /// SSH_OPEN_UNKNOWN_CHANNEL_TYPE 18 | /// 19 | UnknownChannelType = 3, 20 | /// 21 | /// SSH_OPEN_RESOURCE_SHORTAGE 22 | /// 23 | ResourceShortage = 4 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ExceptionEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// Provides data for the ErrorOccured events. 7 | /// 8 | public class ExceptionEventArgs : EventArgs 9 | { 10 | /// 11 | /// Gets the System.Exception that represents the error that occurred. 12 | /// 13 | public Exception Exception { get; private set; } 14 | 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// An System.Exception that represents the error that occurred. 19 | public ExceptionEventArgs(Exception exception) 20 | { 21 | this.Exception = exception; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ChannelRequestEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Messages.Connection; 3 | 4 | namespace Renci.SshNet.Common 5 | { 6 | /// 7 | /// Provides data for event. 8 | /// 9 | public class ChannelRequestEventArgs : EventArgs 10 | { 11 | /// 12 | /// Gets request information. 13 | /// 14 | public RequestInfo Info { get; private set; } 15 | 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// Request information. 20 | public ChannelRequestEventArgs(RequestInfo info) 21 | { 22 | this.Info = info; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Responses/SftpDataResponse.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Sftp.Responses 2 | { 3 | internal class SftpDataResponse : SftpResponse 4 | { 5 | public override SftpMessageTypes SftpMessageType 6 | { 7 | get { return SftpMessageTypes.Data; } 8 | } 9 | 10 | public byte[] Data { get; set; } 11 | 12 | public bool IsEof { get; set; } 13 | 14 | public SftpDataResponse(uint protocolVersion) 15 | : base(protocolVersion) 16 | { 17 | } 18 | 19 | protected override void LoadData() 20 | { 21 | base.LoadData(); 22 | 23 | this.Data = this.ReadBinaryString(); 24 | 25 | if (!this.IsEndOfData) 26 | { 27 | this.IsEof = this.ReadBoolean(); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpExtendedRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | 4 | namespace Renci.SshNet.Sftp.Requests 5 | { 6 | internal abstract class SftpExtendedRequest : SftpRequest 7 | { 8 | public const string NAME = "posix-rename@openssh.com"; 9 | 10 | public override SftpMessageTypes SftpMessageType 11 | { 12 | get { return SftpMessageTypes.Extended; } 13 | } 14 | 15 | public abstract string Name { get; } 16 | 17 | public SftpExtendedRequest(uint protocolVersion, uint requestId, Action statusAction) 18 | : base(protocolVersion, requestId, statusAction) 19 | { 20 | } 21 | 22 | protected override void SaveData() 23 | { 24 | base.SaveData(); 25 | this.Write(this.Name); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Flags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Sftp 4 | { 5 | [Flags] 6 | internal enum Flags 7 | { 8 | None = 0x00000000, 9 | /// 10 | /// SSH_FXF_READ 11 | /// 12 | Read = 0x00000001, 13 | /// 14 | /// SSH_FXF_WRITE 15 | /// 16 | Write = 0x00000002, 17 | /// 18 | /// SSH_FXF_APPEND 19 | /// 20 | Append = 0x00000004, 21 | /// 22 | /// SSH_FXF_CREAT 23 | /// 24 | CreateNewOrOpen = 0x00000008, 25 | /// 26 | /// SSH_FXF_TRUNC 27 | /// 28 | Truncate = 0x00000010, 29 | /// 30 | /// SSH_FXF_EXCL 31 | /// 32 | CreateNew = 0x00000028 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Responses/SftpVersionResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Renci.SshNet.Sftp.Responses 5 | { 6 | internal class SftpVersionResponse : SftpMessage 7 | { 8 | public override SftpMessageTypes SftpMessageType 9 | { 10 | get { return SftpMessageTypes.Version; } 11 | } 12 | 13 | public uint Version { get; private set; } 14 | 15 | public IDictionary Extentions { get; private set; } 16 | 17 | protected override void LoadData() 18 | { 19 | base.LoadData(); 20 | this.Version = this.ReadUInt32(); 21 | this.Extentions = this.ReadExtensionPair(); 22 | } 23 | 24 | protected override void SaveData() 25 | { 26 | throw new InvalidOperationException(); 27 | } 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ObjectIdentifier.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// Describes object identifier for DER encoding 7 | /// 8 | public struct ObjectIdentifier 9 | { 10 | /// 11 | /// Gets the object identifier. 12 | /// 13 | public ulong[] Identifiers { get; private set; } 14 | 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The identifiers. 19 | public ObjectIdentifier(params ulong[] identifiers) 20 | : this() 21 | { 22 | if (identifiers.Length < 2) 23 | throw new ArgumentException("identifiers"); 24 | 25 | this.Identifiers = identifiers; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/ChannelEofMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Connection 2 | { 3 | /// 4 | /// Represents SSH_MSG_CHANNEL_EOF message. 5 | /// 6 | [Message("SSH_MSG_CHANNEL_EOF", 96)] 7 | public class ChannelEofMessage : ChannelMessage 8 | { 9 | /// 10 | /// Initializes a new instance of the class. 11 | /// 12 | public ChannelEofMessage() 13 | { 14 | 15 | } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The local channel number. 21 | public ChannelEofMessage(uint localChannelNumber) 22 | { 23 | this.LocalChannelNumber = localChannelNumber; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Security/Cryptography/DigitalSignature.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Security.Cryptography 2 | { 3 | /// 4 | /// Base class for signature implementations 5 | /// 6 | public abstract class DigitalSignature 7 | { 8 | /// 9 | /// Verifies the signature. 10 | /// 11 | /// The input. 12 | /// The signature. 13 | /// True if signature was successfully verified; otherwise false. 14 | public abstract bool Verify(byte[] input, byte[] signature); 15 | 16 | /// 17 | /// Creates the signature. 18 | /// 19 | /// The input. 20 | /// Signed input data. 21 | public abstract byte[] Sign(byte[] input); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/ChannelCloseMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Connection 2 | { 3 | /// 4 | /// Represents SSH_MSG_CHANNEL_CLOSE message. 5 | /// 6 | [Message("SSH_MSG_CHANNEL_CLOSE", 97)] 7 | public class ChannelCloseMessage : ChannelMessage 8 | { 9 | /// 10 | /// Initializes a new instance of the class. 11 | /// 12 | public ChannelCloseMessage() 13 | { 14 | 15 | } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The local channel number. 21 | public ChannelCloseMessage(uint localChannelNumber) 22 | { 23 | LocalChannelNumber = localChannelNumber; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/AuthenticationPasswordChangeEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Common 2 | { 3 | /// 4 | /// Provides data for event. 5 | /// 6 | public class AuthenticationPasswordChangeEventArgs : AuthenticationEventArgs 7 | { 8 | /// 9 | /// Gets or sets the new password. 10 | /// 11 | /// 12 | /// The new password. 13 | /// 14 | public byte[] NewPassword { get; set; } 15 | 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The username. 20 | public AuthenticationPasswordChangeEventArgs(string username) 21 | : base(username) 22 | { 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/ChannelSuccessMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Connection 2 | { 3 | /// 4 | /// Represents SSH_MSG_CHANNEL_SUCCESS message. 5 | /// 6 | [Message("SSH_MSG_CHANNEL_SUCCESS", 99)] 7 | public class ChannelSuccessMessage : ChannelMessage 8 | { 9 | /// 10 | /// Initializes a new instance of the class. 11 | /// 12 | public ChannelSuccessMessage() 13 | { 14 | 15 | } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The local channel number. 21 | public ChannelSuccessMessage(uint localChannelNumber) 22 | { 23 | this.LocalChannelNumber = localChannelNumber; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/ChannelFailureMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Connection 2 | { 3 | /// 4 | /// Represents SSH_MSG_CHANNEL_FAILURE message. 5 | /// 6 | [Message("SSH_MSG_CHANNEL_FAILURE", 100)] 7 | public class ChannelFailureMessage : ChannelMessage 8 | { 9 | /// 10 | /// Initializes a new instance of the class. 11 | /// 12 | public ChannelFailureMessage() 13 | { 14 | 15 | } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The local channel number. 21 | public ChannelFailureMessage(uint localChannelNumber) 22 | { 23 | this.LocalChannelNumber = localChannelNumber; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Channels/ChannelForwardedTcpip.NET40.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Net.Sockets; 3 | 4 | namespace Renci.SshNet.Channels 5 | { 6 | /// 7 | /// Implements "forwarded-tcpip" SSH channel. 8 | /// 9 | internal partial class ChannelForwardedTcpip 10 | { 11 | partial void OpenSocket(IPEndPoint remoteEndpoint) 12 | { 13 | this._socket = new Socket(remoteEndpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); 14 | this._socket.Connect(remoteEndpoint); 15 | this._socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1); 16 | } 17 | 18 | partial void InternalSocketReceive(byte[] buffer, ref int read) 19 | { 20 | read = this._socket.Receive(buffer); 21 | } 22 | 23 | partial void InternalSocketSend(byte[] data) 24 | { 25 | this._socket.Send(data); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/ServiceFactory.NET.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Renci.SshNet.NetConf; 6 | 7 | namespace Renci.SshNet 8 | { 9 | internal partial class ServiceFactory 10 | { 11 | /// 12 | /// Creates a new in a given 13 | /// and with the specified operation timeout. 14 | /// 15 | /// The to create the in. 16 | /// The operation timeout. 17 | /// 18 | /// An . 19 | /// 20 | public INetConfSession CreateNetConfSession(ISession session, TimeSpan operationTimeout) 21 | { 22 | return new NetConfSession(session, operationTimeout); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/ChannelOpen/ChannelOpenInfo.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Common; 2 | 3 | namespace Renci.SshNet.Messages.Connection 4 | { 5 | /// 6 | /// Base class for open channel messages 7 | /// 8 | public abstract class ChannelOpenInfo : SshData 9 | { 10 | /// 11 | /// Gets the type of the channel to open. 12 | /// 13 | /// 14 | /// The type of the channel to open. 15 | /// 16 | public abstract string ChannelType { get; } 17 | 18 | /// 19 | /// Called when type specific data need to be loaded. 20 | /// 21 | protected override void LoadData() 22 | { 23 | } 24 | 25 | /// 26 | /// Called when type specific data need to be saved. 27 | /// 28 | protected override void SaveData() 29 | { 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/MessageEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet 4 | { 5 | /// 6 | /// Provides data for message events. 7 | /// 8 | /// Message type 9 | public class MessageEventArgs : EventArgs 10 | { 11 | /// 12 | /// Gets the message. 13 | /// 14 | public T Message { get; private set; } 15 | 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The message. 20 | /// is null. 21 | public MessageEventArgs(T message) 22 | { 23 | if (message == null) 24 | throw new ArgumentNullException("message"); 25 | 26 | this.Message = message; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/ChannelRequest/ShellRequestInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Connection 2 | { 3 | /// 4 | /// Represents "shell" type channel request information 5 | /// 6 | internal class ShellRequestInfo : RequestInfo 7 | { 8 | /// 9 | /// Channel request name 10 | /// 11 | public const string NAME = "shell"; 12 | 13 | /// 14 | /// Gets the name of the request. 15 | /// 16 | /// 17 | /// The name of the request. 18 | /// 19 | public override string RequestName 20 | { 21 | get { return NAME; } 22 | } 23 | 24 | /// 25 | /// Initializes a new instance of the class. 26 | /// 27 | public ShellRequestInfo() 28 | { 29 | this.WantReply = true; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using System.Runtime.CompilerServices; 4 | 5 | [assembly: AssemblyTitle("SSH.NET .NET 4.0")] 6 | [assembly: Guid("ad816c5e-6f13-4589-9f3e-59523f8b77a4")] 7 | [assembly: InternalsVisibleTo("Renci.SshNet.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f9194e1eb66b7e2575aaee115ee1d27bc100920e7150e43992d6f668f9737de8b9c7ae892b62b8a36dd1d57929ff1541665d101dc476d6e02390846efae7e5186eec409710fdb596e3f83740afef0d4443055937649bc5a773175b61c57615dac0f0fd10f52b52fedf76c17474cc567b3f7a79de95dde842509fb39aaf69c6c2")] 8 | [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] 9 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpCloseRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | 4 | namespace Renci.SshNet.Sftp.Requests 5 | { 6 | internal class SftpCloseRequest : SftpRequest 7 | { 8 | public override SftpMessageTypes SftpMessageType 9 | { 10 | get { return SftpMessageTypes.Close; } 11 | } 12 | 13 | public byte[] Handle { get; private set; } 14 | 15 | public SftpCloseRequest(uint protocolVersion, uint requestId, byte[] handle, Action statusAction) 16 | : base(protocolVersion, requestId, statusAction) 17 | { 18 | this.Handle = handle; 19 | } 20 | 21 | protected override void LoadData() 22 | { 23 | base.LoadData(); 24 | this.Handle = this.ReadBinaryString(); 25 | } 26 | 27 | protected override void SaveData() 28 | { 29 | base.SaveData(); 30 | this.WriteBinaryString(this.Handle); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Channels/IChannelForwardedTcpip.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using Renci.SshNet.Common; 4 | 5 | namespace Renci.SshNet.Channels 6 | { 7 | /// 8 | /// A "forwarded-tcpip" SSH channel. 9 | /// 10 | internal interface IChannelForwardedTcpip : IDisposable 11 | { 12 | /// 13 | /// Occurs when an exception is thrown while processing channel messages. 14 | /// 15 | event EventHandler Exception; 16 | 17 | /// 18 | /// Binds the channel to the specified endpoint. 19 | /// 20 | /// The endpoint to connect to. 21 | /// The forwarded port for which the channel is opened. 22 | void Bind(IPEndPoint remoteEndpoint, IForwardedPort forwardedPort); 23 | 24 | /// 25 | /// Closes the channel. 26 | /// 27 | void Close(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/ChannelRequest/EndOfWriteRequestInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Connection 2 | { 3 | /// 4 | /// Represents "eow@openssh.com" type channel request information 5 | /// 6 | public class EndOfWriteRequestInfo : RequestInfo 7 | { 8 | /// 9 | /// Channel request name 10 | /// 11 | public const string NAME = "eow@openssh.com"; 12 | 13 | /// 14 | /// Gets the name of the request. 15 | /// 16 | /// 17 | /// The name of the request. 18 | /// 19 | public override string RequestName 20 | { 21 | get { return NAME; } 22 | } 23 | 24 | /// 25 | /// Initializes a new instance of the class. 26 | /// 27 | public EndOfWriteRequestInfo() 28 | { 29 | this.WantReply = false; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/ChannelRequest/KeepAliveRequestInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Connection 2 | { 3 | /// 4 | /// Represents "keepalive@openssh.com" type channel request information 5 | /// 6 | public class KeepAliveRequestInfo : RequestInfo 7 | { 8 | /// 9 | /// Channel request name 10 | /// 11 | public const string NAME = "keepalive@openssh.com"; 12 | 13 | /// 14 | /// Gets the name of the request. 15 | /// 16 | /// 17 | /// The name of the request. 18 | /// 19 | public override string RequestName 20 | { 21 | get { return NAME; } 22 | } 23 | 24 | /// 25 | /// Initializes a new instance of the class. 26 | /// 27 | public KeepAliveRequestInfo() 28 | { 29 | this.WantReply = false; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/StatVfsRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | 4 | namespace Renci.SshNet.Sftp.Requests 5 | { 6 | internal class StatVfsRequest : SftpRequest 7 | { 8 | public const string NAME = "statvfs@openssh.com"; 9 | 10 | public override SftpMessageTypes SftpMessageType 11 | { 12 | get { return SftpMessageTypes.Extended; } 13 | } 14 | 15 | public string Path { get; private set; } 16 | 17 | public StatVfsRequest(uint protocolVersion, uint requestId, string path, Action extendedAction, Action statusAction) 18 | : base(protocolVersion, requestId, statusAction) 19 | { 20 | this.Path = path; 21 | this.SetAction(extendedAction); 22 | } 23 | 24 | protected override void SaveData() 25 | { 26 | base.SaveData(); 27 | this.Write(StatVfsRequest.NAME); 28 | this.Write(this.Path); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /TerminalControl/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 22 | 23 | -------------------------------------------------------------------------------- /libsshnet/include/libssh/knownhosts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 20014 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | 22 | #ifndef KNOWNHOSTS_H_ 23 | #define KNOWNHOSTS_H_ 24 | 25 | char **ssh_knownhosts_algorithms(ssh_session session); 26 | 27 | #endif /* KNOWNHOSTS_H_ */ 28 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Responses/StatVfsResponse.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Sftp.Responses 2 | { 3 | internal class StatVfsResponse : SftpExtendedReplyResponse 4 | { 5 | public SftpFileSytemInformation Information { get; private set; } 6 | 7 | public StatVfsResponse() 8 | : base(0) 9 | { 10 | } 11 | 12 | protected override void LoadData() 13 | { 14 | base.LoadData(); 15 | 16 | this.Information = new SftpFileSytemInformation(this.ReadUInt64(), this.ReadUInt64(), 17 | this.ReadUInt64(), this.ReadUInt64(), 18 | this.ReadUInt64(), this.ReadUInt64(), 19 | this.ReadUInt64(), this.ReadUInt64(), 20 | this.ReadUInt64(), this.ReadUInt64(), 21 | this.ReadUInt64()); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /libsshnet/include/libssh/crc32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * crc32.c - simple CRC32 code 3 | * 4 | * This file is part of the SSH Library 5 | * 6 | * Copyright (c) 2005 by Aris Adamantiadis 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef _CRC32_H 24 | #define _CRC32_H 25 | 26 | uint32_t ssh_crc32(const char *buf, uint32_t len); 27 | 28 | #endif /* _CRC32_H */ 29 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Authentication/RequestMessageNone.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Authentication 2 | { 3 | /// 4 | /// Represents "none" SSH_MSG_USERAUTH_REQUEST message. 5 | /// 6 | internal class RequestMessageNone : RequestMessage 7 | { 8 | /// 9 | /// Gets the name of the authentication method. 10 | /// 11 | /// 12 | /// The name of the method. 13 | /// 14 | public override string MethodName 15 | { 16 | get 17 | { 18 | return "none"; 19 | } 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of the class. 24 | /// 25 | /// Name of the service. 26 | /// Authentication username. 27 | public RequestMessageNone(ServiceName serviceName, string username) 28 | : base(serviceName, username) 29 | { 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/ExtendedRequests/FStatVfsRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | 4 | namespace Renci.SshNet.Sftp.Requests 5 | { 6 | internal class FStatVfsRequest : SftpExtendedRequest 7 | { 8 | public override SftpMessageTypes SftpMessageType 9 | { 10 | get { return SftpMessageTypes.Extended; } 11 | } 12 | 13 | public override string Name 14 | { 15 | get { return "fstatvfs@openssh.com"; } 16 | } 17 | 18 | public byte[] Handle { get; private set; } 19 | 20 | public FStatVfsRequest(uint protocolVersion, uint requestId, byte[] handle, Action extendedAction, Action statusAction) 21 | : base(protocolVersion, requestId, statusAction) 22 | { 23 | this.Handle = handle; 24 | this.SetAction(extendedAction); 25 | } 26 | 27 | protected override void SaveData() 28 | { 29 | base.SaveData(); 30 | this.WriteBinaryString(this.Handle); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpFStatRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | 4 | namespace Renci.SshNet.Sftp.Requests 5 | { 6 | internal class SftpFStatRequest : SftpRequest 7 | { 8 | public override SftpMessageTypes SftpMessageType 9 | { 10 | get { return SftpMessageTypes.FStat; } 11 | } 12 | 13 | public byte[] Handle { get; private set; } 14 | 15 | public SftpFStatRequest(uint protocolVersion, uint requestId, byte[] handle, Action attrsAction, Action statusAction) 16 | : base(protocolVersion, requestId, statusAction) 17 | { 18 | this.Handle = handle; 19 | this.SetAction(attrsAction); 20 | } 21 | 22 | protected override void LoadData() 23 | { 24 | base.LoadData(); 25 | this.Handle = this.ReadBinaryString(); 26 | } 27 | 28 | protected override void SaveData() 29 | { 30 | base.SaveData(); 31 | this.WriteBinaryString(this.Handle); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpReadDirRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | 4 | namespace Renci.SshNet.Sftp.Requests 5 | { 6 | internal class SftpReadDirRequest : SftpRequest 7 | { 8 | public override SftpMessageTypes SftpMessageType 9 | { 10 | get { return SftpMessageTypes.ReadDir; } 11 | } 12 | 13 | public byte[] Handle { get; private set; } 14 | 15 | public SftpReadDirRequest(uint protocolVersion, uint requestId, byte[] handle, Action nameAction, Action statusAction) 16 | : base(protocolVersion, requestId, statusAction) 17 | { 18 | this.Handle = handle; 19 | this.SetAction(nameAction); 20 | } 21 | 22 | protected override void LoadData() 23 | { 24 | base.LoadData(); 25 | this.Handle = this.ReadBinaryString(); 26 | } 27 | 28 | protected override void SaveData() 29 | { 30 | base.SaveData(); 31 | this.WriteBinaryString(this.Handle); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /SSH/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Input; 7 | 8 | namespace npcook.Ssh 9 | { 10 | class RelayCommand : ICommand 11 | { 12 | readonly Action execute; 13 | readonly Predicate canExecute; 14 | 15 | public RelayCommand(Action execute) 16 | : this(execute, null) 17 | { } 18 | 19 | public RelayCommand(Action execute, Predicate canExecute) 20 | { 21 | if (execute == null) 22 | throw new ArgumentNullException(nameof(execute)); 23 | 24 | this.execute = execute; 25 | this.canExecute = canExecute; 26 | } 27 | 28 | public bool CanExecute(object parameter) 29 | { 30 | return canExecute == null ? true : canExecute(parameter); 31 | } 32 | 33 | public event EventHandler CanExecuteChanged 34 | { 35 | add { CommandManager.RequerySuggested += value; } 36 | remove { CommandManager.RequerySuggested -= value; } 37 | } 38 | 39 | public void Execute(object parameter) 40 | { 41 | execute(parameter); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Nicholas Cook 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroupExchangeSha256.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Security.Cryptography; 2 | 3 | namespace Renci.SshNet.Security 4 | { 5 | /// 6 | /// Represents "diffie-hellman-group-exchange-sha256" algorithm implementation. 7 | /// 8 | public class KeyExchangeDiffieHellmanGroupExchangeSha256 : KeyExchangeDiffieHellmanGroupExchangeShaBase 9 | { 10 | /// 11 | /// Gets algorithm name. 12 | /// 13 | public override string Name 14 | { 15 | get { return "diffie-hellman-group-exchange-sha256"; } 16 | } 17 | 18 | /// 19 | /// Hashes the specified data bytes. 20 | /// 21 | /// Data to hash. 22 | /// 23 | /// Hashed bytes 24 | /// 25 | protected override byte[] Hash(byte[] hashBytes) 26 | { 27 | using (var md = new SHA256Hash()) 28 | { 29 | return md.ComputeHash(hashBytes); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/PosixRenameRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | 4 | namespace Renci.SshNet.Sftp.Requests 5 | { 6 | internal class PosixRenameRequest : SftpRequest 7 | { 8 | public const string NAME = "posix-rename@openssh.com"; 9 | 10 | public override SftpMessageTypes SftpMessageType 11 | { 12 | get { return SftpMessageTypes.Extended; } 13 | } 14 | 15 | public string OldPath { get; private set; } 16 | 17 | public string NewPath { get; private set; } 18 | 19 | public PosixRenameRequest(uint protocolVersion, uint requestId, string oldPath, string newPath, Action statusAction) 20 | : base(protocolVersion, requestId, statusAction) 21 | { 22 | this.OldPath = oldPath; 23 | this.NewPath = newPath; 24 | } 25 | 26 | protected override void SaveData() 27 | { 28 | base.SaveData(); 29 | this.Write(PosixRenameRequest.NAME); 30 | this.Write(this.OldPath); 31 | this.Write(this.NewPath); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Responses/SftpStatusResponse.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Sftp.Responses 2 | { 3 | internal class SftpStatusResponse : SftpResponse 4 | { 5 | public override SftpMessageTypes SftpMessageType 6 | { 7 | get { return SftpMessageTypes.Status; } 8 | } 9 | 10 | public SftpStatusResponse(uint protocolVersion) 11 | : base(protocolVersion) 12 | { 13 | } 14 | 15 | public StatusCodes StatusCode { get; private set; } 16 | 17 | public string ErrorMessage { get; private set; } 18 | 19 | public string Language { get; private set; } 20 | 21 | protected override void LoadData() 22 | { 23 | base.LoadData(); 24 | 25 | this.StatusCode = (StatusCodes)this.ReadUInt32(); 26 | 27 | if (this.ProtocolVersion < 3) 28 | { 29 | return; 30 | } 31 | 32 | if (!this.IsEndOfData) 33 | { 34 | this.ErrorMessage = this.ReadString(); 35 | this.Language = this.ReadString(); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Security/Cryptography/Ciphers/Paddings/PKCS5Padding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Security.Cryptography.Ciphers.Paddings 4 | { 5 | /// 6 | /// Implements PKCS5 cipher padding 7 | /// 8 | public class PKCS5Padding : CipherPadding 9 | { 10 | /// 11 | /// Transforms the specified input. 12 | /// 13 | /// Size of the block. 14 | /// The input. 15 | /// 16 | /// Padded data array. 17 | /// 18 | public override byte[] Pad(int blockSize, byte[] input) 19 | { 20 | var numOfPaddedBytes = blockSize - (input.Length % blockSize); 21 | 22 | var output = new byte[input.Length + numOfPaddedBytes]; 23 | Buffer.BlockCopy(input, 0, output, 0, input.Length); 24 | for (int i = 0; i < numOfPaddedBytes; i++) 25 | { 26 | output[input.Length + i] = (byte)numOfPaddedBytes; 27 | } 28 | 29 | return output; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Security/Cryptography/Ciphers/Paddings/PKCS7Padding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Security.Cryptography.Ciphers.Paddings 4 | { 5 | /// 6 | /// Implements PKCS7 cipher padding 7 | /// 8 | public class PKCS7Padding : CipherPadding 9 | { 10 | /// 11 | /// Transforms the specified input. 12 | /// 13 | /// Size of the block. 14 | /// The input. 15 | /// 16 | /// Padded data array. 17 | /// 18 | public override byte[] Pad(int blockSize, byte[] input) 19 | { 20 | var numOfPaddedBytes = blockSize - (input.Length % blockSize); 21 | 22 | var output = new byte[input.Length + numOfPaddedBytes]; 23 | Buffer.BlockCopy(input, 0, output, 0, input.Length); 24 | for (int i = 0; i < numOfPaddedBytes; i++) 25 | { 26 | output[input.Length + i] = (byte)numOfPaddedBytes; 27 | } 28 | 29 | return output; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Responses/ExtendedReplies/StatVfsReplyInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Sftp.Responses 2 | { 3 | internal class StatVfsReplyInfo : ExtendedReplyInfo 4 | { 5 | public SftpFileSytemInformation Information { get; private set; } 6 | 7 | protected override void LoadData() 8 | { 9 | base.LoadData(); 10 | 11 | this.Information = new SftpFileSytemInformation(this.ReadUInt64(), this.ReadUInt64(), 12 | this.ReadUInt64(), this.ReadUInt64(), 13 | this.ReadUInt64(), this.ReadUInt64(), 14 | this.ReadUInt64(), this.ReadUInt64(), 15 | this.ReadUInt64(), this.ReadUInt64(), 16 | this.ReadUInt64()); 17 | } 18 | 19 | protected override void SaveData() 20 | { 21 | throw new System.NotImplementedException(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /TerminalControl/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Input; 7 | 8 | namespace npcook.Terminal.Controls 9 | { 10 | class RelayCommand : ICommand 11 | { 12 | readonly Action execute; 13 | readonly Predicate canExecute; 14 | 15 | public RelayCommand(Action execute) 16 | : this(execute, null) 17 | { } 18 | 19 | public RelayCommand(Action execute, Predicate canExecute) 20 | { 21 | if (execute == null) 22 | throw new ArgumentNullException(nameof(execute)); 23 | 24 | this.execute = execute; 25 | this.canExecute = canExecute; 26 | } 27 | 28 | public bool CanExecute(object parameter) 29 | { 30 | return canExecute == null ? true : canExecute(parameter); 31 | } 32 | 33 | public event EventHandler CanExecuteChanged 34 | { 35 | add { CommandManager.RequerySuggested += value; } 36 | remove { CommandManager.RequerySuggested -= value; } 37 | } 38 | 39 | public void Execute(object parameter) 40 | { 41 | execute(parameter); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ProxyException.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Renci.SshNet.Common 5 | { 6 | [Serializable] 7 | public partial class ProxyException : SshException 8 | { 9 | /// 10 | /// Initializes a new instance of the class. 11 | /// 12 | /// The that holds the serialized object data about the exception being thrown. 13 | /// The that contains contextual information about the source or destination. 14 | /// The parameter is null. 15 | /// The class name is null or is zero (0). 16 | protected ProxyException(SerializationInfo info, StreamingContext context) 17 | : base(info, context) 18 | { 19 | } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/ExtendedRequests/HardLinkRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | 4 | namespace Renci.SshNet.Sftp.Requests 5 | { 6 | internal class HardLinkRequest : SftpExtendedRequest 7 | { 8 | public override SftpMessageTypes SftpMessageType 9 | { 10 | get { return SftpMessageTypes.Extended; } 11 | } 12 | 13 | public override string Name 14 | { 15 | get { return "hardlink@openssh.com"; } 16 | } 17 | 18 | public string OldPath { get; private set; } 19 | 20 | public string NewPath { get; private set; } 21 | 22 | public HardLinkRequest(uint protocolVersion, uint requestId, string oldPath, string newPath, Action statusAction) 23 | : base(protocolVersion, requestId, statusAction) 24 | { 25 | this.OldPath = oldPath; 26 | this.NewPath = newPath; 27 | } 28 | 29 | protected override void SaveData() 30 | { 31 | base.SaveData(); 32 | this.Write(this.OldPath); 33 | this.Write(this.NewPath); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Compression/ZlibOpenSsh.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Compression 2 | { 3 | /// 4 | /// Represents "zlib@openssh.org" compression implementation 5 | /// 6 | public class ZlibOpenSsh : Compressor 7 | { 8 | /// 9 | /// Gets algorithm name. 10 | /// 11 | public override string Name 12 | { 13 | get { return "zlib@openssh.org"; } 14 | } 15 | 16 | /// 17 | /// Initializes the algorithm 18 | /// 19 | /// The session. 20 | public override void Init(Session session) 21 | { 22 | base.Init(session); 23 | 24 | session.UserAuthenticationSuccessReceived += Session_UserAuthenticationSuccessReceived; 25 | } 26 | 27 | private void Session_UserAuthenticationSuccessReceived(object sender, MessageEventArgs e) 28 | { 29 | this.IsActive = true; 30 | this.Session.UserAuthenticationSuccessReceived -= Session_UserAuthenticationSuccessReceived; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /TerminalControl/DebugColors.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Media; 7 | 8 | namespace npcook.Terminal.Controls 9 | { 10 | using Color = System.Windows.Media.Color; 11 | 12 | static class DebugColors 13 | { 14 | static Color[] colors; 15 | 16 | static DebugColors() 17 | { 18 | const byte alpha = 255; 19 | const byte intensity = 128; 20 | colors = new[] 21 | { 22 | Color.FromArgb(alpha, intensity, 0, 0), 23 | Color.FromArgb(alpha, 0, intensity, 0), 24 | Color.FromArgb(alpha, 0, 0, (byte) Math.Min(255, 3 * intensity / 2)), 25 | Color.FromArgb(alpha, intensity, intensity, 0), 26 | Color.FromArgb(alpha, intensity, 0, intensity), 27 | Color.FromArgb(alpha, 0, intensity, intensity), 28 | Color.FromArgb(alpha, intensity, intensity, intensity), 29 | }; 30 | } 31 | 32 | public static Color GetColor(int index) 33 | { 34 | return colors[index % colors.Length]; 35 | } 36 | 37 | public static SolidColorBrush GetBrush(int index) 38 | { 39 | return new SolidColorBrush(GetColor(index)); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SSH/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace npcook.Ssh.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/SshException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// The exception that is thrown when SSH exception occurs. 7 | /// 8 | public partial class SshException : Exception 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public SshException() 14 | { 15 | } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The message. 21 | public SshException(string message) 22 | : base(message) 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The message. 30 | /// The inner. 31 | public SshException(string message, Exception inner) 32 | : base(message, inner) 33 | { 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpRmDirRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Renci.SshNet.Sftp.Responses; 4 | 5 | namespace Renci.SshNet.Sftp.Requests 6 | { 7 | internal class SftpRmDirRequest : SftpRequest 8 | { 9 | public override SftpMessageTypes SftpMessageType 10 | { 11 | get { return SftpMessageTypes.RmDir; } 12 | } 13 | 14 | public string Path { get; private set; } 15 | 16 | public Encoding Encoding { get; private set; } 17 | 18 | public SftpRmDirRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, Action statusAction) 19 | : base(protocolVersion, requestId, statusAction) 20 | { 21 | this.Path = path; 22 | this.Encoding = encoding; 23 | } 24 | 25 | protected override void LoadData() 26 | { 27 | base.LoadData(); 28 | this.Path = this.ReadString(this.Encoding); 29 | } 30 | 31 | protected override void SaveData() 32 | { 33 | base.SaveData(); 34 | this.Write(this.Path, this.Encoding); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ScpException.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Renci.SshNet.Common 5 | { 6 | [Serializable] 7 | public partial class ScpException : SshException 8 | { 9 | /// 10 | /// Initializes a new instance of the class. 11 | /// 12 | /// The that holds the serialized object data about the exception being thrown. 13 | /// The that contains contextual information about the source or destination. 14 | /// The parameter is null. 15 | /// The class name is null or is zero (0). 16 | protected ScpException(SerializationInfo info, StreamingContext context) 17 | : base(info, context) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ShellDataEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// Provides data for Shell DataReceived event 7 | /// 8 | public class ShellDataEventArgs : EventArgs 9 | { 10 | /// 11 | /// Gets the data. 12 | /// 13 | public byte[] Data { get; private set; } 14 | 15 | /// 16 | /// Gets the line data. 17 | /// 18 | public string Line { get; private set; } 19 | 20 | /// 21 | /// Initializes a new instance of the class. 22 | /// 23 | /// The data. 24 | public ShellDataEventArgs(byte[] data) 25 | { 26 | this.Data = data; 27 | } 28 | 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | /// The line. 33 | public ShellDataEventArgs(string line) 34 | { 35 | this.Line = line; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Terminal/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace npcook.Terminal.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/IAuthenticationMethod.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Renci.SshNet 4 | { 5 | /// 6 | /// Base interface for authentication of a session using a given method. 7 | /// 8 | internal interface IAuthenticationMethod 9 | { 10 | /// 11 | /// Authenticates the specified session. 12 | /// 13 | /// The session to authenticate. 14 | /// 15 | /// The result of the authentication process. 16 | /// 17 | AuthenticationResult Authenticate(ISession session); 18 | 19 | /// 20 | /// Gets the list of allowed authentications. 21 | /// 22 | /// 23 | /// The list of allowed authentications. 24 | /// 25 | IEnumerable AllowedAuthentications { get; } 26 | 27 | /// 28 | /// Gets the name of the authentication method. 29 | /// 30 | /// 31 | /// The name of the authentication method. 32 | /// 33 | string Name { get; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /libsshnet/include/libssh/threads.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2010 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef THREADS_H_ 22 | #define THREADS_H_ 23 | 24 | #include 25 | #include 26 | 27 | int ssh_threads_init(void); 28 | void ssh_threads_finalize(void); 29 | const char *ssh_threads_get_type(void); 30 | 31 | #endif /* THREADS_H_ */ 32 | -------------------------------------------------------------------------------- /TerminalControl/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace npcook.Terminal.Controls.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Authentication/BannerMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Authentication 2 | { 3 | /// 4 | /// Represents SSH_MSG_USERAUTH_BANNER message. 5 | /// 6 | [Message("SSH_MSG_USERAUTH_BANNER", 53)] 7 | public class BannerMessage : Message 8 | { 9 | /// 10 | /// Gets banner message. 11 | /// 12 | public string Message { get; private set; } 13 | 14 | /// 15 | /// Gets banner language. 16 | /// 17 | public string Language { get; private set; } 18 | 19 | /// 20 | /// Called when type specific data need to be loaded. 21 | /// 22 | protected override void LoadData() 23 | { 24 | this.Message = this.ReadString(); 25 | this.Language = this.ReadString(); 26 | } 27 | 28 | /// 29 | /// Called when type specific data need to be saved. 30 | /// 31 | protected override void SaveData() 32 | { 33 | this.Write(this.Message); 34 | this.Write(this.Language); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpRemoveRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Renci.SshNet.Sftp.Responses; 4 | 5 | namespace Renci.SshNet.Sftp.Requests 6 | { 7 | internal class SftpRemoveRequest : SftpRequest 8 | { 9 | public override SftpMessageTypes SftpMessageType 10 | { 11 | get { return SftpMessageTypes.Remove; } 12 | } 13 | 14 | public string Filename { get; private set; } 15 | 16 | public Encoding Encoding { get; private set; } 17 | 18 | public SftpRemoveRequest(uint protocolVersion, uint requestId, string filename, Encoding encoding, Action statusAction) 19 | : base(protocolVersion, requestId, statusAction) 20 | { 21 | this.Filename = filename; 22 | this.Encoding = encoding; 23 | } 24 | 25 | protected override void LoadData() 26 | { 27 | base.LoadData(); 28 | this.Filename = this.ReadString(this.Encoding); 29 | } 30 | 31 | protected override void SaveData() 32 | { 33 | base.SaveData(); 34 | this.Write(this.Filename, this.Encoding); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/CipherInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Renci.SshNet.Security.Cryptography; 4 | 5 | namespace Renci.SshNet 6 | { 7 | /// 8 | /// Holds information about key size and cipher to use 9 | /// 10 | public class CipherInfo 11 | { 12 | /// 13 | /// Gets the size of the key. 14 | /// 15 | /// 16 | /// The size of the key. 17 | /// 18 | public int KeySize { get; private set; } 19 | 20 | /// 21 | /// Gets the cipher. 22 | /// 23 | public Func Cipher { get; private set; } 24 | 25 | /// 26 | /// Initializes a new instance of the class. 27 | /// 28 | /// Size of the key. 29 | /// The cipher. 30 | public CipherInfo(int keySize, Func cipher) 31 | { 32 | this.KeySize = keySize; 33 | this.Cipher = (key, iv) => (cipher(key.Take(this.KeySize / 8).ToArray(), iv)); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/AuthenticationBannerEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Common 2 | { 3 | /// 4 | /// Provides data for event. 5 | /// 6 | public class AuthenticationBannerEventArgs : AuthenticationEventArgs 7 | { 8 | /// 9 | /// Gets banner message. 10 | /// 11 | public string BannerMessage { get; private set; } 12 | 13 | /// 14 | /// Gets banner language. 15 | /// 16 | public string Language { get; private set; } 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The username. 22 | /// Banner message. 23 | /// Banner language. 24 | public AuthenticationBannerEventArgs(string username, string message, string language) 25 | : base(username) 26 | { 27 | this.BannerMessage = message; 28 | this.Language = language; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ScpException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// The exception that is thrown when SCP error occurred. 7 | /// 8 | public partial class ScpException : SshException 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public ScpException() 14 | { 15 | 16 | } 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The message. 22 | public ScpException(string message) 23 | : base(message) 24 | { 25 | 26 | } 27 | 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// The message. 32 | /// The inner exception. 33 | public ScpException(string message, Exception innerException) : 34 | base(message, innerException) 35 | { 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/HashInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Security.Cryptography; 4 | 5 | namespace Renci.SshNet 6 | { 7 | /// 8 | /// Holds information about key size and cipher to use 9 | /// 10 | public class HashInfo 11 | { 12 | /// 13 | /// Gets the size of the key. 14 | /// 15 | /// 16 | /// The size of the key. 17 | /// 18 | public int KeySize { get; private set; } 19 | 20 | /// 21 | /// Gets the cipher. 22 | /// 23 | public Func HashAlgorithm { get; private set; } 24 | 25 | /// 26 | /// Initializes a new instance of the class. 27 | /// 28 | /// Size of the key. 29 | /// The hash algorithm to use for a given key. 30 | public HashInfo(int keySize, Func hash) 31 | { 32 | this.KeySize = keySize; 33 | this.HashAlgorithm = key => (hash(key.Take(this.KeySize / 8).ToArray())); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ProxyException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// The exception that is thrown when SCP error occurred. 7 | /// 8 | public partial class ProxyException : SshException 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public ProxyException() 14 | { 15 | } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The message. 21 | public ProxyException(string message) 22 | : base(message) 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The message. 30 | /// The inner exception. 31 | public ProxyException(string message, Exception innerException) : 32 | base(message, innerException) 33 | { 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /libsshnet/include/libssh/options.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2011 Andreas Schneider 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef _OPTIONS_H 22 | #define _OPTIONS_H 23 | 24 | int ssh_config_parse_file(ssh_session session, const char *filename); 25 | int ssh_options_set_algo(ssh_session session, int algo, const char *list); 26 | int ssh_options_apply(ssh_session session); 27 | 28 | #endif /* _OPTIONS_H */ 29 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/SshOperationTimeoutException.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Renci.SshNet.Common 5 | { 6 | [Serializable] 7 | public partial class SshOperationTimeoutException : SshException 8 | { 9 | /// 10 | /// Initializes a new instance of the class. 11 | /// 12 | /// The that holds the serialized object data about the exception being thrown. 13 | /// The that contains contextual information about the source or destination. 14 | /// The parameter is null. 15 | /// The class name is null or is zero (0). 16 | protected SshOperationTimeoutException(SerializationInfo info, StreamingContext context) 17 | : base(info, context) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/ExtendedRequests/StatVfsRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | using System.Text; 4 | 5 | namespace Renci.SshNet.Sftp.Requests 6 | { 7 | internal class StatVfsRequest : SftpExtendedRequest 8 | { 9 | public override SftpMessageTypes SftpMessageType 10 | { 11 | get { return SftpMessageTypes.Extended; } 12 | } 13 | 14 | public override string Name 15 | { 16 | get { return "statvfs@openssh.com"; } 17 | } 18 | 19 | public string Path { get; private set; } 20 | 21 | public Encoding Encoding { get; private set; } 22 | 23 | public StatVfsRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, Action extendedAction, Action statusAction) 24 | : base(protocolVersion, requestId, statusAction) 25 | { 26 | this.Path = path; 27 | this.Encoding = encoding; 28 | this.SetAction(extendedAction); 29 | } 30 | 31 | protected override void SaveData() 32 | { 33 | base.SaveData(); 34 | this.Write(this.Path, this.Encoding); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpStatRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Renci.SshNet.Sftp.Responses; 4 | 5 | namespace Renci.SshNet.Sftp.Requests 6 | { 7 | internal class SftpStatRequest : SftpRequest 8 | { 9 | public override SftpMessageTypes SftpMessageType 10 | { 11 | get { return SftpMessageTypes.Stat; } 12 | } 13 | 14 | public string Path { get; private set; } 15 | 16 | public Encoding Encoding { get; private set; } 17 | 18 | public SftpStatRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, Action attrsAction, Action statusAction) 19 | : base(protocolVersion, requestId, statusAction) 20 | { 21 | this.Path = path; 22 | this.Encoding = encoding; 23 | this.SetAction(attrsAction); 24 | } 25 | 26 | protected override void LoadData() 27 | { 28 | base.LoadData(); 29 | this.Path = this.ReadString(this.Encoding); 30 | } 31 | 32 | protected override void SaveData() 33 | { 34 | base.SaveData(); 35 | this.Write(this.Path, this.Encoding); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpLStatRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Renci.SshNet.Sftp.Responses; 4 | 5 | namespace Renci.SshNet.Sftp.Requests 6 | { 7 | internal class SftpLStatRequest : SftpRequest 8 | { 9 | public override SftpMessageTypes SftpMessageType 10 | { 11 | get { return SftpMessageTypes.LStat; } 12 | } 13 | 14 | public string Path { get; private set; } 15 | 16 | public Encoding Encoding { get; private set; } 17 | 18 | public SftpLStatRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, Action attrsAction, Action statusAction) 19 | : base(protocolVersion, requestId, statusAction) 20 | { 21 | this.Path = path; 22 | this.Encoding = encoding; 23 | this.SetAction(attrsAction); 24 | } 25 | 26 | protected override void LoadData() 27 | { 28 | base.LoadData(); 29 | this.Path = this.ReadString(this.Encoding); 30 | } 31 | 32 | protected override void SaveData() 33 | { 34 | base.SaveData(); 35 | this.Write(this.Path, this.Encoding); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpOpenDirRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Renci.SshNet.Sftp.Responses; 4 | 5 | namespace Renci.SshNet.Sftp.Requests 6 | { 7 | internal class SftpOpenDirRequest : SftpRequest 8 | { 9 | public override SftpMessageTypes SftpMessageType 10 | { 11 | get { return SftpMessageTypes.OpenDir; } 12 | } 13 | 14 | public string Path { get; private set; } 15 | 16 | public Encoding Encoding { get; private set; } 17 | 18 | public SftpOpenDirRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, Action handleAction, Action statusAction) 19 | : base(protocolVersion, requestId, statusAction) 20 | { 21 | this.Path = path; 22 | this.Encoding = encoding; 23 | this.SetAction(handleAction); 24 | } 25 | 26 | protected override void LoadData() 27 | { 28 | base.LoadData(); 29 | this.Path = this.ReadString(this.Encoding); 30 | } 31 | 32 | protected override void SaveData() 33 | { 34 | base.SaveData(); 35 | this.Write(this.Path, this.Encoding); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpReadLinkRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Renci.SshNet.Sftp.Responses; 4 | 5 | namespace Renci.SshNet.Sftp.Requests 6 | { 7 | internal class SftpReadLinkRequest : SftpRequest 8 | { 9 | public override SftpMessageTypes SftpMessageType 10 | { 11 | get { return SftpMessageTypes.ReadLink; } 12 | } 13 | 14 | public string Path { get; private set; } 15 | 16 | public Encoding Encoding { get; private set; } 17 | 18 | public SftpReadLinkRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, Action nameAction, Action statusAction) 19 | : base(protocolVersion, requestId, statusAction) 20 | { 21 | this.Path = path; 22 | this.Encoding = encoding; 23 | this.SetAction(nameAction); 24 | } 25 | 26 | protected override void LoadData() 27 | { 28 | base.LoadData(); 29 | this.Path = this.ReadString(this.Encoding); 30 | } 31 | 32 | protected override void SaveData() 33 | { 34 | base.SaveData(); 35 | this.Write(this.Path, this.Encoding); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Authentication/PasswordChangeRequiredMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Authentication 2 | { 3 | /// 4 | /// Represents SSH_MSG_USERAUTH_PASSWD_CHANGEREQ message. 5 | /// 6 | [Message("SSH_MSG_USERAUTH_PASSWD_CHANGEREQ", 60)] 7 | internal class PasswordChangeRequiredMessage : Message 8 | { 9 | /// 10 | /// Gets password change request message. 11 | /// 12 | public string Message { get; private set; } 13 | 14 | /// 15 | /// Gets message language. 16 | /// 17 | public string Language { get; private set; } 18 | 19 | /// 20 | /// Called when type specific data need to be loaded. 21 | /// 22 | protected override void LoadData() 23 | { 24 | this.Message = this.ReadString(); 25 | this.Language = this.ReadString(); 26 | } 27 | 28 | /// 29 | /// Called when type specific data need to be saved. 30 | /// 31 | protected override void SaveData() 32 | { 33 | this.Write(this.Message); 34 | this.Write(this.Language); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpFSetStatRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | 4 | namespace Renci.SshNet.Sftp.Requests 5 | { 6 | internal class SftpFSetStatRequest : SftpRequest 7 | { 8 | public override SftpMessageTypes SftpMessageType 9 | { 10 | get { return SftpMessageTypes.FSetStat; } 11 | } 12 | 13 | public byte[] Handle { get; private set; } 14 | 15 | public SftpFileAttributes Attributes { get; private set; } 16 | 17 | public SftpFSetStatRequest(uint protocolVersion, uint requestId, byte[] handle, SftpFileAttributes attributes, Action statusAction) 18 | : base(protocolVersion, requestId, statusAction) 19 | { 20 | this.Handle = handle; 21 | this.Attributes = attributes; 22 | } 23 | 24 | protected override void LoadData() 25 | { 26 | base.LoadData(); 27 | this.Handle = this.ReadBinaryString(); 28 | this.Attributes = this.ReadAttributes(); 29 | } 30 | 31 | protected override void SaveData() 32 | { 33 | base.SaveData(); 34 | this.WriteBinaryString(this.Handle); 35 | this.Write(this.Attributes); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/SshException.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Renci.SshNet.Common 5 | { 6 | /// 7 | /// The exception that is thrown when SSH exception occurs. 8 | /// 9 | [Serializable] 10 | public partial class SshException : Exception 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The that holds the serialized object data about the exception being thrown. 16 | /// The that contains contextual information about the source or destination. 17 | /// The parameter is null. 18 | /// 19 | /// The class name is null or is zero (0). 20 | protected SshException(SerializationInfo info, StreamingContext context) 21 | : base(info, context) 22 | { 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/MessageAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Messages 4 | { 5 | 6 | /// 7 | /// Indicates that a class represents SSH message. This class cannot be inherited. 8 | /// 9 | [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)] 10 | public sealed class MessageAttribute : Attribute 11 | { 12 | /// 13 | /// Gets or sets message name as defined in RFC 4250. 14 | /// 15 | /// 16 | /// The name. 17 | /// 18 | public string Name { get; set; } 19 | 20 | /// 21 | /// Gets or sets message number as defined in RFC 4250. 22 | /// 23 | /// 24 | /// The number. 25 | /// 26 | public byte Number { get; set; } 27 | 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// The name. 32 | /// The number. 33 | public MessageAttribute(string name, byte number) 34 | { 35 | this.Name = name; 36 | this.Number = number; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /libsshnet/include/libssh/bignum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2014 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef BIGNUM_H_ 22 | #define BIGNUM_H_ 23 | 24 | #include "libssh/libcrypto.h" 25 | #include "libssh/libgcrypt.h" 26 | 27 | bignum make_string_bn(ssh_string string); 28 | void make_string_bn_inplace(ssh_string string, bignum bnout); 29 | ssh_string make_bignum_string(bignum num); 30 | void ssh_print_bignum(const char *which,bignum num); 31 | 32 | 33 | #endif /* BIGNUM_H_ */ 34 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/NetConfServerException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// The exception that is thrown when there is something wrong with the server capabilities. 7 | /// 8 | public partial class NetConfServerException : SshException 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public NetConfServerException() 14 | { 15 | } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The message. 21 | public NetConfServerException(string message) 22 | : base(message) 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The message. 30 | /// The inner exception. 31 | public NetConfServerException(string message, Exception innerException) : 32 | base(message, innerException) 33 | { 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/SftpPathNotFoundException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// The exception that is thrown when file or directory is not found. 7 | /// 8 | public partial class SftpPathNotFoundException : SshException 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public SftpPathNotFoundException() 14 | { 15 | } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The message. 21 | public SftpPathNotFoundException(string message) 22 | : base(message) 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The message. 30 | /// The inner exception. 31 | public SftpPathNotFoundException(string message, Exception innerException) : 32 | base(message, innerException) 33 | { 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpRealPathRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Renci.SshNet.Sftp.Responses; 4 | 5 | namespace Renci.SshNet.Sftp.Requests 6 | { 7 | internal class SftpRealPathRequest : SftpRequest 8 | { 9 | public override SftpMessageTypes SftpMessageType 10 | { 11 | get { return SftpMessageTypes.RealPath; } 12 | } 13 | 14 | public string Path { get; private set; } 15 | 16 | public Encoding Encoding { get; private set; } 17 | 18 | public SftpRealPathRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, Action nameAction, Action statusAction) 19 | : base(protocolVersion, requestId, statusAction) 20 | { 21 | if (nameAction == null) 22 | throw new ArgumentNullException("nameAction"); 23 | if (statusAction == null) 24 | throw new ArgumentNullException("statusAction"); 25 | 26 | this.Path = path; 27 | this.Encoding = encoding; 28 | this.SetAction(nameAction); 29 | 30 | } 31 | 32 | protected override void SaveData() 33 | { 34 | base.SaveData(); 35 | this.Write(this.Path, this.Encoding); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/SshAuthenticationException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// The exception that is thrown when authentication failed. 7 | /// 8 | public partial class SshAuthenticationException : SshException 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public SshAuthenticationException() 14 | { 15 | 16 | } 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The message. 22 | public SshAuthenticationException(string message) 23 | : base(message) 24 | { 25 | 26 | } 27 | 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// The message. 32 | /// The inner exception. 33 | public SshAuthenticationException(string message, Exception innerException) : 34 | base(message, innerException) 35 | { 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/SftpListDirectoryAsyncResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Renci.SshNet.Common; 4 | 5 | namespace Renci.SshNet.Sftp 6 | { 7 | /// 8 | /// Encapsulates the results of an asynchronous directory list operation. 9 | /// 10 | public class SftpListDirectoryAsyncResult : AsyncResult> 11 | { 12 | /// 13 | /// Gets the number of files read so far. 14 | /// 15 | public int FilesRead { get; private set; } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The async callback. 21 | /// The state. 22 | public SftpListDirectoryAsyncResult(AsyncCallback asyncCallback, Object state) 23 | : base(asyncCallback, state) 24 | { 25 | 26 | } 27 | 28 | /// 29 | /// Updates asynchronous operation status information. 30 | /// 31 | /// The files read. 32 | internal void Update(int filesRead) 33 | { 34 | this.FilesRead = filesRead; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ScpUploadEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// Provides data for the Uploading event. 7 | /// 8 | public class ScpUploadEventArgs : EventArgs 9 | { 10 | /// 11 | /// Gets the uploaded filename. 12 | /// 13 | public string Filename { get; private set; } 14 | 15 | /// 16 | /// Gets the uploaded file size. 17 | /// 18 | public long Size { get; private set; } 19 | 20 | /// 21 | /// Gets number of uploaded bytes so far. 22 | /// 23 | public long Uploaded { get; private set; } 24 | 25 | /// 26 | /// Initializes a new instance of the class. 27 | /// 28 | /// The uploaded filename. 29 | /// The the uploaded file size. 30 | /// The number of uploaded bytes so far. 31 | public ScpUploadEventArgs(string filename, long size, long uploaded) 32 | { 33 | this.Filename = filename; 34 | this.Size = size; 35 | this.Uploaded = uploaded; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/SshConnectionException.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Renci.SshNet.Common 5 | { 6 | /// 7 | /// The exception that is thrown when connection was terminated. 8 | /// 9 | [Serializable] 10 | public partial class SshConnectionException : SshException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The that holds the serialized object data about the exception being thrown. 16 | /// The that contains contextual information about the source or destination. 17 | /// The parameter is null. 18 | /// The class name is null or is zero (0). 19 | protected SshConnectionException(SerializationInfo info, StreamingContext context) 20 | : base(info, context) 21 | { 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/SshOperationTimeoutException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// The exception that is thrown when operation is timed out. 7 | /// 8 | public partial class SshOperationTimeoutException : SshException 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public SshOperationTimeoutException() 14 | { 15 | } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The message. 21 | public SshOperationTimeoutException(string message) 22 | : base(message) 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The message. 30 | /// The inner exception. 31 | public SshOperationTimeoutException(string message, Exception innerException) : 32 | base(message, innerException) 33 | { 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /TerminalControlTests/DequeTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace npcook.Terminal.Controls.Tests 6 | { 7 | [TestClass] 8 | public class DequeTests 9 | { 10 | [TestMethod] 11 | public void TestInsert() 12 | { 13 | Deque test = new Deque(10); 14 | test.Add(0); 15 | test.Add(1); 16 | test.Add(2); 17 | test.Add(3); 18 | test.Add(4); 19 | test.Add(5); 20 | test.Add(6); 21 | test.Add(7); 22 | test.Add(8); 23 | test.Add(9); 24 | test.RemoveAt(0); 25 | test.RemoveAt(0); 26 | test.Insert(3, 7); 27 | test.Insert(3, 8); 28 | 29 | CollectionAssert.AreEqual(test.ToArray(), new int[] { 2, 3, 4, 8, 7, 5, 6, 7, 8, 9 }); 30 | Assert.AreEqual(test.Count, 10); 31 | } 32 | 33 | [TestMethod] 34 | public void TestRemoveAt() 35 | { 36 | Deque test = new Deque(6); 37 | test.Add(0); 38 | test.Add(1); 39 | test.Add(2); 40 | test.Add(3); 41 | test.Add(4); 42 | test.Add(5); 43 | 44 | test.PopFront(); 45 | test.PopFront(); 46 | 47 | test.Add(6); 48 | test.Add(7); 49 | 50 | test.RemoveAt(2); 51 | 52 | int[] arr = test.ToArray(); 53 | 54 | CollectionAssert.AreEqual(arr, new int[] { 2, 3, 5, 6, 7 }); 55 | Assert.AreEqual(test.Count, 5); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/SshAuthenticationException.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Renci.SshNet.Common 5 | { 6 | /// 7 | /// The exception that is thrown when authentication failed. 8 | /// 9 | [Serializable] 10 | public partial class SshAuthenticationException : SshException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The that holds the serialized object data about the exception being thrown. 16 | /// The that contains contextual information about the source or destination. 17 | /// The parameter is null. 18 | /// The class name is null or is zero (0). 19 | protected SshAuthenticationException(SerializationInfo info, StreamingContext context) 20 | : base(info, context) 21 | { 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/SftpPathNotFoundException.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Renci.SshNet.Common 5 | { 6 | /// 7 | /// The exception that is thrown when file or directory is not found. 8 | /// 9 | [Serializable] 10 | public partial class SftpPathNotFoundException : SshException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The that holds the serialized object data about the exception being thrown. 16 | /// The that contains contextual information about the source or destination. 17 | /// The parameter is null. 18 | /// The class name is null or is zero (0). 19 | protected SftpPathNotFoundException(SerializationInfo info, StreamingContext context) 20 | : base(info, context) 21 | { 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/SftpPermissionDeniedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// The exception that is thrown when operation permission is denied. 7 | /// 8 | public partial class SftpPermissionDeniedException : SshException 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public SftpPermissionDeniedException() 14 | { 15 | } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The message. 21 | public SftpPermissionDeniedException(string message) 22 | : base(message) 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The message. 30 | /// The inner exception. 31 | public SftpPermissionDeniedException(string message, Exception innerException) : 32 | base(message, innerException) 33 | { 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/ExtendedRequests/PosixRenameRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | using System.Text; 4 | 5 | namespace Renci.SshNet.Sftp.Requests 6 | { 7 | internal class PosixRenameRequest : SftpExtendedRequest 8 | { 9 | public override SftpMessageTypes SftpMessageType 10 | { 11 | get { return SftpMessageTypes.Extended; } 12 | } 13 | 14 | public override string Name 15 | { 16 | get { return "posix-rename@openssh.com"; } 17 | } 18 | 19 | public string OldPath { get; private set; } 20 | 21 | public string NewPath { get; private set; } 22 | 23 | public Encoding Encoding { get; private set; } 24 | 25 | public PosixRenameRequest(uint protocolVersion, uint requestId, string oldPath, string newPath, Encoding encoding, Action statusAction) 26 | : base(protocolVersion, requestId, statusAction) 27 | { 28 | this.OldPath = oldPath; 29 | this.NewPath = newPath; 30 | this.Encoding = encoding; 31 | } 32 | 33 | protected override void SaveData() 34 | { 35 | base.SaveData(); 36 | this.Write(this.OldPath, this.Encoding); 37 | this.Write(this.NewPath, this.Encoding); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /libsshnet/include/libssh/string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2009 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef STRING_H_ 22 | #define STRING_H_ 23 | #include "libssh/priv.h" 24 | 25 | /* must be 32 bits number + immediately our data */ 26 | #ifdef _MSC_VER 27 | #pragma pack(1) 28 | #endif 29 | struct ssh_string_struct { 30 | uint32_t size; 31 | unsigned char data[1]; 32 | } 33 | #if defined(__GNUC__) 34 | __attribute__ ((packed)) 35 | #endif 36 | #ifdef _MSC_VER 37 | #pragma pack() 38 | #endif 39 | ; 40 | 41 | #endif /* STRING_H_ */ 42 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ScpDownloadEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// Provides data for the Downloading event. 7 | /// 8 | public class ScpDownloadEventArgs : EventArgs 9 | { 10 | /// 11 | /// Gets the downloaded filename. 12 | /// 13 | public string Filename { get; private set; } 14 | 15 | /// 16 | /// Gets the downloaded file size. 17 | /// 18 | public long Size { get; private set; } 19 | 20 | /// 21 | /// Gets number of downloaded bytes so far. 22 | /// 23 | public long Downloaded { get; private set; } 24 | 25 | /// 26 | /// Initializes a new instance of the class. 27 | /// 28 | /// The downloaded filename. 29 | /// The downloaded file size. 30 | /// The number of downloaded bytes so far. 31 | public ScpDownloadEventArgs(string filename, long size, long downloaded) 32 | { 33 | this.Filename = filename; 34 | this.Size = size; 35 | this.Downloaded = downloaded; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /libsshnet/AssemblyInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | using namespace System; 4 | using namespace System::Reflection; 5 | using namespace System::Runtime::CompilerServices; 6 | using namespace System::Runtime::InteropServices; 7 | using namespace System::Security::Permissions; 8 | 9 | // 10 | // General Information about an assembly is controlled through the following 11 | // set of attributes. Change these attribute values to modify the information 12 | // associated with an assembly. 13 | // 14 | [assembly:AssemblyTitleAttribute(L"libsshnet")]; 15 | [assembly:AssemblyDescriptionAttribute(L"")]; 16 | [assembly:AssemblyConfigurationAttribute(L"")]; 17 | [assembly:AssemblyCompanyAttribute(L"")]; 18 | [assembly:AssemblyProductAttribute(L"libsshnet")]; 19 | [assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2015")]; 20 | [assembly:AssemblyTrademarkAttribute(L"")]; 21 | [assembly:AssemblyCultureAttribute(L"")]; 22 | 23 | // 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the value or you can default the Revision and Build Numbers 32 | // by using the '*' as shown below: 33 | 34 | [assembly:AssemblyVersionAttribute("1.0.*")]; 35 | 36 | [assembly:ComVisible(false)]; 37 | 38 | [assembly:CLSCompliantAttribute(true)]; -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/NetConfServerException.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Renci.SshNet.Common 5 | { 6 | /// 7 | /// The exception that is thrown when there is something wrong with the server capabilities. 8 | /// 9 | [Serializable] 10 | public partial class NetConfServerException : SshException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The that holds the serialized object data about the exception being thrown. 16 | /// The that contains contextual information about the source or destination. 17 | /// The parameter is null. 18 | /// The class name is null or is zero (0). 19 | protected NetConfServerException(SerializationInfo info, StreamingContext context) 20 | : base(info, context) 21 | { 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/SftpPermissionDeniedException.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Renci.SshNet.Common 5 | { 6 | /// 7 | /// The exception that is thrown when operation permission is denied. 8 | /// 9 | [Serializable] 10 | public partial class SftpPermissionDeniedException : SshException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The that holds the serialized object data about the exception being thrown. 16 | /// The that contains contextual information about the source or destination. 17 | /// The parameter is null. 18 | /// The class name is null or is zero (0). 19 | protected SftpPermissionDeniedException(SerializationInfo info, StreamingContext context) 20 | : base(info, context) 21 | { 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/Extensions.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Sockets; 5 | using System.Text; 6 | 7 | namespace Renci.SshNet 8 | { 9 | /// 10 | /// Collection of different extension method specific for .NET 4.0 11 | /// 12 | public static partial class Extensions 13 | { 14 | /// 15 | /// Indicates whether a specified string is null, empty, or consists only of white-space characters. 16 | /// 17 | /// The string to test. 18 | /// 19 | /// true if the value parameter is null or System.String.Empty, or if value consists exclusively of white-space characters; otherwise, false. 20 | /// 21 | internal static bool IsNullOrWhiteSpace(this string value) 22 | { 23 | return string.IsNullOrWhiteSpace(value); 24 | } 25 | 26 | internal static bool CanRead(this Socket socket) 27 | { 28 | return socket.Connected && socket.Poll(-1, SelectMode.SelectRead) && socket.Available > 0; 29 | } 30 | 31 | internal static bool CanWrite(this Socket socket) 32 | { 33 | return socket.Connected && socket.Poll(-1, SelectMode.SelectWrite); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/SftpSynchronizeDirectoriesAsyncResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Renci.SshNet.Common; 4 | using System.IO; 5 | 6 | namespace Renci.SshNet.Sftp 7 | { 8 | /// 9 | /// Encapsulates the results of an asynchronous directory synchronization operation. 10 | /// 11 | public class SftpSynchronizeDirectoriesAsyncResult : AsyncResult> 12 | { 13 | /// 14 | /// Gets the number of files read so far. 15 | /// 16 | public int FilesRead { get; private set; } 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The async callback. 22 | /// The state. 23 | public SftpSynchronizeDirectoriesAsyncResult(AsyncCallback asyncCallback, Object state) 24 | : base(asyncCallback, state) 25 | { 26 | } 27 | 28 | /// 29 | /// Updates asynchronous operation status information. 30 | /// 31 | /// The files read. 32 | internal void Update(int filesRead) 33 | { 34 | this.FilesRead = filesRead; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/SshPassPhraseNullOrEmptyException.NET40.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Renci.SshNet.Common 5 | { 6 | /// 7 | /// The exception that is thrown when pass phrase for key file is empty or null 8 | /// 9 | [Serializable] 10 | public partial class SshPassPhraseNullOrEmptyException : SshException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The that holds the serialized object data about the exception being thrown. 16 | /// The that contains contextual information about the source or destination. 17 | /// The parameter is null. 18 | /// The class name is null or is zero (0). 19 | protected SshPassPhraseNullOrEmptyException(SerializationInfo info, StreamingContext context) 20 | : base(info, context) 21 | { 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/ChannelRequest/RequestInfo.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Common; 2 | 3 | namespace Renci.SshNet.Messages.Connection 4 | { 5 | /// 6 | /// Represents type specific information for channel request. 7 | /// 8 | public abstract class RequestInfo : SshData 9 | { 10 | /// 11 | /// Gets the name of the request. 12 | /// 13 | /// 14 | /// The name of the request. 15 | /// 16 | public abstract string RequestName { get; } 17 | 18 | /// 19 | /// Gets or sets a value indicating whether reply message is needed. 20 | /// 21 | /// 22 | /// true if reply message is needed; otherwise, false. 23 | /// 24 | public bool WantReply { get; protected set; } 25 | 26 | /// 27 | /// Called when type specific data need to be loaded. 28 | /// 29 | protected override void LoadData() 30 | { 31 | this.WantReply = this.ReadBoolean(); 32 | } 33 | 34 | /// 35 | /// Called when type specific data need to be saved. 36 | /// 37 | protected override void SaveData() 38 | { 39 | this.Write(this.WantReply); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/SshPassPhraseNullOrEmptyException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// The exception that is thrown when pass phrase for key file is empty or null 7 | /// 8 | public partial class SshPassPhraseNullOrEmptyException : SshException 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public SshPassPhraseNullOrEmptyException() 14 | { 15 | 16 | } 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The message. 22 | public SshPassPhraseNullOrEmptyException(string message) 23 | : base(message) 24 | { 25 | 26 | } 27 | 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// The message. 32 | /// The inner exception. 33 | public SshPassPhraseNullOrEmptyException(string message, Exception innerException) : 34 | base(message, innerException) 35 | { 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Authentication/PublicKeyMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Authentication 2 | { 3 | /// 4 | /// Represents SSH_MSG_USERAUTH_PK_OK message. 5 | /// 6 | [Message("SSH_MSG_USERAUTH_PK_OK", 60)] 7 | internal class PublicKeyMessage : Message 8 | { 9 | /// 10 | /// Gets the name of the public key algorithm. 11 | /// 12 | /// 13 | /// The name of the public key algorithm. 14 | /// 15 | public string PublicKeyAlgorithmName { get; private set; } 16 | 17 | /// 18 | /// Gets the public key data. 19 | /// 20 | public byte[] PublicKeyData { get; private set; } 21 | 22 | /// 23 | /// Called when type specific data need to be loaded. 24 | /// 25 | protected override void LoadData() 26 | { 27 | this.PublicKeyAlgorithmName = this.ReadAsciiString(); 28 | this.PublicKeyData = this.ReadBinaryString(); 29 | } 30 | 31 | /// 32 | /// Called when type specific data need to be saved. 33 | /// 34 | protected override void SaveData() 35 | { 36 | this.WriteAscii(this.PublicKeyAlgorithmName); 37 | this.WriteBinaryString(this.PublicKeyData); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeInit.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Common; 2 | 3 | namespace Renci.SshNet.Messages.Transport 4 | { 5 | /// 6 | /// Represents SSH_MSG_KEX_DH_GEX_INIT message. 7 | /// 8 | [Message("SSH_MSG_KEX_DH_GEX_INIT", 32)] 9 | internal class KeyExchangeDhGroupExchangeInit : Message, IKeyExchangedAllowed 10 | { 11 | /// 12 | /// Gets the E value. 13 | /// 14 | public BigInteger E { get; private set; } 15 | 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The client exchange value. 20 | public KeyExchangeDhGroupExchangeInit(BigInteger clientExchangeValue) 21 | { 22 | this.E = clientExchangeValue; 23 | } 24 | 25 | /// 26 | /// Called when type specific data need to be loaded. 27 | /// 28 | protected override void LoadData() 29 | { 30 | this.E = this.ReadBigInt(); 31 | } 32 | 33 | /// 34 | /// Called when type specific data need to be saved. 35 | /// 36 | protected override void SaveData() 37 | { 38 | this.Write(this.E); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Transport/KeyExchangeDhInitMessage.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Common; 2 | 3 | namespace Renci.SshNet.Messages.Transport 4 | { 5 | /// 6 | /// Represents SSH_MSG_KEXDH_INIT message. 7 | /// 8 | [Message("SSH_MSG_KEXDH_INIT", 30)] 9 | internal class KeyExchangeDhInitMessage : Message, IKeyExchangedAllowed 10 | { 11 | /// 12 | /// Gets the E value. 13 | /// 14 | public BigInteger E { get; private set; } 15 | 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The client exchange value. 20 | public KeyExchangeDhInitMessage(BigInteger clientExchangeValue) 21 | { 22 | this.E = clientExchangeValue; 23 | } 24 | 25 | /// 26 | /// Called when type specific data need to be loaded. 27 | /// 28 | protected override void LoadData() 29 | { 30 | this.ResetReader(); 31 | this.E = this.ReadBigInt(); 32 | } 33 | 34 | /// 35 | /// Called when type specific data need to be saved. 36 | /// 37 | protected override void SaveData() 38 | { 39 | this.Write(this.E); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpRenameRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Renci.SshNet.Sftp.Responses; 4 | 5 | namespace Renci.SshNet.Sftp.Requests 6 | { 7 | internal class SftpRenameRequest : SftpRequest 8 | { 9 | public override SftpMessageTypes SftpMessageType 10 | { 11 | get { return SftpMessageTypes.Rename; } 12 | } 13 | 14 | public string OldPath { get; private set; } 15 | 16 | public string NewPath { get; private set; } 17 | 18 | public Encoding Encoding { get; private set; } 19 | 20 | public SftpRenameRequest(uint protocolVersion, uint requestId, string oldPath, string newPath, Encoding encoding, Action statusAction) 21 | : base(protocolVersion, requestId, statusAction) 22 | { 23 | this.OldPath = oldPath; 24 | this.NewPath = newPath; 25 | this.Encoding = encoding; 26 | } 27 | 28 | protected override void LoadData() 29 | { 30 | base.LoadData(); 31 | this.OldPath = this.ReadString(this.Encoding); 32 | this.NewPath = this.ReadString(this.Encoding); 33 | } 34 | 35 | protected override void SaveData() 36 | { 37 | base.SaveData(); 38 | this.Write(this.OldPath, this.Encoding); 39 | this.Write(this.NewPath, this.Encoding); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpSetStatRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Renci.SshNet.Sftp.Responses; 4 | 5 | namespace Renci.SshNet.Sftp.Requests 6 | { 7 | internal class SftpSetStatRequest : SftpRequest 8 | { 9 | public override SftpMessageTypes SftpMessageType 10 | { 11 | get { return SftpMessageTypes.SetStat; } 12 | } 13 | 14 | public string Path { get; private set; } 15 | 16 | public Encoding Encoding { get; private set; } 17 | 18 | public SftpFileAttributes Attributes { get; private set; } 19 | 20 | public SftpSetStatRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, SftpFileAttributes attributes, Action statusAction) 21 | : base(protocolVersion, requestId, statusAction) 22 | { 23 | this.Path = path; 24 | this.Encoding = encoding; 25 | this.Attributes = attributes; 26 | } 27 | 28 | protected override void LoadData() 29 | { 30 | base.LoadData(); 31 | this.Path = this.ReadString(this.Encoding); 32 | this.Attributes = this.ReadAttributes(); 33 | } 34 | 35 | protected override void SaveData() 36 | { 37 | base.SaveData(); 38 | this.Write(this.Path, this.Encoding); 39 | this.Write(this.Attributes); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpWriteRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | 4 | namespace Renci.SshNet.Sftp.Requests 5 | { 6 | internal class SftpWriteRequest : SftpRequest 7 | { 8 | public override SftpMessageTypes SftpMessageType 9 | { 10 | get { return SftpMessageTypes.Write; } 11 | } 12 | 13 | public byte[] Handle { get; private set; } 14 | 15 | public UInt64 Offset { get; private set; } 16 | 17 | public byte[] Data { get; private set; } 18 | 19 | public SftpWriteRequest(uint protocolVersion, uint requestId, byte[] handle, UInt64 offset, byte[] data, Action statusAction) 20 | : base(protocolVersion, requestId, statusAction) 21 | { 22 | this.Handle = handle; 23 | this.Offset = offset; 24 | this.Data = data; 25 | } 26 | 27 | protected override void LoadData() 28 | { 29 | base.LoadData(); 30 | this.Handle = this.ReadBinaryString(); 31 | this.Offset = this.ReadUInt64(); 32 | this.Data = this.ReadBinaryString(); 33 | } 34 | 35 | protected override void SaveData() 36 | { 37 | base.SaveData(); 38 | this.WriteBinaryString(this.Handle); 39 | this.Write(this.Offset); 40 | this.WriteBinaryString(this.Data); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroup1Sha1.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Common; 2 | using System.Globalization; 3 | 4 | namespace Renci.SshNet.Security 5 | { 6 | /// 7 | /// Represents "diffie-hellman-group1-sha1" algorithm implementation. 8 | /// 9 | public class KeyExchangeDiffieHellmanGroup1Sha1 : KeyExchangeDiffieHellmanGroupSha1 10 | { 11 | private const string SecondOkleyGroup = @"00FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF"; 12 | 13 | /// 14 | /// Gets algorithm name. 15 | /// 16 | public override string Name 17 | { 18 | get { return "diffie-hellman-group1-sha1"; } 19 | } 20 | 21 | /// 22 | /// Gets the group prime. 23 | /// 24 | /// 25 | /// The group prime. 26 | /// 27 | public override BigInteger GroupPrime 28 | { 29 | get 30 | { 31 | BigInteger prime; 32 | BigInteger.TryParse(SecondOkleyGroup, NumberStyles.AllowHexSpecifier, CultureInfo.CurrentCulture, out prime); 33 | return prime; 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpUnblockRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | 4 | namespace Renci.SshNet.Sftp.Requests 5 | { 6 | internal class SftpUnblockRequest : SftpRequest 7 | { 8 | public override SftpMessageTypes SftpMessageType 9 | { 10 | get { return SftpMessageTypes.Block; } 11 | } 12 | 13 | public byte[] Handle { get; private set; } 14 | 15 | public UInt64 Offset { get; private set; } 16 | 17 | public UInt64 Length { get; private set; } 18 | 19 | public SftpUnblockRequest(uint protocolVersion, uint requestId, byte[] handle, UInt64 offset, UInt64 length, UInt32 lockMask, Action statusAction) 20 | : base(protocolVersion, requestId, statusAction) 21 | { 22 | this.Handle = handle; 23 | this.Offset = offset; 24 | this.Length = length; 25 | } 26 | 27 | protected override void LoadData() 28 | { 29 | base.LoadData(); 30 | this.Handle = this.ReadBinaryString(); 31 | this.Offset = this.ReadUInt64(); 32 | this.Length = this.ReadUInt64(); 33 | } 34 | 35 | protected override void SaveData() 36 | { 37 | base.SaveData(); 38 | this.WriteBinaryString(this.Handle); 39 | this.Write(this.Offset); 40 | this.Write(this.Length); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpSymLinkRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Renci.SshNet.Sftp.Responses; 4 | 5 | namespace Renci.SshNet.Sftp.Requests 6 | { 7 | internal class SftpSymLinkRequest : SftpRequest 8 | { 9 | public override SftpMessageTypes SftpMessageType 10 | { 11 | get { return SftpMessageTypes.SymLink; } 12 | } 13 | 14 | public string NewLinkPath { get; set; } 15 | 16 | public string ExistingPath { get; set; } 17 | 18 | public Encoding Encoding { get; set; } 19 | 20 | public SftpSymLinkRequest(uint protocolVersion, uint requestId, string newLinkPath, string existingPath, Encoding encoding, Action statusAction) 21 | : base(protocolVersion, requestId, statusAction) 22 | { 23 | this.NewLinkPath = newLinkPath; 24 | this.ExistingPath = existingPath; 25 | this.Encoding = encoding; 26 | } 27 | 28 | protected override void LoadData() 29 | { 30 | base.LoadData(); 31 | this.NewLinkPath = this.ReadString(this.Encoding); 32 | this.ExistingPath = this.ReadString(this.Encoding); 33 | } 34 | 35 | protected override void SaveData() 36 | { 37 | base.SaveData(); 38 | this.Write(this.NewLinkPath, this.Encoding); 39 | this.Write(this.ExistingPath, this.Encoding); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeGroup.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Common; 2 | 3 | namespace Renci.SshNet.Messages.Transport 4 | { 5 | /// 6 | /// Represents SSH_MSG_KEX_DH_GEX_GROUP message. 7 | /// 8 | [Message("SSH_MSG_KEX_DH_GEX_GROUP", 31)] 9 | public class KeyExchangeDhGroupExchangeGroup : Message 10 | { 11 | /// 12 | /// Gets or sets the safe prime. 13 | /// 14 | /// 15 | /// The safe prime. 16 | /// 17 | public BigInteger SafePrime { get; private set; } 18 | 19 | /// 20 | /// Gets or sets the generator for subgroup in GF(p). 21 | /// 22 | /// 23 | /// The sub group. 24 | /// 25 | public BigInteger SubGroup { get; private set; } 26 | 27 | /// 28 | /// Called when type specific data need to be loaded. 29 | /// 30 | protected override void LoadData() 31 | { 32 | this.SafePrime = this.ReadBigInt(); 33 | this.SubGroup = this.ReadBigInt(); 34 | } 35 | 36 | /// 37 | /// Called when type specific data need to be saved. 38 | /// 39 | protected override void SaveData() 40 | { 41 | this.Write(this.SafePrime); 42 | this.Write(this.SubGroup); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /libsshnet/include/libssh/ecdh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2011 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef ECDH_H_ 22 | #define ECDH_H_ 23 | 24 | #include "config.h" 25 | 26 | #ifdef HAVE_LIBCRYPTO 27 | #ifdef HAVE_OPENSSL_ECDH_H 28 | 29 | #ifdef HAVE_ECC 30 | #define HAVE_ECDH 1 31 | #endif 32 | 33 | #endif /* HAVE_OPENSSL_ECDH_H */ 34 | #endif /* HAVE_LIBCRYPTO */ 35 | 36 | int ssh_client_ecdh_init(ssh_session session); 37 | int ssh_client_ecdh_reply(ssh_session session, ssh_buffer packet); 38 | 39 | #ifdef WITH_SERVER 40 | int ssh_server_ecdh_init(ssh_session session, ssh_buffer packet); 41 | #endif /* WITH_SERVER */ 42 | 43 | #endif /* ECDH_H_ */ 44 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Transport/ServiceAcceptMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Messages.Transport 4 | { 5 | /// 6 | /// Represents SSH_MSG_SERVICE_ACCEPT message. 7 | /// 8 | [Message("SSH_MSG_SERVICE_ACCEPT", 6)] 9 | public class ServiceAcceptMessage : Message 10 | { 11 | /// 12 | /// Gets the name of the service. 13 | /// 14 | /// 15 | /// The name of the service. 16 | /// 17 | public ServiceName ServiceName { get; private set; } 18 | 19 | /// 20 | /// Called when type specific data need to be loaded. 21 | /// 22 | protected override void LoadData() 23 | { 24 | var serviceName = this.ReadAsciiString(); 25 | switch (serviceName) 26 | { 27 | case "ssh-userauth": 28 | this.ServiceName = ServiceName.UserAuthentication; 29 | break; 30 | case "ssh-connection": 31 | this.ServiceName = ServiceName.Connection; 32 | break; 33 | } 34 | } 35 | 36 | /// 37 | /// Called when type specific data need to be saved. 38 | /// 39 | protected override void SaveData() 40 | { 41 | throw new InvalidOperationException("Save data is not supported."); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Security/HostAlgorithm.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Security 2 | { 3 | /// 4 | /// Base class for SSH host algorithms. 5 | /// 6 | public abstract class HostAlgorithm 7 | { 8 | /// 9 | /// Gets the host key name. 10 | /// 11 | public string Name { get; private set; } 12 | 13 | /// 14 | /// Gets the host key data. 15 | /// 16 | public abstract byte[] Data { get; } 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The host key name. 22 | public HostAlgorithm(string name) 23 | { 24 | this.Name = name; 25 | } 26 | 27 | /// 28 | /// Signs the specified data. 29 | /// 30 | /// The data. 31 | /// Signed data. 32 | public abstract byte[] Sign(byte[] data); 33 | 34 | /// 35 | /// Verifies the signature. 36 | /// 37 | /// The data. 38 | /// The signature. 39 | /// True is signature was successfully verifies; otherwise false. 40 | public abstract bool VerifySignature(byte[] data, byte[] signature); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Transport/IgnoreMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Transport 2 | { 3 | /// 4 | /// Represents SSH_MSG_IGNORE message. 5 | /// 6 | [Message("SSH_MSG_IGNORE", 2)] 7 | public class IgnoreMessage : Message 8 | { 9 | /// 10 | /// Gets ignore message data if any. 11 | /// 12 | public byte[] Data { get; private set; } 13 | 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public IgnoreMessage() 18 | { 19 | this.Data = new byte[] { }; 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of the class. 24 | /// 25 | /// The data. 26 | public IgnoreMessage(byte[] data) 27 | { 28 | this.Data = data; 29 | } 30 | 31 | /// 32 | /// Called when type specific data need to be loaded. 33 | /// 34 | protected override void LoadData() 35 | { 36 | this.Data = this.ReadBinaryString(); 37 | } 38 | 39 | /// 40 | /// Called when type specific data need to be saved. 41 | /// 42 | protected override void SaveData() 43 | { 44 | this.WriteBinaryString(this.Data); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpReadRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | 4 | namespace Renci.SshNet.Sftp.Requests 5 | { 6 | internal class SftpReadRequest : SftpRequest 7 | { 8 | public override SftpMessageTypes SftpMessageType 9 | { 10 | get { return SftpMessageTypes.Read; } 11 | } 12 | 13 | public byte[] Handle { get; private set; } 14 | 15 | public UInt64 Offset { get; private set; } 16 | 17 | public UInt32 Length { get; private set; } 18 | 19 | public SftpReadRequest(uint protocolVersion, uint requestId, byte[] handle, UInt64 offset, UInt32 length, Action dataAction, Action statusAction) 20 | : base(protocolVersion, requestId, statusAction) 21 | { 22 | this.Handle = handle; 23 | this.Offset = offset; 24 | this.Length = length; 25 | this.SetAction(dataAction); 26 | } 27 | 28 | protected override void LoadData() 29 | { 30 | base.LoadData(); 31 | this.Handle = this.ReadBinaryString(); 32 | this.Offset = this.ReadUInt64(); 33 | this.Length = this.ReadUInt32(); 34 | } 35 | 36 | protected override void SaveData() 37 | { 38 | base.SaveData(); 39 | this.WriteBinaryString(this.Handle); 40 | this.Write(this.Offset); 41 | this.Write(this.Length); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Authentication/InformationResponseMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Renci.SshNet.Messages.Authentication 5 | { 6 | /// 7 | /// Represents SSH_MSG_USERAUTH_INFO_RESPONSE message. 8 | /// 9 | [Message("SSH_MSG_USERAUTH_INFO_RESPONSE", 61)] 10 | internal class InformationResponseMessage : Message 11 | { 12 | /// 13 | /// Gets authentication responses. 14 | /// 15 | public IList Responses { get; private set; } 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | public InformationResponseMessage() 21 | { 22 | this.Responses = new List(); 23 | } 24 | 25 | /// 26 | /// Called when type specific data need to be loaded. 27 | /// 28 | protected override void LoadData() 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | 33 | /// 34 | /// Called when type specific data need to be saved. 35 | /// 36 | protected override void SaveData() 37 | { 38 | this.Write((UInt32)this.Responses.Count); 39 | foreach (var response in this.Responses) 40 | { 41 | this.Write(response); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ChannelOpenFailedEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Common 2 | { 3 | /// 4 | /// Provides data for event. 5 | /// 6 | internal class ChannelOpenFailedEventArgs : ChannelEventArgs 7 | { 8 | /// 9 | /// Gets failure reason code. 10 | /// 11 | public uint ReasonCode { get; private set; } 12 | 13 | /// 14 | /// Gets failure description. 15 | /// 16 | public string Description { get; private set; } 17 | 18 | /// 19 | /// Gets failure language. 20 | /// 21 | public string Language { get; private set; } 22 | 23 | /// 24 | /// Initializes a new instance of the class. 25 | /// 26 | /// Channel number. 27 | /// Failure reason code. 28 | /// Failure description. 29 | /// Failure language. 30 | public ChannelOpenFailedEventArgs(uint channelNumber, uint reasonCode, string description, string language) 31 | : base(channelNumber) 32 | { 33 | this.ReasonCode = reasonCode; 34 | this.Description = description; 35 | this.Language = language; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/PortForwardEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// Provides data for event. 7 | /// 8 | public class PortForwardEventArgs : EventArgs 9 | { 10 | /// 11 | /// Gets request originator host. 12 | /// 13 | public string OriginatorHost { get; private set; } 14 | 15 | /// 16 | /// Gets request originator port. 17 | /// 18 | public uint OriginatorPort { get; private set; } 19 | 20 | /// 21 | /// Initializes a new instance of the class. 22 | /// 23 | /// The host. 24 | /// The port. 25 | /// is null. 26 | /// is not within and . 27 | internal PortForwardEventArgs(string host, uint port) 28 | { 29 | if (host == null) 30 | throw new ArgumentNullException("host"); 31 | port.ValidatePort("port"); 32 | 33 | OriginatorHost = host; 34 | OriginatorPort = port; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Responses/SftpNameResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text; 3 | 4 | namespace Renci.SshNet.Sftp.Responses 5 | { 6 | internal class SftpNameResponse : SftpResponse 7 | { 8 | public override SftpMessageTypes SftpMessageType 9 | { 10 | get { return SftpMessageTypes.Name; } 11 | } 12 | 13 | public uint Count { get; private set; } 14 | 15 | public Encoding Encoding { get; private set; } 16 | 17 | public KeyValuePair[] Files { get; private set; } 18 | 19 | public SftpNameResponse(uint protocolVersion, Encoding encoding) 20 | : base(protocolVersion) 21 | { 22 | this.Files = new KeyValuePair[0]; 23 | this.Encoding = encoding; 24 | } 25 | 26 | protected override void LoadData() 27 | { 28 | base.LoadData(); 29 | 30 | this.Count = this.ReadUInt32(); 31 | this.Files = new KeyValuePair[this.Count]; 32 | 33 | for (int i = 0; i < this.Count; i++) 34 | { 35 | var fileName = this.ReadString(this.Encoding); 36 | this.ReadString(); // This field value has meaningless information 37 | var attributes = this.ReadAttributes(); 38 | this.Files[i] = new KeyValuePair(fileName, attributes); 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /TerminalTest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TerminalTest")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TerminalTest")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1ee6b27d-6717-4eca-8294-72b6b52b42fe")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/ChannelMessage.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | namespace Renci.SshNet.Messages.Connection 3 | { 4 | /// 5 | /// Base class for all channel specific SSH messages. 6 | /// 7 | public abstract class ChannelMessage : Message 8 | { 9 | /// 10 | /// Gets or sets the local channel number. 11 | /// 12 | /// 13 | /// The local channel number. 14 | /// 15 | public uint LocalChannelNumber { get; protected set; } 16 | 17 | /// 18 | /// Called when type specific data need to be loaded. 19 | /// 20 | protected override void LoadData() 21 | { 22 | this.LocalChannelNumber = this.ReadUInt32(); 23 | } 24 | 25 | /// 26 | /// Called when type specific data need to be saved. 27 | /// 28 | protected override void SaveData() 29 | { 30 | this.Write(this.LocalChannelNumber); 31 | } 32 | 33 | /// 34 | /// Returns a that represents this instance. 35 | /// 36 | /// 37 | /// A that represents this instance. 38 | /// 39 | public override string ToString() 40 | { 41 | return string.Format(CultureInfo.CurrentCulture, "{0} : #{1}", base.ToString(), this.LocalChannelNumber); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ChannelOpenConfirmedEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Common 2 | { 3 | /// 4 | /// Provides data for event. 5 | /// 6 | internal class ChannelOpenConfirmedEventArgs : ChannelEventArgs 7 | { 8 | /// 9 | /// Initializes a new instance of the class. 10 | /// 11 | /// The remote channel number. 12 | /// The initial window size. 13 | /// The maximum packet size. 14 | public ChannelOpenConfirmedEventArgs(uint remoteChannelNumber, uint initialWindowSize, uint maximumPacketSize) 15 | : base(remoteChannelNumber) 16 | { 17 | InitialWindowSize = initialWindowSize; 18 | MaximumPacketSize = maximumPacketSize; 19 | } 20 | 21 | /// 22 | /// Gets the initial size of the window. 23 | /// 24 | /// 25 | /// The initial size of the window. 26 | /// 27 | public uint InitialWindowSize { get; private set; } 28 | 29 | /// 30 | /// Gets the maximum size of the packet. 31 | /// 32 | /// 33 | /// The maximum size of the packet. 34 | /// 35 | public uint MaximumPacketSize { get; private set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /libsshnet/include/libssh/ge25519.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: ge25519.h,v 1.3 2013/12/09 11:03:45 markus Exp $ */ 2 | 3 | /* 4 | * Public Domain, Authors: Daniel J. Bernstein, Niels Duif, Tanja Lange, 5 | * Peter Schwabe, Bo-Yin Yang. 6 | * Copied from supercop-20130419/crypto_sign/ed25519/ref/ge25519.h 7 | */ 8 | 9 | #ifndef GE25519_H 10 | #define GE25519_H 11 | 12 | #include "fe25519.h" 13 | #include "sc25519.h" 14 | 15 | #define ge25519 crypto_sign_ed25519_ref_ge25519 16 | #define ge25519_base crypto_sign_ed25519_ref_ge25519_base 17 | #define ge25519_unpackneg_vartime crypto_sign_ed25519_ref_unpackneg_vartime 18 | #define ge25519_pack crypto_sign_ed25519_ref_pack 19 | #define ge25519_isneutral_vartime crypto_sign_ed25519_ref_isneutral_vartime 20 | #define ge25519_double_scalarmult_vartime crypto_sign_ed25519_ref_double_scalarmult_vartime 21 | #define ge25519_scalarmult_base crypto_sign_ed25519_ref_scalarmult_base 22 | 23 | typedef struct 24 | { 25 | fe25519 x; 26 | fe25519 y; 27 | fe25519 z; 28 | fe25519 t; 29 | } ge25519; 30 | 31 | const ge25519 ge25519_base; 32 | 33 | int ge25519_unpackneg_vartime(ge25519 *r, const unsigned char p[32]); 34 | 35 | void ge25519_pack(unsigned char r[32], const ge25519 *p); 36 | 37 | int ge25519_isneutral_vartime(const ge25519 *p); 38 | 39 | void ge25519_double_scalarmult_vartime(ge25519 *r, const ge25519 *p1, const sc25519 *s1, const ge25519 *p2, const sc25519 *s2); 40 | 41 | void ge25519_scalarmult_base(ge25519 *r, const sc25519 *s); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /TerminalControlTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TerminalControlTests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TerminalControlTests")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("224bde3e-614a-4da4-8dac-3460f6ba781e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/Extensions.NET.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Net; 3 | using System.Net.Sockets; 4 | 5 | namespace Renci.SshNet 6 | { 7 | /// 8 | /// Collection of different extension method specific for .NET 4.0 9 | /// 10 | public static partial class Extensions 11 | { 12 | /// 13 | /// Determines whether [is null or white space] [the specified value]. 14 | /// 15 | /// The value. 16 | /// 17 | /// true if [is null or white space] [the specified value]; otherwise, false. 18 | /// 19 | internal static bool IsNullOrWhiteSpace(this string value) 20 | { 21 | if (string.IsNullOrEmpty(value)) return true; 22 | 23 | return value.All(char.IsWhiteSpace); 24 | } 25 | 26 | internal static bool CanRead(this Socket socket) 27 | { 28 | return socket.Connected && socket.Poll(-1, SelectMode.SelectRead) && socket.Available > 0; 29 | } 30 | 31 | internal static bool CanWrite(this Socket socket) 32 | { 33 | return socket.Connected && socket.Poll(-1, SelectMode.SelectWrite); 34 | } 35 | 36 | internal static IPAddress GetIPAddress(this string host) 37 | { 38 | IPAddress ipAddress; 39 | if (!IPAddress.TryParse(host, out ipAddress)) 40 | ipAddress = Dns.GetHostAddresses(host).First(); 41 | 42 | return ipAddress; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Transport/DebugMessage.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace Renci.SshNet.Messages.Transport 3 | { 4 | /// 5 | /// Represents SSH_MSG_DEBUG message. 6 | /// 7 | [Message("SSH_MSG_DEBUG", 4)] 8 | public class DebugMessage : Message 9 | { 10 | /// 11 | /// Gets a value indicating whether the message to be always displayed. 12 | /// 13 | /// 14 | /// true if the message always to be displayed; otherwise, false. 15 | /// 16 | public bool IsAlwaysDisplay { get; private set; } 17 | 18 | /// 19 | /// Gets debug message. 20 | /// 21 | public string Message { get; private set; } 22 | 23 | /// 24 | /// Gets message language. 25 | /// 26 | public string Language { get; private set; } 27 | 28 | /// 29 | /// Called when type specific data need to be loaded. 30 | /// 31 | protected override void LoadData() 32 | { 33 | this.IsAlwaysDisplay = this.ReadBoolean(); 34 | this.Message = this.ReadString(); 35 | this.Language = this.ReadString(); 36 | } 37 | 38 | /// 39 | /// Called when type specific data need to be saved. 40 | /// 41 | protected override void SaveData() 42 | { 43 | this.Write(this.IsAlwaysDisplay); 44 | this.Write(this.Message); 45 | this.Write(this.Language); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Connection/RequestSuccessMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Messages.Connection 2 | { 3 | /// 4 | /// Represents SSH_MSG_REQUEST_SUCCESS message. 5 | /// 6 | [Message("SSH_MSG_REQUEST_SUCCESS", 81)] 7 | public class RequestSuccessMessage : Message 8 | { 9 | /// 10 | /// Gets the bound port. 11 | /// 12 | public uint? BoundPort { get; private set; } 13 | 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public RequestSuccessMessage() 18 | { 19 | 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of the class. 24 | /// 25 | /// The bound port. 26 | public RequestSuccessMessage(uint boundPort) 27 | { 28 | this.BoundPort = boundPort; 29 | } 30 | 31 | /// 32 | /// Called when type specific data need to be loaded. 33 | /// 34 | protected override void LoadData() 35 | { 36 | if (!this.IsEndOfData) 37 | this.BoundPort = this.ReadUInt32(); 38 | } 39 | 40 | /// 41 | /// Called when type specific data need to be saved. 42 | /// 43 | protected override void SaveData() 44 | { 45 | if (this.BoundPort != null) 46 | this.Write(this.BoundPort.Value); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/ForwardedPortRemote.NET.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | 3 | namespace Renci.SshNet 4 | { 5 | /// 6 | /// Provides functionality for remote port forwarding 7 | /// 8 | public partial class ForwardedPortRemote 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | /// The bound port. 14 | /// The host. 15 | /// The port. 16 | /// 17 | /// 18 | /// 19 | public ForwardedPortRemote(uint boundPort, string host, uint port) 20 | : this(string.Empty, boundPort, host, port) 21 | { 22 | } 23 | 24 | /// 25 | /// Initializes a new instance of the class. 26 | /// 27 | /// The bound host. 28 | /// The bound port. 29 | /// The host. 30 | /// The port. 31 | public ForwardedPortRemote(string boundHost, uint boundPort, string host, uint port) 32 | : this(Dns.GetHostEntry(boundHost).AddressList[0], boundPort, Dns.GetHostEntry(host).AddressList[0], port) 33 | { 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Renci.SshNet.Sftp.Responses; 3 | 4 | namespace Renci.SshNet.Sftp.Requests 5 | { 6 | internal class SftpBlockRequest : SftpRequest 7 | { 8 | public override SftpMessageTypes SftpMessageType 9 | { 10 | get { return SftpMessageTypes.Block; } 11 | } 12 | 13 | public byte[] Handle { get; private set; } 14 | 15 | public UInt64 Offset { get; private set; } 16 | 17 | public UInt64 Length { get; private set; } 18 | 19 | public UInt32 LockMask { get; private set; } 20 | 21 | public SftpBlockRequest(uint protocolVersion, uint requestId, byte[] handle, UInt64 offset, UInt64 length, UInt32 lockMask, Action statusAction) 22 | : base(protocolVersion, requestId, statusAction) 23 | { 24 | this.Handle = handle; 25 | this.Offset = offset; 26 | this.Length = length; 27 | this.LockMask = lockMask; 28 | } 29 | 30 | protected override void LoadData() 31 | { 32 | base.LoadData(); 33 | this.Handle = this.ReadBinaryString(); 34 | this.Offset = this.ReadUInt64(); 35 | this.Length = this.ReadUInt64(); 36 | this.LockMask = this.ReadUInt32(); 37 | } 38 | 39 | protected override void SaveData() 40 | { 41 | base.SaveData(); 42 | this.WriteBinaryString(this.Handle); 43 | this.Write(this.Offset); 44 | this.Write(this.Length); 45 | this.Write(this.LockMask); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/AuthenticationPromptEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Renci.SshNet.Common 4 | { 5 | /// 6 | /// Provides data for event. 7 | /// 8 | public class AuthenticationPromptEventArgs : AuthenticationEventArgs 9 | { 10 | /// 11 | /// Gets prompt language. 12 | /// 13 | public string Language { get; private set; } 14 | 15 | /// 16 | /// Gets prompt instruction. 17 | /// 18 | public string Instruction { get; private set; } 19 | 20 | /// 21 | /// Gets server information request prompts. 22 | /// 23 | public IEnumerable Prompts { get; private set; } 24 | 25 | /// 26 | /// Initializes a new instance of the class. 27 | /// 28 | /// The username. 29 | /// The instruction. 30 | /// The language. 31 | /// The information request prompts. 32 | public AuthenticationPromptEventArgs(string username, string instruction, string language, IEnumerable prompts) 33 | : base(username) 34 | { 35 | this.Instruction = instruction; 36 | this.Language = language; 37 | this.Prompts = prompts; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeReply.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Common; 2 | 3 | namespace Renci.SshNet.Messages.Transport 4 | { 5 | /// 6 | /// Represents SSH_MSG_KEX_DH_GEX_REPLY message. 7 | /// 8 | [Message("SSH_MSG_KEX_DH_GEX_REPLY", 33)] 9 | internal class KeyExchangeDhGroupExchangeReply : Message 10 | { 11 | /// 12 | /// Gets server public host key and certificates 13 | /// 14 | /// The host key. 15 | public byte[] HostKey { get; private set; } 16 | 17 | /// 18 | /// Gets the F value. 19 | /// 20 | public BigInteger F { get; private set; } 21 | 22 | /// 23 | /// Gets the signature of H. 24 | /// 25 | /// The signature. 26 | public byte[] Signature { get; private set; } 27 | 28 | /// 29 | /// Called when type specific data need to be loaded. 30 | /// 31 | protected override void LoadData() 32 | { 33 | this.HostKey = this.ReadBinaryString(); 34 | this.F = this.ReadBigInt(); 35 | this.Signature = this.ReadBinaryString(); 36 | } 37 | 38 | /// 39 | /// Called when type specific data need to be saved. 40 | /// 41 | protected override void SaveData() 42 | { 43 | this.WriteBinaryString(this.HostKey); 44 | this.Write(this.F); 45 | this.WriteBinaryString(this.Signature); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Session.NET40.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using System.Linq; 3 | using System; 4 | using Renci.SshNet.Messages; 5 | using System.Threading; 6 | 7 | namespace Renci.SshNet 8 | { 9 | /// 10 | /// Provides functionality to connect and interact with SSH server. 11 | /// 12 | public partial class Session 13 | { 14 | partial void HandleMessageCore(Message message) 15 | { 16 | this.HandleMessage((dynamic)message); 17 | } 18 | 19 | /// 20 | /// Executes the specified action in a separate thread. 21 | /// 22 | /// The action to execute. 23 | partial void ExecuteThread(Action action) 24 | { 25 | ThreadPool.QueueUserWorkItem(o => action()); 26 | } 27 | 28 | partial void InternalRegisterMessage(string messageName) 29 | { 30 | lock (this._messagesMetadata) 31 | { 32 | Parallel.ForEach( 33 | from m in this._messagesMetadata where m.Name == messageName select m, 34 | item => { item.Enabled = true; item.Activated = true; }); 35 | } 36 | } 37 | 38 | partial void InternalUnRegisterMessage(string messageName) 39 | { 40 | lock (this._messagesMetadata) 41 | { 42 | Parallel.ForEach( 43 | from m in this._messagesMetadata where m.Name == messageName select m, 44 | item => { item.Enabled = false; item.Activated = false; }); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Transport/KeyExchangeDhReplyMessage.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Common; 2 | 3 | namespace Renci.SshNet.Messages.Transport 4 | { 5 | /// 6 | /// Represents SSH_MSG_KEXDH_REPLY message. 7 | /// 8 | [Message("SSH_MSG_KEXDH_REPLY", 31)] 9 | public class KeyExchangeDhReplyMessage : Message 10 | { 11 | /// 12 | /// Gets server public host key and certificates 13 | /// 14 | /// The host key. 15 | public byte[] HostKey { get; private set; } 16 | 17 | /// 18 | /// Gets the F value. 19 | /// 20 | public BigInteger F { get; private set; } 21 | 22 | /// 23 | /// Gets the signature of H. 24 | /// 25 | /// The signature. 26 | public byte[] Signature { get; private set; } 27 | 28 | /// 29 | /// Called when type specific data need to be loaded. 30 | /// 31 | protected override void LoadData() 32 | { 33 | this.ResetReader(); 34 | this.HostKey = this.ReadBinaryString(); 35 | this.F = this.ReadBigInt(); 36 | this.Signature = this.ReadBinaryString(); 37 | } 38 | 39 | /// 40 | /// Called when type specific data need to be saved. 41 | /// 42 | protected override void SaveData() 43 | { 44 | this.WriteBinaryString(this.HostKey); 45 | this.Write(this.F); 46 | this.WriteBinaryString(this.Signature); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /TerminalTest/TerminalLineTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using npcook.Terminal; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace npcook.Terminal.Tests 10 | { 11 | [TestClass()] 12 | public class TerminalLineTests 13 | { 14 | void AssertAreEqual(TerminalRun run1, TerminalRun run2) 15 | { 16 | Assert.AreEqual(run1.Text, run2.Text); 17 | Assert.AreEqual(run1.Font, run2.Font); 18 | } 19 | 20 | [TestMethod()] 21 | public void DeleteCharactersTest() 22 | { 23 | TerminalLine line = new TerminalLine(); 24 | line.SetCharacters(0, new string('0', 4), new TerminalFont() { Foreground = Color.FromRgb(0, 0, 0) }); 25 | line.SetCharacters(4, new string('1', 4), new TerminalFont() { Foreground = Color.FromRgb(1, 1, 1) }); 26 | line.SetCharacters(8, new string('2', 4), new TerminalFont() { Foreground = Color.FromRgb(2, 2, 2) }); 27 | line.SetCharacters(12, new string('3', 4), new TerminalFont() { Foreground = Color.FromRgb(3, 3, 3) }); 28 | line.DeleteCharacters(7, 6); 29 | 30 | TerminalRun[] expectedRuns = new[] 31 | { 32 | new TerminalRun(new string('0', 4), new TerminalFont() { Foreground = Color.FromRgb(0, 0, 0) }), 33 | new TerminalRun(new string('1', 3), new TerminalFont() { Foreground = Color.FromRgb(1, 1, 1) }), 34 | new TerminalRun(new string('3', 3), new TerminalFont() { Foreground = Color.FromRgb(3, 3, 3) }), 35 | }; 36 | 37 | AssertAreEqual(line.Runs[0], expectedRuns[0]); 38 | AssertAreEqual(line.Runs[1], expectedRuns[1]); 39 | AssertAreEqual(line.Runs[2], expectedRuns[2]); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Common/ChannelDataEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace Renci.SshNet.Common 2 | { 3 | /// 4 | /// Provides data for event and events. 5 | /// 6 | public class ChannelDataEventArgs : ChannelEventArgs 7 | { 8 | /// 9 | /// Gets channel data. 10 | /// 11 | public byte[] Data { get; private set; } 12 | 13 | /// 14 | /// Gets the data type code. 15 | /// 16 | public uint DataTypeCode { get; private set; } 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// Channel number. 22 | /// Channel data. 23 | public ChannelDataEventArgs(uint channelNumber, byte[] data) 24 | : base(channelNumber) 25 | { 26 | this.Data = data; 27 | } 28 | 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | /// Channel number. 33 | /// Channel data. 34 | /// Channel data type code. 35 | public ChannelDataEventArgs(uint channelNumber, byte[] data, uint dataTypeCode) 36 | : this(channelNumber, data) 37 | { 38 | this.DataTypeCode = dataTypeCode; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Messages/Transport/KeyExchangeEcdhInitMessage.cs: -------------------------------------------------------------------------------- 1 | using Renci.SshNet.Common; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | 5 | namespace Renci.SshNet.Messages.Transport 6 | { 7 | /// 8 | /// Represents SSH_MSG_KEXECDH_INIT message. 9 | /// 10 | [Message("SSH_MSG_KEXECDH_INIT", 30)] 11 | internal class KeyExchangeEcdhInitMessage : Message, IKeyExchangedAllowed 12 | { 13 | /// 14 | /// Gets the client's ephemeral contribution to the ECDH exchange, encoded as an octet string 15 | /// 16 | public byte[] QC { get; private set; } 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | public KeyExchangeEcdhInitMessage(BigInteger d, BigInteger q) 22 | { 23 | var data = new List(); 24 | data.Add(0x04); 25 | data.AddRange(d.ToByteArray().Reverse()); 26 | data.AddRange(q.ToByteArray().Reverse()); 27 | this.QC = data.ToArray(); 28 | } 29 | 30 | /// 31 | /// Called when type specific data need to be loaded. 32 | /// 33 | protected override void LoadData() 34 | { 35 | this.ResetReader(); 36 | this.QC = this.ReadBinaryString(); 37 | } 38 | 39 | /// 40 | /// Called when type specific data need to be saved. 41 | /// 42 | protected override void SaveData() 43 | { 44 | this.WriteBinaryString(this.QC); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /libsshnet/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | DYNAMIC LINK LIBRARY : libsshnet Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this libsshnet DLL for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your libsshnet application. 9 | 10 | libsshnet.vcxproj 11 | This is the main project file for VC++ projects generated using an Application Wizard. 12 | It contains information about the version of Visual C++ that generated the file, and 13 | information about the platforms, configurations, and project features selected with the 14 | Application Wizard. 15 | 16 | libsshnet.vcxproj.filters 17 | This is the filters file for VC++ projects generated using an Application Wizard. 18 | It contains information about the association between the files in your project 19 | and the filters. This association is used in the IDE to show grouping of files with 20 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 21 | "Source Files" filter). 22 | 23 | libsshnet.cpp 24 | This is the main DLL source file. 25 | 26 | libsshnet.h 27 | This file contains a class declaration. 28 | 29 | AssemblyInfo.cpp 30 | Contains custom attributes for modifying assembly metadata. 31 | 32 | ///////////////////////////////////////////////////////////////////////////// 33 | Other notes: 34 | 35 | AppWizard uses "TODO:" to indicate parts of the source code you 36 | should add to or customize. 37 | 38 | ///////////////////////////////////////////////////////////////////////////// 39 | -------------------------------------------------------------------------------- /Ssh.Net/Renci.SshNet/Sftp/Requests/SftpMkDirRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Renci.SshNet.Sftp.Responses; 4 | 5 | namespace Renci.SshNet.Sftp.Requests 6 | { 7 | internal class SftpMkDirRequest : SftpRequest 8 | { 9 | public override SftpMessageTypes SftpMessageType 10 | { 11 | get { return SftpMessageTypes.MkDir; } 12 | } 13 | 14 | public string Path { get; private set; } 15 | 16 | public Encoding Encoding { get; private set; } 17 | 18 | public SftpFileAttributes Attributes { get; private set; } 19 | 20 | public SftpMkDirRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, Action statusAction) 21 | : this(protocolVersion, requestId, path, encoding, null, statusAction) 22 | { 23 | } 24 | 25 | public SftpMkDirRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, SftpFileAttributes attributes, Action statusAction) 26 | : base(protocolVersion, requestId, statusAction) 27 | { 28 | this.Path = path; 29 | this.Encoding = encoding; 30 | this.Attributes = attributes; 31 | } 32 | 33 | protected override void LoadData() 34 | { 35 | base.LoadData(); 36 | this.Path = this.ReadString(this.Encoding); 37 | this.Attributes = this.ReadAttributes(); 38 | } 39 | 40 | protected override void SaveData() 41 | { 42 | base.SaveData(); 43 | this.Write(this.Path, this.Encoding); 44 | this.Write(this.Attributes); 45 | } 46 | } 47 | } 48 | --------------------------------------------------------------------------------