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);
        }
Esempio n. 2
0
 public FileFsSizeInformation(byte[] buffer, int offset)
 {
     TotalAllocationUnits     = LittleEndianConverter.ToInt64(buffer, offset + 0);
     AvailableAllocationUnits = LittleEndianConverter.ToInt64(buffer, offset + 8);
     SectorsPerAllocationUnit = LittleEndianConverter.ToUInt32(buffer, offset + 16);
     BytesPerSector           = LittleEndianConverter.ToUInt32(buffer, offset + 20);
 }
        public Nullable <DateTime> GetDateTimeProperty(PropertyID propertyID)
        {
            PropertyContextRecord record = GetRecordByPropertyID(propertyID);

            if (record != null)
            {
                if (record.wPropType == PropertyTypeName.PtypTime)
                {
                    if (!record.HeapOrNodeID.IsEmpty)
                    {
                        byte[]   dateTimeBytes = this.GetHeapItem(record.HeapID);
                        long     temp          = LittleEndianConverter.ToInt64(dateTimeBytes, 0);
                        DateTime result        = DateTime.FromFileTimeUtc(temp);
                        return(result);
                    }
                    else
                    {
                        // The hid is set to zero if the data item is empty
                        return(null);
                    }
                }
                else
                {
                    throw new InvalidPropertyException("Unexpected PC data type found");
                }
            }
            else
            {
                return(null);
            }
        }
        public Nullable <long> GetInt64Property(PropertyID propertyID)
        {
            PropertyContextRecord record = GetRecordByPropertyID(propertyID);

            if (record != null)
            {
                if (record.wPropType == PropertyTypeName.PtypInteger64)
                {
                    if (!record.HeapOrNodeID.IsEmpty)
                    {
                        byte[] longBytes = this.GetHeapItem(record.HeapID);
                        long   result    = LittleEndianConverter.ToInt64(longBytes, 0);
                        return(result);
                    }
                    else
                    {
                        // The hid is set to zero if the data item is empty
                        return(null);
                    }
                }
                else
                {
                    throw new InvalidPropertyException("Unexpected PC data type found");
                }
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
 public QueryFSSizeInfo(byte[] buffer, int offset)
 {
     TotalAllocationUnits     = LittleEndianConverter.ToInt64(buffer, 0);
     TotalFreeAllocationUnits = LittleEndianConverter.ToInt64(buffer, 8);
     SectorsPerAllocationUnit = LittleEndianConverter.ToUInt32(buffer, 16);
     BytesPerSector           = LittleEndianConverter.ToUInt32(buffer, 20);
 }
Esempio n. 6
0
 public FileStreamEntry(byte[] buffer, int offset)
 {
     NextEntryOffset      = LittleEndianConverter.ToUInt32(buffer, offset + 0);
     StreamNameLength     = LittleEndianConverter.ToUInt32(buffer, offset + 4);
     StreamSize           = LittleEndianConverter.ToInt64(buffer, offset + 8);
     StreamAllocationSize = LittleEndianConverter.ToInt64(buffer, offset + 16);
     StreamName           = ByteReader.ReadUTF16String(buffer, offset + 24, (int)StreamNameLength / 2);
 }
Esempio n. 7
0
 public FileCompressionInformation(byte[] buffer, int offset)
 {
     CompressedFileSize   = LittleEndianConverter.ToInt64(buffer, offset + 0);
     CompressionFormat    = (CompressionFormat)LittleEndianConverter.ToUInt16(buffer, offset + 8);
     CompressionUnitShift = ByteReader.ReadByte(buffer, offset + 10);
     ChunkShift           = ByteReader.ReadByte(buffer, offset + 11);
     ClusterShift         = ByteReader.ReadByte(buffer, offset + 12);
     Reserved             = ByteReader.ReadBytes(buffer, offset + 13, 3);
 }
 public FileStandardInformation(byte[] buffer, int offset)
 {
     AllocationSize = LittleEndianConverter.ToInt64(buffer, offset + 0);
     EndOfFile      = LittleEndianConverter.ToInt64(buffer, offset + 8);
     NumberOfLinks  = LittleEndianConverter.ToUInt32(buffer, offset + 16);
     DeletePending  = (ByteReader.ReadByte(buffer, offset + 20) > 0);
     Directory      = (ByteReader.ReadByte(buffer, offset + 21) > 0);
     Reserved       = LittleEndianConverter.ToUInt16(buffer, offset + 22);
 }
Esempio n. 9
0
 public FileFsControlInformation(byte[] buffer, int offset)
 {
     FreeSpaceStartFiltering = LittleEndianConverter.ToInt64(buffer, offset + 0);
     FreeSpaceThreshold      = LittleEndianConverter.ToInt64(buffer, offset + 8);
     FreeSpaceStopFiltering  = LittleEndianConverter.ToInt64(buffer, offset + 16);
     DefaultQuotaThreshold   = LittleEndianConverter.ToUInt64(buffer, offset + 24);
     DefaultQuotaLimit       = LittleEndianConverter.ToUInt64(buffer, offset + 32);
     FileSystemControlFlags  = (FileSystemControlFlags)LittleEndianConverter.ToUInt32(buffer, offset + 40);
     Padding = LittleEndianConverter.ToUInt32(buffer, offset + 44);
 }
Esempio n. 10
0
        public NTLMv2ClientChallengeStructure(byte[] buffer, int offset)
        {
            ResponseVersion     = ByteReader.ReadByte(buffer, offset + 0);
            ResponseVersionHigh = ByteReader.ReadByte(buffer, offset + 1);
            long temp = LittleEndianConverter.ToInt64(buffer, offset + 8);

            Time            = DateTime.FromFileTimeUtc(temp);
            ClientChallenge = ByteReader.ReadBytes(buffer, offset + 16, 8);
            AVPairs         = AVPairUtils.ReadAVPairSequence(buffer, offset + 28);
        }
Esempio n. 11
0
 public static DateTime ReadDateTime(byte[] buffer, int offset)
 {
     try
     {
         return(DateTime.FromFileTimeUtc(LittleEndianConverter.ToInt64(buffer, offset)));
     }
     catch (ArgumentException)
     {
         return(DateTime.MinValue);
     }
 }
Esempio n. 12
0
        public static DateTime ReadFileTime(byte[] buffer, int offset)
        {
            long span = LittleEndianConverter.ToInt64(buffer, offset);

            if (span >= 0)
            {
                return(DateTime.FromFileTimeUtc(span));
            }

            throw new System.IO.InvalidDataException("FILETIME cannot be negative");
        }
 public FileNetworkOpenInformation(byte[] buffer, int offset)
 {
     CreationTime   = FileTimeHelper.ReadNullableFileTime(buffer, offset + 0);
     LastAccessTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + 8);
     LastWriteTime  = FileTimeHelper.ReadNullableFileTime(buffer, offset + 16);
     ChangeTime     = FileTimeHelper.ReadNullableFileTime(buffer, offset + 24);
     AllocationSize = LittleEndianConverter.ToInt64(buffer, offset + 32);
     EndOfFile      = LittleEndianConverter.ToInt64(buffer, offset + 40);
     FileAttributes = (FileAttributes)LittleEndianConverter.ToUInt32(buffer, offset + 48);
     Reserved       = LittleEndianConverter.ToUInt32(buffer, offset + 52);
 }
Esempio n. 14
0
 public Nullable <long> GetInt64Property(int rowIndex, int columnIndex)
 {
     byte[] cellValue = GetPropertyValue(rowIndex, columnIndex);
     if (cellValue == null)
     {
         return(null);
     }
     else
     {
         return(LittleEndianConverter.ToInt64(cellValue, 0));
     }
 }
Esempio n. 15
0
 public FileDirectoryInformation(byte[] buffer, int offset) : base(buffer, offset)
 {
     CreationTime   = DateTime.FromFileTimeUtc(LittleEndianConverter.ToInt64(buffer, offset + 8));
     LastAccessTime = DateTime.FromFileTimeUtc(LittleEndianConverter.ToInt64(buffer, offset + 16));
     LastWriteTime  = DateTime.FromFileTimeUtc(LittleEndianConverter.ToInt64(buffer, offset + 24));
     ChangeTime     = DateTime.FromFileTimeUtc(LittleEndianConverter.ToInt64(buffer, offset + 32));
     EndOfFile      = LittleEndianConverter.ToInt64(buffer, offset + 40);
     AllocationSize = LittleEndianConverter.ToInt64(buffer, offset + 48);
     FileAttributes = (FileAttributes)LittleEndianConverter.ToUInt32(buffer, offset + 56);
     FileNameLength = LittleEndianConverter.ToUInt32(buffer, offset + 60);
     FileName       = ByteReader.ReadUTF16String(buffer, offset + 64, (int)FileNameLength / 2);
 }
Esempio n. 16
0
 public CloseResponse(byte[] buffer, int offset) : base(buffer, offset)
 {
     StructureSize  = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 0);
     Flags          = (CloseFlags)LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 2);
     Reserved       = LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 4);
     CreationTime   = FileTimeHelper.ReadNullableFileTime(buffer, offset + SMB2Header.Length + 8);
     LastAccessTime = FileTimeHelper.ReadNullableFileTime(buffer, offset + SMB2Header.Length + 16);
     LastWriteTime  = FileTimeHelper.ReadNullableFileTime(buffer, offset + SMB2Header.Length + 24);
     ChangeTime     = FileTimeHelper.ReadNullableFileTime(buffer, offset + SMB2Header.Length + 32);
     AllocationSize = LittleEndianConverter.ToInt64(buffer, offset + SMB2Header.Length + 40);
     EndofFile      = LittleEndianConverter.ToInt64(buffer, offset + SMB2Header.Length + 48);
     FileAttributes = (FileAttributes)LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 56);
 }
