MCPcopy Index your code
hub / github.com/secdev/scapy / send_ioctl_response

Method send_ioctl_response

scapy/layers/smbserver.py:906–1015  ·  view source on GitHub ↗
(self, pkt)

Source from the content-addressed store, hash-verified

904
905 @ATMT.action(receive_ioctl)
906 def send_ioctl_response(self, pkt):
907 self.update_smbheader(pkt)
908 if pkt.CtlCode == 0x11C017:
909 # FSCTL_PIPE_TRANSCEIVE
910 self.rpc_server.recv(pkt.Input.load)
911 self.send(
912 self.smb_header.copy()
913 / SMB2_IOCTL_Response(
914 CtlCode=0x11C017,
915 FileId=pkt[SMB2_IOCTL_Request].FileId,
916 Buffer=[("Output", self.rpc_server.get_response())],
917 )
918 )
919 elif pkt.CtlCode == 0x00140204 and self.session.sspcontext.SessionKey:
920 # FSCTL_VALIDATE_NEGOTIATE_INFO
921 # This is a security measure asking the server to validate
922 # what flags were negotiated during the SMBNegotiate exchange.
923 # This packet is ALWAYS signed, and expects a signed response.
924
925 # https://docs.microsoft.com/en-us/archive/blogs/openspecification/smb3-secure-dialect-negotiation
926 # > "Down-level servers (pre-Windows 2012) will return
927 # > STATUS_NOT_SUPPORTED or STATUS_INVALID_DEVICE_REQUEST
928 # > since they do not allow or implement
929 # > FSCTL_VALIDATE_NEGOTIATE_INFO.
930 # > The client should accept the
931 # > response provided it's properly signed".
932
933 if (self.session.Dialect or 0) < 0x0300:
934 # SMB < 3 isn't supposed to support FSCTL_VALIDATE_NEGOTIATE_INFO
935 self._ioctl_error(Status="STATUS_FILE_CLOSED")
936 return
937
938 # SMB3
939 self.send(
940 self.smb_header.copy()
941 / SMB2_IOCTL_Response(
942 CtlCode=0x00140204,
943 FileId=pkt[SMB2_IOCTL_Request].FileId,
944 Buffer=[
945 (
946 "Output",
947 SMB2_IOCTL_Validate_Negotiate_Info_Response(
948 GUID=self.GUID,
949 DialectRevision=self.session.Dialect,
950 SecurityMode=(
951 "SIGNING_ENABLED+SIGNING_REQUIRED"
952 if self.session.SigningRequired
953 else "SIGNING_ENABLED"
954 ),
955 Capabilities=self.NegotiateCapabilities,
956 ),
957 )
958 ],
959 )
960 )
961 elif pkt.CtlCode == 0x001401FC:
962 # FSCTL_QUERY_NETWORK_INTERFACE_INFO
963 self.send(

Callers

nothing calls this directly

Calls 15

update_smbheaderMethod · 0.95
sendMethod · 0.95
_ioctl_errorMethod · 0.95
SMB2_IOCTL_ResponseClass · 0.90
SOCKADDR_STORAGEClass · 0.90
DFS_REFERRAL_V3Class · 0.90
DFS_REFERRAL_ENTRY1Class · 0.90
SMB2_Error_ResponseClass · 0.90

Tested by

no test coverage detected