Python impacket.dcerpc.v5.scmr.SERVICE_WIN32_OWN_PROCESS Examples
The following are 16
code examples of impacket.dcerpc.v5.scmr.SERVICE_WIN32_OWN_PROCESS().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
impacket.dcerpc.v5.scmr
, or try the search function
.
Example #1
Source File: test_scmr.py From CVE-2017-7494 with GNU General Public License v3.0 | 6 votes |
def test_REnumServicesStatusExW(self): dce, rpctransport, scHandle = self.connect() request = scmr.REnumServicesStatusExW() request['hSCManager'] = scHandle request['InfoLevel'] = scmr.SC_STATUS_PROCESS_INFO request['dwServiceType'] = scmr.SERVICE_WIN32_OWN_PROCESS request['dwServiceState'] = scmr.SERVICE_STATE_ALL request['lpResumeIndex'] = NULL request['pszGroupName'] = NULL request['cbBufSize'] = 0 #request.dump() #print "\n" # Request again with the right bufSize try: resp = dce.request(request) except Exception, e: if str(e).find('ERROR_MORE_DATA') <= 0: raise else: resp = e.get_packet()
Example #2
Source File: test_scmr.py From CVE-2017-7494 with GNU General Public License v3.0 | 6 votes |
def te_REnumServiceGroupW(self): dce, rpctransport, scHandle = self.connect() dwServiceType = scmr.SERVICE_WIN32_OWN_PROCESS dwServiceState = scmr.SERVICE_STATE_ALL cbBufSize = 10 lpResumeIndex = 0 pszGroupName = 'RemoteRegistry\x00' try: resp = scmr.hREnumServiceGroupW(dce, scHandle, dwServiceType, dwServiceState, cbBufSize, lpResumeIndex, pszGroupName ) resp.dump() except Exception, e: if str(e).find('ERROR_SERVICE_DOES_NOT_EXISTS') <= 0: raise
Example #3
Source File: test_scmr.py From cracke-dit with MIT License | 6 votes |
def test_REnumServicesStatusExW(self): dce, rpctransport, scHandle = self.connect() request = scmr.REnumServicesStatusExW() request['hSCManager'] = scHandle request['InfoLevel'] = scmr.SC_STATUS_PROCESS_INFO request['dwServiceType'] = scmr.SERVICE_WIN32_OWN_PROCESS request['dwServiceState'] = scmr.SERVICE_STATE_ALL request['lpResumeIndex'] = NULL request['pszGroupName'] = NULL request['cbBufSize'] = 0 #request.dump() #print "\n" # Request again with the right bufSize try: resp = dce.request(request) except Exception, e: if str(e).find('ERROR_MORE_DATA') <= 0: raise else: resp = e.get_packet()
Example #4
Source File: test_scmr.py From cracke-dit with MIT License | 6 votes |
def te_REnumServiceGroupW(self): dce, rpctransport, scHandle = self.connect() dwServiceType = scmr.SERVICE_WIN32_OWN_PROCESS dwServiceState = scmr.SERVICE_STATE_ALL cbBufSize = 10 lpResumeIndex = 0 pszGroupName = 'RemoteRegistry\x00' try: resp = scmr.hREnumServiceGroupW(dce, scHandle, dwServiceType, dwServiceState, cbBufSize, lpResumeIndex, pszGroupName ) resp.dump() except Exception, e: if str(e).find('ERROR_SERVICE_DOES_NOT_EXISTS') <= 0: raise
Example #5
Source File: test_scmr.py From Slackor with GNU General Public License v3.0 | 6 votes |
def te_REnumServiceGroupW(self): dce, rpctransport, scHandle = self.connect() dwServiceType = scmr.SERVICE_WIN32_OWN_PROCESS dwServiceState = scmr.SERVICE_STATE_ALL cbBufSize = 10 lpResumeIndex = 0 pszGroupName = 'RemoteRegistry\x00' try: resp = scmr.hREnumServiceGroupW(dce, scHandle, dwServiceType, dwServiceState, cbBufSize, lpResumeIndex, pszGroupName ) resp.dump() except Exception as e: if str(e).find('ERROR_SERVICE_DOES_NOT_EXISTS') <= 0: raise scmr.hRCloseServiceHandle(dce, scHandle)
Example #6
Source File: test_scmr.py From PiBunny with MIT License | 6 votes |
def test_REnumServicesStatusExW(self): dce, rpctransport, scHandle = self.connect() request = scmr.REnumServicesStatusExW() request['hSCManager'] = scHandle request['InfoLevel'] = scmr.SC_STATUS_PROCESS_INFO request['dwServiceType'] = scmr.SERVICE_WIN32_OWN_PROCESS request['dwServiceState'] = scmr.SERVICE_STATE_ALL request['lpResumeIndex'] = NULL request['pszGroupName'] = NULL request['cbBufSize'] = 0 #request.dump() #print "\n" # Request again with the right bufSize try: resp = dce.request(request) except Exception, e: if str(e).find('ERROR_MORE_DATA') <= 0: raise else: resp = e.get_packet()
Example #7
Source File: test_scmr.py From PiBunny with MIT License | 6 votes |
def te_REnumServiceGroupW(self): dce, rpctransport, scHandle = self.connect() dwServiceType = scmr.SERVICE_WIN32_OWN_PROCESS dwServiceState = scmr.SERVICE_STATE_ALL cbBufSize = 10 lpResumeIndex = 0 pszGroupName = 'RemoteRegistry\x00' try: resp = scmr.hREnumServiceGroupW(dce, scHandle, dwServiceType, dwServiceState, cbBufSize, lpResumeIndex, pszGroupName ) resp.dump() except Exception, e: if str(e).find('ERROR_SERVICE_DOES_NOT_EXISTS') <= 0: raise
Example #8
Source File: test_scmr.py From CVE-2017-7494 with GNU General Public License v3.0 | 5 votes |
def test_enumservices(self): dce, rpctransport, scHandle = self.connect() ##################### # EnumServicesStatusW dwServiceType = scmr.SERVICE_KERNEL_DRIVER | scmr.SERVICE_FILE_SYSTEM_DRIVER | scmr.SERVICE_WIN32_OWN_PROCESS | scmr.SERVICE_WIN32_SHARE_PROCESS dwServiceState = scmr.SERVICE_STATE_ALL cbBufSize = 0 resp = scmr.hREnumServicesStatusW(dce, scHandle, dwServiceType, dwServiceState) resp = scmr.hRCloseServiceHandle(dce, scHandle)
Example #9
Source File: test_scmr.py From CVE-2017-7494 with GNU General Public License v3.0 | 5 votes |
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()
Example #10
Source File: test_scmr.py From cracke-dit with MIT License | 5 votes |
def test_enumservices(self): dce, rpctransport, scHandle = self.connect() ##################### # EnumServicesStatusW dwServiceType = scmr.SERVICE_KERNEL_DRIVER | scmr.SERVICE_FILE_SYSTEM_DRIVER | scmr.SERVICE_WIN32_OWN_PROCESS | scmr.SERVICE_WIN32_SHARE_PROCESS dwServiceState = scmr.SERVICE_STATE_ALL cbBufSize = 0 resp = scmr.hREnumServicesStatusW(dce, scHandle, dwServiceType, dwServiceState) resp = scmr.hRCloseServiceHandle(dce, scHandle)
Example #11
Source File: test_scmr.py From cracke-dit with MIT License | 5 votes |
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()
Example #12
Source File: test_scmr.py From Slackor with GNU General Public License v3.0 | 5 votes |
def test_REnumServicesStatusExW(self): dce, rpctransport, scHandle = self.connect() request = scmr.REnumServicesStatusExW() request['hSCManager'] = scHandle request['InfoLevel'] = scmr.SC_STATUS_PROCESS_INFO request['dwServiceType'] = scmr.SERVICE_WIN32_OWN_PROCESS request['dwServiceState'] = scmr.SERVICE_STATE_ALL request['lpResumeIndex'] = NULL request['pszGroupName'] = NULL request['cbBufSize'] = 0 #request.dump() #print "\n" # Request again with the right bufSize try: resp = dce.request(request) except Exception as e: if str(e).find('ERROR_MORE_DATA') <= 0: raise else: resp = e.get_packet() resp.dump() request['cbBufSize'] = resp['pcbBytesNeeded'] resp = dce.request(request) resp.dump()
Example #13
Source File: test_scmr.py From Slackor with GNU General Public License v3.0 | 5 votes |
def test_enumservices(self): dce, rpctransport, scHandle = self.connect() ##################### # EnumServicesStatusW dwServiceType = scmr.SERVICE_KERNEL_DRIVER | scmr.SERVICE_FILE_SYSTEM_DRIVER | scmr.SERVICE_WIN32_OWN_PROCESS | scmr.SERVICE_WIN32_SHARE_PROCESS dwServiceState = scmr.SERVICE_STATE_ALL scmr.hREnumServicesStatusW(dce, scHandle, dwServiceType, dwServiceState) scmr.hRCloseServiceHandle(dce, scHandle)
Example #14
Source File: test_scmr.py From PiBunny with MIT License | 5 votes |
def test_enumservices(self): dce, rpctransport, scHandle = self.connect() ##################### # EnumServicesStatusW dwServiceType = scmr.SERVICE_KERNEL_DRIVER | scmr.SERVICE_FILE_SYSTEM_DRIVER | scmr.SERVICE_WIN32_OWN_PROCESS | scmr.SERVICE_WIN32_SHARE_PROCESS dwServiceState = scmr.SERVICE_STATE_ALL cbBufSize = 0 resp = scmr.hREnumServicesStatusW(dce, scHandle, dwServiceType, dwServiceState) resp = scmr.hRCloseServiceHandle(dce, scHandle)
Example #15
Source File: test_scmr.py From PiBunny with MIT License | 5 votes |
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()
Example #16
Source File: computer.py From BloodHound.py with MIT License | 4 votes |
def rpc_get_services(self): """ Query services with stored credentials via RPC. These credentials can be dumped with mimikatz via lsadump::secrets or via secretsdump.py """ binding = r'ncacn_np:%s[\PIPE\svcctl]' % self.addr serviceusers = [] dce = self.dce_rpc_connect(binding, scmr.MSRPC_UUID_SCMR) if dce is None: return try: resp = scmr.hROpenSCManagerW(dce) scManagerHandle = resp['lpScHandle'] # TODO: Figure out if filtering out service types makes sense resp = scmr.hREnumServicesStatusW(dce, scManagerHandle, dwServiceType=scmr.SERVICE_WIN32_OWN_PROCESS, dwServiceState=scmr.SERVICE_STATE_ALL) # TODO: Skip well-known services to save on traffic for i in range(len(resp)): try: ans = scmr.hROpenServiceW(dce, scManagerHandle, resp[i]['lpServiceName'][:-1]) serviceHandle = ans['lpServiceHandle'] svcresp = scmr.hRQueryServiceConfigW(dce, serviceHandle) svc_user = svcresp['lpServiceConfig']['lpServiceStartName'][:-1] if '@' in svc_user: logging.info("Found user service: %s running as %s on %s", resp[i]['lpServiceName'][:-1], svc_user, self.hostname) serviceusers.append(svc_user) except DCERPCException as e: if 'rpc_s_access_denied' not in str(e): logging.debug('Exception querying service %s via RPC: %s', resp[i]['lpServiceName'][:-1], e) except DCERPCException as e: logging.debug('Exception connecting to RPC: %s', e) except Exception as e: if 'connection reset' in str(e): logging.debug('Connection was reset: %s', e) else: raise e dce.disconnect() return serviceusers