diff --git a/impacket/smb3.py b/impacket/smb3.py index 34e4ddd41a..6dddbca23c 100644 --- a/impacket/smb3.py +++ b/impacket/smb3.py @@ -1171,7 +1171,7 @@ def connectTree(self, share): treeConnect = SMB2TreeConnect() treeConnect['Buffer'] = path.encode('utf-16le') - treeConnect['PathLength'] = len(path)*2 + treeConnect['PathLength'] = len(path.encode('utf-16le')) packet = self.SMB_PACKET() packet['Command'] = SMB2_TREE_CONNECT @@ -1284,7 +1284,7 @@ def create(self, treeId, fileName, desiredAccess, shareMode, creationOptions, cr smb2Create['CreateDisposition'] = creationDisposition smb2Create['CreateOptions'] = creationOptions - smb2Create['NameLength'] = len(fileName)*2 + smb2Create['NameLength'] = len(fileName.encode('utf-16le')) if fileName != '': smb2Create['Buffer'] = fileName.encode('utf-16le') else: @@ -1470,7 +1470,7 @@ def queryDirectory(self, treeId, fileId, searchString = '*', resumeIndex = 0, in if maxBufferSize is None: maxBufferSize = self._Connection['MaxReadSize'] queryDirectory['OutputBufferLength'] = maxBufferSize - queryDirectory['FileNameLength'] = len(searchString)*2 + queryDirectory['FileNameLength'] = len(searchString.encode('utf-16le')) queryDirectory['Buffer'] = searchString.encode('utf-16le') packet['Data'] = queryDirectory @@ -1718,7 +1718,7 @@ def rename(self, shareName, oldPath, newPath): renameReq = FILE_RENAME_INFORMATION_TYPE_2() renameReq['ReplaceIfExists'] = 1 renameReq['RootDirectory'] = '\x00'*8 - renameReq['FileNameLength'] = len(newPath)*2 + renameReq['FileNameLength'] = len(newPath.encode('utf-16le')) renameReq['FileName'] = newPath.encode('utf-16le') self.setInfo(treeId, fileId, renameReq, infoType = SMB2_0_INFO_FILE, fileInfoClass = SMB2_FILE_RENAME_INFO) finally: @@ -1964,7 +1964,7 @@ def waitNamedPipe(self, treeId, pipename, timeout = 5): pipeWait = FSCTL_PIPE_WAIT_STRUCTURE() pipeWait['Timeout'] = timeout*100000 - pipeWait['NameLength'] = len(pipename)*2 + pipeWait['NameLength'] = len(pipename.encode('utf-16le')) pipeWait['TimeoutSpecified'] = 1 pipeWait['Name'] = pipename.encode('utf-16le')