Exemplo n.º 1
0
        private Cipher _tCipher;                            //cipher for transmission

        // exec command for SCP
        //private bool _executingExecCmd = false;

        public SSH1Connection(SSHConnectionParameter param, AbstractGranadosSocket s, ISSHConnectionEventReceiver er, string serverversion, string clientversion) : base(param, s, er)
        {
            _cInfo = new SSH1ConnectionInfo();
            _cInfo._serverVersionString = serverversion;
            _cInfo._clientVersionString = clientversion;
            _shellID        = -1;
            _packetReceiver = new SynchronizedPacketReceiver(this);
            _packetBuilder  = new SSH1PacketBuilder(_packetReceiver);
        }
Exemplo n.º 2
0
        protected bool _execCmdWaitFlag;  // wait response flag for sending exec command to server

        protected SSHConnection(SSHConnectionParameter param, AbstractGranadosSocket strm, ISSHConnectionEventReceiver receiver)
        {
            _param              = (SSHConnectionParameter)param.Clone();
            _stream             = strm;
            _eventReceiver      = receiver;
            _channel_collection = new ChannelCollection();
            _autoDisconnect     = true;
            _execCmd            = null;
            _execCmdWaitFlag    = true;
        }
Exemplo n.º 3
0
        /**
         * writes to encrypted stream
         */
        public void WriteTo(AbstractGranadosSocket output, Cipher cipher)
        {
            byte[] image = BuildImage();
            //dumpBA(image);
            byte[] encrypted = new byte[image.Length - 4];
            cipher.Encrypt(image, 4, image.Length - 4, encrypted, 0); //length field must not be encrypted

            Array.Copy(encrypted, 0, image, 4, encrypted.Length);
            output.Write(image, 0, image.Length);
        }
Exemplo n.º 4
0
        private static SSHConnection ConnectMain(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, VersionExchangeHandler pnh, AbstractGranadosSocket s)
        {
            DataFragment data = pnh.WaitResponse();
            string       sv   = pnh.ServerVersion;

            SSHConnection con = null;

            if (param.Protocol == SSHProtocol.SSH1)
            {
                con = new SSH1Connection(param, s, receiver, sv, SSHUtil.ClientVersionString(param.Protocol));
            }
            else
            {
                con = new SSH2Connection(param, s, receiver, sv, SSHUtil.ClientVersionString(param.Protocol));
            }

            con.TraceReceptionEvent("server version-string", sv.Trim());
            pnh.Close();
            s.SetHandler(con.PacketBuilder);
            con.SendMyVersion(param);

            if (con.Connect() != AuthenticationResult.Failure)
            {
                return(con);
            }
            else
            {
                s.Close();
                return(null);
            }
        }
Exemplo n.º 5
0
 internal DummySSHConnection(SSHConnectionParameter param, AbstractGranadosSocket strm, ISSHConnectionEventReceiver receiver)
     : base(param, strm, receiver)
 {
 }
Exemplo n.º 6
0
 /**
  * writes to plain stream
  */
 public void WriteTo(AbstractGranadosSocket output)
 {
     byte[] image = BuildImage();
     output.Write(image, 0, image.Length);
 }