Version.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Utilities;
  11. namespace SMBLibrary.Authentication
  12. {
  13. public class Version
  14. {
  15. public const byte NTLMSSP_REVISION_W2K3 = 0x0F;
  16. public byte ProductMajorVersion;
  17. public byte ProductMinorVersion;
  18. public ushort ProductBuild;
  19. // Reserved - 3 bytes
  20. public byte NTLMRevisionCurrent;
  21. public Version(byte majorVersion, byte minorVersion, ushort build, byte ntlmRevisionCurrent)
  22. {
  23. ProductMajorVersion = majorVersion;
  24. ProductMinorVersion = minorVersion;
  25. ProductBuild = build;
  26. NTLMRevisionCurrent = ntlmRevisionCurrent;
  27. }
  28. public Version(byte[] buffer, int offset)
  29. {
  30. ProductMajorVersion = ByteReader.ReadByte(buffer, offset + 0);
  31. ProductMinorVersion = ByteReader.ReadByte(buffer, offset + 1);
  32. ProductBuild = LittleEndianConverter.ToUInt16(buffer, offset + 2);
  33. NTLMRevisionCurrent = ByteReader.ReadByte(buffer, offset + 7);
  34. }
  35. public void WriteBytes(byte[] buffer, int offset)
  36. {
  37. ByteWriter.WriteByte(buffer, offset + 0, ProductMajorVersion);
  38. ByteWriter.WriteByte(buffer, offset + 1, ProductMinorVersion);
  39. LittleEndianWriter.WriteUInt16(buffer, offset + 2, ProductBuild);
  40. ByteWriter.WriteByte(buffer, offset + 7, NTLMRevisionCurrent);
  41. }
  42. public static Version WindowsXP
  43. {
  44. get
  45. {
  46. return new Version(5, 1, 2600, NTLMSSP_REVISION_W2K3);
  47. }
  48. }
  49. public static Version Server2003
  50. {
  51. get
  52. {
  53. return new Version(5, 2, 3790, NTLMSSP_REVISION_W2K3);
  54. }
  55. }
  56. }
  57. }