/// <summary>
        /// to decode the smb data: from the general SmbDada to the concrete Smb Data.
        /// </summary>
        protected override void DecodeData()
        {
            using (MemoryStream memoryStream = new MemoryStream(CifsMessageUtils.ToBytes <SmbData>(this.smbDataBlock)))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    this.smbData.ByteCount = channel.Read <ushort>();
                    this.smbData.Password  = channel.ReadBytes(this.SmbParameters.PasswordLength);

                    // pad:
                    if ((Marshal.SizeOf(this.SmbHeader) + Marshal.SizeOf(this.SmbParameters)
                         + Marshal.SizeOf(this.smbData.ByteCount) + this.SmbParameters.PasswordLength) % 2 != 0)
                    {
                        this.smbData.Pad = channel.ReadBytes(1);
                    }
                    else
                    {
                        this.smbData.Pad = new byte[0];
                    }

                    // Path:
                    this.smbData.Path = CifsMessageUtils.ReadNullTerminatedString(channel,
                                                                                  (this.smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);

                    // Service:
                    this.smbData.Service = channel.ReadBytes(this.smbData.ByteCount - this.smbData.Password.Length
                                                             - this.smbData.Pad.Length - this.smbData.Path.Length);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// to decode the smb data: from the general SmbDada to the concrete Smb Data.
        /// </summary>
        protected override void DecodeData()
        {
            using (MemoryStream memoryStream = new MemoryStream(CifsMessageUtils.ToBytes <SmbData>(this.smbDataBlock)))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    this.smbData.ByteCount       = channel.Read <ushort>();
                    this.smbData.OEMPassword     = channel.ReadBytes(this.SmbParameters.OEMPasswordLen);
                    this.smbData.UnicodePassword = channel.ReadBytes(this.SmbParameters.UnicodePasswordLen);

                    bool isUnicode = (this.smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE;
                    // pad:
                    if (isUnicode == true &&
                        (Marshal.SizeOf(this.SmbHeader) + Marshal.SizeOf(this.SmbParameters)
                         + Marshal.SizeOf(this.smbData.ByteCount) + this.SmbParameters.OEMPasswordLen
                         + this.SmbParameters.UnicodePasswordLen) % 2 != 0)
                    {
                        this.smbData.Pad = channel.ReadBytes(1);
                    }
                    else
                    {
                        this.smbData.Pad = new byte[0];
                    }

                    this.smbData.AccountName   = CifsMessageUtils.ReadNullTerminatedString(channel, isUnicode);
                    this.smbData.PrimaryDomain = CifsMessageUtils.ReadNullTerminatedString(channel, isUnicode);
                    this.smbData.NativeOS      = CifsMessageUtils.ReadNullTerminatedString(channel, isUnicode);
                    this.smbData.NativeLanMan  = CifsMessageUtils.ReadNullTerminatedString(channel, isUnicode);
                }
            }
        }
예제 #3
0
 /// <summary>
 /// to decode the smb data: from the general SmbDada to the concrete Smb Data.
 /// </summary>
 protected override void DecodeData()
 {
     using (MemoryStream memoryStream = new MemoryStream(CifsMessageUtils.ToBytes <SmbData>(this.smbDataBlock)))
     {
         using (Channel channel = new Channel(null, memoryStream))
         {
             this.smbData.ByteCount     = channel.Read <ushort>();
             this.smbData.BufferFormat1 = channel.Read <byte>();
             this.smbData.OldFileName   = CifsMessageUtils.ReadNullTerminatedString(channel,
                                                                                    (this.smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);
             this.smbData.BufferFormat2 = channel.Read <byte>();
             this.smbData.NewFileName   = CifsMessageUtils.ReadNullTerminatedString(channel,
                                                                                    (this.smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);
         }
     }
 }
        /// <summary>
        /// to decode the smb data: from the general SmbDada to the concrete Smb Data.
        /// </summary>
        protected override void DecodeData()
        {
            using (MemoryStream memoryStream = new MemoryStream(CifsMessageUtils.ToBytes <SmbData>(this.smbDataBlock)))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    this.smbData.ByteCount     = channel.Read <ushort>();
                    this.smbData.BufferFormat1 = channel.Read <byte>();
                    this.smbData.Path          = CifsMessageUtils.ReadNullTerminatedString(channel, false);
                    this.smbData.BufferFormat2 = channel.Read <byte>();
                    this.smbData.Password      = CifsMessageUtils.ReadNullTerminatedString(channel, false);
                    this.smbData.BufferFormat3 = channel.Read <byte>();

                    // Service:
                    int serviceLen = this.smbDataBlock.Bytes.Length - this.smbData.Path.Length - this.smbData.Password.Length
                                     - 3; // 3 is the bytes count of BufferFormat1, BufferFormat2 and BufferFormat3.
                    this.smbData.Service = channel.ReadBytes(serviceLen);
                }
            }
        }
        /// <summary>
        /// to decode the smb data: from the general SmbDada to the concrete Smb Data.
        /// </summary>
        protected override void DecodeData()
        {
            using (MemoryStream memoryStream = new MemoryStream(CifsMessageUtils.ToBytes <SmbData>(this.smbDataBlock)))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    this.smbData.ByteCount     = channel.Read <ushort>();
                    this.smbData.BufferFormat1 = channel.Read <byte>();
                    this.smbData.FileName      = CifsMessageUtils.ReadNullTerminatedString(channel,
                                                                                           (this.smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);
                    this.smbData.BufferFormat2   = channel.Read <byte>();
                    this.smbData.ResumeKeyLength = channel.Read <ushort>();

                    if (this.smbData.ResumeKeyLength != 0)
                    {
                        this.smbData.ResumeKey = new SMB_Resume_Key[] { channel.Read <SMB_Resume_Key>() };
                    }
                    else
                    {
                        this.smbData.ResumeKey = new SMB_Resume_Key[0];
                    }
                }
            }
        }