Exemple #1
0
        public override byte[] GetBytes(bool isUnicode)
        {
            SecurityBlobLength = (ushort)SecurityBlob.Length;

            this.SMBParameters = new byte[ParametersLength];
            LittleEndianWriter.WriteUInt16(this.SMBParameters, 4, MaxBufferSize);
            LittleEndianWriter.WriteUInt16(this.SMBParameters, 6, MaxMpxCount);
            LittleEndianWriter.WriteUInt16(this.SMBParameters, 8, VcNumber);
            LittleEndianWriter.WriteUInt32(this.SMBParameters, 10, SessionKey);
            LittleEndianWriter.WriteUInt16(this.SMBParameters, 14, SecurityBlobLength);
            LittleEndianWriter.WriteUInt32(this.SMBParameters, 16, Reserved);

            int padding = 0;

            if (isUnicode)
            {
                // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header.
                // Note: SMBData starts at an odd offset.
                padding      = (SecurityBlobLength + 1) % 2;
                this.SMBData = new byte[SecurityBlob.Length + (NativeOS.Length + 1) * 2 + (NativeLanMan.Length + 1) * 2];
            }
            else
            {
                this.SMBData = new byte[SecurityBlob.Length + NativeOS.Length + 1 + NativeLanMan.Length + 1];
            }
            int offset = 0;

            ByteWriter.WriteBytes(this.SMBData, ref offset, SecurityBlob);
            offset += padding;
            SMB1Helper.WriteSMBString(this.SMBData, ref offset, isUnicode, NativeOS);
            SMB1Helper.WriteSMBString(this.SMBData, ref offset, isUnicode, NativeLanMan);

            return(base.GetBytes(isUnicode));
        }
        public NTTransactCreateRequest(byte[] parameters, byte[] data, bool isUnicode)
        {
            int parametersOffset = 0;

            Flags             = (NTCreateFlags)LittleEndianReader.ReadUInt32(parameters, ref parametersOffset);
            RootDirectoryFID  = LittleEndianReader.ReadUInt32(parameters, ref parametersOffset);
            DesiredAccess     = (AccessMask)LittleEndianReader.ReadUInt32(parameters, ref parametersOffset);
            AllocationSize    = LittleEndianReader.ReadInt64(parameters, ref parametersOffset);
            ExtFileAttributes = (ExtendedFileAttributes)LittleEndianReader.ReadUInt32(parameters, ref parametersOffset);
            ShareAccess       = (ShareAccess)LittleEndianReader.ReadUInt32(parameters, ref parametersOffset);
            CreateDisposition = (CreateDisposition)LittleEndianReader.ReadUInt32(parameters, ref parametersOffset);
            CreateOptions     = (CreateOptions)LittleEndianReader.ReadUInt32(parameters, ref parametersOffset);
            uint securityDescriptiorLength = LittleEndianReader.ReadUInt32(parameters, ref parametersOffset);

            _ = LittleEndianReader.ReadUInt32(parameters, ref parametersOffset);
            uint nameLength = LittleEndianReader.ReadUInt32(parameters, ref parametersOffset);

            ImpersonationLevel = (ImpersonationLevel)LittleEndianReader.ReadUInt32(parameters, ref parametersOffset);
            SecurityFlags      = (SecurityFlags)ByteReader.ReadByte(parameters, ref parametersOffset);

            if (isUnicode)
            {
                parametersOffset++;
            }
            Name = SMB1Helper.ReadFixedLengthString(parameters, ref parametersOffset, isUnicode, (int)nameLength);
            if (securityDescriptiorLength > 0)
            {
                SecurityDescriptor = new SecurityDescriptor(data, 0);
            }
            ExtendedAttributes = FileFullEAInformation.ReadList(data, (int)securityDescriptiorLength);
        }
        public override byte[] GetData(bool isUnicode)
        {
            if (PipeName == null)
            {
                return(new byte[0]);
            }

            int length = 8;

            if (isUnicode)
            {
                length += PipeName.Length * 2 + 2;
            }
            else
            {
                length += PipeName.Length + 1;
            }
            byte[] data = new byte[length];
            LittleEndianWriter.WriteUInt16(data, 0, OutputBufferSize);
            LittleEndianWriter.WriteUInt16(data, 2, InputBufferSize);
            ByteWriter.WriteByte(data, 4, MaximumInstances);
            ByteWriter.WriteByte(data, 5, CurrentInstances);
            ByteWriter.WriteByte(data, 6, PipeNameLength);
            SMB1Helper.WriteSMBString(data, 8, isUnicode, PipeName);
            return(data);
        }
        public NTCreateAndXRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
        {
            Reserved           = ByteReader.ReadByte(this.SMBParameters, 4);
            NameLength         = LittleEndianConverter.ToUInt16(this.SMBParameters, 5);
            Flags              = (NTCreateFlags)LittleEndianConverter.ToUInt32(this.SMBParameters, 7);
            RootDirectoryFID   = LittleEndianConverter.ToUInt32(this.SMBParameters, 11);
            DesiredAccess      = (FileAccessMask)LittleEndianConverter.ToUInt32(this.SMBParameters, 15);
            AllocationSize     = LittleEndianConverter.ToInt64(this.SMBParameters, 19);
            ExtFileAttributes  = (ExtendedFileAttributes)LittleEndianConverter.ToUInt32(this.SMBParameters, 27);
            ShareAccess        = (ShareAccess)LittleEndianConverter.ToUInt32(this.SMBParameters, 31);
            CreateDisposition  = (CreateDisposition)LittleEndianConverter.ToUInt32(this.SMBParameters, 35);
            CreateOptions      = (CreateOptions)LittleEndianConverter.ToUInt32(this.SMBParameters, 39);
            ImpersonationLevel = (ImpersonationLevel)LittleEndianConverter.ToUInt32(this.SMBParameters, 43);
            SecurityFlags      = (SecurityFlags)ByteReader.ReadByte(this.SMBParameters, 47);

            int dataOffset = 0;

            if (isUnicode)
            {
                // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header.
                // Note: SMBData starts at an odd offset.
                dataOffset = 1;
            }
            FileName = SMB1Helper.ReadSMBString(this.SMBData, dataOffset, isUnicode);
        }
        public override byte[] GetBytes(bool isUnicode)
        {
            this.SMBParameters = new byte[ParametersLength];
            LittleEndianWriter.WriteUInt16(this.SMBParameters, 0, (ushort)SearchAttributes);

            if (isUnicode)
            {
                int padding = 1;
                this.SMBData = new byte[2 + OldFileName.Length * 2 + NewFileName.Length * 2 + 4 + padding];
            }
            else
            {
                this.SMBData = new byte[2 + OldFileName.Length + NewFileName.Length + 2];
            }
            int dataOffset = 0;

            ByteWriter.WriteByte(this.SMBData, ref dataOffset, BufferFormat1);
            SMB1Helper.WriteSMBString(this.SMBData, ref dataOffset, isUnicode, OldFileName);
            ByteWriter.WriteByte(this.SMBData, ref dataOffset, BufferFormat2);
            if (isUnicode)
            {
                dataOffset++; // padding
            }
            SMB1Helper.WriteSMBString(this.SMBData, ref dataOffset, isUnicode, NewFileName);

            return(base.GetBytes(isUnicode));
        }
