MCPcopy Create free account
hub / github.com/secdev/scapy / update_smbheader

Method update_smbheader

scapy/layers/smbserver.py:591–628  ·  view source on GitHub ↗

Called when receiving a SMB2 packet to update the current smb_header

(self, pkt)

Source from the content-addressed store, hash-verified

589 pass
590
591 def update_smbheader(self, pkt):
592 """
593 Called when receiving a SMB2 packet to update the current smb_header
594 """
595 # [MS-SMB2] sect 3.2.5.1.4 - always grant client its credits
596 self.smb_header.CreditRequest = pkt.CreditRequest
597 # [MS-SMB2] sect 3.3.4.1
598 # "the server SHOULD set the CreditCharge field in the SMB2 header
599 # of the response to the CreditCharge value in the SMB2 header of the request."
600 self.smb_header.CreditCharge = pkt.CreditCharge
601 # If the packet has a NextCommand, set NextCompound to True
602 self.NextCompound = bool(pkt.NextCommand)
603 # [MS-SMB2] sect 3.3.4.1.1 - "If the request was signed by the client..."
604 # If the packet was signed, note we must answer with a signed packet.
605 if (
606 not self.session.SigningRequired
607 and pkt.SecuritySignature != b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
608 ):
609 self.NextForceSign = True
610 # [MS-SMB2] sect 3.3.4.1.4 - "If the message being sent is any response to a
611 # client request for which Request.IsEncrypted is TRUE"
612 if pkt[SMB2_Header]._decrypted:
613 self.NextForceEncrypt = True
614 # [MS-SMB2] sect 3.3.5.2.7.2
615 # Add SMB2_FLAGS_RELATED_OPERATIONS to the response if present
616 if pkt.Flags.SMB2_FLAGS_RELATED_OPERATIONS:
617 self.smb_header.Flags += "SMB2_FLAGS_RELATED_OPERATIONS"
618 else:
619 self.smb_header.Flags -= "SMB2_FLAGS_RELATED_OPERATIONS"
620 # [MS-SMB2] sect 2.2.1.2 - Priority
621 if (self.session.Dialect or 0) >= 0x0311:
622 self.smb_header.Flags &= 0xFF8F
623 self.smb_header.Flags |= int(pkt.Flags) & 0x70
624 # Update IDs
625 self.smb_header.SessionId = pkt.SessionId
626 self.smb_header.TID = pkt.TID
627 self.smb_header.MID = pkt.MID
628 self.smb_header.PID = pkt.PID
629
630 @ATMT.receive_condition(NEGOTIATED)
631 def received_negotiate_smb2(self, pkt):

Callers 15

on_negotiateMethod · 0.95
on_setup_andx_requestMethod · 0.95
send_logoff_responseMethod · 0.95
send_ioctl_responseMethod · 0.95
send_write_responseMethod · 0.95
send_read_responseMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected