From ec4188105a47a04d83ed8812bf5319485a756111 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Wed, 8 Jan 2025 04:25:37 +1000 Subject: [PATCH] Pad all SMB2 packets, even the last in a compound response --- impacket/smbserver.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/impacket/smbserver.py b/impacket/smbserver.py index 7b1681e01c..255d6fd790 100644 --- a/impacket/smbserver.py +++ b/impacket/smbserver.py @@ -1,6 +1,6 @@ # Impacket - Collection of Python classes for working with network protocols. # -# Copyright Fortra, LLC and its affiliated companies +# Copyright Fortra, LLC and its affiliated companies # # All rights reserved. # @@ -3759,7 +3759,7 @@ def smb2QueryDirectory(connId, smbServer, recvPacket): lenData = len(data) padLen = (8 - (lenData % 8)) % 8 - # For larger directory we might reach the OutputBufferLength so we need to set + # For larger directory we might reach the OutputBufferLength so we need to set # the NextEntryOffset to 0 for the last entry the will fit the buffer try: # Check if the next data will exceed the OutputBufferLength @@ -4635,9 +4635,8 @@ def processRequest(self, connId, data): finalData = [] totalPackets = len(packetsToSend) for idx, packet in enumerate(packetsToSend): - padLen = 0 + padLen = -len(packet) % 8 if idx + 1 < totalPackets: - padLen = -len(packet) % 8 packet['NextCommand'] = len(packet) + padLen if connData['SignatureEnabled']: