<s> from impacket . dcerpc . v5 . ndr import NDRSTRUCT , NDRUniConformantVaryingArray , NDRENUM <EOL> from impacket . dcerpc . v5 . dcomrt import DCOMCALL , DCOMANSWER , IRemUnknown2 , PMInterfacePointer , INTERFACE <EOL> from impacket . dcerpc . v5 . dtypes import LPWSTR , ULONG , DWORD , SHORT , GUID <EOL> from impacket . dcerpc . v5 . rpcrt import DCERPCException <EOL> from impacket . dcerpc . v5 . enum import Enum <EOL> from impacket import hresult_errors <EOL> from impacket . uuid import string_to_bin <EOL> class DCERPCSessionError ( DCERPCException ) : <EOL> def __init__ ( self , error_string = None , error_code = None , packet = None ) : <EOL> DCERPCException . __init__ ( self , error_string , error_code , packet ) <EOL> def __str__ ( self ) : <EOL> if hresult_errors . ERROR_MESSAGES . has_key ( self . error_code ) : <EOL> error_msg_short = hresult_errors . ERROR_MESSAGES [ self . error_code ] [ <NUM_LIT:0> ] <EOL> error_msg_verbose = hresult_errors . ERROR_MESSAGES [ self . error_code ] [ <NUM_LIT:1> ] <EOL> return '<STR_LIT>' % ( self . error_code , error_msg_short , error_msg_verbose ) <EOL> else : <EOL> return '<STR_LIT>' % ( self . error_code ) <EOL> CLSID_VirtualDiskService = string_to_bin ( '<STR_LIT>' ) <EOL> IID_IEnumVdsObject = string_to_bin ( '<STR_LIT>' ) <EOL> IID_IVdsAdviseSink = string_to_bin ( '<STR_LIT>' ) <EOL> IID_IVdsAsync = string_to_bin ( '<STR_LIT>' ) <EOL> IID_IVdsServiceInitialization = string_to_bin ( '<STR_LIT>' ) <EOL> IID_IVdsService = string_to_bin ( '<STR_LIT>' ) <EOL> IID_IVdsSwProvider = string_to_bin ( '<STR_LIT>' ) <EOL> IID_IVdsProvider = string_to_bin ( '<STR_LIT>' ) <EOL> error_status_t = ULONG <EOL> VDS_OBJECT_ID = GUID <EOL> class VDS_SERVICE_PROP ( NDRSTRUCT ) : <EOL> structure = ( <EOL> ( '<STR_LIT>' , LPWSTR ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ) <EOL> class OBJECT_ARRAY ( NDRUniConformantVaryingArray ) : <EOL> item = PMInterfacePointer <EOL> class VDS_PROVIDER_TYPE ( NDRENUM ) : <EOL> class enumItems ( Enum ) : <EOL> VDS_PT_UNKNOWN = <NUM_LIT:0> <EOL> VDS_PT_SOFTWARE = <NUM_LIT:1> <EOL> VDS_PT_HARDWARE = <NUM_LIT:2> <EOL> VDS_PT_VIRTUALDISK = <NUM_LIT:3> <EOL> VDS_PT_MAX = <NUM_LIT:4> <EOL> class VDS_PROVIDER_PROP ( NDRSTRUCT ) : <EOL> structure = ( <EOL> ( '<STR_LIT:id>' , VDS_OBJECT_ID ) , <EOL> ( '<STR_LIT>' , LPWSTR ) , <EOL> ( '<STR_LIT>' , GUID ) , <EOL> ( '<STR_LIT>' , LPWSTR ) , <EOL> ( '<STR_LIT:type>' , VDS_PROVIDER_TYPE ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , SHORT ) , <EOL> ) <EOL> class IVdsServiceInitialization_Initialize ( DCOMCALL ) : <EOL> opnum = <NUM_LIT:3> <EOL> structure = ( <EOL> ( '<STR_LIT>' , LPWSTR ) , <EOL> ) <EOL> class IVdsServiceInitialization_InitializeResponse ( DCOMANSWER ) : <EOL> structure = ( <EOL> ( '<STR_LIT>' , error_status_t ) , <EOL> ) <EOL> class IVdsService_IsServiceReady ( DCOMCALL ) : <EOL> opnum = <NUM_LIT:3> <EOL> structure = ( <EOL> ) <EOL> class IVdsService_IsServiceReadyResponse ( DCOMANSWER ) : <EOL> structure = ( <EOL> ( '<STR_LIT>' , error_status_t ) , <EOL> ) <EOL> class IVdsService_WaitForServiceReady ( DCOMCALL ) : <EOL> opnum = <NUM_LIT:4> <EOL> structure = ( <EOL> ) <EOL> class IVdsService_WaitForServiceReadyResponse ( DCOMANSWER ) : <EOL> structure = ( <EOL> ( '<STR_LIT>' , error_status_t ) , <EOL> ) <EOL> class IVdsService_GetProperties ( DCOMCALL ) : <EOL> opnum = <NUM_LIT:5> <EOL> structure = ( <EOL> ) <EOL> class IVdsService_GetPropertiesResponse ( DCOMANSWER ) : <EOL> structure = ( <EOL> ( '<STR_LIT>' , VDS_SERVICE_PROP ) , <EOL> ( '<STR_LIT>' , error_status_t ) , <EOL> ) <EOL> class IVdsService_QueryProviders ( DCOMCALL ) : <EOL> opnum = <NUM_LIT:6> <EOL> structure = ( <EOL> ( '<STR_LIT>' , DWORD ) , <EOL> ) <EOL> class IVdsService_QueryProvidersResponse ( DCOMANSWER ) : <EOL> structure = ( <EOL> ( '<STR_LIT>' , PMInterfacePointer ) , <EOL> ( '<STR_LIT>' , error_status_t ) , <EOL> ) <EOL> class IEnumVdsObject_Next ( DCOMCALL ) : <EOL> opnum = <NUM_LIT:3> <EOL> structure = ( <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ) <EOL> class IEnumVdsObject_NextResponse ( DCOMANSWER ) : <EOL> structure = ( <EOL> ( '<STR_LIT>' , OBJECT_ARRAY ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , error_status_t ) , <EOL> ) <EOL> class IVdsProvider_GetProperties ( DCOMCALL ) : <EOL> opnum = <NUM_LIT:3> <EOL> structure = ( <EOL> ) <EOL> class IVdsProvider_GetPropertiesResponse ( DCOMANSWER ) : <EOL> structure = ( <EOL> ( '<STR_LIT>' , VDS_PROVIDER_PROP ) , <EOL> ( '<STR_LIT>' , error_status_t ) , <EOL> ) <EOL> OPNUMS = { <EOL> } <EOL> class IEnumVdsObject ( IRemUnknown2 ) : <EOL> def Next ( self , celt = <NUM_LIT> ) : <EOL> request = IEnumVdsObject_Next ( ) <EOL> request [ '<STR_LIT>' ] = self . get_cinstance ( ) . get_ORPCthis ( ) <EOL> request [ '<STR_LIT>' ] [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> request [ '<STR_LIT>' ] = celt <EOL> try : <EOL> resp = self . request ( request , uuid = self . get_iPid ( ) ) <EOL> except Exception , e : <EOL> resp = e . get_packet ( ) <EOL> if resp [ '<STR_LIT>' ] != <NUM_LIT:1> : <EOL> raise <EOL> interfaces = list ( ) <EOL> for interface in resp [ '<STR_LIT>' ] : <EOL> interfaces . append ( IRemUnknown2 ( INTERFACE ( self . get_cinstance ( ) , '<STR_LIT>' . join ( interface [ '<STR_LIT>' ] ) , self . get_ipidRemUnknown ( ) , target = self . get_target ( ) ) ) ) <EOL> return interfaces <EOL> class IVdsProvider ( IRemUnknown2 ) : <EOL> def GetProperties ( self ) : <EOL> request = IVdsProvider_GetProperties ( ) <EOL> request [ '<STR_LIT>' ] = self . get_cinstance ( ) . get_ORPCthis ( ) <EOL> request [ '<STR_LIT>' ] [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> resp = self . request ( request , uuid = self . get_iPid ( ) ) <EOL> return resp <EOL> class IVdsServiceInitialization ( IRemUnknown2 ) : <EOL> def __init__ ( self , interface ) : <EOL> IRemUnknown2 . __init__ ( self , interface ) <EOL> def Initialize ( self ) : <EOL> request = IVdsServiceInitialization_Initialize ( ) <EOL> request [ '<STR_LIT>' ] = self . get_cinstance ( ) . get_ORPCthis ( ) <EOL> request [ '<STR_LIT>' ] [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> request [ '<STR_LIT>' ] = '<STR_LIT:\x00>' <EOL> resp = self . request ( request , uuid = self . get_iPid ( ) ) <EOL> return resp <EOL> class IVdsService ( IRemUnknown2 ) : <EOL> def __init__ ( self , interface ) : <EOL> IRemUnknown2 . __init__ ( self , interface ) <EOL> def IsServiceReady ( self ) : <EOL> request = IVdsService_IsServiceReady ( ) <EOL> request [ '<STR_LIT>' ] = self . get_cinstance ( ) . get_ORPCthis ( ) <EOL> request [ '<STR_LIT>' ] [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> try : <EOL> resp = self . request ( request , uuid = self . get_iPid ( ) ) <EOL> except Exception , e : <EOL> resp = e . get_packet ( ) <EOL> return resp <EOL> def WaitForServiceReady ( self ) : <EOL> request = IVdsService_WaitForServiceReady ( ) <EOL> request [ '<STR_LIT>' ] = self . get_cinstance ( ) . get_ORPCthis ( ) <EOL> request [ '<STR_LIT>' ] [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> resp = self . request ( request , uuid = self . get_iPid ( ) ) <EOL> return resp <EOL> def GetProperties ( self ) : <EOL> request = IVdsService_GetProperties ( ) <EOL> request [ '<STR_LIT>' ] = self . get_cinstance ( ) . get_ORPCthis ( ) <EOL> request [ '<STR_LIT>' ] [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> resp = self . request ( request , uuid = self . get_iPid ( ) ) <EOL> return resp <EOL> def QueryProviders ( self , masks ) : <EOL> request = IVdsService_QueryProviders ( ) <EOL> request [ '<STR_LIT>' ] = self . get_cinstance ( ) . get_ORPCthis ( ) <EOL> request [ '<STR_LIT>' ] [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> request [ '<STR_LIT>' ] = masks <EOL> resp = self . request ( request , uuid = self . get_iPid ( ) ) <EOL> return IEnumVdsObject ( INTERFACE ( self . get_cinstance ( ) , '<STR_LIT>' . join ( resp [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) , self . get_ipidRemUnknown ( ) , target = self . get_target ( ) ) ) </s>