Esempio n. 17
0
        public static DateTime ReadSetFileTime(byte[] buffer, int offset)
        {
            long span = LittleEndianConverter.ToInt64(buffer, offset);

            if (span >= 0)
            {
                return(DateTime.FromFileTimeUtc(span));
            }
            else
            {
                return(FileTimeNotSpecified);
            }
        }
Esempio n. 18
0
 public Nullable <DateTime> GetDateTimeProperty(int rowIndex, int columnIndex)
 {
     byte[] cellValue = GetPropertyValue(rowIndex, columnIndex);
     if (cellValue == null)
     {
         return(null);
     }
     else
     {
         long temp = LittleEndianConverter.ToInt64(cellValue, 0);
         return(DateTime.FromFileTimeUtc(temp));
     }
 }
Esempio n. 19
0
        public static DateTime ReadFileTime(byte[] buffer, int offset)
        {
            long span = LittleEndianConverter.ToInt64(buffer, offset);

            if (span >= 0)
            {
                return(DateTime.FromFileTimeUtc(span));
            }
            else
            {
                // Tick = 100ns
                return(DateTime.Now.Subtract(TimeSpan.FromTicks(span)));
            }
        }
Esempio n. 20
0
        public static DateTime?ReadNullableFileTime(byte[] buffer, int offset)
        {
            long span = LittleEndianConverter.ToInt64(buffer, offset);

            if (span >= 0)
            {
                return(DateTime.FromFileTimeUtc(span));
            }

            if (span == 0)
            {
                return(null);
            }
            // Tick = 100ns
            return(DateTime.UtcNow.Subtract(TimeSpan.FromTicks(span)));
        }
Esempio n. 21
0
        public NegotiateRequest(byte[] buffer, int offset) : base(buffer, offset)
        {
            StructureSize   = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 0);
            DialectCount    = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 2);
            SecurityMode    = (SecurityMode)LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 4);
            Reserved        = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 6);
            Capabilities    = (ServerCapabilities)LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 8);
            ClientGuid      = LittleEndianConverter.ToGuid(buffer, offset + SMB2Header.Length + 12);
            ClientStartTime = DateTime.FromFileTimeUtc(LittleEndianConverter.ToInt64(buffer, offset + SMB2Header.Length + 28));

            for (int index = 0; index < DialectCount; index++)
            {
                SMB2Dialect dialect = (SMB2Dialect)LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 36 + index * 2);
                Dialects.Add(dialect);
            }
        }
Esempio n. 22
0
 public NegotiateResponse(byte[] buffer, int offset) : base(buffer, offset)
 {
     StructureSize          = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 0);
     SecurityMode           = (SecurityMode)LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 2);
     DialectRevision        = (SMB2Dialect)LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 4);
     NegotiateContextCount  = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 6);
     ServerGuid             = LittleEndianConverter.ToGuid(buffer, offset + SMB2Header.Length + 8);
     Capabilities           = (Capabilities)LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 24);
     MaxTransactSize        = LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 28);
     MaxReadSize            = LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 32);
     MaxWriteSize           = LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 36);
     SystemTime             = DateTime.FromFileTimeUtc(LittleEndianConverter.ToInt64(buffer, offset + SMB2Header.Length + 40));
     ServerStartTime        = DateTime.FromFileTimeUtc(LittleEndianConverter.ToInt64(buffer, offset + SMB2Header.Length + 48));
     SecurityBufferOffset   = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 56);
     SecurityBufferLength   = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 58);
     NegotiateContextOffset = LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 60);
     SecurityBuffer         = ByteReader.ReadBytes(buffer, offset + SecurityBufferOffset, SecurityBufferLength);
     NegotiateContextList   = NegotiateContext.ReadNegotiateContextList(buffer, (int)NegotiateContextOffset, NegotiateContextCount);
 }
