1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-01-02 11:36:22 +01:00

Use RegOpenKeyExW for checking existance

This has two benefits:
1. It's the same function as what's used to open keys, ensuring that the
   options is consistent.
2. It allows the desired permissions to be explicitly set instead of
   being inferred from the "default securitya ccess mask". See:
   https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeya#return-value
This commit is contained in:
Spencer McIntyre 2022-09-01 15:01:27 -04:00
parent 9d11bb84b1
commit d720a549a4

View File

@ -22,7 +22,7 @@ DWORD request_registry_check_key_exists(Remote *remote, Packet *packet)
if (rootKey && baseKey) {
BOOL exists = FALSE;
HKEY resultKey = NULL;
if (RegOpenKeyW(rootKey, baseKey, &resultKey) == ERROR_SUCCESS) {
if (RegOpenKeyExW(rootKey, baseKey, 0, KEY_QUERY_VALUE, &resultKey) == ERROR_SUCCESS) {
dprintf("[REG] Key found");
RegCloseKey(resultKey);
exists = TRUE;