Exemple #6
0
        public SessionSetupAndXRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
        {
            MaxBufferSize         = LittleEndianConverter.ToUInt16(this.SMBParameters, 4);
            MaxMpxCount           = LittleEndianConverter.ToUInt16(this.SMBParameters, 6);
            VcNumber              = LittleEndianConverter.ToUInt16(this.SMBParameters, 8);
            SessionKey            = LittleEndianConverter.ToUInt32(this.SMBParameters, 10);
            OEMPasswordLength     = LittleEndianConverter.ToUInt16(this.SMBParameters, 14);
            UnicodePasswordLength = LittleEndianConverter.ToUInt16(this.SMBParameters, 16);
            Reserved              = LittleEndianConverter.ToUInt32(this.SMBParameters, 18);
            Capabilities          = (ServerCapabilities)LittleEndianConverter.ToUInt32(this.SMBParameters, 22);

            OEMPassword     = ByteReader.ReadBytes(this.SMBData, 0, OEMPasswordLength);
            UnicodePassword = ByteReader.ReadBytes(this.SMBData, OEMPasswordLength, UnicodePasswordLength);

            int dataOffset = OEMPasswordLength + UnicodePasswordLength;

            if (isUnicode)
            {
                // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header.
                // Note: SMBData starts at an odd offset.
                int padding = (OEMPasswordLength + UnicodePasswordLength + 1) % 2;
                dataOffset += padding;
            }
            AccountName   = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
            PrimaryDomain = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
            NativeOS      = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
            NativeLanMan  = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
        }
