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) { ushort passwordLength = (ushort)Password.Length; SMBParameters = new byte[ParametersLength]; int parametersOffset = 4; LittleEndianWriter.WriteUInt16(SMBParameters, ref parametersOffset, (ushort)Flags); LittleEndianWriter.WriteUInt16(SMBParameters, ref parametersOffset, passwordLength); string serviceString = ServiceNameHelper.GetServiceString(Service); int dataLength = Password.Length + serviceString.Length + 1; if (isUnicode) { int padding = (1 + passwordLength) % 2; dataLength += Path.Length * 2 + 2 + padding; } else { dataLength += Path.Length + 1; } SMBData = new byte[dataLength]; int dataOffset = 0; ByteWriter.WriteBytes(SMBData, ref dataOffset, Password); if (isUnicode) { // wordCount is 1 byte int padding = (1 + passwordLength) % 2; dataOffset += padding; } SMB1Helper.WriteSMBString(SMBData, ref dataOffset, isUnicode, Path); ByteWriter.WriteNullTerminatedAnsiString(SMBData, ref dataOffset, serviceString); return(base.GetBytes(isUnicode)); }