Skip to content

Commit

Permalink
Merge branch 'fortra:master' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
GeisericII authored Jan 7, 2025
2 parents 0b1f379 + 2d2e562 commit 3d73407
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
6 changes: 6 additions & 0 deletions impacket/smb3structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,12 @@ class FILE_ALL_INFORMATION(Structure):
('NameInformation',':',FILE_NAME_INFORMATION),
)

class FILE_ATTRIBUTE_TAG_INFORMATION(Structure):
structure = (
('FileAttributes','<L'),
('ReparseTag','<L=0'),
)

# SMB2_SET_INFO
class SMB2SetInfo(Structure):
SIZE = 32
Expand Down
41 changes: 29 additions & 12 deletions impacket/smbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,20 +532,38 @@ def queryPathInformation(path, filename, level):

if os.path.exists(pathName):
(mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(pathName)
if os.path.isdir(pathName):
fileAttributes = smb.ATTR_DIRECTORY
else:
fileAttributes = smb.ATTR_NORMAL | smb.ATTR_ARCHIVE

if level == smb.SMB_QUERY_FILE_BASIC_INFO:
infoRecord = smb.SMBQueryFileBasicInfo()
infoRecord['CreationTime'] = getFileTime(ctime)
infoRecord['LastAccessTime'] = getFileTime(atime)
infoRecord['LastWriteTime'] = getFileTime(mtime)
infoRecord['LastChangeTime'] = getFileTime(mtime)
infoRecord['ExtFileAttributes'] = fileAttributes
elif level == smb2.SMB2_FILE_BASIC_INFO:
infoRecord = smb2.FILE_BASIC_INFORMATION()
infoRecord['CreationTime'] = getFileTime(ctime)
infoRecord['LastAccessTime'] = getFileTime(atime)
infoRecord['LastWriteTime'] = getFileTime(mtime)
infoRecord['ChangeTime'] = getFileTime(mtime)
infoRecord['FileAttributes'] = fileAttributes
elif level == smb.SMB_QUERY_FILE_STANDARD_INFO:
infoRecord = smb.SMBQueryFileStandardInfo()
infoRecord['AllocationSize'] = size
infoRecord['EndOfFile'] = size
if os.path.isdir(pathName):
infoRecord['ExtFileAttributes'] = smb.ATTR_DIRECTORY
infoRecord['Directory'] = 1
else:
infoRecord['ExtFileAttributes'] = smb.ATTR_NORMAL | smb.ATTR_ARCHIVE
elif level == smb.SMB_QUERY_FILE_STANDARD_INFO or level == smb2.SMB2_FILE_STANDARD_INFO:
infoRecord = smb.SMBQueryFileStandardInfo()
infoRecord['Directory'] = 0
elif level == smb2.SMB2_FILE_STANDARD_INFO:
infoRecord = smb2.FILE_STANDARD_INFORMATION()
infoRecord['AllocationSize'] = size
infoRecord['EndOfFile'] = size
infoRecord['NumberOfLinks'] = 0
if os.path.isdir(pathName):
infoRecord['Directory'] = 1
else:
Expand All @@ -556,10 +574,7 @@ def queryPathInformation(path, filename, level):
infoRecord['LastAccessTime'] = getFileTime(atime)
infoRecord['LastWriteTime'] = getFileTime(mtime)
infoRecord['LastChangeTime'] = getFileTime(mtime)
if os.path.isdir(pathName):
infoRecord['ExtFileAttributes'] = smb.ATTR_DIRECTORY
else:
infoRecord['ExtFileAttributes'] = smb.ATTR_NORMAL | smb.ATTR_ARCHIVE
infoRecord['ExtFileAttributes'] = fileAttributes
infoRecord['AllocationSize'] = size
infoRecord['EndOfFile'] = size
if os.path.isdir(pathName):
Expand Down Expand Up @@ -609,14 +624,14 @@ def queryPathInformation(path, filename, level):
infoRecord['ChangeTime'] = getFileTime(mtime)
infoRecord['AllocationSize'] = size
infoRecord['EndOfFile'] = size
if os.path.isdir(pathName):
infoRecord['FileAttributes'] = smb.ATTR_DIRECTORY
else:
infoRecord['FileAttributes'] = smb.ATTR_NORMAL | smb.ATTR_ARCHIVE
infoRecord['FileAttributes'] = fileAttributes
elif level == smb.SMB_QUERY_FILE_EA_INFO or level == smb2.SMB2_FILE_EA_INFO:
infoRecord = smb.SMBQueryFileEaInfo()
elif level == smb.SMB_QUERY_FILE_STREAM_INFO or level == smb2.SMB2_FILE_STREAM_INFO:
infoRecord = smb.SMBFileStreamInformation()
elif level == smb2.SMB2_ATTRIBUTE_TAG_INFO:
infoRecord = smb2.FILE_ATTRIBUTE_TAG_INFORMATION()
infoRecord['FileAttributes'] = fileAttributes
else:
LOG.error('Unknown level for query path info! 0x%x' % level)
# UNSUPPORTED
Expand Down Expand Up @@ -2911,6 +2926,8 @@ def smb2SessionSetup(connId, smbServer, recvPacket):
ansFlags |= ntlm.NTLMSSP_NEGOTIATE_UNICODE
if negotiateMessage['flags'] & ntlm.NTLM_NEGOTIATE_OEM:
ansFlags |= ntlm.NTLM_NEGOTIATE_OEM
if negotiateMessage['flags'] & ntlm.NTLMSSP_NEGOTIATE_SIGN:
ansFlags |= ntlm.NTLMSSP_NEGOTIATE_SIGN

ansFlags |= ntlm.NTLMSSP_NEGOTIATE_VERSION | ntlm.NTLMSSP_NEGOTIATE_TARGET_INFO | ntlm.NTLMSSP_TARGET_TYPE_SERVER | ntlm.NTLMSSP_NEGOTIATE_NTLM | ntlm.NTLMSSP_REQUEST_TARGET

Expand Down

0 comments on commit 3d73407

Please sign in to comment.