Exemple #7
0
        public override byte[] GetBytes(bool isUnicode)
        {
            this.SMBParameters = new byte[ParametersLength];
            int parametersOffset = 4;

            LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, (ushort)OptionalSupport);
            MaximalShareAccessRights.WriteBytes(this.SMBParameters, ref parametersOffset);
            GuestMaximalShareAccessRights.WriteBytes(this.SMBParameters, ref parametersOffset);

            // Should be written as OEM string but it doesn't really matter
            string serviceString = ServiceNameHelper.GetServiceString(Service);

            if (isUnicode)
            {
                this.SMBData = new byte[serviceString.Length + NativeFileSystem.Length * 2 + 3];
            }
            else
            {
                this.SMBData = new byte[serviceString.Length + NativeFileSystem.Length + 2];
            }

            int offset = 0;

            ByteWriter.WriteNullTerminatedAnsiString(this.SMBData, ref offset, serviceString);
            SMB1Helper.WriteSMBString(this.SMBData, ref offset, isUnicode, NativeFileSystem);

            return(base.GetBytes(isUnicode));
        }
        public override byte[] GetBytes(bool isUnicode)
        {
            ChallengeLength = (byte)Challenge.Length;

            SMBParameters = new byte[ParametersLength];
            LittleEndianWriter.WriteUInt16(SMBParameters, 0, DialectIndex);
            ByteWriter.WriteByte(SMBParameters, 2, (byte)SecurityMode);
            LittleEndianWriter.WriteUInt16(SMBParameters, 3, MaxMpxCount);
            LittleEndianWriter.WriteUInt16(SMBParameters, 5, MaxNumberVcs);
            LittleEndianWriter.WriteUInt32(SMBParameters, 7, MaxBufferSize);
            LittleEndianWriter.WriteUInt32(SMBParameters, 11, MaxRawSize);
            LittleEndianWriter.WriteUInt32(SMBParameters, 15, SessionKey);
            LittleEndianWriter.WriteUInt32(SMBParameters, 19, (uint)Capabilities);
            FileTimeHelper.WriteFileTime(SMBParameters, 23, SystemTime);
            LittleEndianWriter.WriteInt16(SMBParameters, 31, ServerTimeZone);
            ByteWriter.WriteByte(SMBParameters, 33, ChallengeLength);

            // [MS-CIFS] <90> Padding is not added before DomainName
            // DomainName and ServerName are always in Unicode
            SMBData = new byte[Challenge.Length + (DomainName.Length + 1) * 2 + (ServerName.Length + 1) * 2];
            int offset = 0;

            ByteWriter.WriteBytes(SMBData, ref offset, Challenge);
            SMB1Helper.WriteSMBString(SMBData, ref offset, true, DomainName);
            SMB1Helper.WriteSMBString(SMBData, ref offset, true, ServerName);

            return(base.GetBytes(isUnicode));
        }
