1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-03-24 18:16:24 +01:00

Land : Fix unicode REG_EXPAND_SZ handling

Fixes 
This commit is contained in:
OJ 2016-09-30 14:39:36 +10:00
commit 4ba1d16acc
No known key found for this signature in database
GPG Key ID: D5DC61FB93260597

@ -459,11 +459,15 @@ static void set_value(Remote *remote, Packet *packet, HKEY hkey)
} else { } else {
// Now let's rock this shit! // Now let's rock this shit!
void *buf; void *buf;
size_t len = valueData.header.length; size_t len;
if (valueType == REG_SZ) { switch (valueType) {
case REG_SZ:
case REG_EXPAND_SZ:
buf = utf8_to_wchar(valueData.buffer); buf = utf8_to_wchar(valueData.buffer);
len = (wcslen(buf) + 1) * sizeof(wchar_t); len = (wcslen(buf) + 1) * sizeof(wchar_t);
} else { break;
default:
len = valueData.header.length;
buf = valueData.buffer; buf = valueData.buffer;
} }
result = RegSetValueExW(hkey, valueName, 0, valueType, buf, (DWORD)len); result = RegSetValueExW(hkey, valueName, 0, valueType, buf, (DWORD)len);
@ -561,6 +565,7 @@ static void query_value(Remote *remote, Packet *packet, HKEY hkey)
switch (valueType) { switch (valueType) {
case REG_SZ: case REG_SZ:
case REG_EXPAND_SZ:
tmp = wchar_to_utf8((wchar_t *)valueData); tmp = wchar_to_utf8((wchar_t *)valueData);
if (tmp) { if (tmp) {
packet_add_tlv_string(response, TLV_TYPE_VALUE_DATA, tmp); packet_add_tlv_string(response, TLV_TYPE_VALUE_DATA, tmp);