def changeServiceAndQuery(self, dce, cbBufSize, hService, dwServiceType, dwStartType, dwErrorControl, lpBinaryPathName, lpLoadOrderGroup, lpdwTagId, lpDependencies, dwDependSize, lpServiceStartName, lpPassword, dwPwSize, lpDisplayName): try: resp = scmr.hRChangeServiceConfigW( dce, hService, dwServiceType, dwStartType, dwErrorControl, lpBinaryPathName, lpLoadOrderGroup, lpdwTagId, lpDependencies, dwDependSize, lpServiceStartName, lpPassword, dwPwSize, lpDisplayName) resp = scmr.hRQueryServiceConfigW(dce, hService) resp.dump() # Now let's compare all the results if dwServiceType != scmr.SERVICE_NO_CHANGE: self.assertTrue( resp['lpServiceConfig']['dwServiceType'] == dwServiceType ) if dwStartType != scmr.SERVICE_NO_CHANGE: self.assertTrue( resp['lpServiceConfig']['dwStartType'] == dwStartType ) if dwErrorControl != scmr.SERVICE_NO_CHANGE: self.assertTrue( resp['lpServiceConfig']['dwErrorControl'] == dwErrorControl ) if lpBinaryPathName != NULL: self.assertTrue( resp['lpServiceConfig']['lpBinaryPathName'] == lpBinaryPathName ) if lpBinaryPathName != NULL: self.assertTrue( resp['lpServiceConfig']['lpBinaryPathName'] == lpBinaryPathName ) if lpLoadOrderGroup != NULL: self.assertTrue( resp['lpServiceConfig']['lpLoadOrderGroup'] == lpLoadOrderGroup ) #if lpDependencies != '': # self.assertTrue( resp['lpServiceConfig']['lpDependencies'] == lpDependencies[:-4]+'/\x00\x00\x00') if lpServiceStartName != NULL: self.assertTrue( resp['lpServiceConfig']['lpServiceStartName'] == lpServiceStartName ) if lpDisplayName != NULL: self.assertTrue( resp['lpServiceConfig']['lpDisplayName'] == lpDisplayName ) #if lpdwTagId != scmr.SERVICE_NO_CHANGE: # if resp['lpServiceConfig']['dwTagId']['Data'] != lpdwTagId: # print "ERROR %s" % 'lpdwTagId' except: resp = scmr.hRDeleteService(dce, hService) raise
def test_create_change_delete(self): dce, rpctransport, scHandle = self.connect() ##################### # Create / Change / Query / Delete a service lpServiceName = 'TESTSVC\x00' lpDisplayName = 'DisplayName\x00' dwDesiredAccess = scmr.SERVICE_ALL_ACCESS dwServiceType = scmr.SERVICE_WIN32_OWN_PROCESS dwStartType = scmr.SERVICE_DEMAND_START dwErrorControl = scmr.SERVICE_ERROR_NORMAL lpBinaryPathName = 'binaryPath\x00' lpLoadOrderGroup = NULL lpdwTagId = NULL lpDependencies = NULL dwDependSize = 0 lpServiceStartName = NULL lpPassword = NULL dwPwSize = 0 resp = scmr.hRCreateServiceW(dce, scHandle, lpServiceName, lpDisplayName, dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl, lpBinaryPathName, lpLoadOrderGroup, lpdwTagId, lpDependencies, dwDependSize, lpServiceStartName, lpPassword, dwPwSize) resp.dump() newHandle = resp['lpServiceHandle'] # Aca hay que chequear cada uno de los items cbBufSize = 0 try: resp = scmr.hRQueryServiceConfigW(dce, newHandle) except Exception, e: if str(e).find('ERROR_INSUFFICIENT_BUFFER') <= 0: raise else: resp = e.get_packet()
def changeServiceAndQuery(self, dce, cbBufSize, hService, dwServiceType, dwStartType, dwErrorControl, lpBinaryPathName, lpLoadOrderGroup, lpdwTagId, lpDependencies, dwDependSize, lpServiceStartName, lpPassword, dwPwSize, lpDisplayName): try: resp = scmr.hRChangeServiceConfigW( dce, hService, dwServiceType, dwStartType, dwErrorControl, lpBinaryPathName, lpLoadOrderGroup, lpdwTagId, lpDependencies, dwDependSize, lpServiceStartName, lpPassword, dwPwSize, lpDisplayName) resp = scmr.hRQueryServiceConfigW(dce, hService) resp.dump() # Now let's compare all the results if dwServiceType != scmr.SERVICE_NO_CHANGE: self.assertTrue( resp['lpServiceConfig']['dwServiceType'] == dwServiceType) if dwStartType != scmr.SERVICE_NO_CHANGE: self.assertTrue( resp['lpServiceConfig']['dwStartType'] == dwStartType) if dwErrorControl != scmr.SERVICE_NO_CHANGE: self.assertTrue(resp['lpServiceConfig']['dwErrorControl'] == dwErrorControl) if lpBinaryPathName != NULL: self.assertTrue(resp['lpServiceConfig']['lpBinaryPathName'] == lpBinaryPathName) if lpBinaryPathName != NULL: self.assertTrue(resp['lpServiceConfig']['lpBinaryPathName'] == lpBinaryPathName) if lpLoadOrderGroup != NULL: self.assertTrue(resp['lpServiceConfig']['lpLoadOrderGroup'] == lpLoadOrderGroup) #if lpDependencies != '': # self.assertTrue( resp['lpServiceConfig']['lpDependencies'] == lpDependencies[:-4]+'/\x00\x00\x00') if lpServiceStartName != NULL: self.assertTrue(resp['lpServiceConfig']['lpServiceStartName'] == lpServiceStartName) if lpDisplayName != NULL: self.assertTrue( resp['lpServiceConfig']['lpDisplayName'] == lpDisplayName) #if lpdwTagId != scmr.SERVICE_NO_CHANGE: # if resp['lpServiceConfig']['dwTagId']['Data'] != lpdwTagId: # print "ERROR %s" % 'lpdwTagId' except: resp = scmr.hRDeleteService(dce, hService) raise
def test_create_change_delete(self): dce, rpctransport, scHandle = self.connect() ##################### # Create / Change / Query / Delete a service lpServiceName = 'TESTSVC\x00' lpDisplayName = 'DisplayName\x00' dwDesiredAccess = scmr.SERVICE_ALL_ACCESS dwServiceType = scmr.SERVICE_WIN32_OWN_PROCESS dwStartType = scmr.SERVICE_DEMAND_START dwErrorControl = scmr.SERVICE_ERROR_NORMAL lpBinaryPathName = 'binaryPath\x00' lpLoadOrderGroup = NULL lpdwTagId = NULL lpDependencies = NULL dwDependSize = 0 lpServiceStartName = NULL lpPassword = NULL dwPwSize = 0 resp = scmr.hRCreateServiceW( dce, scHandle, lpServiceName, lpDisplayName, dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl, lpBinaryPathName, lpLoadOrderGroup, lpdwTagId, lpDependencies, dwDependSize, lpServiceStartName, lpPassword, dwPwSize) resp.dump() newHandle = resp['lpServiceHandle'] # Aca hay que chequear cada uno de los items cbBufSize = 0 try: resp = scmr.hRQueryServiceConfigW(dce, newHandle) except Exception, e: if str(e).find('ERROR_INSUFFICIENT_BUFFER') <= 0: raise else: resp = e.get_packet()