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)); }
public byte[] GetBytes(int bytesPerSystemPage, bool applyUsaProtection) { m_systemPageSize = (uint)bytesPerSystemPage; int strideCount = bytesPerSystemPage / MultiSectorHelper.BytesPerStride; ushort updateSequenceArraySize = (ushort)(1 + strideCount); MultiSectorHeader multiSectorHeader = new MultiSectorHeader(ValidSignature, UpdateSequenceArrayOffset, updateSequenceArraySize); int restartOffset = (int)Math.Ceiling((double)(UpdateSequenceArrayOffset + updateSequenceArraySize * 2) / 8) * 8; byte[] buffer = new byte[bytesPerSystemPage]; multiSectorHeader.WriteBytes(buffer, 0); LittleEndianWriter.WriteUInt64(buffer, 0x08, ChkDskLsn); LittleEndianWriter.WriteUInt32(buffer, 0x10, m_systemPageSize); LittleEndianWriter.WriteUInt32(buffer, 0x14, LogPageSize); LittleEndianWriter.WriteUInt16(buffer, 0x18, (ushort)restartOffset); LittleEndianWriter.WriteInt16(buffer, 0x1A, MinorVersion); LittleEndianWriter.WriteInt16(buffer, 0x1C, MajorVersion); LittleEndianWriter.WriteUInt16(buffer, UpdateSequenceArrayOffset, UpdateSequenceNumber); RestartArea.WriteBytes(buffer, restartOffset); if (applyUsaProtection) { MultiSectorHelper.ApplyUsaProtection(buffer, 0); } return(buffer); }
public override byte[] GetBytes(bool isUnicode) { ChallengeLength = 0; this.SMBParameters = new byte[ParametersLength]; LittleEndianWriter.WriteUInt16(this.SMBParameters, 0, DialectIndex); ByteWriter.WriteByte(this.SMBParameters, 2, (byte)SecurityMode); LittleEndianWriter.WriteUInt16(this.SMBParameters, 3, MaxMpxCount); LittleEndianWriter.WriteUInt16(this.SMBParameters, 5, MaxNumberVcs); LittleEndianWriter.WriteUInt32(this.SMBParameters, 7, MaxBufferSize); LittleEndianWriter.WriteUInt32(this.SMBParameters, 11, MaxRawSize); LittleEndianWriter.WriteUInt32(this.SMBParameters, 15, SessionKey); LittleEndianWriter.WriteUInt32(this.SMBParameters, 19, (uint)Capabilities); FileTimeHelper.WriteFileTime(this.SMBParameters, 23, SystemTime); LittleEndianWriter.WriteInt16(this.SMBParameters, 31, ServerTimeZone); ByteWriter.WriteByte(this.SMBParameters, 33, ChallengeLength); this.SMBData = new byte[16 + SecurityBlob.Length]; LittleEndianWriter.WriteGuid(this.SMBData, 0, ServerGuid); ByteWriter.WriteBytes(this.SMBData, 16, SecurityBlob); return(base.GetBytes(isUnicode)); }
public override byte[] GetBytes(bool isUnicode) { byte challengeLength = (byte)this.Challenge.Length; this.SMBParameters = new byte[ParametersLength]; LittleEndianWriter.WriteUInt16(this.SMBParameters, 0, DialectIndex); ByteWriter.WriteByte(this.SMBParameters, 2, (byte)SecurityMode); LittleEndianWriter.WriteUInt16(this.SMBParameters, 3, MaxMpxCount); LittleEndianWriter.WriteUInt16(this.SMBParameters, 5, MaxNumberVcs); LittleEndianWriter.WriteUInt32(this.SMBParameters, 7, MaxBufferSize); LittleEndianWriter.WriteUInt32(this.SMBParameters, 11, MaxRawSize); LittleEndianWriter.WriteUInt32(this.SMBParameters, 15, SessionKey); LittleEndianWriter.WriteUInt32(this.SMBParameters, 19, (uint)Capabilities); LittleEndianWriter.WriteInt64(this.SMBParameters, 23, SystemTime.ToFileTimeUtc()); LittleEndianWriter.WriteInt16(this.SMBParameters, 31, ServerTimeZone); ByteWriter.WriteByte(this.SMBParameters, 33, challengeLength); int padding = 0; if (isUnicode) { padding = Challenge.Length % 2; this.SMBData = new byte[Challenge.Length + padding + DomainName.Length * 2 + ServerName.Length * 2 + 4]; } else { this.SMBData = new byte[Challenge.Length + DomainName.Length + ServerName.Length + 2]; } int offset = 0; ByteWriter.WriteBytes(this.SMBData, ref offset, Challenge); offset += padding; SMBHelper.WriteSMBString(this.SMBData, ref offset, isUnicode, DomainName); SMBHelper.WriteSMBString(this.SMBData, ref offset, isUnicode, ServerName); return(base.GetBytes(isUnicode)); }
public byte[] GetBytes(int bytesPerSystemPage) { m_systemPageSize = (uint)bytesPerSystemPage; int strideCount = bytesPerSystemPage / MultiSectorHelper.BytesPerStride; ushort updateSequenceArraySize = (ushort)(1 + strideCount); MultiSectorHeader multiSectorHeader = new MultiSectorHeader(ValidSignature, UpdateSequenceArrayOffset, updateSequenceArraySize); int restartOffset = (int)Math.Ceiling((double)(UpdateSequenceArrayOffset + updateSequenceArraySize * 2) / 8) * 8; byte[] buffer = new byte[bytesPerSystemPage]; multiSectorHeader.WriteBytes(buffer, 0); LittleEndianWriter.WriteUInt64(buffer, 0x08, ChkDskLsn); LittleEndianWriter.WriteUInt32(buffer, 0x10, m_systemPageSize); LittleEndianWriter.WriteUInt32(buffer, 0x14, LogPageSize); LittleEndianWriter.WriteUInt16(buffer, 0x18, (ushort)restartOffset); LittleEndianWriter.WriteInt16(buffer, 0x1A, MinorVersion); LittleEndianWriter.WriteInt16(buffer, 0x1C, MajorVersion); LogRestartArea.WriteBytes(buffer, restartOffset); // Write UpdateSequenceNumber and UpdateSequenceReplacementData List <byte[]> updateSequenceReplacementData = MultiSectorHelper.EncodeSegmentBuffer(buffer, 0, bytesPerSystemPage, UpdateSequenceNumber); MultiSectorHelper.WriteUpdateSequenceArray(buffer, UpdateSequenceArrayOffset, updateSequenceArraySize, UpdateSequenceNumber, updateSequenceReplacementData); return(buffer); }