public string NativeLanMan;  // SMB_STRING (this field WILL be aligned to start on a 2-byte boundary from the start of the SMB header)

        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);
            ushort OEMPasswordLength     = LittleEndianConverter.ToUInt16(this.SMBParameters, 14);
            ushort 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)
            {
                // wordCount is 1 byte
                int padding = (1 + OEMPasswordLength + UnicodePasswordLength) % 2;
                dataOffset += padding;
            }
            AccountName   = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
            PrimaryDomain = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
            NativeOS      = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
            NativeLanMan  = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
        }
示例#2
0
        public QueryFSInfoVolume(bool isUnicode, byte[] buffer, int offset)
        {
            VolumeSerialNumber = LittleEndianConverter.ToUInt32(buffer, offset + 0);
            byte charCount = ByteReader.ReadByte(buffer, offset + 4);

            VolumeLabel = SMBHelper.ReadSMBString(buffer, offset + 5, isUnicode);
        }
 public CreateDirectoryRequest(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 = SMBHelper.ReadSMBString(this.SMBData, 1, isUnicode);
 }
示例#4
0
 public Transaction2FindNext2Request(byte[] parameters, byte[] data, bool isUnicode) : base()
 {
     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         = SMBHelper.ReadSMBString(parameters, 12, 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 = SMBHelper.ReadSMBString(parameters, 8, isUnicode);
 }
示例#6
0
        public Transaction2QueryPathInformationRequest(byte[] parameters, byte[] data, bool isUnicode) : base()
        {
            InformationLevel = (QueryInformationLevel)LittleEndianConverter.ToUInt16(parameters, 0);
            Reserved         = LittleEndianConverter.ToUInt32(parameters, 4);
            FileName         = SMBHelper.ReadSMBString(parameters, 6, isUnicode);

            if (InformationLevel == QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST)
            {
                GetExtendedAttributeList = new FullExtendedAttributeList(data, 0);
            }
        }
示例#7
0
        public DeleteRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
        {
            SearchAttributes = (FileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0);

            BufferFormat = ByteReader.ReadByte(this.SMBData, 0);
            if (BufferFormat != SupportedBufferFormat)
            {
                throw new InvalidRequestException("Unsupported Buffer Format");
            }
            FileName = SMBHelper.ReadSMBString(this.SMBData, 1, isUnicode);
        }
        public TreeConnectAndXResponse(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
        {
            OptionalSupport = (OptionalSupportFlags)LittleEndianConverter.ToUInt16(this.SMBParameters, 4);

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

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

            Service = TreeConnectHelper.GetServiceName(serviceString);
        }
示例#9
0
        public SetInformationRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
        {
            FileAttributes = (FileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
            LastWriteTime  = SMBHelper.ReadUTime(this.SMBParameters, 2);
            Reserved       = ByteReader.ReadBytes(this.SMBParameters, 6, 10);

            BufferFormat = ByteReader.ReadByte(this.SMBData, 0);
            if (BufferFormat != SupportedBufferFormat)
            {
                throw new InvalidRequestException("Unsupported Buffer Format");
            }
            FileName = SMBHelper.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 = (FileAttributes)LittleEndianConverter.ToUInt16(parameters, 6);
            CreationTime = SMBHelper.ReadUTime(parameters, 8);
            OpenMode = new OpenMode(parameters, 12);
            AllocationSize = LittleEndianConverter.ToUInt32(parameters, 14);
            Reserved = ByteReader.ReadBytes(parameters, 18, 10);
            FileName = SMBHelper.ReadSMBString(parameters, 28, isUnicode);

            ExtendedAttributeList = new FullExtendedAttributeList(data, 0);
        }
示例#11
0
        public Transaction2FindFirst2Request(byte[] parameters, byte[] data, bool isUnicode) : base()
        {
            SearchAttributes  = (FileAttributes)LittleEndianConverter.ToUInt16(parameters, 0);
            SearchCount       = LittleEndianConverter.ToUInt16(parameters, 2);
            Flags             = (FindFlags)LittleEndianConverter.ToUInt16(parameters, 4);
            InformationLevel  = (FindInformationLevel)LittleEndianConverter.ToUInt16(parameters, 6);
            SearchStorageType = (SearchStorageType)LittleEndianConverter.ToUInt32(parameters, 8);
            FileName          = SMBHelper.ReadSMBString(parameters, 12, isUnicode);

            if (InformationLevel == FindInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST)
            {
                GetExtendedAttributeList = new FullExtendedAttributeList(data, 0);
            }
        }
        public SessionSetupAndXResponse(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
        {
            Action = (SessionSetupAction)LittleEndianConverter.ToUInt16(this.SMBParameters, 4);

            int dataOffset = 0;

            if (isUnicode)
            {
                dataOffset++;
            }
            NativeOS      = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
            NativeLanMan  = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
            PrimaryDomain = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
        }
示例#13
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 = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);

            Service = TreeConnectHelper.GetServiceName(serviceString);
        }
        public FindInfoStandard(byte[] buffer, ref int offset, bool isUnicode, bool returnResumeKeys) : base(returnResumeKeys)
        {
            if (returnResumeKeys)
            {
                ResumeKey = LittleEndianReader.ReadUInt32(buffer, ref offset);
            }
            CreationDateTime   = SMBHelper.ReadSMBDateTime(buffer, ref offset);
            LastAccessDateTime = SMBHelper.ReadSMBDateTime(buffer, ref offset);
            LastWriteDateTime  = SMBHelper.ReadSMBDateTime(buffer, ref offset);
            FileDataSize       = LittleEndianReader.ReadUInt32(buffer, ref offset);
            AllocationSize     = LittleEndianReader.ReadUInt32(buffer, ref offset);
            Attributes         = (FileAttributes)LittleEndianReader.ReadUInt16(buffer, ref offset);
            byte fileNameLength = ByteReader.ReadByte(buffer, ref offset);

            FileName = SMBHelper.ReadSMBString(buffer, ref offset, isUnicode);
        }
示例#15
0
        public TransactionRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
        {
            TotalParameterCount = LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
            TotalDataCount      = LittleEndianConverter.ToUInt16(this.SMBParameters, 2);
            MaxParameterCount   = LittleEndianConverter.ToUInt16(this.SMBParameters, 4);
            MaxDataCount        = LittleEndianConverter.ToUInt16(this.SMBParameters, 6);
            MaxSetupCount       = ByteReader.ReadByte(this.SMBParameters, 8);
            Reserved1           = ByteReader.ReadByte(this.SMBParameters, 9);
            Flags     = (TransactionFlags)LittleEndianConverter.ToUInt16(this.SMBParameters, 10);
            Timeout   = LittleEndianConverter.ToUInt32(this.SMBParameters, 12);
            Reserved2 = LittleEndianConverter.ToUInt16(this.SMBParameters, 16);
            ushort ParameterCount  = LittleEndianConverter.ToUInt16(this.SMBParameters, 18);
            ushort ParameterOffset = LittleEndianConverter.ToUInt16(this.SMBParameters, 20);
            ushort DataCount       = LittleEndianConverter.ToUInt16(this.SMBParameters, 22);
            ushort DataOffset      = LittleEndianConverter.ToUInt16(this.SMBParameters, 24);
            byte   SetupCount      = ByteReader.ReadByte(this.SMBParameters, 26);

            Reserved3 = ByteReader.ReadByte(this.SMBParameters, 27);
            Setup     = ByteReader.ReadBytes(this.SMBParameters, 28, SetupCount * 2);

            if (this.SMBData.Length > 0) // Workaround, Some SAMBA clients will set ByteCount to 0 (Popcorn Hour A-400)
            {
                int dataOffset = 0;
                if (this is Transaction2Request)
                {
                    Name        = String.Empty;
                    dataOffset += 1;
                }
                else
                {
                    if (isUnicode)
                    {
                        int namePadding = 1;
                        dataOffset += namePadding;
                    }
                    Name = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
                }
            }
            TransParameters = ByteReader.ReadBytes(buffer, ParameterOffset, ParameterCount);
            TransData       = ByteReader.ReadBytes(buffer, DataOffset, DataCount);
        }
        public ServiceName Service; // OEM string

        public TreeConnectAndXRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
        {
            int parametersOffset = 4;

            Flags = (TreeConnectFlags)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
            ushort passwordLength = LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);

            int dataOffset = 0;

            Password = ByteReader.ReadBytes(this.SMBData, ref dataOffset, passwordLength);
            if (isUnicode)
            {
                // wordCount is 1 byte
                int padding = (1 + passwordLength) % 2;
                dataOffset += padding;
            }
            Path = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
            // Should be read as OEM string but it doesn't really matter
            string serviceString = ByteReader.ReadNullTerminatedAnsiString(this.SMBData, ref dataOffset);

            Service = TreeConnectHelper.GetServiceName(serviceString);
        }
示例#17
0
        public OpenAndXRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
        {
            int parametersOffset = 4;

            Flags          = (OpenFlags)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
            AccessMode     = AccessModeOptions.Read(this.SMBParameters, ref parametersOffset);
            SearchAttrs    = (FileAttributes)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
            FileAttrs      = (FileAttributes)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
            CreationTime   = SMBHelper.ReadUTime(this.SMBParameters, ref parametersOffset);
            OpenMode       = OpenMode.Read(this.SMBParameters, ref parametersOffset);
            AllocationSize = LittleEndianReader.ReadUInt32(this.SMBParameters, ref parametersOffset);
            Timeout        = LittleEndianReader.ReadUInt32(this.SMBParameters, ref parametersOffset);
            Reserved       = LittleEndianReader.ReadUInt32(this.SMBParameters, ref parametersOffset);

            int dataOffset = 0;

            if (isUnicode)
            {
                dataOffset = 1; // 1 byte padding for 2 byte alignment
            }
            FileName = SMBHelper.ReadSMBString(this.SMBData, dataOffset, isUnicode);
        }
示例#18
0
        public RenameRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
        {
            SearchAttributes = (FileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0);

            int dataOffset = 0;

            BufferFormat1 = ByteReader.ReadByte(this.SMBData, ref dataOffset);
            if (BufferFormat1 != SupportedBufferFormat)
            {
                throw new InvalidRequestException("Unsupported Buffer Format");
            }
            OldFileName   = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
            BufferFormat2 = ByteReader.ReadByte(this.SMBData, ref dataOffset);
            if (BufferFormat2 != SupportedBufferFormat)
            {
                throw new InvalidRequestException("Unsupported Buffer Format");
            }
            if (isUnicode)
            {
                dataOffset++;
            }
            NewFileName = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
        }
        public string NativeLanMan; // SMB_STRING (this field WILL be aligned to start on a 2-byte boundary from the start of the SMB header)

        public SessionSetupAndXRequestExtended(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);
            ushort securityBlobLength = LittleEndianConverter.ToUInt16(this.SMBParameters, 14);

            Reserved     = LittleEndianConverter.ToUInt32(this.SMBParameters, 16);
            Capabilities = (ServerCapabilities)LittleEndianConverter.ToUInt32(this.SMBParameters, 20);

            SecurityBlob = ByteReader.ReadBytes(this.SMBData, 0, securityBlobLength);

            int dataOffset = SecurityBlob.Length;

            if (isUnicode)
            {
                int padding = securityBlobLength % 2;
                dataOffset += padding;
            }
            NativeOS     = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
            NativeLanMan = SMBHelper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
        }
示例#20
0
        public NTCreateAndXRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
        {
            Reserved = ByteReader.ReadByte(this.SMBParameters, 4);
            ushort nameLength = LittleEndianConverter.ToUInt16(this.SMBParameters, 5);

            Flags              = (NTCreateFlags)LittleEndianConverter.ToUInt32(this.SMBParameters, 7);
            RootDirectoryFID   = LittleEndianConverter.ToUInt32(this.SMBParameters, 11);
            DesiredAccess      = (DesiredAccess)LittleEndianConverter.ToUInt32(this.SMBParameters, 15);
            AllocationSize     = LittleEndianConverter.ToUInt64(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)
            {
                dataOffset = 1; // 1 byte padding for 2 byte alignment
            }
            FileName = SMBHelper.ReadSMBString(this.SMBData, dataOffset, isUnicode);
        }
 public Transaction2CreateDirectoryRequest(byte[] parameters, byte[] data, bool isUnicode) : base()
 {
     Reserved              = LittleEndianConverter.ToUInt32(parameters, 0);
     DirectoryName         = SMBHelper.ReadSMBString(parameters, 4, isUnicode);
     ExtendedAttributeList = new FullExtendedAttributeList(data);
 }
 public Transaction2SetPathInformationRequest(byte[] parameters, byte[] data, bool isUnicode) : base()
 {
     InformationLevel = (SetInformationLevel)LittleEndianConverter.ToUInt16(parameters, 0);
     Reserved         = LittleEndianConverter.ToUInt32(parameters, 2);
     FileName         = SMBHelper.ReadSMBString(parameters, 6, isUnicode);
 }