Exemple #9
0
        public override byte[] GetBytes(bool isUnicode)
        {
            ushort securityBlobLength = (ushort)SecurityBlob.Length;

            SMBParameters = new byte[ParametersLength];
            LittleEndianWriter.WriteUInt16(SMBParameters, 4, (ushort)Action);
            LittleEndianWriter.WriteUInt16(SMBParameters, 6, securityBlobLength);

            int padding = 0;

            if (isUnicode)
            {
                // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header.
                // Note: SMBData starts at an odd offset.
                padding = (1 + securityBlobLength) % 2;
                SMBData = new byte[SecurityBlob.Length + padding + NativeOS.Length * 2 + NativeLanMan.Length * 2 + 4];
            }
            else
            {
                SMBData = new byte[SecurityBlob.Length + NativeOS.Length + NativeLanMan.Length + 2];
            }
            int offset = 0;

            ByteWriter.WriteBytes(SMBData, ref offset, SecurityBlob);
            offset += padding;
            SMB1Helper.WriteSMBString(SMBData, ref offset, isUnicode, NativeOS);
            SMB1Helper.WriteSMBString(SMBData, ref offset, isUnicode, NativeLanMan);

            return(base.GetBytes(isUnicode));
        }
Exemple #10
0
        public override byte[] GetBytes(bool isUnicode)
        {
            SMBParameters = new byte[ParametersLength];
            int parametersOffset = 4;

            LittleEndianWriter.WriteUInt16(SMBParameters, ref parametersOffset, (ushort)Flags);
            AccessMode.WriteBytes(SMBParameters, ref parametersOffset);
            LittleEndianWriter.WriteUInt16(SMBParameters, ref parametersOffset, (ushort)SearchAttrs);
            LittleEndianWriter.WriteUInt16(SMBParameters, ref parametersOffset, (ushort)FileAttrs);
            UTimeHelper.WriteUTime(SMBParameters, ref parametersOffset, CreationTime);
            OpenMode.WriteBytes(SMBParameters, ref parametersOffset);
            LittleEndianWriter.WriteUInt32(SMBParameters, ref parametersOffset, AllocationSize);
            LittleEndianWriter.WriteUInt32(SMBParameters, ref parametersOffset, Timeout);
            LittleEndianWriter.WriteUInt32(SMBParameters, ref parametersOffset, Reserved);

            int padding = 0;

            if (isUnicode)
            {
                padding = 1;
                SMBData = new byte[padding + FileName.Length * 2 + 2];
            }
            else
            {
                SMBData = new byte[FileName.Length + 1];
            }
            SMB1Helper.WriteSMBString(SMBData, padding, isUnicode, FileName);

            return(base.GetBytes(isUnicode));
        }
        public override byte[] GetParameters(bool isUnicode)
        {
            int length = 28;

            if (isUnicode)
            {
                length += FileName.Length * 2 + 2;
            }
            else
            {
                length += FileName.Length + 1;
            }

            byte[] parameters = new byte[length];
            LittleEndianWriter.WriteUInt16(parameters, 0, (ushort)Flags);
            AccessMode.WriteBytes(parameters, 2);
            LittleEndianWriter.WriteUInt16(parameters, 4, Reserved1);
            LittleEndianWriter.WriteUInt16(parameters, 6, (ushort)FileAttributes);
            UTimeHelper.WriteUTime(parameters, 8, CreationTime);
            OpenMode.WriteBytes(parameters, 12);
            LittleEndianWriter.WriteUInt32(parameters, 14, AllocationSize);
            ByteWriter.WriteBytes(parameters, 18, Reserved, 10);
            SMB1Helper.WriteSMBString(parameters, 28, isUnicode, FileName);
            return(parameters);
        }
Exemple #12
0
        public override byte[] GetBytes(bool isUnicode)
        {
            this.SMBParameters = new byte[ParametersLength];
            LittleEndianWriter.WriteUInt16(this.SMBParameters, 4, (ushort)Action);

            int offset = 0;

            if (isUnicode)
            {
                // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header.
                // Note: SMBData starts at an odd offset.
                int padding = 1;
                this.SMBData = new byte[padding + NativeOS.Length * 2 + NativeLanMan.Length * 2 + PrimaryDomain.Length * 2 + 6];
                offset       = padding;
            }
            else
            {
                this.SMBData = new byte[NativeOS.Length + NativeLanMan.Length + PrimaryDomain.Length + 3];
            }
            SMB1Helper.WriteSMBString(this.SMBData, ref offset, isUnicode, NativeOS);
            SMB1Helper.WriteSMBString(this.SMBData, ref offset, isUnicode, NativeLanMan);
            SMB1Helper.WriteSMBString(this.SMBData, ref offset, isUnicode, PrimaryDomain);

            return(base.GetBytes(isUnicode));
        }
        public override byte[] GetBytes(bool isUnicode)
        {
            NameLength         = (ushort)FileName.Length;
            this.SMBParameters = new byte[ParametersLength];
            ByteWriter.WriteByte(this.SMBParameters, 0, (byte)AndXCommand);
            ByteWriter.WriteByte(this.SMBParameters, 1, AndXReserved);
            LittleEndianWriter.WriteUInt16(this.SMBParameters, 2, AndXOffset);
            ByteWriter.WriteByte(this.SMBParameters, 4, Reserved);
            LittleEndianWriter.WriteUInt16(this.SMBParameters, 5, NameLength);
            LittleEndianWriter.WriteUInt32(this.SMBParameters, 7, (uint)Flags);
            LittleEndianWriter.WriteUInt32(this.SMBParameters, 11, RootDirectoryFID);
            LittleEndianWriter.WriteUInt32(this.SMBParameters, 15, (uint)DesiredAccess);
            LittleEndianWriter.WriteInt64(this.SMBParameters, 19, AllocationSize);
            LittleEndianWriter.WriteUInt32(this.SMBParameters, 27, (uint)ExtFileAttributes);
            LittleEndianWriter.WriteUInt32(this.SMBParameters, 31, (uint)ShareAccess);
            LittleEndianWriter.WriteUInt32(this.SMBParameters, 35, (uint)CreateDisposition);
            LittleEndianWriter.WriteUInt32(this.SMBParameters, 39, (uint)CreateOptions);
            LittleEndianWriter.WriteUInt32(this.SMBParameters, 43, (uint)ImpersonationLevel);
            ByteWriter.WriteByte(this.SMBParameters, 47, (byte)SecurityFlags);

            int padding = 0;

            if (isUnicode)
            {
                padding      = 1;
                this.SMBData = new byte[padding + FileName.Length * 2 + 2];
            }
            else
            {
                this.SMBData = new byte[FileName.Length + 1];
            }
            SMB1Helper.WriteSMBString(this.SMBData, padding, isUnicode, FileName);

            return(base.GetBytes(isUnicode));
        }
 public SetInformation2Request(byte[] buffer, int offset) : base(buffer, offset, false)
 {
     FID = LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
     CreationDateTime   = SMB1Helper.ReadNullableSMBDateTime(this.SMBParameters, 2);
     LastAccessDateTime = SMB1Helper.ReadNullableSMBDateTime(this.SMBParameters, 6);
     LastWriteDateTime  = SMB1Helper.ReadNullableSMBDateTime(this.SMBParameters, 10);
 }
        public Transaction2SetPathInformationRequest(byte[] parameters, byte[] data, bool isUnicode)
        {
            InformationLevel = LittleEndianConverter.ToUInt16(parameters, 0);
            Reserved         = LittleEndianConverter.ToUInt32(parameters, 2);
            FileName         = SMB1Helper.ReadSMBString(parameters, 6, isUnicode);

            InformationBytes = data;
        }
        public FindFileNamesInfo(byte[] buffer, int offset, bool isUnicode)
        {
            NextEntryOffset = LittleEndianReader.ReadUInt32(buffer, ref offset);
            FileIndex       = LittleEndianReader.ReadUInt32(buffer, ref offset);
            uint fileNameLength = LittleEndianReader.ReadUInt32(buffer, ref offset);

            FileName = SMB1Helper.ReadFixedLengthString(buffer, ref offset, isUnicode, (int)fileNameLength);
        }
        public override void WriteBytes(byte[] buffer, ref int offset, bool isUnicode)
        {
            uint fileNameLength = (uint)(isUnicode ? FileName.Length * 2 : FileName.Length);

            LittleEndianWriter.WriteUInt32(buffer, ref offset, NextEntryOffset);
            LittleEndianWriter.WriteUInt32(buffer, ref offset, FileIndex);
            LittleEndianWriter.WriteUInt32(buffer, ref offset, fileNameLength);
            SMB1Helper.WriteSMBString(buffer, ref offset, isUnicode, FileName);
        }
Exemple #18
0
 public QueryInformationRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset)
 {
     BufferFormat = ByteReader.ReadByte(SMBData, 0);
     if (BufferFormat != SupportedBufferFormat)
     {
         throw new InvalidDataException("Unsupported Buffer Format");
     }
     FileName = SMB1Helper.ReadSMBString(SMBData, 1, isUnicode);
 }
Exemple #19
0
 public DeleteDirectoryRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
 {
     BufferFormat = ByteReader.ReadByte(this.SMBData, 0);
     if (BufferFormat != SupportedBufferFormat)
     {
         throw new InvalidRequestException("Unsupported Buffer Format");
     }
     DirectoryName = SMB1Helper.ReadSMBString(this.SMBData, 1, isUnicode);
 }
 public TransactionQueryNamedPipeInfoResponse(byte[] parameters, bool isUnicode) : base()
 {
     OutputBufferSize = LittleEndianConverter.ToUInt16(parameters, 0);
     InputBufferSize  = LittleEndianConverter.ToUInt16(parameters, 2);
     MaximumInstances = ByteReader.ReadByte(parameters, 4);
     CurrentInstances = ByteReader.ReadByte(parameters, 5);
     PipeNameLength   = ByteReader.ReadByte(parameters, 6);
     // Note: Trans_Parameters is aligned to 4 byte boundary
     PipeName = SMB1Helper.ReadSMBString(parameters, 8, isUnicode);
 }
        public override byte[] GetBytes(bool isUnicode)
        {
            this.SMBParameters = new byte[ParametersLength];
            LittleEndianWriter.WriteUInt16(this.SMBParameters, 0, FID);
            SMB1Helper.WriteSMBDateTime(this.SMBParameters, 2, CreationDateTime);
            SMB1Helper.WriteSMBDateTime(this.SMBParameters, 6, LastAccessDateTime);
            SMB1Helper.WriteSMBDateTime(this.SMBParameters, 10, LastWriteDateTime);

            return(base.GetBytes(isUnicode));
        }
Exemple #22
0
        public override byte[] GetParameters(bool isUnicode)
        {
            int length = 4;

            length += isUnicode ? DirectoryName.Length * 2 + 2 : DirectoryName.Length + 1 + 1;
            byte[] parameters = new byte[length];
            LittleEndianWriter.WriteUInt32(parameters, 0, Reserved);
            SMB1Helper.WriteSMBString(parameters, 4, isUnicode, DirectoryName);
            return(parameters);
        }
Exemple #23
0
        public DeleteRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset)
        {
            SearchAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(SMBParameters, 0);

            BufferFormat = ByteReader.ReadByte(SMBData, 0);
            if (BufferFormat != SupportedBufferFormat)
            {
                throw new InvalidDataException("Unsupported Buffer Format");
            }
            FileName = SMB1Helper.ReadSMBString(SMBData, 1, isUnicode);
        }
Exemple #24
0
        public Transaction2QueryPathInformationRequest(byte[] parameters, byte[] data, bool isUnicode) : base()
        {
            InformationLevel = (QueryInformationLevel)LittleEndianConverter.ToUInt16(parameters, 0);
            Reserved         = LittleEndianConverter.ToUInt32(parameters, 4);
            FileName         = SMB1Helper.ReadSMBString(parameters, 6, isUnicode);

            if (InformationLevel == QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST)
            {
                GetExtendedAttributeList = new FullExtendedAttributeList(data, 0);
            }
        }
        public TreeConnectAndXResponse(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset)
        {
            OptionalSupport = (OptionalSupportFlags)LittleEndianConverter.ToUInt16(SMBParameters, 4);

            int    dataOffset    = 0;
            string serviceString = ByteReader.ReadNullTerminatedAnsiString(SMBData, ref dataOffset);

            NativeFileSystem = SMB1Helper.ReadSMBString(SMBData, ref dataOffset, isUnicode);

            Service = ServiceNameHelper.GetServiceName(serviceString);
        }
