From 01ac52c5720eaefd2758bc9e38acb0a6931c3713 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Wed, 9 Oct 2024 06:31:40 +1000 Subject: [PATCH] SMB Server fix filename offsets Correctly set the NextEntryOffset for the SMBFindFileNamesInfo results when querying the names of files. The current logic does not set this value so will be set to 0 making the client believe there are no more entries in the result if going by the MS-SMB2 logic. --- impacket/smbserver.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/impacket/smbserver.py b/impacket/smbserver.py index 5e1f08dd90..a97d667ced 100644 --- a/impacket/smbserver.py +++ b/impacket/smbserver.py @@ -502,6 +502,9 @@ def findFirst2(path, fileName, level, searchAttributes, pktFlags=smb.SMB.FLAGS2_ item['LastAccessTime'] = getSMBTime(atime) item['LastWriteDate'] = getSMBDate(mtime) item['LastWriteTime'] = getSMBTime(mtime) + elif level in [smb.SMB_FIND_FILE_NAMES_INFO, smb2.SMB2_FILE_NAMES_INFO]: + padLen = (8 - (len(item) % 8)) % 8 + item['NextEntryOffset'] = len(item) + padLen searchResult.append(item) # No more files