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 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); }
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 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 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); }
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 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); }
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 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); }
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 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 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 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); }
public SessionSetupAndXResponse(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode) { Action = (SessionSetupAction)LittleEndianConverter.ToUInt16(this.SMBParameters, 4); 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++; } NativeOS = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode); NativeLanMan = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode); PrimaryDomain = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode); }
public SessionSetupAndXResponseExtended(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode) { Action = (SessionSetupAction)LittleEndianConverter.ToUInt16(this.SMBParameters, 4); SecurityBlobLength = LittleEndianConverter.ToUInt16(this.SMBParameters, 6); SecurityBlob = ByteReader.ReadBytes(this.SMBData, 0, SecurityBlobLength); int dataOffset = SecurityBlob.Length; 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 = (SecurityBlobLength + 1) % 2; dataOffset += padding; } NativeOS = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode); NativeLanMan = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode); }
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; int nameLength = 1; dataOffset += nameLength; } else { if (isUnicode) { int namePadding = 1; dataOffset += namePadding; } Name = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode); } } TransParameters = ByteReader.ReadBytes(buffer, ParameterOffset, ParameterCount); TransData = ByteReader.ReadBytes(buffer, DataOffset, DataCount); }
public SessionSetupAndXResponse(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset) { Action = (SessionSetupAction)LittleEndianConverter.ToUInt16(SMBParameters, 4); 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++; } NativeOS = SMB1Helper.ReadSMBString(SMBData, ref dataOffset, isUnicode); NativeLanMan = SMB1Helper.ReadSMBString(SMBData, ref dataOffset, isUnicode); if ((SMBData.Length - dataOffset) % 2 == 1) { // Workaround for a single terminating null byte SMBData = ByteUtils.Concatenate(SMBData, new byte[1]); } PrimaryDomain = SMB1Helper.ReadSMBString(SMBData, ref dataOffset, isUnicode); }
public NegotiateResponse(byte[] buffer, int offset) : base(buffer, offset) { DialectIndex = LittleEndianConverter.ToUInt16(SMBParameters, 0); SecurityMode = (SecurityMode)ByteReader.ReadByte(SMBParameters, 2); MaxMpxCount = LittleEndianConverter.ToUInt16(SMBParameters, 3); MaxNumberVcs = LittleEndianConverter.ToUInt16(SMBParameters, 5); MaxBufferSize = LittleEndianConverter.ToUInt32(SMBParameters, 7); MaxRawSize = LittleEndianConverter.ToUInt32(SMBParameters, 11); SessionKey = LittleEndianConverter.ToUInt32(SMBParameters, 15); Capabilities = (Capabilities)LittleEndianConverter.ToUInt32(SMBParameters, 19); SystemTime = FileTimeHelper.ReadFileTime(SMBParameters, 23); ServerTimeZone = LittleEndianConverter.ToInt16(SMBParameters, 31); ChallengeLength = ByteReader.ReadByte(SMBParameters, 33); int dataOffset = 0; Challenge = ByteReader.ReadBytes(SMBData, ref dataOffset, ChallengeLength); // [MS-CIFS] <90> Padding is not added before DomainName // DomainName and ServerName are always in Unicode DomainName = SMB1Helper.ReadSMBString(SMBData, ref dataOffset, true); ServerName = SMB1Helper.ReadSMBString(SMBData, ref dataOffset, true); }
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 = (SMBFileAttributes)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset); FileAttrs = (SMBFileAttributes)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset); CreationTime = UTimeHelper.ReadNullableUTime(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 = SMB1Helper.ReadSMBString(this.SMBData, dataOffset, isUnicode); }
public TreeConnectAndXRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset) { int parametersOffset = 4; Flags = (TreeConnectFlags)LittleEndianReader.ReadUInt16(SMBParameters, ref parametersOffset); ushort passwordLength = LittleEndianReader.ReadUInt16(SMBParameters, ref parametersOffset); int dataOffset = 0; Password = ByteReader.ReadBytes(SMBData, ref dataOffset, passwordLength); if (isUnicode) { // wordCount is 1 byte int padding = (1 + passwordLength) % 2; dataOffset += padding; } Path = SMB1Helper.ReadSMBString(SMBData, ref dataOffset, isUnicode); // Should be read as OEM string but it doesn't really matter string serviceString = ByteReader.ReadNullTerminatedAnsiString(SMBData, ref dataOffset); Service = ServiceNameHelper.GetServiceName(serviceString); }
public RenameRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode) { SearchAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0); int dataOffset = 0; BufferFormat1 = ByteReader.ReadByte(this.SMBData, ref dataOffset); if (BufferFormat1 != SupportedBufferFormat) { throw new InvalidDataException("Unsupported Buffer Format"); } OldFileName = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode); BufferFormat2 = ByteReader.ReadByte(this.SMBData, ref dataOffset); if (BufferFormat2 != SupportedBufferFormat) { throw new InvalidDataException("Unsupported Buffer Format"); } if (isUnicode) { dataOffset++; } NewFileName = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode); }
public SessionSetupAndXResponseExtended(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset) { Action = (SessionSetupAction)LittleEndianConverter.ToUInt16(SMBParameters, 4); SecurityBlobLength = LittleEndianConverter.ToUInt16(SMBParameters, 6); SecurityBlob = ByteReader.ReadBytes(SMBData, 0, SecurityBlobLength); int dataOffset = SecurityBlob.Length; 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 + SecurityBlobLength) % 2; dataOffset += padding; } NativeOS = SMB1Helper.ReadSMBString(SMBData, ref dataOffset, isUnicode); if ((SMBData.Length - dataOffset) % 2 == 1) { // Workaround for a single terminating null byte SMBData = ByteUtils.Concatenate(SMBData, new byte[1]); } NativeLanMan = SMB1Helper.ReadSMBString(SMBData, ref dataOffset, isUnicode); }
public SessionSetupAndXRequestExtended(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset) { MaxBufferSize = LittleEndianConverter.ToUInt16(SMBParameters, 4); MaxMpxCount = LittleEndianConverter.ToUInt16(SMBParameters, 6); VcNumber = LittleEndianConverter.ToUInt16(SMBParameters, 8); SessionKey = LittleEndianConverter.ToUInt32(SMBParameters, 10); SecurityBlobLength = LittleEndianConverter.ToUInt16(SMBParameters, 14); Reserved = LittleEndianConverter.ToUInt32(SMBParameters, 16); Capabilities = (Capabilities)LittleEndianConverter.ToUInt32(SMBParameters, 20); SecurityBlob = ByteReader.ReadBytes(SMBData, 0, SecurityBlobLength); int dataOffset = SecurityBlob.Length; 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 + SecurityBlobLength) % 2; dataOffset += padding; } NativeOS = SMB1Helper.ReadSMBString(SMBData, ref dataOffset, isUnicode); NativeLanMan = SMB1Helper.ReadSMBString(SMBData, ref dataOffset, isUnicode); }
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); if (isUnicode && parameters.Length == 13 && parameters[12] == 0x00) { // Workaround for PlayStation2 Slim FileName = String.Empty; } else { FileName = SMB1Helper.ReadSMBString(parameters, 12, isUnicode); } if (InformationLevel == FindInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST) { GetExtendedAttributeList = new ExtendedAttributeNameList(data, 0); } }
public Transaction2CreateDirectoryRequest(byte[] parameters, byte[] data, bool isUnicode) : base() { Reserved = LittleEndianConverter.ToUInt32(parameters, 0); DirectoryName = SMB1Helper.ReadSMBString(parameters, 4, isUnicode); ExtendedAttributeList = new FullExtendedAttributeList(data); }