Esempio n. 23
0
 public CreateResponse(byte[] buffer, int offset) : base(buffer, offset)
 {
     StructureSize         = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 0);
     OplockLevel           = (OplockLevel)ByteReader.ReadByte(buffer, offset + SMB2Header.Length + 2);
     Flags                 = (CreateResponseFlags)ByteReader.ReadByte(buffer, offset + SMB2Header.Length + 3);
     CreateAction          = (CreateAction)LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 4);
     CreationTime          = FileTimeHelper.ReadNullableFileTime(buffer, offset + SMB2Header.Length + 8);
     LastAccessTime        = FileTimeHelper.ReadNullableFileTime(buffer, offset + SMB2Header.Length + 16);
     LastWriteTime         = FileTimeHelper.ReadNullableFileTime(buffer, offset + SMB2Header.Length + 24);
     ChangeTime            = FileTimeHelper.ReadNullableFileTime(buffer, offset + SMB2Header.Length + 32);
     AllocationSize        = LittleEndianConverter.ToInt64(buffer, offset + SMB2Header.Length + 40);
     EndofFile             = LittleEndianConverter.ToInt64(buffer, offset + SMB2Header.Length + 48);
     FileAttributes        = (FileAttributes)LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 56);
     Reserved2             = LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 60);
     FileId                = new FileID(buffer, offset + SMB2Header.Length + 64);
     CreateContextsOffsets = LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 80);
     CreateContextsLength  = LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 84);
     if (CreateContextsLength > 0)
     {
         CreateContexts = CreateContext.ReadCreateContextList(buffer, offset + (int)CreateContextsOffsets);
     }
 }
Esempio n. 24
0
 public FileValidDataLengthInformation(byte[] buffer, int offset)
 {
     ValidDataLength = LittleEndianConverter.ToInt64(buffer, offset);
 }
Esempio n. 25
0
 public FileInternalInformation(byte[] buffer, int offset)
 {
     IndexNumber = LittleEndianConverter.ToInt64(buffer, offset + 0);
 }
Esempio n. 26
0
 public FilePositionInformation(byte[] buffer, int offset)
 {
     CurrentByteOffset = LittleEndianConverter.ToInt64(buffer, offset + 0);
 }
 public FileAllocationInformation(byte[] buffer, int offset)
 {
     AllocationSize = LittleEndianConverter.ToInt64(buffer, offset);
 }
Esempio n. 28
0
        /// <summary>
        /// When setting file attributes, a value of -1 indicates to the server that it MUST NOT change this attribute for all subsequent operations on the same file handle.
        /// </summary>
        public static SetFileTime ReadSetFileTime(byte[] buffer, int offset)
        {
            long span = LittleEndianConverter.ToInt64(buffer, offset);

            return(SetFileTime.FromFileTimeUtc(span));
        }
Esempio n. 29
0
 public FileEndOfFileInformation(byte[] buffer, int offset)
 {
     EndOfFile = LittleEndianConverter.ToInt64(buffer, offset);
 }
Esempio n. 30
0
 protected override long ConvertGroupToValue()
 => LittleEndianConverter.ToInt64(ToBytes());