Skip to content

Commit

Permalink
Pad all SMB2 packets, even the last in a compound response
Browse files Browse the repository at this point in the history
  • Loading branch information
jborean93 committed Jan 7, 2025
1 parent 0704387 commit ec41881
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions impacket/smbserver.py
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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']:
Expand Down

0 comments on commit ec41881

Please sign in to comment.