Exemple #26
0
        public SetInformationRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
        {
            FileAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
            LastWriteTime  = UTimeHelper.ReadNullableUTime(this.SMBParameters, 2);
            Reserved       = ByteReader.ReadBytes(this.SMBParameters, 6, 10);

            BufferFormat = ByteReader.ReadByte(this.SMBData, 0);
            if (BufferFormat != SupportedBufferFormat)
            {
                throw new InvalidDataException("Unsupported Buffer Format");
            }
            FileName = SMB1Helper.ReadSMBString(this.SMBData, 1, isUnicode);
        }
        public Transaction2Open2Request(byte[] parameters, byte[] data, bool isUnicode) : base()
        {
            Flags          = (Open2Flags)LittleEndianConverter.ToUInt16(parameters, 0);
            AccessMode     = new AccessModeOptions(parameters, 2);
            Reserved1      = LittleEndianConverter.ToUInt16(parameters, 4);
            FileAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(parameters, 6);
            CreationTime   = UTimeHelper.ReadNullableUTime(parameters, 8);
            OpenMode       = new OpenMode(parameters, 12);
            AllocationSize = LittleEndianConverter.ToUInt32(parameters, 14);
            Reserved       = ByteReader.ReadBytes(parameters, 18, 10);
            FileName       = SMB1Helper.ReadSMBString(parameters, 28, isUnicode);

            ExtendedAttributeList = new FullExtendedAttributeList(data, 0);
        }
        public Transaction2FindNext2Request(byte[] parameters, byte[] data, bool isUnicode)
        {
            SID              = LittleEndianConverter.ToUInt16(parameters, 0);
            SearchCount      = LittleEndianConverter.ToUInt16(parameters, 2);
            InformationLevel = (FindInformationLevel)LittleEndianConverter.ToUInt16(parameters, 4);
            ResumeKey        = LittleEndianConverter.ToUInt32(parameters, 6);
            Flags            = (FindFlags)LittleEndianConverter.ToUInt16(parameters, 10);
            FileName         = SMB1Helper.ReadSMBString(parameters, 12, isUnicode);

            if (InformationLevel == FindInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST)
            {
                GetExtendedAttributeList = new ExtendedAttributeNameList(data, 0);
            }
        }
        public FindFileDirectoryInfo(byte[] buffer, int offset, bool isUnicode) : base()
        {
            NextEntryOffset    = LittleEndianReader.ReadUInt32(buffer, ref offset);
            FileIndex          = LittleEndianReader.ReadUInt32(buffer, ref offset);
            CreationTime       = FileTimeHelper.ReadNullableFileTime(buffer, ref offset);
            LastAccessTime     = FileTimeHelper.ReadNullableFileTime(buffer, ref offset);
            LastWriteTime      = FileTimeHelper.ReadNullableFileTime(buffer, ref offset);
            LastAttrChangeTime = FileTimeHelper.ReadNullableFileTime(buffer, ref offset);
            EndOfFile          = LittleEndianReader.ReadInt64(buffer, ref offset);
            AllocationSize     = LittleEndianReader.ReadInt64(buffer, ref offset);
            ExtFileAttributes  = (ExtendedFileAttributes)LittleEndianReader.ReadUInt32(buffer, ref offset);
            uint fileNameLength = LittleEndianReader.ReadUInt32(buffer, ref offset);

            FileName = SMB1Helper.ReadFixedLengthString(buffer, ref offset, isUnicode, (int)fileNameLength);
        }
Exemple #30
0
        public TreeConnectAndXResponseExtended(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
        {
            int parametersOffset = 4;

            OptionalSupport               = (OptionalSupportFlags)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
            MaximalShareAccessRights      = new AccessMask(this.SMBParameters, ref parametersOffset);
            GuestMaximalShareAccessRights = new AccessMask(this.SMBParameters, ref parametersOffset);

            int    dataOffset    = 0;
            string serviceString = ByteReader.ReadNullTerminatedAnsiString(this.SMBData, ref dataOffset);

            NativeFileSystem = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);

            Service = ServiceNameHelper.GetServiceName(serviceString);
        }