Ejemplo n.º 1
0
 public override void Load(ByteReader reader)
 {
     ChannelType       = reader.GetString(Encoding.ASCII);
     SenderChannel     = reader.GetUInt32();
     InitialWindowSize = reader.GetUInt32();
     MaximumPacketSize = reader.GetUInt32();
 }
Ejemplo n.º 2
0
        /*
         * // public string Data { get; set; }
         *
         * // TODO - HACK - RFC 4254 specifies that the channel data is a string. But it looks like SFTP treats the data as binary...
         *
         * public uint Length { get; set; }
         * public uint FxpLength { get; set; }
         * public byte Type { get; set; }
         * public byte[] RawData { get; set; }
         *
         * public uint Version { get; set; }
         */


        public override void Load(ByteReader reader)
        {
            RecipientChannel = reader.GetUInt32();

            var length = (int)reader.GetUInt32();

            Data = reader.GetBytes(length);

            /*
             * Length = reader.GetUInt32();    // Length of the data area
             * FxpLength = reader.GetUInt32(); // Length of the SFTP sub-area
             * Type = reader.GetByte();
             *
             * // TODO - clean up this mess
             *
             * RawData = reader.GetBytes((int)(FxpLength - 1));      // -1 as we've already read the Type
             *
             * using (var subreader = new ByteReader(RawData))
             * {
             *  // TODO - enum - SSH_FXP_INIT
             *  if (Type == 1)
             *  {
             *      Version = subreader.GetUInt32();
             *
             *      // TODO - extension data?
             *  }
             * }
             */
        }
Ejemplo n.º 3
0
        public void HandleData(byte[] data)
        {
            using (var reader = new ByteReader(data))
            {
                var length = reader.GetUInt32() - 1;    // -1 because we'll read the type next
                var type   = (SftpPacketType)reader.GetByte();

                if (packetTypes.ContainsKey(type))
                {
                    var packet = Activator.CreateInstance(packetTypes[type]) as SftpPacket;
                    packet.Load(reader);

                    try
                    {
                        HandlePacket((dynamic)packet);
                    }
                    catch (RuntimeBinderException)
                    {
                        logger.LogWarning("Unhandled SFTP packet type: {Type}.", type);
                    }
                }
                else
                {
                    logger.LogWarning("Unimplemented SFTP packet type: {Type}.", type);
                }
            }
        }
Ejemplo n.º 4
0
 public override void Load(ByteReader reader)
 {
     Reason      = (DisconnectReason)reader.GetUInt32();
     Description = reader.GetString(Encoding.UTF8);
     if (!reader.IsEOF)
     {
         Language = reader.GetString();
     }
 }
Ejemplo n.º 5
0
 public override void Load(ByteReader reader)
 {
     Cookie                              = reader.GetBytes(16);
     KexAlgorithms                       = reader.GetNameList();
     ServerHostKeyAlgorithms             = reader.GetNameList();
     EncryptionAlgorithmsClientToServer  = reader.GetNameList();
     EncryptionAlgorithmsServerToClient  = reader.GetNameList();
     MacAlgorithmsClientToServer         = reader.GetNameList();
     MacAlgorithmsServerToClient         = reader.GetNameList();
     CompressionAlgorithmsClientToServer = reader.GetNameList();
     CompressionAlgorithmsServerToClient = reader.GetNameList();
     LanguagesClientToServer             = reader.GetNameList();
     LanguagesServerToClient             = reader.GetNameList();
     FirstKexPacketFollows               = reader.GetBoolean();
     uint reserved = reader.GetUInt32();
 }
Ejemplo n.º 6
0
        public override void Load(ByteReader reader)
        {
            RecipientChannel = reader.GetUInt32();
            RequestType      = reader.GetString(Encoding.ASCII);
            WantReply        = reader.GetBoolean();

            if (RequestType == "env")
            {
                VariableName  = reader.GetString(Encoding.UTF8);
                VariableValue = reader.GetString(Encoding.UTF8);
            }
            else if (RequestType == "subsystem")
            {
                SubsystemName = reader.GetString(Encoding.UTF8);
            }
        }
Ejemplo n.º 7
0
 public override void Load(ByteReader reader)
 {
     Id   = reader.GetUInt32();
     Path = reader.GetString();
 }
Ejemplo n.º 8
0
 public override void Load(ByteReader reader)
 {
     RecipientChannel = reader.GetUInt32();
 }
Ejemplo n.º 9
0
 public override void Load(ByteReader reader)
 {
     Version = reader.GetUInt32();
 }
Ejemplo n.º 10
0
 public override void Load(ByteReader reader)
 {
     RejectedPacketNumber = reader.GetUInt32();
 }