| 1405 | return self.send(DCERPC_RawCall(function, body, uuid)) |
| 1406 | |
| 1407 | def request(self, request, uuid=None, checkError=True): |
| 1408 | if self.transfer_syntax == self.NDR64Syntax: |
| 1409 | request.changeTransferSyntax(self.NDR64Syntax) |
| 1410 | isNDR64 = True |
| 1411 | else: |
| 1412 | isNDR64 = False |
| 1413 | |
| 1414 | self.call(request.opnum, request, uuid) |
| 1415 | answer = self.recv() |
| 1416 | |
| 1417 | __import__(request.__module__) |
| 1418 | module = sys.modules[request.__module__] |
| 1419 | respClass = getattr(module, request.__class__.__name__ + 'Response') |
| 1420 | |
| 1421 | if answer[-4:] != b'\x00\x00\x00\x00' and checkError is True: |
| 1422 | error_code = unpack('<L', answer[-4:])[0] |
| 1423 | if error_code in rpc_status_codes: |
| 1424 | # This is an error we can handle |
| 1425 | exception = DCERPCException(error_code = error_code) |
| 1426 | else: |
| 1427 | sessionErrorClass = getattr(module, 'DCERPCSessionError') |
| 1428 | try: |
| 1429 | # Try to unpack the answer, even if it is an error, it works most of the times |
| 1430 | response = respClass(answer, isNDR64 = isNDR64) |
| 1431 | except: |
| 1432 | # No luck :( |
| 1433 | exception = sessionErrorClass(error_code = error_code) |
| 1434 | else: |
| 1435 | exception = sessionErrorClass(packet = response, error_code = error_code) |
| 1436 | raise exception |
| 1437 | else: |
| 1438 | response = respClass(answer, isNDR64 = isNDR64) |
| 1439 | return response |
| 1440 | |
| 1441 | class DCERPC_v4(DCERPC): |
| 1442 | pass |