(self, pkt)
| 368 | |
| 369 | @ATMT.receive_condition(SENT_NEGOTIATE) |
| 370 | def receive_negotiate_response(self, pkt): |
| 371 | if ( |
| 372 | SMBNegotiate_Response_Extended_Security in pkt |
| 373 | or SMB2_Negotiate_Protocol_Response in pkt |
| 374 | ): |
| 375 | # Extended SMB1 / SMB2 |
| 376 | try: |
| 377 | ssp_blob = pkt.SecurityBlob # eventually SPNEGO server initiation |
| 378 | except AttributeError: |
| 379 | ssp_blob = None |
| 380 | if ( |
| 381 | SMB2_Negotiate_Protocol_Response in pkt |
| 382 | and pkt.DialectRevision & 0xFF == 0xFF |
| 383 | ): |
| 384 | # Version is SMB X.??? |
| 385 | # [MS-SMB2] 3.2.5.2 |
| 386 | # If the DialectRevision field in the SMB2 NEGOTIATE Response is |
| 387 | # 0x02FF ... the client MUST allocate sequence number 1 from |
| 388 | # Connection.SequenceWindow, and MUST set MessageId field of the |
| 389 | # SMB2 header to 1. |
| 390 | self.SequenceWindow = (1, 1) |
| 391 | self.smb_header = DirectTCP() / SMB2_Header(PID=0xFEFF, MID=1) |
| 392 | self.SMB2 = True # We're now using SMB2 to talk to the server |
| 393 | raise self.SMB2_NEGOTIATE() |
| 394 | else: |
| 395 | if SMB2_Negotiate_Protocol_Response in pkt: |
| 396 | # SMB2 was negotiated ! |
| 397 | self.session.Dialect = pkt.DialectRevision |
| 398 | # If required, compute sessions |
| 399 | self.session.computeSMBConnectionPreauth( |
| 400 | bytes(pkt[SMB2_Header]), # nego response |
| 401 | ) |
| 402 | # Process max sizes |
| 403 | self.session.MaxReadSize = pkt.MaxReadSize |
| 404 | self.session.MaxTransactionSize = pkt.MaxTransactionSize |
| 405 | self.session.MaxWriteSize = pkt.MaxWriteSize |
| 406 | # Process SecurityMode |
| 407 | if pkt.SecurityMode.SIGNING_REQUIRED: |
| 408 | self.session.SigningRequired = True |
| 409 | # Process capabilities |
| 410 | if self.session.Dialect >= 0x0300: |
| 411 | self.session.SupportsEncryption = pkt.Capabilities.ENCRYPTION |
| 412 | # Process NegotiateContext |
| 413 | if self.session.Dialect >= 0x0311 and pkt.NegotiateContextsCount: |
| 414 | for ngctx in pkt.NegotiateContexts: |
| 415 | if ngctx.ContextType == 0x0002: |
| 416 | # SMB2_ENCRYPTION_CAPABILITIES |
| 417 | if ngctx.Ciphers[0] != 0: |
| 418 | self.session.CipherId = SMB2_ENCRYPTION_CIPHERS[ |
| 419 | ngctx.Ciphers[0] |
| 420 | ] |
| 421 | self.session.SupportsEncryption = True |
| 422 | elif ngctx.ContextType == 0x0008: |
| 423 | # SMB2_SIGNING_CAPABILITIES |
| 424 | self.session.SigningAlgorithmId = ( |
| 425 | SMB2_SIGNING_ALGORITHMS[ngctx.SigningAlgorithms[0]] |
| 426 | ) |
| 427 | if self.REQUIRE_ENCRYPTION and not self.session.SupportsEncryption: |
nothing calls this directly
no test coverage detected