MCPcopy
hub / github.com/fortra/impacket / processRequest

Method processRequest

impacket/smbserver.py:4664–4905  ·  view source on GitHub ↗
(self, connId, data)

Source from the content-addressed store, hash-verified

4662 # print "%s" % packet['Signature'].encode('hex')
4663
4664 def processRequest(self, connId, data):
4665
4666 # TODO: Process batched commands.
4667 isSMB2 = False
4668 SMBCommand = None
4669 try:
4670 packet = smb.NewSMBPacket(data=data)
4671 SMBCommand = smb.SMBCommand(packet['Data'][0])
4672 except:
4673 # Maybe a SMB2 packet?
4674 packet = smb2.SMB2Packet(data=data)
4675 connData = self.getConnectionData(connId, False)
4676 self.signSMBv2(packet, connData['SigningSessionKey'])
4677 isSMB2 = True
4678
4679 connData = self.getConnectionData(connId, False)
4680
4681 # We might have compound requests
4682 compoundedPacketsResponse = []
4683 compoundedPackets = []
4684 try:
4685 # Search out list of implemented commands
4686 # We provide them with:
4687 # connId : representing the data for this specific connection
4688 # self : the SMBSERVER if they want to ask data to it
4689 # SMBCommand : the SMBCommand they are expecting to process
4690 # packet : the received packet itself, in case they need more data than the actual command
4691 # Only for Transactions
4692 # transCommand: a list of transaction subcommands
4693 # We expect to get:
4694 # respCommands: a list of answers for the commands processed
4695 # respPacket : if the commands chose to directly craft packet/s, we use this and not the previous
4696 # this MUST be a list
4697 # errorCode : self explanatory
4698 if isSMB2 is False:
4699 # Is the client authenticated already?
4700 if connData['Authenticated'] is False and packet['Command'] not in (
4701 smb.SMB.SMB_COM_NEGOTIATE, smb.SMB.SMB_COM_SESSION_SETUP_ANDX):
4702 # Nope.. in that case he should only ask for a few commands, if not throw him out.
4703 errorCode = STATUS_ACCESS_DENIED
4704 respPackets = None
4705 respCommands = [smb.SMBCommand(packet['Command'])]
4706 else:
4707 if packet['Command'] == smb.SMB.SMB_COM_TRANSACTION2:
4708 respCommands, respPackets, errorCode = self.__smbCommands[packet['Command']](
4709 connId,
4710 self,
4711 SMBCommand,
4712 packet,
4713 self.__smbTrans2Commands)
4714 elif packet['Command'] == smb.SMB.SMB_COM_NT_TRANSACT:
4715 respCommands, respPackets, errorCode = self.__smbCommands[packet['Command']](
4716 connId,
4717 self,
4718 SMBCommand,
4719 packet,
4720 self.__smbNTTransCommands)
4721 elif packet['Command'] == smb.SMB.SMB_COM_TRANSACTION:

Callers 1

handleMethod · 0.45

Calls 8

getConnectionDataMethod · 0.95
signSMBv2Method · 0.95
logMethod · 0.95
setConnectionDataMethod · 0.95
signSMBv1Method · 0.95
appendMethod · 0.80
addCommandMethod · 0.45
getDataMethod · 0.45

Tested by

no test coverage detected