def generateResponse(self): response = MSRPCBindAck() request = self.requestData bind = MSRPCBind(request['pduData']) response['ver_major'] = request['ver_major'] response['ver_minor'] = request['ver_minor'] response['type'] = self.packetType['bindAck'] response['flags'] = self.packetFlags['firstFrag'] | self.packetFlags[ 'lastFrag'] | self.packetFlags['multiplex'] response['representation'] = request['representation'] response['frag_len'] = 36 + bind['ctx_num'] * 24 response['auth_len'] = request['auth_len'] response['call_id'] = request['call_id'] response['max_tfrag'] = bind['max_tfrag'] response['max_rfrag'] = bind['max_rfrag'] response['assoc_group'] = 0x1063bf3f port = str(self.config['port']) response['SecondaryAddrLen'] = len(port) + 1 response['SecondaryAddr'] = port pad = (4 - ((response["SecondaryAddrLen"] + MSRPCBindAck._SIZE) % 4)) % 4 response['Pad'] = '\0' * pad response['ctx_num'] = bind['ctx_num'] preparedResponses = {} preparedResponses[uuidNDR32] = CtxItemResult(0, 0, uuidNDR32, 2) preparedResponses[uuidNDR64] = CtxItemResult(2, 2, uuidEmpty, 0) preparedResponses[uuidTime] = CtxItemResult(3, 3, uuidEmpty, 0) response['ctx_items'] = '' for i in range(0, bind['ctx_num']): ts_uuid = bind['ctx_items'][i].ts() resp = preparedResponses[ts_uuid] response['ctx_items'] += str(resp) shell_message(nshell=4) response = byterize(response) logging.debug("RPC Bind Response: \n%s\n" % justify(response.dump(print_to_stdout=False))) logging.debug("RPC Bind Response Bytes: \n%s\n" % justify( binascii.b2a_hex( str(response).encode('latin-1')).decode('utf-8'))) #*2to3* return response
def generateResponse(self): response = MSRPCBindAck() request = self.requestData bind = MSRPCBind(request['pduData']) response['ver_major'] = request['ver_major'] response['ver_minor'] = request['ver_minor'] response['type'] = self.packetType['bindAck'] response['flags'] = self.packetFlags['firstFrag'] | self.packetFlags[ 'lastFrag'] | self.packetFlags['multiplex'] response['representation'] = request['representation'] response['frag_len'] = 36 + bind['ctx_num'] * 24 response['auth_len'] = request['auth_len'] response['call_id'] = request['call_id'] response['max_tfrag'] = bind['max_tfrag'] response['max_rfrag'] = bind['max_rfrag'] response['assoc_group'] = 0x1063bf3f port = str(self.config['port']) response['SecondaryAddrLen'] = len(port) + 1 response['SecondaryAddr'] = port pad = (4 - ((response["SecondaryAddrLen"] + MSRPCBindAck._SIZE) % 4)) % 4 response['Pad'] = '\0' * pad response['ctx_num'] = bind['ctx_num'] preparedResponses = {} preparedResponses[uuidNDR32] = CtxItemResult(0, 0, uuidNDR32, 2) preparedResponses[uuidNDR64] = CtxItemResult(2, 2, uuidEmpty, 0) preparedResponses[uuidTime] = CtxItemResult(3, 3, uuidEmpty, 0) response['ctx_items'] = '' for i in range(0, bind['ctx_num']): ts_uuid = bind['ctx_items'][i].ts() resp = preparedResponses[ts_uuid] response['ctx_items'] += str(resp) if self.config['debug']: print "RPC Bind Response:", response.dump() print "RPC Bind Response Bytes:", binascii.b2a_hex(str(response)) return response
def generateResponse(self): response = MSRPCBindAck() request = self.requestData bind = MSRPCBind(request['pduData']) response['ver_major'] = request['ver_major'] response['ver_minor'] = request['ver_minor'] response['type'] = self.packetType['bindAck'] response['flags'] = self.packetFlags['firstFrag'] | self.packetFlags['lastFrag'] | self.packetFlags['multiplex'] response['representation'] = request['representation'] response['frag_len'] = 36 + bind['ctx_num'] * 24 response['auth_len'] = request['auth_len'] response['call_id'] = request['call_id'] response['max_tfrag'] = bind['max_tfrag'] response['max_rfrag'] = bind['max_rfrag'] response['assoc_group'] = 0x1063bf3f port = str(self.config['port']) response['SecondaryAddrLen'] = len(port) + 1 response['SecondaryAddr'] = port pad = (4 - ((response["SecondaryAddrLen"] + MSRPCBindAck._SIZE) % 4)) % 4 response['Pad'] = '\0' * pad response['ctx_num'] = bind['ctx_num'] preparedResponses = {} preparedResponses[uuidNDR32] = CtxItemResult(0, 0, uuidNDR32, 2) preparedResponses[uuidNDR64] = CtxItemResult(2, 2, uuidEmpty, 0) preparedResponses[uuidTime] = CtxItemResult(3, 3, uuidEmpty, 0) response['ctx_items'] = '' for i in range (0, bind['ctx_num']): ts_uuid = bind['ctx_items'][i].ts() resp = preparedResponses[ts_uuid] response['ctx_items'] += str(resp) shell_message(nshell = 4) response = byterize(response) logging.debug("RPC Bind Response: \n%s\n" % justify(response.dump(print_to_stdout = False))) logging.debug("RPC Bind Response Bytes: \n%s\n" % justify(binascii.b2a_hex(str(response).encode('latin-1')).decode('utf-8'))) #*2to3* return response
def generateResponse(self, request): response = MSRPCBindAck() bind = MSRPCBind(request['pduData']) response['ver_major'] = request['ver_major'] response['ver_minor'] = request['ver_minor'] response['type'] = self.packetType['bindAck'] response['flags'] = self.packetFlags['firstFrag'] | self.packetFlags[ 'lastFrag'] response['flags'] |= request['flags'] & self.packetFlags['multiplex'] response['representation'] = request['representation'] response['frag_len'] = 36 + bind['ctx_num'] * 24 response['auth_len'] = request['auth_len'] response['call_id'] = request['call_id'] response['max_tfrag'] = bind['max_tfrag'] response['max_rfrag'] = bind['max_rfrag'] response['assoc_group'] = 0x1063bf3f port = str(self.config['port']).encode() response['SecondaryAddrLen'] = len(port) + 1 response['SecondaryAddr'] = port response['ctx_num'] = bind['ctx_num'] preparedResponses = {} preparedResponses[uuidNDR32] = CtxItemResult(0, 0, uuidNDR32, 2) preparedResponses[uuidNDR64] = CtxItemResult(0, 0, uuidNDR64, 1) preparedResponses[uuidTime] = CtxItemResult(3, 3, uuidEmpty, 0) response['ctx_items'] = b'' for i in range(0, bind['ctx_num']): ts_uuid = bind['ctx_items'][i].ts() resp = preparedResponses[ts_uuid] response['ctx_items'] += resp.__bytes__() if self.config['debug']: print("RPC Bind Response:", response.dump()) print("RPC Bind Response Bytes:", binascii.b2a_hex(response.__bytes__())) return response
def generateResponse(self): response = MSRPCBindAck() request = self.requestData bind = MSRPCBind(request['pduData']) response['ver_major'] = request['ver_major'] response['ver_minor'] = request['ver_minor'] response['type'] = self.packetType['bindAck'] response['flags'] = self.packetFlags['firstFrag'] | self.packetFlags['lastFrag'] | self.packetFlags['multiplex'] response['representation'] = request['representation'] response['frag_len'] = 36 + bind['ctx_num'] * 24 response['auth_len'] = request['auth_len'] response['call_id'] = request['call_id'] response['max_tfrag'] = bind['max_tfrag'] response['max_rfrag'] = bind['max_rfrag'] response['assoc_group'] = 0x1063bf3f port = str(self.config['port']) response['SecondaryAddrLen'] = len(port) + 1 response['SecondaryAddr'] = port pad = (4-((response["SecondaryAddrLen"]+MSRPCBindAck._SIZE) % 4))%4 response['Pad'] = '\0' * pad response['ctx_num'] = bind['ctx_num'] preparedResponses = {} preparedResponses[uuidNDR32] = CtxItemResult(0, 0, uuidNDR32, 2) preparedResponses[uuidNDR64] = CtxItemResult(2, 2, uuidEmpty, 0) preparedResponses[uuidTime] = CtxItemResult(3, 3, uuidEmpty, 0) response['ctx_items'] = '' for i in range (0, bind['ctx_num']): ts_uuid = bind['ctx_items'][i].ts() resp = preparedResponses[ts_uuid] response['ctx_items'] += str(resp) if self.config['debug']: print "RPC Bind Response:", response.dump() print "RPC Bind Response Bytes:", binascii.b2a_hex(str(response)) return response
def generateResponse(self, request): response = MSRPCBindAck() bind = MSRPCBind(request['pduData']) response['ver_major'] = request['ver_major'] response['ver_minor'] = request['ver_minor'] response['flags'] = self.packetFlags['firstFrag'] | self.packetFlags[ 'lastFrag'] if request['type'] == MSRPC_BIND: response['type'] = MSRPC_BINDACK response[ 'flags'] |= request['flags'] & self.packetFlags['multiplex'] elif request['type'] == MSRPC_ALTERCTX: response['type'] = MSRPC_ALTERCTX_R else: raise TypeError( 'Unknown RPC request type for bind like handler: %s' % response['type']) response['representation'] = request['representation'] response['auth_len'] = request['auth_len'] response['call_id'] = request['call_id'] response['max_tfrag'] = bind['max_tfrag'] response['max_rfrag'] = bind['max_rfrag'] response['assoc_group'] = 0x1063bf3f port = str(self.config['port']).encode() if request['type'] == MSRPC_BIND: response['SecondaryAddrLen'] = len(port) + 1 response['SecondaryAddr'] = port response['frag_len'] = 36 + bind['ctx_num'] * 24 elif request['type'] == MSRPC_ALTERCTX: response['SecondaryAddrLen'] = 0 response['frag_len'] = 32 + bind['ctx_num'] * 24 else: raise TypeError( 'Unknown RPC request type for bind like handler: %s' % response['type']) response['ctx_num'] = bind['ctx_num'] preparedResponses = {} if request['type'] == MSRPC_BIND: if uuidNDR64 in [ bind['ctx_items'][i].ts() for i in range(bind['ctx_num']) ]: preparedResponses[uuidNDR32] = CtxItemResult( 2, 2, uuidEmpty, 0) preparedResponses[uuidNDR64] = CtxItemResult( 0, 0, uuidNDR64, 1) preparedResponses[uuidTime] = CtxItemResult(3, 3, uuidEmpty, 0) else: preparedResponses[uuidNDR32] = CtxItemResult( 0, 0, uuidNDR32, 2) preparedResponses[uuidNDR64] = CtxItemResult( 2, 2, uuidEmpty, 0) preparedResponses[uuidTime] = CtxItemResult(3, 3, uuidEmpty, 0) elif request['type'] == MSRPC_ALTERCTX: preparedResponses[uuidNDR32] = CtxItemResult(0, 0, uuidNDR32, 2) else: raise TypeError( 'Unknown RPC request type for bind like handler: %s' % response['type']) response['ctx_items'] = b'' for i in range(0, bind['ctx_num']): ts_uuid = bind['ctx_items'][i].ts() resp = preparedResponses[ts_uuid] response['ctx_items'] += resp.__bytes__() if self.config['debug']: print("RPC Bind Response:", response.dump()) print("RPC Bind Response Bytes:", binascii.b2a_hex(response.__bytes__())) return response