Author Archives: superadmin

Accessing a service credentials on Windows 10

I worked on some Windows app that registers a Windows service with a C++ code like this:

SC_HANDLE hService = ::CreateService(
    hSCM, m_szServiceName, _T(SERVICE_NAME),
    SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
    SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
    szFilePath, NULL, NULL, _T("RPCSS\0"), user_name, password);

where user_name and password are strings that are provided by the app user during the app install. Assuming the service name is MyService this creates a registry key HKEY_LOCAL_MACHINE\SECURITY\Policy\Secrets\_SC_MyService that is hidden by default and even administrator does not have a permission to read it and regedit does not show the content of HKEY_LOCAL_MACHINE\SECURITY key by default. But fortunately the access can be allowed by right clicking on HKEY_LOCAL_MACHINE\SECURITY and selecting Permissions or alternatively by running

Enable-TSDuplicateToken

in PowerShell. To list the content of the key I used the following command:

dir HKLM:\SECURITY\Policy\Secrets\_SC_MyService
(more…)