Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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);
            }
        }
 internal DummySSHConnection(SSHConnectionParameter param, AbstractGranadosSocket strm, ISSHConnectionEventReceiver receiver)
     : base(param, strm, receiver)
 {
 }
Beispiel #6
0
 /**
  * writes to plain stream
  */
 public void WriteTo(AbstractGranadosSocket output)
 {
     byte[] image = BuildImage();
     output.Write(image, 0, image.Length);
 }