# SECUREAUTH LABS. Copyright 2018 SecureAuth Corporation. All rights reserved. # # This software is provided under under a slightly modified version # of the Apache Software License. See the accompanying LICENSE file # for more information. # # Author: Alberto Solino (@agsolino) # Itamar Mizrahi (@MrAnde7son) # # Description: # [MS-EVEN] Interface implementation # # Best way to learn how to use these calls is to grab the protocol standard # so you understand what the call does, and then read the test case located # at https://github.com/SecureAuthCorp/impacket/tree/master/tests/SMB_RPC # # Some calls have helper functions, which makes it even easier to use. # They are located at the end of this file. # Helper functions start with "h". # There are test cases for them too. # from __future__ import division from __future__ import print_function from impacket.dcerpc.v5.ndr import NDRCALL, NDRSTRUCT, NDR, NDRPOINTERNULL, NDRUniConformantArray from impacket.dcerpc.v5.dtypes import ULONG, LPWSTR, RPC_UNICODE_STRING, LPSTR, NTSTATUS, NULL, PRPC_UNICODE_STRING, PULONG, USHORT, PRPC_SID, LPBYTE from impacket.dcerpc.v5.lsad import PRPC_UNICODE_STRING_ARRAY from impacket.structure import Structure from impacket import nt_errors from impacket.uuid import uuidtup_to_bin from impacket.dcerpc.v5.rpcrt import DCERPCException MSRPC_UUID_EVEN = uuidtup_to_bin(('82273FDC-E32A-18C3-3F78-827929DC23EA','0.0')) class DCERPCSessionError(DCERPCException): def __init__(self, error_string=None, error_code=None, packet=None): DCERPCException.__init__(self, error_string, error_code, packet) def __str__( self ): key = self.error_code if key in nt_errors.ERROR_MESSAGES: error_msg_short = nt_errors.ERROR_MESSAGES[key][0] error_msg_verbose = nt_errors.ERROR_MESSAGES[key][1] return 'EVEN SessionError: code: 0x%x - %s - %s' % (self.error_code, error_msg_short, error_msg_verbose) else: return 'EVEN SessionError: unknown error code: 0x%x' % self.error_code ################################################################################ # CONSTANTS ################################################################################ # 2.2.2 EventType EVENTLOG_SUCCESS = 0x0000 EVENTLOG_ERROR_TYPE = 0x0001 EVENTLOG_WARNING_TYPE = 0x0002 EVENTLOG_INFORMATION_TYPE = 0x0004 EVENTLOG_AUDIT_SUCCESS = 0x0008 EVENTLOG_AUDIT_FAILURE = 0x0010 # 2.2.7 EVENTLOG_HANDLE_A and EVENTLOG_HANDLE_W #EVENTLOG_HANDLE_A EVENTLOG_HANDLE_W = LPWSTR # 2.2.9 Constants Used in Method Definitions MAX_STRINGS = 0x00000100 MAX_SINGLE_EVENT = 0x0003FFFF MAX_BATCH_BUFF = 0x0007FFFF # 3.1.4.7 ElfrReadELW (Opnum 10) EVENTLOG_SEQUENTIAL_READ = 0x00000001 EVENTLOG_SEEK_READ = 0x00000002 EVENTLOG_FORWARDS_READ = 0x00000004 EVENTLOG_BACKWARDS_READ = 0x00000008 ################################################################################ # STRUCTURES ################################################################################ class IELF_HANDLE(NDRSTRUCT): structure = ( ('Data','20s=""'), ) def getAlignment(self): return 1 # 2.2.3 EVENTLOGRECORD class EVENTLOGRECORD(Structure): structure = ( ('Length','